Skip to content

Commit

Permalink
fix all warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
dangfan committed Aug 29, 2024
1 parent 6960e92 commit 239cc0b
Show file tree
Hide file tree
Showing 19 changed files with 119 additions and 157 deletions.
1 change: 1 addition & 0 deletions lib/controller/applets/oath.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class OathController extends Controller {

List<int> nameBytes = utf8.encode(name);
String capduData = '71${nameBytes.length.toRadixString(16).padLeft(2, '0')}${hex.encode(nameBytes)}'; // name 0x71
// ignore: prefer_interpolation_to_compose_strings
capduData += '73' + // tag
(secretHex.length ~/ 2 + 2).toRadixString(16).padLeft(2, '0') + // length
(type.value | algo.value).toRadixString(16).padLeft(2, '0') + // type & algo
Expand Down
2 changes: 1 addition & 1 deletion lib/helper/utils/prompts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class Prompts {
labelText: label,
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(4)),
borderSide: BorderSide(width: 1, strokeAlign: 0, color: AppTheme.theme.colorScheme.onBackground.withAlpha(80)),
borderSide: BorderSide(width: 1, strokeAlign: 0, color: AppTheme.theme.colorScheme.onSurface.withAlpha(80)),
),
floatingLabelBehavior: FloatingLabelBehavior.auto,
suffixIcon: IconButton(
Expand Down
64 changes: 28 additions & 36 deletions lib/helper/utils/shadow.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,57 +20,53 @@ class Shadow {
late int alpha;
late double elevation, spreadRadius, blurRadius;
Offset? offset;
ShadowPosition? position;
ShadowPosition position;
Color? color;
bool? darkShadow;
bool darkShadow;

Shadow(
{this.elevation = 3,
double? spreadRadius,
double? blurRadius,
Offset? offset,
ShadowPosition position = ShadowPosition.bottom,
this.offset,
this.position = ShadowPosition.bottom,
int? alpha,
Color? color,
bool darkShadow = false}) {
this.color,
this.darkShadow = false}) {
this.spreadRadius = spreadRadius ?? elevation * 0.125;
this.blurRadius = blurRadius ?? elevation * 2;
this.alpha = alpha ?? (darkShadow ? 80 : 25);
this.offset = offset;
this.position = position;
this.color = color;
this.darkShadow = darkShadow;

if (offset == null) {
switch (position) {
case ShadowPosition.topLeft:
this.offset = Offset(-elevation, -elevation);
offset = Offset(-elevation, -elevation);
break;
case ShadowPosition.top:
this.offset = Offset(0, -elevation);
offset = Offset(0, -elevation);
break;
case ShadowPosition.topRight:
this.offset = Offset(elevation, -elevation);
offset = Offset(elevation, -elevation);
break;
//TODO: Shadow problem
case ShadowPosition.centerLeft:
this.offset = Offset(-elevation, elevation * 0.25);
offset = Offset(-elevation, elevation * 0.25);
break;
case ShadowPosition.center:
this.offset = Offset(0, 0);
offset = Offset(0, 0);
break;
//TODO: Shadow problem
case ShadowPosition.centerRight:
this.offset = Offset(elevation, elevation * 0.25);
offset = Offset(elevation, elevation * 0.25);
break;
case ShadowPosition.bottomLeft:
this.offset = Offset(-elevation, elevation);
offset = Offset(-elevation, elevation);
break;
case ShadowPosition.bottom:
this.offset = Offset(0, elevation);
offset = Offset(0, elevation);
break;
case ShadowPosition.bottomRight:
this.offset = Offset(elevation, elevation);
offset = Offset(elevation, elevation);
break;
}
}
Expand All @@ -80,49 +76,45 @@ class Shadow {
{this.elevation = 0,
double? spreadRadius,
double? blurRadius,
Offset? offset,
ShadowPosition position = ShadowPosition.bottom,
this.offset,
this.position = ShadowPosition.bottom,
int? alpha,
Color? color,
bool darkShadow = false}) {
this.color,
this.darkShadow = false}) {
this.spreadRadius = spreadRadius ?? elevation * 0.125;
this.blurRadius = blurRadius ?? elevation * 2;
this.alpha = alpha ?? (darkShadow ? 100 : 36);
this.offset = offset;
this.position = position;
this.color = color;
this.darkShadow = darkShadow;

if (offset == null) {
switch (position) {
case ShadowPosition.topLeft:
this.offset = Offset(-elevation, -elevation);
offset = Offset(-elevation, -elevation);
break;
case ShadowPosition.top:
this.offset = Offset(0, -elevation);
offset = Offset(0, -elevation);
break;
case ShadowPosition.topRight:
this.offset = Offset(elevation, -elevation);
offset = Offset(elevation, -elevation);
break;
//TODO: Shadow problem
case ShadowPosition.centerLeft:
this.offset = Offset(-elevation, elevation * 0.25);
offset = Offset(-elevation, elevation * 0.25);
break;
case ShadowPosition.center:
this.offset = Offset(0, 0);
offset = Offset(0, 0);
break;
//TODO: Shadow problem
case ShadowPosition.centerRight:
this.offset = Offset(elevation, elevation * 0.25);
offset = Offset(elevation, elevation * 0.25);
break;
case ShadowPosition.bottomLeft:
this.offset = Offset(-elevation, elevation);
offset = Offset(-elevation, elevation);
break;
case ShadowPosition.bottom:
this.offset = Offset(0, elevation);
offset = Offset(0, elevation);
break;
case ShadowPosition.bottomRight:
this.offset = Offset(elevation, elevation);
offset = Offset(elevation, elevation);
break;
}
}
Expand Down
6 changes: 3 additions & 3 deletions lib/helper/utils/ui_mixins.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ mixin UIMixin {

OutlineInputBorder get outlineInputBorder => OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(4)),
borderSide: BorderSide(width: 1, strokeAlign: 0, color: theme.colorScheme.onBackground.withAlpha(80)),
borderSide: BorderSide(width: 1, strokeAlign: 0, color: theme.colorScheme.onSurface.withAlpha(80)),
);

OutlineInputBorder focusedInputBorder = OutlineInputBorder(
Expand All @@ -42,12 +42,12 @@ mixin UIMixin {
return InkWell(
onTap: navigationMixin.goBack,
child: Center(
child: Icon(Icons.chevron_left_rounded, size: 26, color: theme.colorScheme.onBackground),
child: Icon(Icons.chevron_left_rounded, size: 26, color: theme.colorScheme.onSurface),
),
);
}

Widget getDashedDivider() {
return DashedDivider(dashWidth: 6, dashSpace: 4, color: theme.colorScheme.onBackground.withAlpha(64), height: 0.5);
return DashedDivider(dashWidth: 6, dashSpace: 4, color: theme.colorScheme.onSurface.withAlpha(64), height: 0.5);
}
}
54 changes: 27 additions & 27 deletions lib/helper/widgets/customized_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,27 @@ class CustomizedButton extends StatelessWidget {
final bool? block;
final bool soft;

final MaterialStateProperty<EdgeInsetsGeometry>? msPadding;
final WidgetStateProperty<EdgeInsetsGeometry>? msPadding;
final EdgeInsetsGeometry? padding;

final MaterialStateProperty<double>? msElevation;
final WidgetStateProperty<double>? msElevation;
final double? elevation;

final MaterialStateProperty<EdgeInsetsGeometry>? msShape;
final WidgetStateProperty<EdgeInsetsGeometry>? msShape;
final OutlinedBorder? shape;
final BorderRadiusGeometry? borderRadius;
final double? borderRadiusAll;

final MaterialStateProperty<Color>? msBackgroundColor;
final WidgetStateProperty<Color>? msBackgroundColor;
final Color? backgroundColor;

final MaterialStateProperty<BorderSide>? msSide;
final WidgetStateProperty<BorderSide>? msSide;
final BorderSide? side;
final Color borderColor;

final MaterialTapTargetSize? tapTargetSize;

final MaterialStateProperty<Color>? msShadowColor;
final WidgetStateProperty<Color>? msShadowColor;
final Color? shadowColor;

final Color? splashColor;
Expand Down Expand Up @@ -263,17 +263,17 @@ class CustomizedButton extends StatelessWidget {
ButtonStyle(
tapTargetSize: tapTargetSize,
side: msSide ??
MaterialStateProperty.all(side ??
WidgetStateProperty.all(side ??
BorderSide(
color: soft ? borderColor.withAlpha(100) : borderColor,
width: soft ? 0.8 : 1,
)),
overlayColor: MaterialStateProperty.all(splashColor ?? (bgColor.withAlpha(40))),
backgroundColor: soft ? MaterialStateProperty.all(borderColor.withAlpha(40)) : null,
foregroundColor: MaterialStateProperty.all(borderColor.withAlpha(40)),
shadowColor: msShadowColor ?? MaterialStateProperty.all(shadowColor),
padding: msPadding ?? MaterialStateProperty.all(padding),
shape: MaterialStateProperty.all(shape ??
overlayColor: WidgetStateProperty.all(splashColor ?? (bgColor.withAlpha(40))),
backgroundColor: soft ? WidgetStateProperty.all(borderColor.withAlpha(40)) : null,
foregroundColor: WidgetStateProperty.all(borderColor.withAlpha(40)),
shadowColor: msShadowColor ?? WidgetStateProperty.all(shadowColor),
padding: msPadding ?? WidgetStateProperty.all(padding),
shape: WidgetStateProperty.all(shape ??
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(borderRadiusAll ?? WidgetConstant.constant.buttonRadius),
))),
Expand All @@ -286,27 +286,27 @@ class CustomizedButton extends StatelessWidget {
tapTargetSize: tapTargetSize,
visualDensity: VisualDensity.compact,
elevation: msElevation ??
MaterialStateProperty.resolveWith<double>(
(Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
WidgetStateProperty.resolveWith<double>(
(Set<WidgetState> states) {
if (states.contains(WidgetState.disabled)) {
return 0;
} else if (states.contains(MaterialState.pressed))
} else if (states.contains(WidgetState.pressed))
return elevation! * 2;
else if (states.contains(MaterialState.hovered)) return elevation! * 1.5;
else if (states.contains(WidgetState.hovered)) return elevation! * 1.5;
return elevation!;
},
),
backgroundColor: msBackgroundColor ??
MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) return bgColor.withAlpha(100);
WidgetStateProperty.resolveWith<Color>(
(Set<WidgetState> states) {
if (states.contains(WidgetState.disabled)) return bgColor.withAlpha(100);
return bgColor;
},
),
shadowColor: msShadowColor ?? MaterialStateProperty.all(shadowColor ?? bgColor),
padding: msPadding ?? MaterialStateProperty.all(padding),
overlayColor: MaterialStateProperty.all(splashColor ?? (Theme.of(context).colorScheme.onPrimary.withAlpha(36))),
shape: MaterialStateProperty.all(shape ??
shadowColor: msShadowColor ?? WidgetStateProperty.all(shadowColor ?? bgColor),
padding: msPadding ?? WidgetStateProperty.all(padding),
overlayColor: WidgetStateProperty.all(splashColor ?? (Theme.of(context).colorScheme.onPrimary.withAlpha(36))),
shape: WidgetStateProperty.all(shape ??
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(borderRadiusAll ?? WidgetConstant.constant.buttonRadius),
))),
Expand All @@ -315,8 +315,8 @@ class CustomizedButton extends StatelessWidget {
} else {
button = TextButton(
style: ButtonStyle(
overlayColor: MaterialStateProperty.all(splashColor ?? (bgColor.withAlpha(40))),
padding: msPadding ?? MaterialStateProperty.all(padding),
overlayColor: WidgetStateProperty.all(splashColor ?? (bgColor.withAlpha(40))),
padding: msPadding ?? WidgetStateProperty.all(padding),
// visualDensity: VisualDensity.standard,
tapTargetSize: tapTargetSize),
onPressed: onPressed,
Expand Down
20 changes: 8 additions & 12 deletions lib/helper/widgets/customized_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CustomizedCard extends StatelessWidget {
final Color? splashColor;

const CustomizedCard(
{Key? key,
{super.key,
required this.child,
this.borderRadius,
this.padding,
Expand All @@ -37,11 +37,10 @@ class CustomizedCard extends StatelessWidget {
this.margin,
this.splashColor,
this.width,
this.height})
: super(key: key);
this.height});

const CustomizedCard.bordered(
{Key? key,
{super.key,
required this.child,
this.borderRadius,
this.padding,
Expand All @@ -58,11 +57,10 @@ class CustomizedCard extends StatelessWidget {
this.margin,
this.splashColor,
this.width,
this.height})
: super(key: key);
this.height});

const CustomizedCard.circular(
{Key? key,
{super.key,
required this.child,
this.borderRadius,
this.padding,
Expand All @@ -79,11 +77,10 @@ class CustomizedCard extends StatelessWidget {
this.margin,
this.splashColor,
this.width,
this.height})
: super(key: key);
this.height});

const CustomizedCard.none(
{Key? key,
{super.key,
required this.child,
this.borderRadius,
this.padding,
Expand All @@ -100,8 +97,7 @@ class CustomizedCard extends StatelessWidget {
this.margin,
this.splashColor,
this.width,
this.height})
: super(key: key);
this.height});

@override
Widget build(BuildContext context) {
Expand Down
Loading

0 comments on commit 239cc0b

Please sign in to comment.