Skip to content

Commit

Permalink
Compatibility Changes for NomoApp
Browse files Browse the repository at this point in the history
  • Loading branch information
dev2-nomo committed Dec 6, 2023
1 parent de4f245 commit 2a29b84
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 81 deletions.
54 changes: 31 additions & 23 deletions example/lib/sections/button_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ class TextButtonWrapper extends StatelessWidget {
PrimaryNomoButton(
foregroundColor: primaryColor.lighten(0.5),
text: "Primary",
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
padding: const EdgeInsets.symmetric(
horizontal: 16, vertical: 12),
onPressed: () {},
textStyle: context.typography.h1,
),
Expand Down Expand Up @@ -106,23 +107,26 @@ class TextButtonWrapper extends StatelessWidget {
PrimaryNomoButton(
foregroundColor: primaryColor.lighten(0.5),
text: "Danger Primary",
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
padding: const EdgeInsets.symmetric(
horizontal: 16, vertical: 12),
onPressed: () {},
textStyle: context.typography.h1,
type: ActionType.danger,
),
PrimaryNomoButton(
foregroundColor: primaryColor.lighten(0.5),
text: "Disabled Primary",
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
padding: const EdgeInsets.symmetric(
horizontal: 16, vertical: 12),
onPressed: () {},
textStyle: context.typography.h1,
type: ActionType.disabled,
),
PrimaryNomoButton(
foregroundColor: primaryColor.lighten(0.5),
text: "NonInteractive Primary",
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
padding: const EdgeInsets.symmetric(
horizontal: 16, vertical: 12),
onPressed: () {},
textStyle: context.typography.h1,
type: ActionType.nonInteractive,
Expand Down Expand Up @@ -158,7 +162,8 @@ class TextButtonWrapper extends StatelessWidget {
children: [
SecondaryNomoButton(
text: "Secondary",
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
padding: const EdgeInsets.symmetric(
horizontal: 16, vertical: 12),
onPressed: () {},
textStyle: context.typography.h1,
),
Expand Down Expand Up @@ -191,23 +196,26 @@ class TextButtonWrapper extends StatelessWidget {
textStyle: context.typography.h1,
backgroundColor: context.colors.error.lighten(0.25),
icon: Icons.access_alarm_outlined,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
padding: const EdgeInsets.symmetric(
horizontal: 16, vertical: 12),
text: "Danger Secondary",
type: ActionType.danger,
),
SecondaryNomoButton(
onPressed: () {},
textStyle: context.typography.h1,
icon: Icons.access_alarm_outlined,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
padding: const EdgeInsets.symmetric(
horizontal: 16, vertical: 12),
text: "Disabled Secondary",
type: ActionType.disabled,
),
SecondaryNomoButton(
onPressed: () {},
textStyle: context.typography.h1,
icon: Icons.access_alarm_outlined,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
padding: const EdgeInsets.symmetric(
horizontal: 16, vertical: 12),
text: "NonInteractive Secondary",
type: ActionType.nonInteractive,
),
Expand Down Expand Up @@ -433,21 +441,21 @@ class TextButtonWrapper extends StatelessWidget {
// children: [
// Row(
// children: [
// NomoButton.text(
// PrimaryNomoButton(
// elevation: 0.0,
// border: const BorderSide(color: Color(0xFF272626)),
// size: ButtonSize.small,
// onPressed: () {},
// text: "Search",
// ),
// const SizedBox(width: 16),
// NomoButton.text(
// PrimaryNomoButton(
// size: ButtonSize.medium,
// onPressed: () {},
// text: "Search",
// ),
// const SizedBox(width: 16),
// NomoButton.text(
// PrimaryNomoButton(
// color: Colors.red,
// textStyle: context.typography.h1.copyWith(
// color: Colors.black,
Expand All @@ -461,21 +469,21 @@ class TextButtonWrapper extends StatelessWidget {
// const SizedBox(height: 16),
// Row(
// children: [
// NomoButton.text(
// PrimaryNomoButton(
// size: ButtonSize.small,
// borderRadius: BorderRadius.circular(12.0),
// onPressed: () {},
// text: "Search",
// ),
// const SizedBox(width: 16),
// NomoButton.text(
// PrimaryNomoButton(
// size: ButtonSize.medium,
// borderRadius: BorderRadius.circular(12.0),
// onPressed: () {},
// text: "Search",
// ),
// const SizedBox(width: 16),
// NomoButton.text(
// PrimaryNomoButton(
// size: ButtonSize.large,
// borderRadius: BorderRadius.circular(12.0),
// onPressed: () => {},
Expand All @@ -486,15 +494,15 @@ class TextButtonWrapper extends StatelessWidget {
// const SizedBox(height: 16),
// Row(
// children: [
// NomoButton.text(
// PrimaryNomoButton(
// size: ButtonSize.small,
// leading: const Icon(Icons.search),
// borderRadius: BorderRadius.circular(12.0),
// onPressed: () => {},
// text: "Search",
// ),
// const SizedBox(width: 16),
// NomoButton.text(
// PrimaryNomoButton(
// size: ButtonSize.medium,
// leading: const Icon(Icons.search),
// borderRadius: BorderRadius.circular(12.0),
Expand All @@ -503,7 +511,7 @@ class TextButtonWrapper extends StatelessWidget {
// trailing: const Icon(Icons.search),
// ),
// const SizedBox(width: 16),
// NomoButton.text(
// PrimaryNomoButton(
// size: ButtonSize.large,
// leading: const Icon(Icons.search),
// borderRadius: BorderRadius.circular(12.0),
Expand All @@ -515,7 +523,7 @@ class TextButtonWrapper extends StatelessWidget {
// const SizedBox(height: 16),
// Row(
// children: [
// NomoButton.text(
// PrimaryNomoButton(
// color: Colors.red,
// splashColor: Colors.green,
// textStyle: const TextStyle(color: Colors.white, fontSize: 16),
Expand All @@ -527,7 +535,7 @@ class TextButtonWrapper extends StatelessWidget {
// text: "Search",
// ),
// const SizedBox(width: 16),
// NomoButton.text(
// PrimaryNomoButton(
// isEnabled: false,
// size: ButtonSize.medium,
// color: Colors.green,
Expand All @@ -538,7 +546,7 @@ class TextButtonWrapper extends StatelessWidget {
// text: "Search",
// ),
// const SizedBox(width: 16),
// NomoButton.text(
// PrimaryNomoButton(
// highlightColor: Colors.green,
// color: Colors.blue,
// size: ButtonSize.large,
Expand All @@ -553,7 +561,7 @@ class TextButtonWrapper extends StatelessWidget {
// const SizedBox(height: 16),
// Row(
// children: [
// NomoButton.text(
// PrimaryNomoButton(
// isLoading: true,
// size: ButtonSize.small,
// elevation: 3.0,
Expand All @@ -563,7 +571,7 @@ class TextButtonWrapper extends StatelessWidget {
// text: "Search",
// ),
// const SizedBox(width: 16),
// NomoButton.text(
// PrimaryNomoButton(
// isLoading: true,
// size: ButtonSize.medium,
// elevation: 3.0,
Expand All @@ -573,7 +581,7 @@ class TextButtonWrapper extends StatelessWidget {
// text: "Search",
// ),
// const SizedBox(width: 16),
// NomoButton.text(
// PrimaryNomoButton(
// isLoading: true,
// size: ButtonSize.large,
// elevation: 3.0,
Expand Down
22 changes: 14 additions & 8 deletions example/lib/sections/dialogs/dialog_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class DialogWrapper extends StatelessWidget {
),
child: Row(
children: [
// NomoButton.text(
// PrimaryNomoButton(
// onPressed: () {
// showDialog(
// context: context,
Expand Down Expand Up @@ -54,7 +54,7 @@ class DialogWrapper extends StatelessWidget {
// Expanded(
// child: SizedBox(
// height: 50,
// child: NomoButton.text(
// child: PrimaryNomoButton(
// onPressed: () => Navigator.pop(context),
// text: "Cancel",
// ),
Expand Down Expand Up @@ -94,15 +94,18 @@ class DialogWrapper extends StatelessWidget {
items: const [
NomoDropdownItem<int>(displayText: "Item 1", value: 1),
NomoDropdownItem<int>(
displayText: "Item 2 is a very long item and it will fit insid the dropdown menu", value: 2),
NomoDropdownItem<int>(displayText: "Item 3 is kinda long", value: 3),
displayText:
"Item 2 is a very long item and it will fit insid the dropdown menu",
value: 2),
NomoDropdownItem<int>(
displayText: "Item 3 is kinda long", value: 3),
NomoDropdownItem<int>(displayText: "Item 4", value: 4),
NomoDropdownItem<int>(displayText: "Item 5", value: 5),
],
height: 40,
width: 140,
),
// NomoButton.text(
// PrimaryNomoButton(
// onPressed: () {
// WoltModalSheet.show(
// context: context,
Expand Down Expand Up @@ -141,7 +144,8 @@ class DialogWrapper extends StatelessWidget {
);
}

WoltModalSheetPage page2(BuildContext modalSheetContext, ValueNotifier<int> pageIndexNotifier) {
WoltModalSheetPage page2(
BuildContext modalSheetContext, ValueNotifier<int> pageIndexNotifier) {
return WoltModalSheetPage.withCustomSliverList(
stickyActionBar: Padding(
padding: const EdgeInsets.fromLTRB(50, 50 / 4, 50, 50),
Expand Down Expand Up @@ -194,7 +198,8 @@ class DialogWrapper extends StatelessWidget {
);
}

WoltModalSheetPage page1(BuildContext modalSheetContext, ValueNotifier<int> pageIndexNotifier) {
WoltModalSheetPage page1(
BuildContext modalSheetContext, ValueNotifier<int> pageIndexNotifier) {
return WoltModalSheetPage.withSingleChild(
hasSabGradient: false,
stickyActionBar: Padding(
Expand All @@ -211,7 +216,8 @@ class DialogWrapper extends StatelessWidget {
),
const SizedBox(height: 8),
ElevatedButton(
onPressed: () => pageIndexNotifier.value = pageIndexNotifier.value + 1,
onPressed: () =>
pageIndexNotifier.value = pageIndexNotifier.value + 1,
child: const SizedBox(
height: 20,
width: double.infinity,
Expand Down
47 changes: 27 additions & 20 deletions lib/components/buttons/primary/nomo_primary_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class PrimaryNomoButton extends StatelessWidget with NomoButtonMixin {
final TextStyle? textStyle;
final double? iconSize;
final ActionType type;
final Widget? child;

@override
final VoidCallback? onPressed;
Expand Down Expand Up @@ -81,7 +82,9 @@ class PrimaryNomoButton extends StatelessWidget with NomoButtonMixin {
this.textStyle,
this.iconSize,
this.shape,
});
this.child,
}) : assert(child == null || (icon == null && text == null),
'Either Specify child or text and icon');

@override
Widget build(BuildContext context) {
Expand All @@ -91,7 +94,9 @@ class PrimaryNomoButton extends StatelessWidget with NomoButtonMixin {
elevation: theme.elevation,
backgroundColor: switch (type) {
ActionType.danger => context.colors.error,
ActionType.disabled || ActionType.nonInteractive => context.colors.disabled,
ActionType.disabled ||
ActionType.nonInteractive =>
context.colors.disabled,
_ => theme.backgroundColor,
},
foregroundColor: switch (type) {
Expand All @@ -113,24 +118,26 @@ class PrimaryNomoButton extends StatelessWidget with NomoButtonMixin {
_ => SystemMouseCursors.click,
},
enabled: enabled,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (type == ActionType.loading)
Loading(
size: switch (height) {
final double height => height / 3,
_ => 24,
},
color: foregroundColor,
)
else if (icon != null)
Icon(icon, size: iconSize),
if (icon != null && text != null) SizedBox(width: spacing),
if (text != null && type == ActionType.loading) SizedBox(width: spacing),
if (text != null) NomoText(text!, style: textStyle),
],
),
child: child ??
Row(
mainAxisSize: MainAxisSize.min,
children: [
if (type == ActionType.loading)
Loading(
size: switch (height) {
final double height => height / 3,
_ => 24,
},
color: foregroundColor,
)
else if (icon != null)
Icon(icon, size: iconSize),
if (icon != null && text != null) SizedBox(width: spacing),
if (text != null && type == ActionType.loading)
SizedBox(width: spacing),
if (text != null) NomoText(text!, style: textStyle),
],
),
);
}
}
Loading

0 comments on commit 2a29b84

Please sign in to comment.