Skip to content

Commit

Permalink
feat: [MDS-916] Change code snippet text font family (#324)
Browse files Browse the repository at this point in the history
Co-authored-by: BirgittMajas <79840500+BirgittMajas@users.noreply.github.com>
  • Loading branch information
GittHub-d and GittHub-d authored Dec 21, 2023
1 parent 1c58769 commit 8c9f851
Show file tree
Hide file tree
Showing 33 changed files with 1,020 additions and 908 deletions.
Binary file added example/assets/RobotoMono-Regular.ttf
Binary file not shown.
98 changes: 49 additions & 49 deletions example/assets/code_snippets/accordion.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,59 @@ import 'package:moon_design/moon_design.dart';

enum AccordionItems { first, second }

class Accordion extends StatefulWidget {
const Accordion({super.key});
class Accordion extends StatefulWidget {
const Accordion({super.key});

@override
State<Accordion> createState() => _AccordionState();
@override
State<Accordion> createState() => _AccordionState();
}

class _AccordionState extends State<Accordion> {
AccordionItems? _currentlyOpenAccordionItem = AccordionItems.first;
AccordionItems? _currentlyOpenAccordionItem = AccordionItems.first;

@override
Widget build(BuildContext context) {
const String contentText =
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, "
"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, "
"quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.";
@override
Widget build(BuildContext context) {
const String contentText =
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, "
"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, "
"quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.";

return Column(
children: [
MoonAccordion<AccordionItems>(
// identityValue and groupIdentityValue can be used to control the
// auto collapse behaviour of the accordion.
identityValue: AccordionItems.first,
groupIdentityValue: _currentlyOpenAccordionItem,
accordionSize: MoonAccordionSize.sm,
childrenPadding: const EdgeInsets.all(12),
onExpansionChanged: (AccordionItems? value) => setState(
() => _currentlyOpenAccordionItem = value,
),
leading: const Icon(MoonIcons.other_frame_24_light),
title: const Text("Grouped MoonAccordion item #1"),
children: const [
Text(contentText),
],
),
MoonAccordion<AccordionItems>(
// identityValue and groupIdentityValue can be used to control the
// auto collapse behaviour of the accordion.
identityValue: AccordionItems.second,
groupIdentityValue: _currentlyOpenAccordionItem,
accordionSize: MoonAccordionSize.sm,
hasContentOutside: true,
childrenPadding: const EdgeInsets.all(12),
onExpansionChanged: (AccordionItems? value) => setState(
() => _currentlyOpenAccordionItem = value,
),
leading: const Icon(MoonIcons.other_frame_24_light),
title: const Text("Grouped MoonAccordion item #2"),
children: const [
Text(contentText),
],
),
],
);
}
return Column(
children: [
MoonAccordion<AccordionItems>(
// identityValue and groupIdentityValue can be used to control the
// auto collapse behaviour of the accordion.
identityValue: AccordionItems.first,
groupIdentityValue: _currentlyOpenAccordionItem,
accordionSize: MoonAccordionSize.sm,
childrenPadding: const EdgeInsets.all(12),
onExpansionChanged: (AccordionItems? value) => setState(
() => _currentlyOpenAccordionItem = value,
),
leading: const Icon(MoonIcons.other_frame_24_light),
title: const Text("Grouped MoonAccordion item #1"),
children: const [
Text(contentText),
],
),
MoonAccordion<AccordionItems>(
// identityValue and groupIdentityValue can be used to control the
// auto collapse behaviour of the accordion.
identityValue: AccordionItems.second,
groupIdentityValue: _currentlyOpenAccordionItem,
accordionSize: MoonAccordionSize.sm,
hasContentOutside: true,
childrenPadding: const EdgeInsets.all(12),
onExpansionChanged: (AccordionItems? value) => setState(
() => _currentlyOpenAccordionItem = value,
),
leading: const Icon(MoonIcons.other_frame_24_light),
title: const Text("Grouped MoonAccordion item #2"),
children: const [
Text(contentText),
],
),
],
);
}
}
82 changes: 49 additions & 33 deletions example/assets/code_snippets/alert.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,54 @@ import 'package:flutter/material.dart';
import 'package:moon_design/moon_design.dart';

class Alert extends StatelessWidget {
const Alert({super.key});
const Alert({super.key});

@override
Widget build(BuildContext context) {
return Column(
children: [
MoonAlert(
show: true,
leading: const Icon(MoonIcons.other_frame_24_light),
title: const Text("Base MoonAlert"),
trailing: MoonButton.icon(
buttonSize: MoonButtonSize.xs,
onTap: () => {},
icon: const Icon(MoonIcons.controls_close_24_light),
),
body: const Text("Here goes MoonAlert body"),
),
MoonFilledAlert(
show: true,
color: context.moonColors!.chichi,
onTrailingTap: () => {},
leading: const Icon(MoonIcons.notifications_alert_24_light),
title: const Text("Filled error MoonAlert"),
),
MoonOutlinedAlert(
show: true,
color: context.moonColors!.roshi,
onTrailingTap: () => {},
leading: const Icon(MoonIcons.generic_check_rounded_24_light),
title: const Text("Outlined success MoonAlert"),
),
],
);
}
@override
Widget build(BuildContext context) {
return Column(
children: [
MoonAlert(
show: true,
leading: const Icon(MoonIcons.other_frame_24_light),
title: const Text("Base MoonAlert"),
trailing: MoonButton.icon(
buttonSize: MoonButtonSize.xs,
onTap: () => {},
icon: const Icon(MoonIcons.controls_close_24_light),
),
body: const Text("Here goes MoonAlert body"),
),
MoonAlert.filled(
show: true,
color: context.moonColors!.chichi,
backgroundColor: context.moonColors!.chichi10,
leading: const Icon(MoonIcons.notifications_alert_24_light),
title: const Text("Filled error MoonAlert"),
trailing: MoonButton.icon(
buttonSize: MoonButtonSize.xs,
onTap: () {},
icon: Icon(
MoonIcons.controls_close_small_24_light,
color: context.moonColors!.chichi,
),
),
),
MoonAlert.outlined(
show: true,
color: context.moonColors!.roshi,
borderColor: context.moonColors!.roshi,
leading: const Icon(MoonIcons.generic_check_rounded_24_light),
title: const Text("Outlined success MoonAlert"),
trailing: MoonButton.icon(
buttonSize: MoonButtonSize.xs,
onTap: () {},
icon: Icon(
MoonIcons.controls_close_small_24_light,
color: context.moonColors!.roshi,
),
),
),
],
);
}
}
86 changes: 43 additions & 43 deletions example/assets/code_snippets/auth_code.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,52 @@ import 'package:flutter/material.dart';
import 'package:moon_design/moon_design.dart';

class AuthCode extends StatefulWidget {
const AuthCode({super.key});
const AuthCode({super.key});

@override
State<AuthCode> createState() => _AuthCodeState();
@override
State<AuthCode> createState() => _AuthCodeState();
}

class _AuthCodeState extends State<AuthCode> {
late StreamController<ErrorAnimationType> _errorStreamController;

@override
void initState() {
super.initState();

_errorStreamController = StreamController<ErrorAnimationType>();
}

@override
void dispose() {
_errorStreamController.close();

super.dispose();
}

@override
Widget build(BuildContext context) {
return SizedBox(
height: 95, // To avoid widget jumping with error text, use a fixed-height wrapper.
child: MoonAuthCode(
errorStreamController: _errorStreamController,
onCompleted: (String pin) {
if (pin != '123456') {
_errorStreamController.add(ErrorAnimationType.shake);
}
},
validator: (String? pin) => pin?.length == 6 && pin != '123456'
? 'Invalid authentication code. Please try again.'
: null,
errorBuilder: (BuildContext context, String? errorText) {
return Align(
child: Padding(
padding: const EdgeInsets.only(top: 8),
child: Text(errorText ?? ''),
),
);
},
late StreamController<ErrorAnimationType> _errorStreamController;

@override
void initState() {
super.initState();

_errorStreamController = StreamController<ErrorAnimationType>();
}

@override
void dispose() {
_errorStreamController.close();

super.dispose();
}

@override
Widget build(BuildContext context) {
return SizedBox(
height: 95, // To avoid widget jumping with error text, use a fixed-height wrapper.
child: MoonAuthCode(
errorStreamController: _errorStreamController,
onCompleted: (String pin) {
if (pin != '123456') {
_errorStreamController.add(ErrorAnimationType.shake);
}
},
validator: (String? pin) => pin?.length == 6 && pin != '123456'
? 'Invalid authentication code. Please try again.'
: null,
errorBuilder: (BuildContext context, String? errorText) {
return Align(
child: Padding(
padding: const EdgeInsets.only(top: 8),
child: Text(errorText ?? ''),
),
);
}
);
},
),
);
}
}
22 changes: 11 additions & 11 deletions example/assets/code_snippets/avatar.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import 'package:flutter/material.dart';
import 'package:flutter/material.dart';
import 'package:moon_design/moon_design.dart';

class Avatar extends StatelessWidget {
const Avatar({super.key});
class Avatar extends StatelessWidget {
const Avatar({super.key});

@override
Widget build(BuildContext context) {
return const MoonAvatar(
avatarSize: MoonAvatarSize.sm,
showBadge: true,
content: Text('MD'),
);
}
@override
Widget build(BuildContext context) {
return const MoonAvatar(
avatarSize: MoonAvatarSize.sm,
showBadge: true,
content: Text('MD'),
);
}
}
Loading

0 comments on commit 8c9f851

Please sign in to comment.