Skip to content

Commit

Permalink
feat: Chat Item (#37)
Browse files Browse the repository at this point in the history
* feat(main): Chat Item

* [automated commit] lint format and import sort

* remove hard coded avatar

* [automated commit] lint format and import sort

---------

Co-authored-by: github-actions <[email protected]>
  • Loading branch information
2 people authored and thelukewalton committed May 2, 2024
1 parent 84b727c commit c2dd630
Show file tree
Hide file tree
Showing 7 changed files with 487 additions and 0 deletions.
2 changes: 2 additions & 0 deletions example/lib/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:zeta_example/pages/components/banner_example.dart';
import 'package:zeta_example/pages/components/bottom_sheet_example.dart';
import 'package:zeta_example/pages/components/breadcrumbs_example.dart';
import 'package:zeta_example/pages/components/button_example.dart';
import 'package:zeta_example/pages/components/chat_item_example.dart';
import 'package:zeta_example/pages/components/checkbox_example.dart';
import 'package:zeta_example/pages/components/chip_example.dart';
import 'package:zeta_example/pages/components/contact_item_example.dart';
Expand Down Expand Up @@ -57,6 +58,7 @@ final List<Component> components = [
Component(BottomSheetExample.name, (context) => const BottomSheetExample()),
Component(BreadCrumbsExample.name, (context) => const BreadCrumbsExample()),
Component(ButtonExample.name, (context) => const ButtonExample()),
Component(ChatItemExample.name, (context) => const ChatItemExample()),
Component(CheckBoxExample.name, (context) => const CheckBoxExample()),
Component(ChipExample.name, (context) => const ChipExample()),
Component(ContactItemExample.name, (context) => const ContactItemExample()),
Expand Down
61 changes: 61 additions & 0 deletions example/lib/pages/components/chat_item_example.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import 'package:flutter/material.dart';
import 'package:zeta_example/widgets.dart';
import 'package:zeta_flutter/zeta_flutter.dart';

class ChatItemExample extends StatefulWidget {
static const String name = 'ChatItem';

const ChatItemExample({Key? key}) : super(key: key);

@override
State<ChatItemExample> createState() => _ChatItemExampleState();
}

class _ChatItemExampleState extends State<ChatItemExample> {
@override
Widget build(BuildContext context) {
return ExampleScaffold(
name: 'Chat Item',
child: SingleChildScrollView(
child: Column(
children: [
ZetaChatItem(
time: DateTime.now(),
enabledWarningIcon: true,
enabledNotificationIcon: true,
leading: const ZetaAvatar(
size: ZetaAvatarSize.l,
),
count: 100,
onTap: () {},
onDeleteTap: () {},
onCallTap: () {},
onMenuMoreTap: () {},
onPttTap: () {},
title: Text("Chat name ID"),
subtitle: Text(
"Dummy text to represent the first lines of most recent message dsadas dsa dsa ds dssd sd sdsd s ds"),
),
Padding(
padding: const EdgeInsets.only(top: ZetaSpacing.b),
child: ZetaChatItem(
highlighted: true,
count: 99,
time: DateTime.now(),
onTap: () {},
starred: true,
leading: const ZetaAvatar(
size: ZetaAvatarSize.l,
),
title: Text("Chat name ID"),
subtitle: Text(
"Dummy text to represent the first lines of most recent message",
),
),
),
],
),
),
);
}
}
5 changes: 5 additions & 0 deletions example/widgetbook/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'pages/components/banner_widgetbook.dart';
import 'pages/components/bottom_sheet_widgetbook.dart';
import 'pages/components/breadcrumbs_widgetbook.dart';
import 'pages/components/button_widgetbook.dart';
import 'pages/components/chat_item_widgetbook.dart';
import 'pages/components/checkbox_widgetbook.dart';
import 'pages/components/chip_widgetbook.dart';
import 'pages/components/contact_item_widgetbook.dart';
Expand Down Expand Up @@ -83,6 +84,10 @@ class HotReload extends StatelessWidget {
],
),
WidgetbookUseCase(name: 'Avatar', builder: (context) => avatarUseCase(context)),
WidgetbookUseCase(
name: 'Chat Item',
builder: (context) => chatItemWidgetBook(context),
),
WidgetbookUseCase(name: 'Checkbox', builder: (context) => checkboxUseCase(context)),
WidgetbookUseCase(name: 'Contact Item', builder: (context) => contactItemUseCase(context)),
WidgetbookComponent(
Expand Down
49 changes: 49 additions & 0 deletions example/widgetbook/pages/components/chat_item_widgetbook.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import 'package:flutter/material.dart';
import 'package:widgetbook/widgetbook.dart';
import 'package:zeta_flutter/zeta_flutter.dart';

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

Widget chatItemWidgetBook(BuildContext context) {
final title = context.knobs.string(label: 'Title', initialValue: 'Chat name ID');

final subtitle = context.knobs.string(
label: 'Subtitle',
initialValue: 'Dummy text to represent the first lines of most recent message',
);

final count = context.knobs.int.input(label: 'Count', initialValue: 3);

final enabledWarningIcon = context.knobs.boolean(label: 'Warning Icon', initialValue: false);
final enabledNotificationIcon = context.knobs.boolean(label: 'Notification Icon', initialValue: false);
final starred = context.knobs.boolean(label: 'Starred', initialValue: false);

final enabledOnTap = context.knobs.boolean(label: 'Enabled Tap', initialValue: true);
final enabledOnDelete = context.knobs.boolean(label: 'Delete', initialValue: true);

final enabledOnMenuMore = context.knobs.boolean(label: 'Menu More', initialValue: true);

final enabledOnCall = context.knobs.boolean(label: 'Call', initialValue: true);

final enabledOnPtt = context.knobs.boolean(label: 'Ptt', initialValue: true);

return WidgetbookTestWidget(
widget: ZetaChatItem(
time: DateTime.now(),
enabledWarningIcon: enabledWarningIcon,
enabledNotificationIcon: enabledNotificationIcon,
count: count,
onTap: enabledOnTap ? () {} : null,
onDeleteTap: enabledOnDelete ? () {} : null,
onCallTap: enabledOnCall ? () {} : null,
onMenuMoreTap: enabledOnMenuMore ? () {} : null,
onPttTap: enabledOnPtt ? () {} : null,
starred: starred,
leading: const ZetaAvatar(
size: ZetaAvatarSize.l,
),
title: Text(title),
subtitle: Text(subtitle),
),
);
}
Loading

0 comments on commit c2dd630

Please sign in to comment.