-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(UX-1231): created avatar rail (#196)
feat: created avatar rail test: created tests for avatar rail feat: added label to avatar test: fixed parent folder for stepper chore(automated): Lint commit and format fix: added MainAxisSize.min to avatar column to regulate height fix: widgetbook max lines avatar rail
- Loading branch information
Showing
18 changed files
with
869 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// import 'package:cached_network_image/cached_network_image.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:zeta_example/widgets.dart'; | ||
import 'package:zeta_flutter/zeta_flutter.dart'; | ||
|
||
class AvatarRailExample extends StatefulWidget { | ||
static const String name = 'AvatarRail'; | ||
|
||
const AvatarRailExample({super.key}); | ||
|
||
@override | ||
State<AvatarRailExample> createState() => _AvatarRailExampleState(); | ||
} | ||
|
||
class _AvatarRailExampleState extends State<AvatarRailExample> { | ||
int? selected; | ||
@override | ||
Widget build(BuildContext context) { | ||
final avatarList = [ | ||
ZetaAvatar.initials( | ||
initials: 'AZ', | ||
label: 'Archie', | ||
), | ||
ZetaAvatar.initials( | ||
initials: 'BY', | ||
label: 'Beth', | ||
), | ||
ZetaAvatar.initials( | ||
initials: 'CX', | ||
label: 'Clara', | ||
), | ||
ZetaAvatar.initials( | ||
initials: 'DW', | ||
label: 'Dan', | ||
), | ||
ZetaAvatar.initials( | ||
initials: 'EV', | ||
label: 'Emily', | ||
), | ||
ZetaAvatar.initials( | ||
initials: 'FU', | ||
label: 'Frank', | ||
), | ||
ZetaAvatar.initials( | ||
initials: 'GT', | ||
label: 'George', | ||
), | ||
ZetaAvatar.initials( | ||
initials: 'HS', | ||
label: 'Harith', | ||
), | ||
ZetaAvatar.initials( | ||
initials: 'IR', | ||
label: 'Irene', | ||
), | ||
ZetaAvatar.initials( | ||
initials: 'KQ', | ||
label: 'Katie', | ||
), | ||
]; | ||
return ExampleScaffold( | ||
name: AvatarRailExample.name, | ||
child: SingleChildScrollView( | ||
child: Column( | ||
children: [ | ||
for (final size in ZetaAvatarSize.values) | ||
Row( | ||
children: [ | ||
Text(size.toString()), | ||
SizedBox( | ||
width: 500, | ||
child: ZetaAvatarRail( | ||
gap: 10, | ||
size: size, | ||
labelMaxLines: 3, | ||
onTap: (key) => { | ||
setState(() { | ||
selected = int.parse(key.toString().replaceAll(RegExp(r'[^0-9]'), '')); | ||
}) | ||
}, | ||
avatars: avatarList, | ||
), | ||
), | ||
if (selected != null) | ||
Padding( | ||
padding: const EdgeInsets.all(8.0), | ||
child: avatarList[selected!].copyWith(size: size), | ||
), | ||
].gap(50), | ||
) | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
174 changes: 174 additions & 0 deletions
174
example/widgetbook/pages/components/avatar_rail_widgetbook.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:widgetbook/widgetbook.dart'; | ||
import 'package:zeta_flutter/zeta_flutter.dart'; | ||
|
||
import '../../utils/scaffold.dart'; | ||
|
||
Widget avatarRailUseCase(BuildContext context) { | ||
final Widget image = Image.asset('assets/Omer.jpg', fit: BoxFit.cover); | ||
final colors = Zeta.of(context).colors; | ||
|
||
return WidgetbookScaffold( | ||
builder: (context, _) => ZetaAvatarRail( | ||
labelMaxLines: context.knobs.int.slider(label: 'Label Max Lines', min: 1, max: 3, initialValue: 1), | ||
avatars: [ | ||
ZetaAvatar( | ||
image: context.knobs.boolean(label: 'Image') ? image : null, | ||
size: context.knobs.list( | ||
label: 'Size', | ||
options: ZetaAvatarSize.values, | ||
labelBuilder: (value) => value.name.split('.').last.toUpperCase(), | ||
initialOption: ZetaAvatarSize.m, | ||
), | ||
upperBadge: context.knobs.boolean(label: 'Status Badge', initialValue: false) | ||
? ZetaAvatarBadge.icon( | ||
icon: ZetaIcons.close, | ||
color: context.knobs.colorOrNull(label: "Upper Badge Color", initialValue: colors.green) ?? | ||
colors.iconDefault, | ||
) | ||
: null, | ||
borderColor: context.knobs.colorOrNull(label: 'Outline', initialValue: colors.green), | ||
lowerBadge: context.knobs.boolean(label: 'Notification Badge', initialValue: false) | ||
? ZetaAvatarBadge.notification( | ||
value: context.knobs.intOrNull.input(label: "Value", initialValue: 1), | ||
) | ||
: null, | ||
initials: context.knobs.stringOrNull(label: 'Initials', initialValue: 'AZ'), | ||
backgroundColor: context.knobs.colorOrNull(label: 'Background color', initialValue: colors.purple.shade80), | ||
onTap: () => print('Avatar tapped'), | ||
label: context.knobs.stringOrNull(label: 'Label', initialValue: 'ABC'), | ||
), | ||
ZetaAvatar( | ||
image: context.knobs.boolean(label: 'Image') ? image : null, | ||
size: context.knobs.list( | ||
label: 'Size', | ||
options: ZetaAvatarSize.values, | ||
labelBuilder: (value) => value.name.split('.').last.toUpperCase(), | ||
initialOption: ZetaAvatarSize.m, | ||
), | ||
upperBadge: context.knobs.boolean(label: 'Status Badge', initialValue: false) | ||
? ZetaAvatarBadge.icon( | ||
icon: ZetaIcons.close, | ||
color: context.knobs.colorOrNull(label: "Upper Badge Color", initialValue: colors.green) ?? | ||
colors.iconDefault, | ||
) | ||
: null, | ||
borderColor: context.knobs.colorOrNull(label: 'Outline', initialValue: colors.green), | ||
lowerBadge: context.knobs.boolean(label: 'Notification Badge', initialValue: false) | ||
? ZetaAvatarBadge.notification( | ||
value: context.knobs.intOrNull.input(label: "Value", initialValue: 1), | ||
) | ||
: null, | ||
initials: context.knobs.stringOrNull(label: 'Initials', initialValue: 'AZ'), | ||
backgroundColor: context.knobs.colorOrNull(label: 'Background color', initialValue: colors.purple.shade80), | ||
onTap: () => print('Avatar tapped'), | ||
label: context.knobs.stringOrNull(label: 'Label', initialValue: 'ABC'), | ||
), | ||
ZetaAvatar( | ||
image: context.knobs.boolean(label: 'Image') ? image : null, | ||
size: context.knobs.list( | ||
label: 'Size', | ||
options: ZetaAvatarSize.values, | ||
labelBuilder: (value) => value.name.split('.').last.toUpperCase(), | ||
initialOption: ZetaAvatarSize.m, | ||
), | ||
upperBadge: context.knobs.boolean(label: 'Status Badge', initialValue: false) | ||
? ZetaAvatarBadge.icon( | ||
icon: ZetaIcons.close, | ||
color: context.knobs.colorOrNull(label: "Upper Badge Color", initialValue: colors.green) ?? | ||
colors.iconDefault, | ||
) | ||
: null, | ||
borderColor: context.knobs.colorOrNull(label: 'Outline', initialValue: colors.green), | ||
lowerBadge: context.knobs.boolean(label: 'Notification Badge', initialValue: false) | ||
? ZetaAvatarBadge.notification( | ||
value: context.knobs.intOrNull.input(label: "Value", initialValue: 1), | ||
) | ||
: null, | ||
initials: context.knobs.stringOrNull(label: 'Initials', initialValue: 'AZ'), | ||
backgroundColor: context.knobs.colorOrNull(label: 'Background color', initialValue: colors.purple.shade80), | ||
onTap: () => print('Avatar tapped'), | ||
label: context.knobs.stringOrNull(label: 'Label', initialValue: 'ABC'), | ||
), | ||
ZetaAvatar( | ||
image: context.knobs.boolean(label: 'Image') ? image : null, | ||
size: context.knobs.list( | ||
label: 'Size', | ||
options: ZetaAvatarSize.values, | ||
labelBuilder: (value) => value.name.split('.').last.toUpperCase(), | ||
initialOption: ZetaAvatarSize.m, | ||
), | ||
upperBadge: context.knobs.boolean(label: 'Status Badge', initialValue: false) | ||
? ZetaAvatarBadge.icon( | ||
icon: ZetaIcons.close, | ||
color: context.knobs.colorOrNull(label: "Upper Badge Color", initialValue: colors.green) ?? | ||
colors.iconDefault, | ||
) | ||
: null, | ||
borderColor: context.knobs.colorOrNull(label: 'Outline', initialValue: colors.green), | ||
lowerBadge: context.knobs.boolean(label: 'Notification Badge', initialValue: false) | ||
? ZetaAvatarBadge.notification( | ||
value: context.knobs.intOrNull.input(label: "Value", initialValue: 1), | ||
) | ||
: null, | ||
initials: context.knobs.stringOrNull(label: 'Initials', initialValue: 'AZ'), | ||
backgroundColor: context.knobs.colorOrNull(label: 'Background color', initialValue: colors.purple.shade80), | ||
onTap: () => print('Avatar tapped'), | ||
label: context.knobs.stringOrNull(label: 'Label', initialValue: 'ABC'), | ||
), | ||
ZetaAvatar( | ||
image: context.knobs.boolean(label: 'Image') ? image : null, | ||
size: context.knobs.list( | ||
label: 'Size', | ||
options: ZetaAvatarSize.values, | ||
labelBuilder: (value) => value.name.split('.').last.toUpperCase(), | ||
initialOption: ZetaAvatarSize.m, | ||
), | ||
upperBadge: context.knobs.boolean(label: 'Status Badge', initialValue: false) | ||
? ZetaAvatarBadge.icon( | ||
icon: ZetaIcons.close, | ||
color: context.knobs.colorOrNull(label: "Upper Badge Color", initialValue: colors.green) ?? | ||
colors.iconDefault, | ||
) | ||
: null, | ||
borderColor: context.knobs.colorOrNull(label: 'Outline', initialValue: colors.green), | ||
lowerBadge: context.knobs.boolean(label: 'Notification Badge', initialValue: false) | ||
? ZetaAvatarBadge.notification( | ||
value: context.knobs.intOrNull.input(label: "Value", initialValue: 1), | ||
) | ||
: null, | ||
initials: context.knobs.stringOrNull(label: 'Initials', initialValue: 'AZ'), | ||
backgroundColor: context.knobs.colorOrNull(label: 'Background color', initialValue: colors.purple.shade80), | ||
onTap: () => print('Avatar tapped'), | ||
label: context.knobs.stringOrNull(label: 'Label', initialValue: 'ABC'), | ||
), | ||
ZetaAvatar( | ||
image: context.knobs.boolean(label: 'Image') ? image : null, | ||
size: context.knobs.list( | ||
label: 'Size', | ||
options: ZetaAvatarSize.values, | ||
labelBuilder: (value) => value.name.split('.').last.toUpperCase(), | ||
initialOption: ZetaAvatarSize.m, | ||
), | ||
upperBadge: context.knobs.boolean(label: 'Status Badge', initialValue: false) | ||
? ZetaAvatarBadge.icon( | ||
icon: ZetaIcons.close, | ||
color: context.knobs.colorOrNull(label: "Upper Badge Color", initialValue: colors.green) ?? | ||
colors.iconDefault, | ||
) | ||
: null, | ||
borderColor: context.knobs.colorOrNull(label: 'Outline', initialValue: colors.green), | ||
lowerBadge: context.knobs.boolean(label: 'Notification Badge', initialValue: false) | ||
? ZetaAvatarBadge.notification( | ||
value: context.knobs.intOrNull.input(label: "Value", initialValue: 1), | ||
) | ||
: null, | ||
initials: context.knobs.stringOrNull(label: 'Initials', initialValue: 'AZ'), | ||
backgroundColor: context.knobs.colorOrNull(label: 'Background color', initialValue: colors.purple.shade80), | ||
onTap: () => print('Avatar tapped'), | ||
label: context.knobs.stringOrNull(label: 'Label', initialValue: 'ABC'), | ||
), | ||
], | ||
), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.