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: Notification list item #45

Merged
merged 36 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
1fe3bfc
Component dialog (#18)
atanasyordanov21 Apr 12, 2024
dfe4dd6
feat(main): AppBar (#19)
thelukewalton Apr 12, 2024
d66cc3c
Component dialog (#22)
atanasyordanov21 Apr 12, 2024
7a5dabb
Merge branch 'ZebraDevs:main' into main
thelukewalton Apr 12, 2024
b2d8022
Component phone input (#21)
atanasyordanov21 Apr 16, 2024
b53a177
restore main.dart in example (#23)
atanasyordanov21 Apr 16, 2024
a950ea5
Component phone input (#24)
atanasyordanov21 Apr 16, 2024
8c8650a
Component phone input (#25)
atanasyordanov21 Apr 16, 2024
2f82ae1
Navigation rail (#27)
atanasyordanov21 Apr 19, 2024
e206aa6
Component tooltip (#31)
atanasyordanov21 Apr 22, 2024
f0a8aae
feat(main): Segmented control (#26)
sd-athlon Apr 22, 2024
3facff6
Component phone input (#28)
atanasyordanov21 Apr 23, 2024
93f3dae
use ZetaWidgetSize from enums.dart (#32)
atanasyordanov21 Apr 23, 2024
4c2f908
Component tooltip (#33)
atanasyordanov21 Apr 23, 2024
a9e2a8e
Component search bar (#29)
atanasyordanov21 Apr 23, 2024
0b6f620
Component phone input (#34)
atanasyordanov21 Apr 23, 2024
15b20a4
Merge branch 'ZebraDevs:main' into main
thelukewalton Apr 25, 2024
0325001
Select input (#35)
atanasyordanov21 Apr 26, 2024
766c637
Select input (#35)
atanasyordanov21 Apr 26, 2024
d2eb46e
Filter Selection (#36)
atanasyordanov21 Apr 29, 2024
4dbdeb8
ZetaScreenHeaderBar (#39)
atanasyordanov21 Apr 29, 2024
8608323
merge
Apr 29, 2024
3a42dde
feat : Avatar update (#30)
ahmed-osman3 Apr 30, 2024
9972802
feat(main): Contact List (#40)
sd-athlon Apr 30, 2024
b20080a
feat(main): Chat Item (#37)
sd-athlon Apr 30, 2024
6e6f7ee
Merge branch 'main' of https://github.com/zebrafed/zeta_flutter
Apr 30, 2024
c9878a6
Update banners (#41)
atanasyordanov21 Apr 30, 2024
06ddad2
Merge branch 'main' of https://github.com/zebrafed/zeta_flutter
May 1, 2024
c9b0625
Merge
May 20, 2024
6d1d096
Merge
May 22, 2024
cc15703
Create list item notification
May 29, 2024
51695a6
Merge
May 29, 2024
e928811
Create widgetbook
May 29, 2024
93e645f
Refactor
May 30, 2024
c7556ab
Fix lint errors
May 30, 2024
6cd739a
Respond to comms
Jun 3, 2024
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
2 changes: 2 additions & 0 deletions example/lib/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import 'package:zeta_example/pages/components/filter_selection_example.dart';
import 'package:zeta_example/pages/components/list_item_example.dart';
import 'package:zeta_example/pages/components/navigation_bar_example.dart';
import 'package:zeta_example/pages/components/navigation_rail_example.dart';
import 'package:zeta_example/pages/components/notification_list_example.dart';
import 'package:zeta_example/pages/components/phone_input_example.dart';
import 'package:zeta_example/pages/components/radio_example.dart';
import 'package:zeta_example/pages/components/screen_header_bar_example.dart';
Expand Down Expand Up @@ -68,6 +69,7 @@ final List<Component> components = [
Component(ContactItemExample.name, (context) => const ContactItemExample()),
Component(ListItemExample.name, (context) => const ListItemExample()),
Component(NavigationBarExample.name, (context) => const NavigationBarExample()),
Component(NotificationListItemExample.name, (context) => const NotificationListItemExample()),
Component(PaginationExample.name, (context) => const PaginationExample()),
Component(PasswordInputExample.name, (context) => const PasswordInputExample()),
Component(GroupHeaderExample.name, (context) => const GroupHeaderExample()),
Expand Down
65 changes: 65 additions & 0 deletions example/lib/pages/components/notification_list_example.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import 'package:flutter/material.dart';
import 'package:zeta_example/widgets.dart';
import 'package:zeta_flutter/zeta_flutter.dart';

class NotificationListItemExample extends StatefulWidget {
static const String name = 'NotificationListItem';

const NotificationListItemExample({super.key});

@override
State<NotificationListItemExample> createState() => _NotificationListItemExampleState();
}

class _NotificationListItemExampleState extends State<NotificationListItemExample> {
@override
Widget build(BuildContext context) {
return ExampleScaffold(
name: "NotificationListItem",
child: SingleChildScrollView(
child: Column(
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 400),
child: ZetaNotificationListItem(
body: Text(
"New urgent" * 300,
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
title: 'Urgent Message',
leading: ZetaNotificationBadge.icon(icon: ZetaIcons.check_circle_round),
notificationTime: "Just now",
action: ZetaButton.negative(
label: "Remove",
onPressed: () {},
),
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 200),
child: ZetaNotificationListItem(
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"New urgent" * 300,
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
ZetaButton.text(label: "label")
],
),
title: 'Urgent Message',
leading: ZetaNotificationBadge.icon(icon: ZetaIcons.check_circle_round),
notificationTime: "Just now",
action: ZetaButton.negative(
label: "Remove",
onPressed: () {},
),
),
),
].gap(ZetaSpacing.l))),
);
}
}
3 changes: 3 additions & 0 deletions example/widgetbook/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:zeta_flutter/zeta_flutter.dart';

import 'pages/assets/icon_widgetbook.dart';
import 'pages/components/accordion_widgetbook.dart';
import 'pages/components/notification_list_item_widgetbook.dart';
import 'pages/components/text_input_widgetbook.dart';
import 'pages/components/top_app_bar_widgetbook.dart';
import 'pages/components/avatar_widgetbook.dart';
Expand Down Expand Up @@ -122,6 +123,8 @@ class HotReload extends StatelessWidget {
WidgetbookUseCase(name: 'Dial Pad', builder: (context) => dialPadUseCase(context)),
WidgetbookUseCase(name: 'Global Header', builder: (context) => globalHeaderUseCase(context)),
WidgetbookUseCase(name: 'List Item', builder: (context) => listItemUseCase(context)),
WidgetbookUseCase(
name: 'Notification List Item', builder: (context) => notificationListItemUseCase(context)),
WidgetbookUseCase(name: 'Navigation Bar', builder: (context) => navigationBarUseCase(context)),
WidgetbookUseCase(name: 'Pagination', builder: (context) => paginationUseCase(context)),
WidgetbookUseCase(name: 'Radio Button', builder: (context) => radioButtonUseCase(context)),
Expand Down
12 changes: 5 additions & 7 deletions example/widgetbook/pages/components/avatar_widgetbook.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ Widget avatarUseCase(BuildContext context) {
widget: 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(),
),
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_round,
Expand All @@ -33,9 +33,7 @@ Widget avatarUseCase(BuildContext context) {
)
: null,
initials: context.knobs.stringOrNull(label: 'Initials', initialValue: null),
backgroundColor: context.knobs.colorOrNull(
label: 'Background color',
),
backgroundColor: context.knobs.colorOrNull(label: 'Background color', initialValue: colors.purple.shade80),
),
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import 'package:flutter/material.dart';
import 'package:widgetbook/widgetbook.dart';
import 'package:zeta_flutter/zeta_flutter.dart';

import '../../test/test_components.dart';

Widget notificationListItemUseCase(BuildContext context) => WidgetbookTestWidget(
widget: Padding(
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),
leading: context.knobs.list(
label: 'Badge',
options: [
ZetaNotificationBadge.avatar(avatar: ZetaAvatar.initials(initials: "AO")),
ZetaNotificationBadge.icon(icon: ZetaIcons.check_circle_round),
ZetaNotificationBadge.image(
image: Image.network(
"https://www.google.com/url?sa=i&url=https%3A%2F%2Fgithub.com%2Fzebratechnologies&psig=AOvVaw0fBPVE5gUkkpFw8mVf6B8G&ust=1717073069230000&source=images&cd=vfe&opi=89978449&ved=0CBIQjRxqFwoTCPCwn-XxsoYDFQAAAAAdAAAAABAE"))
],
labelBuilder: (value) => value.avatar != null
? "Avatar"
: value.icon != null
? "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"),
),
),
);
4 changes: 2 additions & 2 deletions lib/src/components/avatars/avatar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,8 @@ class ZetaAvatarBadge extends StatelessWidget {
this.color,
this.icon = ZetaIcons.star_round,
this.iconColor,
this.size = ZetaAvatarSize.xxxl,
}) : value = null,
size = ZetaAvatarSize.xxxl,
type = ZetaAvatarBadgeType.icon;

/// Constructs [ZetaAvatarBadge] with notifications
Expand Down Expand Up @@ -407,7 +407,7 @@ class ZetaAvatarBadge extends StatelessWidget {
)
: null,
),
child: Center(child: innerContent),
child: innerContent,
);
}

Expand Down
12 changes: 10 additions & 2 deletions lib/src/components/badges/indicator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class ZetaIndicator extends StatelessWidget {
this.icon,
this.value,
this.inverse = false,
this.color,
});

/// Constructor for [ZetaIndicator] of type [ZetaIndicatorType.icon].
Expand All @@ -31,6 +32,7 @@ class ZetaIndicator extends StatelessWidget {
this.size = ZetaWidgetSize.large,
this.inverse = false,
this.icon,
this.color,
}) : type = ZetaIndicatorType.icon,
value = null;

Expand All @@ -41,6 +43,7 @@ class ZetaIndicator extends StatelessWidget {
this.inverse = false,
this.icon,
this.value,
this.color,
}) : type = ZetaIndicatorType.notification;

/// The type of the [ZetaIndicator] - icon or notification.
Expand All @@ -62,6 +65,9 @@ class ZetaIndicator extends StatelessWidget {
/// Value for the type `notification`.
final int? value;

/// Color for zeta indicator
final Color? color;

/// Creates a clone.
ZetaIndicator copyWith({
ZetaIndicatorType? type,
Expand All @@ -82,7 +88,8 @@ class ZetaIndicator extends StatelessWidget {
@override
Widget build(BuildContext context) {
final zetaColors = Zeta.of(context).colors;
final Color backgroundColor = (type == ZetaIndicatorType.icon ? zetaColors.blue : zetaColors.surfaceNegative);
final Color backgroundColor =
color ?? (type == ZetaIndicatorType.icon ? zetaColors.blue : zetaColors.surfaceNegative);
final Color foregroundColor = backgroundColor.onColor;
final sizePixels = _getSizePixels(size, type);

Expand Down Expand Up @@ -163,6 +170,7 @@ class ZetaIndicator extends StatelessWidget {
..add(DiagnosticsProperty<ZetaWidgetSize>('size', size))
..add(DiagnosticsProperty<int?>('value', value))
..add(DiagnosticsProperty<IconData?>('icon', icon))
..add(DiagnosticsProperty<bool>('inverseBorder', inverse));
..add(DiagnosticsProperty<bool>('inverseBorder', inverse))
..add(ColorProperty('color', color));
}
}
2 changes: 1 addition & 1 deletion lib/src/components/buttons/button_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ ButtonStyle buttonStyle(
return isSolid ? color.shade50 : colors.cool.shade20;
}
if (backgroundColor != null) return backgroundColor;
return isSolid ? color : Colors.transparent;
return isSolid ? color : colors.surfacePrimary;
},
),
foregroundColor: WidgetStateProperty.resolveWith<Color?>(
Expand Down
Loading