Skip to content

Commit

Permalink
feat: [MDS-800] Make relevant changes to use the latest moon_icons_fl…
Browse files Browse the repository at this point in the history
…utter library in moon_flutter (#287)
  • Loading branch information
Kypsis committed Nov 12, 2023
1 parent 1298d73 commit 4c9d572
Show file tree
Hide file tree
Showing 28 changed files with 247 additions and 1,365 deletions.
1,170 changes: 0 additions & 1,170 deletions example/lib/src/storybook/common/icons_map.dart

This file was deleted.

60 changes: 60 additions & 0 deletions example/lib/src/storybook/common/widgets/segment.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import 'package:example/src/storybook/common/widgets/text_divider.dart';
import 'package:flutter/material.dart';

class IconsSegment extends StatelessWidget {
final Map<String, IconData> segmentMap;

const IconsSegment({
super.key,
required this.segmentMap,
});

@override
Widget build(BuildContext context) {
String createSegmentTitle(String text) {
final String title = text.split('_').first;
return title[0].toUpperCase() + title.substring(1);
}

return SliverPadding(
padding: const EdgeInsets.symmetric(vertical: 64.0, horizontal: 16.0),
sliver: SliverMainAxisGroup(
slivers: [
SliverToBoxAdapter(
child: TextDivider(text: createSegmentTitle(segmentMap.keys.first)),
),
SliverGrid.builder(
itemCount: segmentMap.length,
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
crossAxisSpacing: 8,
mainAxisExtent: 104,
),
itemBuilder: (BuildContext context, int index) {
return Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.end,
children: [
if (segmentMap.keys.toList()[index].contains("16"))
Icon(segmentMap.values.toList()[index], size: 16)
else if (segmentMap.keys.toList()[index].contains("24"))
Icon(segmentMap.values.toList()[index], size: 24)
else
Icon(segmentMap.values.toList()[index], size: 32),
const SizedBox(height: 20),
Text(
segmentMap.keys.toList()[index],
style: TextStyle(
fontSize: 12,
color: Colors.grey[600],
),
),
],
);
},
),
],
),
);
}
}
4 changes: 2 additions & 2 deletions example/lib/src/storybook/stories/accordion.dart
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class _AccordionStoryState extends State<AccordionStory> {
shadows: showShadowKnob == true ? null : [],
childrenPadding: const EdgeInsets.all(12),
onExpansionChanged: (AccordionItems? value) => setState(() => _currentlyOpenAccordionItem = value),
leading: const MoonIcon(MoonIcons.frame_24),
leading: const Icon(MoonIcons.other_frame_24_light),
title: const Text("Grouped MoonAccordion item #1"),
children: [
Text(
Expand Down Expand Up @@ -218,7 +218,7 @@ class _AccordionStoryState extends State<AccordionStory> {
shadows: showShadowKnob == true ? null : [],
childrenPadding: const EdgeInsets.all(12),
onExpansionChanged: (AccordionItems? value) => setState(() => _currentlyOpenAccordionItem = value),
leading: const MoonIcon(MoonIcons.frame_24),
leading: const Icon(MoonIcons.other_frame_24_light),
title: const Text("Grouped MoonAccordion item #2"),
children: [
Text(
Expand Down
16 changes: 8 additions & 8 deletions example/lib/src/storybook/stories/alert.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ class _AlertStoryState extends State<AlertStory> {
backgroundColor: backgroundColor,
borderRadius: borderRadius,
leading: showLeadingKnob
? MoonIcon(
MoonIcons.frame_24,
? Icon(
MoonIcons.other_frame_24_light,
color: leadingColor,
)
: null,
Expand All @@ -162,8 +162,8 @@ class _AlertStoryState extends State<AlertStory> {
buttonSize: MoonButtonSize.xs,
borderRadius: borderRadius,
disabledOpacityValue: 1,
icon: MoonIcon(
MoonIcons.close_small_24,
icon: Icon(
MoonIcons.controls_close_small_24_light,
color: trailingColor,
size: 24,
),
Expand Down Expand Up @@ -197,7 +197,7 @@ class _AlertStoryState extends State<AlertStory> {
show: true,
color: context.moonColors!.chiChi100,
borderRadius: borderRadius,
leading: showLeadingKnob ? const MoonIcon(MoonIcons.alert_24) : null,
leading: showLeadingKnob ? const Icon(MoonIcons.notifications_alert_24_light) : null,
title: const Text("Filled error MoonAlert"),
body: showBodyKnob
? const SizedBox(
Expand All @@ -215,7 +215,7 @@ class _AlertStoryState extends State<AlertStory> {
show: true,
color: context.moonColors!.krillin100,
borderRadius: borderRadius,
leading: showLeadingKnob ? const MoonIcon(MoonIcons.alarm_round_24) : null,
leading: showLeadingKnob ? const Icon(MoonIcons.generic_alarm_round_24_light) : null,
title: const Text("Filled warning MoonAlert"),
body: showBodyKnob
? const SizedBox(
Expand All @@ -233,7 +233,7 @@ class _AlertStoryState extends State<AlertStory> {
show: true,
color: context.moonColors!.roshi100,
borderRadius: borderRadius,
leading: showLeadingKnob ? const MoonIcon(MoonIcons.check_rounded_24) : null,
leading: showLeadingKnob ? const Icon(MoonIcons.generic_check_rounded_24_light) : null,
title: const Text("Outlined success MoonAlert"),
body: showBodyKnob
? const SizedBox(
Expand All @@ -251,7 +251,7 @@ class _AlertStoryState extends State<AlertStory> {
show: true,
color: context.moonColors!.whis100,
borderRadius: borderRadius,
leading: showLeadingKnob ? const MoonIcon(MoonIcons.alert_24) : null,
leading: showLeadingKnob ? const Icon(MoonIcons.notifications_alert_24_light) : null,
title: const Text('Outlined info MoonAlert'),
body: showBodyKnob
? const SizedBox(
Expand Down
2 changes: 1 addition & 1 deletion example/lib/src/storybook/stories/bottom_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class BottomSheetStory extends StatelessWidget {
child: Align(
alignment: Alignment.centerLeft,
child: MoonButton.icon(
icon: const MoonIcon(MoonIcons.close_small_16),
icon: const Icon(MoonIcons.controls_close_small_16_light),
buttonSize: MoonButtonSize.sm,
backgroundColor: context.moonColors!.beerus,
borderRadius: BorderRadius.circular(24),
Expand Down
34 changes: 17 additions & 17 deletions example/lib/src/storybook/stories/button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,17 @@ class ButtonStory extends StatelessWidget {
IconData resolveIconVariant(MoonButtonSize? buttonSize) {
switch (buttonSize) {
case MoonButtonSize.xs:
return MoonIcons.frame_16;
return MoonIcons.other_frame_16_light;
case MoonButtonSize.sm:
return MoonIcons.frame_24;
return MoonIcons.other_frame_24_light;
case MoonButtonSize.md:
return MoonIcons.frame_24;
return MoonIcons.other_frame_24_light;
case MoonButtonSize.lg:
return MoonIcons.frame_24;
return MoonIcons.other_frame_24_light;
case MoonButtonSize.xl:
return MoonIcons.frame_24;
return MoonIcons.other_frame_24_light;
default:
return MoonIcons.frame_24;
return MoonIcons.other_frame_24_light;
}
}

Expand Down Expand Up @@ -157,9 +157,9 @@ class ButtonStory extends StatelessWidget {
textColor: textColor,
showPulseEffect: showPulseEffectKnob,
showPulseEffectJiggle: showPulseEffectJiggleKnob,
leading: showLeadingKnob ? MoonIcon(resolvedIconVariant) : null,
leading: showLeadingKnob ? Icon(resolvedIconVariant) : null,
label: showLabelKnob ? Text(customLabelTextKnob) : null,
trailing: showTrailingKnob ? MoonIcon(resolvedIconVariant) : null,
trailing: showTrailingKnob ? Icon(resolvedIconVariant) : null,
),
const SizedBox(height: 32),
MoonButton.icon(
Expand All @@ -172,17 +172,17 @@ class ButtonStory extends StatelessWidget {
borderColor: borderColor,
showPulseEffect: showPulseEffectKnob,
showPulseEffectJiggle: showPulseEffectJiggleKnob,
icon: showLeadingKnob ? MoonIcon(resolvedIconVariant) : null,
icon: showLeadingKnob ? Icon(resolvedIconVariant) : null,
),
const TextDivider(text: "MoonButton variants"),
MoonFilledButton(
onTap: isDisabledKnob ? null : () {},
buttonSize: buttonSizeKnob,
isFullWidth: setFullWidthKnob,
showPulseEffect: showPulseEffectKnob,
leading: showLeadingKnob ? MoonIcon(resolvedIconVariant) : null,
leading: showLeadingKnob ? Icon(resolvedIconVariant) : null,
label: showLabelKnob ? const Text("MoonFilledButton") : null,
trailing: showTrailingKnob ? MoonIcon(resolvedIconVariant) : null,
trailing: showTrailingKnob ? Icon(resolvedIconVariant) : null,
),
const SizedBox(height: 32),
MoonOutlinedButton(
Expand All @@ -191,19 +191,19 @@ class ButtonStory extends StatelessWidget {
isFullWidth: setFullWidthKnob,
showPulseEffect: showPulseEffectKnob,
borderColor: borderColor,
leading: showLeadingKnob ? MoonIcon(resolvedIconVariant) : null,
leading: showLeadingKnob ? Icon(resolvedIconVariant) : null,
label: showLabelKnob ? const Text("MoonOutlinedButton") : null,
trailing: showTrailingKnob ? MoonIcon(resolvedIconVariant) : null,
trailing: showTrailingKnob ? Icon(resolvedIconVariant) : null,
),
const SizedBox(height: 32),
MoonTextButton(
onTap: isDisabledKnob ? null : () {},
buttonSize: buttonSizeKnob,
isFullWidth: setFullWidthKnob,
showPulseEffect: showPulseEffectKnob,
leading: showLeadingKnob ? MoonIcon(resolvedIconVariant) : null,
leading: showLeadingKnob ? Icon(resolvedIconVariant) : null,
label: showLabelKnob ? const Text("MoonTextButton") : null,
trailing: showTrailingKnob ? MoonIcon(resolvedIconVariant) : null,
trailing: showTrailingKnob ? Icon(resolvedIconVariant) : null,
),
const TextDivider(text: "Custom MoonButtons with non-standard children"),
MoonButton(
Expand Down Expand Up @@ -261,8 +261,8 @@ class ButtonStory extends StatelessWidget {
height: 32,
child: CircleAvatar(
backgroundColor: context.moonColors!.frieza60,
child: const MoonIcon(
MoonIcons.rocket_24,
child: const Icon(
MoonIcons.other_rocket_24_light,
size: 24,
color: Colors.white,
),
Expand Down
12 changes: 6 additions & 6 deletions example/lib/src/storybook/stories/carousel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ class _CarouselStoryState extends State<CarouselStory> {
MoonButton.icon(
buttonSize: MoonButtonSize.sm,
showBorder: true,
icon: MoonIcon(
icon: Icon(
Directionality.of(context) == TextDirection.ltr
? MoonIcons.chevron_left_small_24
: MoonIcons.chevron_right_small_24,
? MoonIcons.controls_chevron_left_small_24_light
: MoonIcons.controls_chevron_right_small_24_light,
),
decoration: ShapeDecorationWithPremultipliedAlpha(
color: context.moonColors!.goku,
Expand All @@ -164,10 +164,10 @@ class _CarouselStoryState extends State<CarouselStory> {
MoonButton.icon(
buttonSize: MoonButtonSize.sm,
showBorder: true,
icon: MoonIcon(
icon: Icon(
Directionality.of(context) == TextDirection.ltr
? MoonIcons.chevron_right_small_24
: MoonIcons.chevron_left_small_24,
? MoonIcons.controls_chevron_right_small_24_light
: MoonIcons.controls_chevron_left_small_24_light,
),
decoration: ShapeDecorationWithPremultipliedAlpha(
color: context.moonColors!.goku,
Expand Down
12 changes: 6 additions & 6 deletions example/lib/src/storybook/stories/chip.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ class ChipStory extends StatelessWidget {
borderRadius: borderRadius,
showBorder: showBorderKnob,
chipSize: chipSizeKnob,
leading: showLeadingKnob ? const MoonIcon(MoonIcons.frame_24) : null,
leading: showLeadingKnob ? const Icon(MoonIcons.other_frame_24_light) : null,
label: showLabelKnob ? Text(customLabelTextKnob) : null,
trailing: showTrailingKnob ? const MoonIcon(MoonIcons.frame_24) : null,
trailing: showTrailingKnob ? const Icon(MoonIcons.other_frame_24_light) : null,
),
const TextDivider(text: "Text MoonChip"),
MoonChip.text(
Expand All @@ -153,9 +153,9 @@ class ChipStory extends StatelessWidget {
borderRadius: borderRadius,
showBorder: showBorderKnob,
chipSize: chipSizeKnob,
leading: showLeadingKnob ? const MoonIcon(MoonIcons.frame_24) : null,
leading: showLeadingKnob ? const Icon(MoonIcons.other_frame_24_light) : null,
label: showLabelKnob ? Text(customLabelTextKnob) : null,
trailing: showTrailingKnob ? const MoonIcon(MoonIcons.frame_24) : null,
trailing: showTrailingKnob ? const Icon(MoonIcons.other_frame_24_light) : null,
),
const TextDivider(text: "Preset MoonChip"),
MoonChip(
Expand All @@ -167,9 +167,9 @@ class ChipStory extends StatelessWidget {
borderWidth: 2,
showBorder: showBorderKnob,
chipSize: chipSizeKnob,
leading: showLeadingKnob ? const MoonIcon(MoonIcons.frame_24) : null,
leading: showLeadingKnob ? const Icon(MoonIcons.other_frame_24_light) : null,
label: showLabelKnob ? Text(customLabelTextKnob) : null,
trailing: showTrailingKnob ? const MoonIcon(MoonIcons.frame_24) : null,
trailing: showTrailingKnob ? const Icon(MoonIcons.other_frame_24_light) : null,
),
],
),
Expand Down
4 changes: 2 additions & 2 deletions example/lib/src/storybook/stories/dropdown.dart
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ class _DropdownStoryState extends State<DropdownStory> {
onTap: () => setState(() {
_showInner = !_showInner;
}),
trailing: const MoonIcon(
MoonIcons.chevron_right_16,
trailing: const Icon(
MoonIcons.controls_chevron_right_16_light,
size: 16,
),
),
Expand Down
Loading

0 comments on commit 4c9d572

Please sign in to comment.