Skip to content

Commit

Permalink
feat: created avatar rail
Browse files Browse the repository at this point in the history
test: created tests for avatar rail

feat: added label to avatar

test: fixed parent folder for stepper
  • Loading branch information
DE7924 committed Oct 28, 2024
1 parent 17a6995 commit 555afd6
Show file tree
Hide file tree
Showing 19 changed files with 876 additions and 55 deletions.
2 changes: 2 additions & 0 deletions example/lib/home.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:zeta_example/pages/components/accordion_example.dart';
import 'package:zeta_example/pages/components/avatar_rail_example.dart';
import 'package:zeta_example/pages/components/avatar_example.dart';
import 'package:zeta_example/pages/components/badges_example.dart';
import 'package:zeta_example/pages/components/banner_example.dart';
Expand Down Expand Up @@ -61,6 +62,7 @@ class Component {
final List<Component> components = [
Component(AccordionExample.name, (context) => const AccordionExample()),
Component(TopAppBarExample.name, (context) => const TopAppBarExample()),
Component(AvatarRailExample.name, (context) => const AvatarRailExample()),
Component(AvatarExample.name, (context) => const AvatarExample()),
Component(BannerExample.name, (context) => const BannerExample()),
Component(BadgesExample.name, (context) => const BadgesExample()),
Expand Down
96 changes: 96 additions & 0 deletions example/lib/pages/components/avatar_rail_example.dart
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),
)
],
),
),
);
}
}
2 changes: 1 addition & 1 deletion example/macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Foundation

import path_provider_foundation
import shared_preferences_foundation
import sqflite_darwin
import sqflite
import url_launcher_macos

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
Expand Down
12 changes: 10 additions & 2 deletions example/widgetbook/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'pages/components/notification_list_item_widgetbook.dart';
import 'pages/components/slider_widgetbook.dart';
import 'pages/components/text_input_widgetbook.dart';
import 'pages/components/top_app_bar_widgetbook.dart';
import 'pages/components/avatar_rail_widgetbook.dart';
import 'pages/components/avatar_widgetbook.dart';
import 'pages/components/badges_widgetbook.dart';
import 'pages/components/banner_widgetbook.dart';
Expand Down Expand Up @@ -121,6 +122,13 @@ class _HotReloadState extends State<HotReload> {
name: 'Components',
isInitiallyExpanded: false,
children: [
WidgetbookComponent(
name: 'Avatar',
useCases: [
WidgetbookUseCase(name: 'Avatar', builder: (context) => avatarUseCase(context)),
WidgetbookUseCase(name: 'Avatar Rail', builder: (context) => avatarRailUseCase(context)),
],
),
WidgetbookComponent(
name: 'Top App Bar',
useCases: [
Expand Down Expand Up @@ -181,7 +189,6 @@ class _HotReloadState extends State<HotReload> {
],
),
WidgetbookUseCase(name: 'Accordion', builder: (context) => accordionUseCase(context)),
WidgetbookUseCase(name: 'Avatar', builder: (context) => avatarUseCase(context)),
WidgetbookUseCase(name: 'Banners', builder: (context) => bannerUseCase(context)),
WidgetbookUseCase(name: 'Bottom Sheet', builder: (context) => bottomSheetContentUseCase(context)),
WidgetbookUseCase(name: 'BreadCrumbs', builder: (context) => breadCrumbsUseCase(context)),
Expand Down Expand Up @@ -246,7 +253,8 @@ class _HotReloadState extends State<HotReload> {
ZetaAddon(),
InspectorAddon(enabled: false),
ZoomAddon(initialZoom: 1.0),
TextScaleAddon(min: 1, max: 2, divisions: 4, initialScale: 1),
// min: 1, max: 2, divisions: 4,
TextScaleAddon(scales: [1, 1.25, 1.5, 1.75, 2], initialScale: 1),
],
);
}
Expand Down
179 changes: 179 additions & 0 deletions example/widgetbook/pages/components/avatar_rail_widgetbook.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
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(
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'),
labelMaxLines: context.knobs.int.slider(label: 'Label Max Lines', min: 1, max: 3, initialValue: 1),
),
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'),
labelMaxLines: context.knobs.int.slider(label: 'Label Max Lines', min: 1, max: 3, initialValue: 1),
),
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'),
labelMaxLines: context.knobs.int.slider(label: 'Label Max Lines', min: 1, max: 3, initialValue: 1),
),
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'),
labelMaxLines: context.knobs.int.slider(label: 'Label Max Lines', min: 1, max: 3, initialValue: 1),
),
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'),
labelMaxLines: context.knobs.int.slider(label: 'Label Max Lines', min: 1, max: 3, initialValue: 1),
),
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'),
labelMaxLines: context.knobs.int.slider(label: 'Label Max Lines', min: 1, max: 3, initialValue: 1),
),
],
),
);
}
3 changes: 3 additions & 0 deletions example/widgetbook/pages/components/avatar_widgetbook.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ Widget avatarUseCase(BuildContext context) {
: 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'),
labelMaxLines: context.knobs.int.slider(label: 'Label Max Lines', min: 1, max: 3, initialValue: 1),
),
);
}
Loading

0 comments on commit 555afd6

Please sign in to comment.