-
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(main): Contact List * [automated commit] lint format and import sort --------- Co-authored-by: github-actions <[email protected]>
- Loading branch information
1 parent
3f51508
commit 84b727c
Showing
6 changed files
with
153 additions
and
0 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,27 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:zeta_example/widgets.dart'; | ||
import 'package:zeta_flutter/zeta_flutter.dart'; | ||
|
||
class ContactItemExample extends StatefulWidget { | ||
static const String name = 'ContactItem'; | ||
|
||
const ContactItemExample({super.key}); | ||
|
||
@override | ||
State<ContactItemExample> createState() => _ContactItemExampleState(); | ||
} | ||
|
||
class _ContactItemExampleState extends State<ContactItemExample> { | ||
@override | ||
Widget build(BuildContext context) { | ||
return ExampleScaffold( | ||
name: ContactItemExample.name, | ||
child: ZetaContactItem( | ||
onTap: () {}, | ||
leading: ZetaAvatar(size: ZetaAvatarSize.s), | ||
title: Text("Contact / Group Name"), | ||
subtitle: Text("Store Associate - Bakery Dept."), | ||
), | ||
); | ||
} | ||
} |
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
21 changes: 21 additions & 0 deletions
21
example/widgetbook/pages/components/contact_item_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,21 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:widgetbook/widgetbook.dart'; | ||
import 'package:zeta_flutter/zeta_flutter.dart'; | ||
|
||
import '../../test/test_components.dart'; | ||
|
||
Widget contactItemUseCase(BuildContext context) { | ||
final title = context.knobs.string(label: 'Title', initialValue: "Contact / Group Name"); | ||
final subtitle = context.knobs.string(label: 'Subtitle', initialValue: "Store Associate - Bakery Dept."); | ||
final enabledDivider = context.knobs.boolean(label: 'Enabled Divider', initialValue: true); | ||
|
||
return WidgetbookTestWidget( | ||
widget: ZetaContactItem( | ||
onTap: () {}, | ||
leading: ZetaAvatar(size: ZetaAvatarSize.s), | ||
title: Text(title), | ||
subtitle: Text(subtitle), | ||
enabledDivider: enabledDivider, | ||
), | ||
); | ||
} |
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,100 @@ | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter/material.dart'; | ||
import '../../../zeta_flutter.dart'; | ||
|
||
/// A single row that contains avatar, title and subtitle. | ||
class ZetaContactItem extends StatelessWidget { | ||
/// Constructs [ZetaContactItem]. | ||
const ZetaContactItem({ | ||
required this.title, | ||
required this.leading, | ||
required this.subtitle, | ||
this.enabledDivider = true, | ||
this.onTap, | ||
super.key, | ||
}); | ||
|
||
/// The main text to be displayed on the top. | ||
final Widget title; | ||
|
||
/// Normally an Avatar | ||
final Widget leading; | ||
|
||
/// Text to be displayed under [title]. | ||
final Widget subtitle; | ||
|
||
/// Callback to be called onTap. | ||
final VoidCallback? onTap; | ||
|
||
/// Whether to display a divider at the bottom. | ||
final bool enabledDivider; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final colors = Zeta.of(context).colors; | ||
|
||
return DecoratedBox( | ||
decoration: BoxDecoration( | ||
color: colors.surfacePrimary, | ||
border: enabledDivider | ||
? Border( | ||
bottom: BorderSide(color: colors.borderDisabled), | ||
) | ||
: null, | ||
), | ||
child: Material( | ||
color: Colors.transparent, | ||
child: InkWell( | ||
onTap: onTap, | ||
child: Padding( | ||
padding: const EdgeInsets.only( | ||
top: ZetaSpacing.xs, | ||
bottom: ZetaSpacing.xs, | ||
left: ZetaSpacing.m, | ||
), | ||
child: Row( | ||
children: [ | ||
leading, | ||
Flexible( | ||
child: Padding( | ||
padding: const EdgeInsets.only(left: ZetaSpacing.s), | ||
child: Column( | ||
mainAxisSize: MainAxisSize.min, | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
DefaultTextStyle( | ||
style: ZetaTextStyles.bodyMedium.copyWith( | ||
color: colors.textDefault, | ||
), | ||
maxLines: 1, | ||
overflow: TextOverflow.ellipsis, | ||
child: title, | ||
), | ||
DefaultTextStyle( | ||
style: ZetaTextStyles.bodySmall.copyWith( | ||
color: colors.textSubtle, | ||
), | ||
maxLines: 1, | ||
overflow: TextOverflow.ellipsis, | ||
child: subtitle, | ||
), | ||
], | ||
), | ||
), | ||
), | ||
], | ||
), | ||
), | ||
), | ||
), | ||
); | ||
} | ||
|
||
@override | ||
void debugFillProperties(DiagnosticPropertiesBuilder properties) { | ||
super.debugFillProperties(properties); | ||
properties | ||
..add(ObjectFlagProperty<VoidCallback?>.has('onTap', onTap)) | ||
..add(DiagnosticsProperty<bool>('enabledDivider', enabledDivider)); | ||
} | ||
} |
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