feat(ui_kit): finalize material ready buttons
This commit is contained in:
@@ -15,7 +15,6 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart';
|
||||
import 'package:wyatt_ui_kit/src/components/buttons/cubit/button_cubit.dart';
|
||||
@@ -30,8 +29,6 @@ class InvalidButtonCubit extends ButtonCubit {
|
||||
emit(
|
||||
state.copyWith(
|
||||
state: ControlState.hovered,
|
||||
// TODO(hpcl): change this
|
||||
invalid: Random().nextBool(),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -45,8 +42,6 @@ class InvalidButtonCubit extends ButtonCubit {
|
||||
emit(
|
||||
state.copyWith(
|
||||
state: ControlState.normal,
|
||||
// TODO(hpcl): change this
|
||||
invalid: Random().nextBool(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
+2
-3
@@ -218,7 +218,6 @@ class FileSelectionButtonScreen
|
||||
padding: style.padding ?? EdgeInsets.zero,
|
||||
child: Row(
|
||||
mainAxisSize: mainAxisSize ?? MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
if (leading != null) ...[
|
||||
leading ?? const SizedBox.shrink(),
|
||||
@@ -240,7 +239,7 @@ class FileSelectionButtonScreen
|
||||
///
|
||||
/// More infos in `negociate()` method
|
||||
if (title != null) ...[
|
||||
Gap(style.padding?.horizontal ?? 10),
|
||||
Gap(style.padding?.vertical ?? 10),
|
||||
Text(
|
||||
title!.text,
|
||||
style: title!.style ?? style.title,
|
||||
@@ -267,7 +266,7 @@ class FileSelectionButtonScreen
|
||||
///
|
||||
/// More infos in `negociate()` method
|
||||
if (subTitle != null) ...[
|
||||
Gap(style.padding?.horizontal ?? 10),
|
||||
Gap(style.padding?.vertical ?? 10),
|
||||
Text(
|
||||
subTitle!.text,
|
||||
style: subTitle!.style ?? style.subTitle,
|
||||
|
||||
+42
-11
@@ -30,17 +30,48 @@ class FileSelectionButtonThemeResolver extends ThemeResolver<
|
||||
FileSelectionButtonStyle computeDefaultValue(
|
||||
BuildContext context, {
|
||||
ButtonState? extra,
|
||||
}) =>
|
||||
FileSelectionButtonStyle(
|
||||
title: context.textTheme.labelLarge,
|
||||
subTitle: context.textTheme.labelSmall,
|
||||
radius: (context.buttonTheme.shape is RoundedRectangleBorder)
|
||||
? (context.buttonTheme.shape as RoundedRectangleBorder).borderRadius
|
||||
: null,
|
||||
padding: context.buttonTheme.padding,
|
||||
foregroundColors: MultiColor.single(context.colorScheme.onPrimary),
|
||||
backgroundColors: MultiColor.single(context.colorScheme.primary),
|
||||
);
|
||||
}) {
|
||||
MultiColor backgroundColor = MultiColor.single(context.colorScheme.primary);
|
||||
MultiColor foregroundColor =
|
||||
MultiColor.single(context.colorScheme.onPrimary);
|
||||
|
||||
switch (extra?.state) {
|
||||
case ControlState.disabled:
|
||||
backgroundColor =
|
||||
MultiColor.single(context.colorScheme.onSurface.withOpacity(0.12));
|
||||
foregroundColor =
|
||||
MultiColor.single(context.colorScheme.onSurface.withOpacity(0.38));
|
||||
break;
|
||||
case ControlState.hovered:
|
||||
backgroundColor =
|
||||
MultiColor.single(context.colorScheme.primary.withOpacity(0.92));
|
||||
break;
|
||||
case ControlState.tapped:
|
||||
backgroundColor =
|
||||
MultiColor.single(context.colorScheme.primary.withOpacity(0.92));
|
||||
break;
|
||||
case null:
|
||||
case ControlState.normal:
|
||||
case ControlState.focused:
|
||||
break;
|
||||
}
|
||||
|
||||
if (extra?.isInvalid ?? false) {
|
||||
backgroundColor =
|
||||
MultiColor.single(context.colorScheme.error);
|
||||
}
|
||||
|
||||
return FileSelectionButtonStyle(
|
||||
title: context.textTheme.labelLarge,
|
||||
subTitle: context.textTheme.labelSmall,
|
||||
radius: (context.buttonTheme.shape is RoundedRectangleBorder)
|
||||
? (context.buttonTheme.shape as RoundedRectangleBorder).borderRadius
|
||||
: null,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
foregroundColors: foregroundColor,
|
||||
backgroundColors: backgroundColor,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
final FileSelectionButtonStyle? Function(
|
||||
|
||||
+36
-10
@@ -29,16 +29,42 @@ class SimpleIconButtonThemeResolver extends ThemeResolver<SimpleIconButtonStyle,
|
||||
SimpleIconButtonStyle computeDefaultValue(
|
||||
BuildContext context, {
|
||||
ControlState? extra,
|
||||
}) =>
|
||||
SimpleIconButtonStyle(
|
||||
dimension: context.buttonTheme.height,
|
||||
radius: (context.buttonTheme.shape is RoundedRectangleBorder)
|
||||
? (context.buttonTheme.shape as RoundedRectangleBorder).borderRadius
|
||||
: null,
|
||||
padding: context.buttonTheme.padding,
|
||||
foregroundColors: MultiColor.single(context.colorScheme.onPrimary),
|
||||
backgroundColors: MultiColor.single(context.colorScheme.primary),
|
||||
);
|
||||
}) {
|
||||
MultiColor backgroundColor = MultiColor.single(context.colorScheme.primary);
|
||||
MultiColor foregroundColor =
|
||||
MultiColor.single(context.colorScheme.onPrimary);
|
||||
|
||||
switch (extra) {
|
||||
case ControlState.disabled:
|
||||
backgroundColor =
|
||||
MultiColor.single(context.colorScheme.onSurface.withOpacity(0.12));
|
||||
foregroundColor =
|
||||
MultiColor.single(context.colorScheme.onSurface.withOpacity(0.38));
|
||||
break;
|
||||
case ControlState.hovered:
|
||||
backgroundColor =
|
||||
MultiColor.single(context.colorScheme.primary.withOpacity(0.92));
|
||||
break;
|
||||
case ControlState.tapped:
|
||||
backgroundColor =
|
||||
MultiColor.single(context.colorScheme.primary.withOpacity(0.92));
|
||||
break;
|
||||
case null:
|
||||
case ControlState.normal:
|
||||
case ControlState.focused:
|
||||
break;
|
||||
}
|
||||
|
||||
return SimpleIconButtonStyle(
|
||||
dimension: context.buttonTheme.height,
|
||||
radius: (context.buttonTheme.shape is RoundedRectangleBorder)
|
||||
? (context.buttonTheme.shape as RoundedRectangleBorder).borderRadius
|
||||
: null,
|
||||
padding: EdgeInsets.zero,
|
||||
foregroundColors: foregroundColor,
|
||||
backgroundColors: backgroundColor,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
final SimpleIconButtonStyle? Function(
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ class SymbolButtonThemeResolver extends ThemeResolver<SymbolButtonStyle,
|
||||
|
||||
return SymbolButtonStyle(
|
||||
label: context.textTheme.labelLarge,
|
||||
dimension: context.buttonTheme.height,
|
||||
dimension: context.buttonTheme.height*1.5,
|
||||
radius: (context.buttonTheme.shape is RoundedRectangleBorder)
|
||||
? (context.buttonTheme.shape as RoundedRectangleBorder).borderRadius
|
||||
: null,
|
||||
|
||||
Reference in New Issue
Block a user