Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(UX-1073): List Item notification #172

Merged
merged 4 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
204 changes: 175 additions & 29 deletions example/lib/pages/components/notification_list_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,183 @@ class NotificationListItemExample extends StatelessWidget {

@override
Widget build(BuildContext context) {
final Image image = Image.network(
"https://i.ytimg.com/vi/KItsWUzFUOs/maxresdefault.jpg",
);

return ExampleScaffold(
name: name,
child: Column(
children: [
ZetaNotificationListItem(
body: Text(
"New urgent" * 300,
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
title: 'Urgent Message',
leading: ZetaNotificationBadge.icon(icon: ZetaIcons.check_circle),
notificationTime: "Just now",
action: ZetaButton.negative(
label: "Remove",
onPressed: () {},
),
),
ZetaNotificationListItem(
body: Text(
"New urgent",
),
title: 'Urgent Message',
leading: ZetaNotificationBadge.icon(icon: ZetaIcons.check_circle),
notificationTime: "Just now",
action: ZetaButton.negative(
label: "Remove",
onPressed: () {},
),
),
].gap(Zeta.of(context).spacing.xl_4),
child: SingleChildScrollView(
child: Column(
children: [
Text(
'ZetaNotificationListItem with avatar',
style: TextStyle(fontWeight: FontWeight.bold),
),
ZetaNotificationListItem(
body: Text(
"New urgent message from John Smith that spans multiple lines but line count caps at two",
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
title: 'Urgent Message',
leading: ZetaNotificationBadge.avatar(
avatar: ZetaAvatar.initials(
initials: "JS",
lowerBadge: ZetaAvatarBadge.icon(
color: ZetaColors().surfacePositive,
icon: Icons.check,
),
)),
notificationTime: "Just now",
attachment: Text("Spring-Donation-Drive.pdf"),
showBellIcon: true,
action: ZetaButton.outline(
label: "User Action",
onPressed: () {},
size: ZetaWidgetSize.small,
),
// attachment: Text("Spring-Donation-Drive.pdf"),
),
ZetaNotificationListItem(
body: Text(
"New urgent message from John Smith that spans multiple lines but line count caps at two",
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
title: 'Urgent Message',
leading: ZetaNotificationBadge.avatar(
avatar: ZetaAvatar.initials(
initials: "JS",
lowerBadge: ZetaAvatarBadge.icon(
color: ZetaColors().surfacePositive,
icon: Icons.check,
),
)),
showDivider: true,
notificationTime: "10:32 AM",
showBellIcon: true,
attachment: Text("Spring-Donation-Drive.pdf"),
),
ZetaNotificationListItem(
body: Text(
"New urgent message from John Smith that spans multiple lines but line count caps at two",
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
title: 'Urgent Message',
leading: ZetaNotificationBadge.avatar(
avatar: ZetaAvatar.initials(
initials: "JS",
lowerBadge: ZetaAvatarBadge.icon(
color: ZetaColors().surfacePositive,
icon: Icons.check,
),
),
),
notificationRead: true,
notificationTime: "03/09/2024",
),
const SizedBox(height: 20),
Text(
'ZetaNotificationListItem with image',
style: TextStyle(fontWeight: FontWeight.bold),
),
ZetaNotificationListItem(
body: Text(
"New urgent message from John Smith that spans multiple lines but line count caps at two",
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
title: 'Urgent Message',
leading: ZetaNotificationBadge.image(
image: image,
),
notificationTime: "Just now",
showBellIcon: true,
action: ZetaButton.outline(
label: "User Action",
onPressed: () {},
size: ZetaWidgetSize.small,
),
attachment: Text("Spring-Donation-Drive.pdf"),
),
ZetaNotificationListItem(
body: Text(
"New urgent message from John Smith that spans multiple lines but line count caps at two",
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
title: 'Urgent Message',
leading: ZetaNotificationBadge.image(
image: image,
),
showDivider: true,
notificationTime: "10:32 AM",
showBellIcon: true,
attachment: Text("Spring-Donation-Drive.pdf"),
),
ZetaNotificationListItem(
body: Text(
"New urgent message from John Smith that spans multiple lines but line count caps at two",
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
title: 'Urgent Message',
leading: ZetaNotificationBadge.image(
image: image,
),
notificationRead: true,
notificationTime: "03/09/2024",
),
const SizedBox(height: 20),
Text(
'ZetaNotificationListItem with icon',
style: TextStyle(fontWeight: FontWeight.bold),
),
ZetaNotificationListItem(
body: Text(
"New urgent message from John Smith that spans multiple lines but line count caps at two",
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
title: 'Urgent Message',
leading: ZetaNotificationBadge.icon(icon: ZetaIcons.check_circle),
notificationTime: "Just now",
showBellIcon: true,
action: ZetaButton.outline(
label: "User Action",
onPressed: () {},
size: ZetaWidgetSize.small,
),
attachment: Text("Spring-Donation-Drive.pdf"),
),
ZetaNotificationListItem(
body: Text(
"New urgent message from John Smith that spans multiple lines but line count caps at two",
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
title: 'Urgent Message',
leading: ZetaNotificationBadge.icon(icon: ZetaIcons.check_circle),
showDivider: true,
notificationTime: "10:32 AM",
showBellIcon: true,
attachment: Text("Spring-Donation-Drive.pdf"),
),
ZetaNotificationListItem(
body: Text(
"New urgent message from John Smith that spans multiple lines but line count caps at two",
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
title: 'Urgent Message',
leading: ZetaNotificationBadge.icon(icon: ZetaIcons.check_circle),
notificationRead: true,
notificationTime: "03/09/2024",
),
].gap(Zeta.of(context).spacing.xl_4),
),
),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,30 @@ import '../../utils/scaffold.dart';

Widget notificationListItemUseCase(BuildContext context) => WidgetbookScaffold(
builder: (context, _) => Padding(
padding: EdgeInsets.symmetric(horizontal: context.knobs.list(label: "Size", options: [100, 200, 400])),
padding: EdgeInsets.symmetric(
horizontal:
context.knobs.list(label: "Size", options: [100, 200, 400])),
child: ZetaNotificationListItem(
body: context.knobs.boolean(label: "Include Link")
? Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"New urgent" * 300,
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
ZetaButton.text(label: "label")
],
)
: Text(
"New urgent" * 300,
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
title: context.knobs.string(label: "Title", initialValue: "Urgent Notification"),
notificationTime: context.knobs.stringOrNull(label: "Notification Time", initialValue: "Just Now"),
notificationRead: context.knobs.boolean(label: "Notification Read", initialValue: false),
body: Text(
"New urgent message " * 300,
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
attachment:
context.knobs.boolean(label: "Attachment", initialValue: false)
? Text("Spring-Donation-Drive.pdf")
: null,
title: context.knobs
.string(label: "Title", initialValue: "Urgent Notification"),
notificationTime: context.knobs.stringOrNull(
label: "Notification Time", initialValue: "Just Now"),
notificationRead: context.knobs
.boolean(label: "Notification Read", initialValue: false),
leading: context.knobs.list(
label: 'Badge',
options: [
ZetaNotificationBadge.avatar(avatar: ZetaAvatar.initials(initials: "AO")),
ZetaNotificationBadge.avatar(
avatar: ZetaAvatar.initials(initials: "JS")),
ZetaNotificationBadge.icon(icon: ZetaIcons.check_circle),
ZetaNotificationBadge.image(
image: Image.network(
Expand All @@ -43,23 +41,19 @@ Widget notificationListItemUseCase(BuildContext context) => WidgetbookScaffold(
? "Icon"
: "Image",
),
action: context.knobs.list(
label: "Action Buttons",
options: [
ZetaButton.negative(label: "Remove"),
ZetaButton.positive(label: "Add"),
ZetaButton.outline(label: "Action"),
],
labelBuilder: (value) {
final button = (value as ZetaButton);
return button.label == "Remove"
? "Negative"
: button.label == "Add"
? "Positive"
: "Netutral";
},
),
showDivider: context.knobs.booleanOrNull(label: "Has More"),
action:
context.knobs.boolean(label: "Show action", initialValue: true)
? ZetaButton.outline(
label: "User Action",
onPressed: () {},
size: ZetaWidgetSize.small,
borderType: ZetaWidgetBorder.rounded,
)
: null,
showDivider:
context.knobs.boolean(label: "Show Divider", initialValue: false),
showBellIcon: context.knobs
.boolean(label: "Show Bell Icon", initialValue: true),
),
),
);
Loading
Loading