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: UIKit chip component #568

Merged
merged 38 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
fed4da8
feat: Add VoicesAppBar (#531)
coire1 Jun 11, 2024
7bb6c8d
fix: Fix .earthlyignore excluded directories/files (#536)
dtscalac Jun 11, 2024
9054387
fix: catalyst cardano support for NFTs (#537)
dtscalac Jun 11, 2024
04f5c3a
feat: cardano wallet cip 95 (#538)
dtscalac Jun 11, 2024
77c5222
docs: add common issues docs (#548)
dtscalac Jun 14, 2024
8b8c4fd
feat: use theme builder
dtscalac Jun 17, 2024
91a0034
chore: enable earthly files
dtscalac Jun 17, 2024
06f18be
chore: enable disabled earthly target
dtscalac Jun 18, 2024
d2826c7
Merge branch 'feat/frontend' into feat/navigation-drawer
dtscalac Jun 18, 2024
723ef89
chore: rerun target without cache
dtscalac Jun 18, 2024
a3f010f
chore: no-cache earthly target
dtscalac Jun 18, 2024
667966d
chore: trigger rebuild
dtscalac Jun 18, 2024
2381dd6
Merge branch 'main' into feat/frontend
dtscalac Jun 18, 2024
6a41db4
Merge branch 'main' into feat/frontend
dtscalac Jun 18, 2024
9b71b00
Merge branch 'main' into feat/frontend
stevenj Jun 18, 2024
e2c2442
Merge branch 'feat/frontend' into feat/navigation-drawer
dtscalac Jun 19, 2024
97027bd
refactor: extract widget
dtscalac Jun 19, 2024
458f783
Merge branch 'main' into feat/frontend
minikin Jun 19, 2024
ff9fe21
Merge branch 'main' into feat/navigation-drawer
dtscalac Jun 19, 2024
8648ad2
Merge branch 'main' into feat/frontend
dtscalac Jun 19, 2024
09169cf
Merge branch 'main' into feat/frontend
dtscalac Jun 19, 2024
a09074e
Merge branch 'feat/frontend' into feat/navigation-drawer
dtscalac Jun 19, 2024
dbfafab
feat: uikit example
dtscalac Jun 19, 2024
42d491a
Merge branch 'main' into feat/navigation-drawer
dtscalac Jun 19, 2024
324deda
Merge branch 'main' into feat/navigation-drawer
dtscalac Jun 20, 2024
4882988
Merge branch 'main' into feat/navigation-drawer
dtscalac Jun 22, 2024
6a37793
feat: voices drawer
dtscalac Jun 22, 2024
b276705
feat: finish nav drawer
dtscalac Jun 23, 2024
43264a4
feat: add docs and voices list tiles
dtscalac Jun 23, 2024
af7035c
feat: update to named navigation to preserve route when hot restarting
dtscalac Jun 24, 2024
3d1db8a
refactor: cleanup code
dtscalac Jun 24, 2024
6ddeedd
refactor: cleanup
dtscalac Jun 24, 2024
89317e1
feat: uikit chips
dtscalac Jun 24, 2024
f2fcecb
feat: add missing properties to chips
dtscalac Jun 24, 2024
4704a77
chore: add unknown word
dtscalac Jun 24, 2024
6569f89
docs: missing documentation
dtscalac Jun 24, 2024
30a15b2
Merge branch 'main' into feat/navigation-drawer
dtscalac Jun 24, 2024
45147b3
Merge branch 'feat/navigation-drawer' into feat/uikit-chips
dtscalac Jun 24, 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
3 changes: 2 additions & 1 deletion .config/dictionaries/project.dic
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,5 @@ xcworkspace
yoroi
multiasset
unawaited
Gitbook
Gitbook
trailings
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:catalyst_voices/pages/login/login.dart';
import 'package:catalyst_voices/pages/widgets/widgets.dart';
import 'package:catalyst_voices/widgets/widgets.dart';
import 'package:flutter_test/flutter_test.dart';

final class LoginRobot {
Expand Down
2 changes: 1 addition & 1 deletion catalyst_voices/lib/pages/login/login_form.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:catalyst_voices/pages/login/login.dart';
import 'package:catalyst_voices/pages/widgets/widgets.dart';
import 'package:catalyst_voices/widgets/widgets.dart';
import 'package:catalyst_voices_blocs/catalyst_voices_blocs.dart';
import 'package:catalyst_voices_localization/catalyst_voices_localization.dart';
import 'package:flutter/material.dart';
Expand Down
113 changes: 113 additions & 0 deletions catalyst_voices/lib/widgets/chips/voices_chip.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import 'package:catalyst_voices_brands/catalyst_voices_brands.dart';
import 'package:flutter/material.dart';

/// A contextual chip acting as a label with some extra
/// small piece of information.
class VoicesChip extends StatelessWidget {
/// The main content of the chip, usually a [Text] widget.
final Widget content;

/// The widget in front of the [content].
final Widget? leading;

/// The widget in back of the [content].
final Widget? trailing;

/// The color of the background, transparent by default.
final Color? backgroundColor;

/// The radius of rounded corners of the chip.
final BorderRadius borderRadius;

/// The internal padding from the widget borders to the internal content.
final EdgeInsets padding;

/// The callback called when the widget is tapped.
final VoidCallback? onTap;

/// The default constructor for the [VoicesChip].
const VoicesChip({
super.key,
required this.content,
this.leading,
this.trailing,
this.backgroundColor,
required this.borderRadius,
this.padding = const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
this.onTap,
});

/// A constructor that creates a [VoicesChip] with fully rounded corners.
const VoicesChip.round({
super.key,
required this.content,
this.leading,
this.trailing,
this.backgroundColor,
this.padding = const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
this.onTap,
}) : borderRadius = const BorderRadius.all(Radius.circular(32));

/// A constructor that creates a [VoicesChip] with slightly rounded,
/// rectangular corners.
const VoicesChip.rectangular({
super.key,
required this.content,
this.leading,
this.trailing,
this.backgroundColor,
this.padding = const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
this.onTap,
}) : borderRadius = const BorderRadius.all(Radius.circular(8));

@override
Widget build(BuildContext context) {
return DecoratedBox(
decoration: BoxDecoration(
color: backgroundColor,
border: backgroundColor != null
? null
: Border.all(
color: Theme.of(context).colors.outlineBorderVariant!,
),
borderRadius: borderRadius,
),
child: Material(
type: MaterialType.transparency,
borderRadius: borderRadius,
clipBehavior: Clip.antiAlias,
child: InkWell(
onTap: onTap,
child: Padding(
padding: padding,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (leading != null)
Padding(
padding: const EdgeInsetsDirectional.only(end: 8),
child: IconTheme(
data: const IconThemeData(size: 18),
child: leading!,
),
),
DefaultTextStyle(
style: Theme.of(context).textTheme.labelLarge!,
child: content,
),
if (trailing != null)
Padding(
padding: const EdgeInsetsDirectional.only(start: 8),
child: IconTheme(
data: const IconThemeData(size: 18),
child: trailing!,
),
),
],
),
),
),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:catalyst_voices/pages/widgets/menu/voices_list_tile.dart';
import 'package:catalyst_voices/widgets/menu/voices_list_tile.dart';
import 'package:catalyst_voices_brands/catalyst_voices_brands.dart';
import 'package:flutter/material.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:catalyst_voices/pages/widgets/voices_app_bar/actions/voices_app_bar_actions.dart';
import 'package:catalyst_voices/widgets/voices_app_bar/actions/voices_app_bar_actions.dart';
import 'package:catalyst_voices_assets/catalyst_voices_assets.dart';
import 'package:catalyst_voices_brands/catalyst_voices_brands.dart';
import 'package:catalyst_voices_shared/catalyst_voices_shared.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:catalyst_voices/pages/widgets/menu/voices_list_tile.dart';
import 'package:catalyst_voices/widgets/menu/voices_list_tile.dart';
import 'package:catalyst_voices_assets/catalyst_voices_assets.dart';
import 'package:catalyst_voices_brands/catalyst_voices_brands.dart';
import 'package:flutter/material.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
<color name="light_avatars_warning">#FDE1CE</color>
<color name="light_avatars_error">#FFD1D1</color>
<color name="light_elevations_on_surface_neutral_lv0">#FFFFFF</color>
<color name="light_outline_border_outline">#FFD9DEE8</color>
<color name="light_outline_border_outline_variant">#61BFC8D9</color>
<color name="dark_text_primary">#FFFFFF</color>
<color name="dark_text_on_primary">#E6E9F0</color>
<color name="dark_text_on_primary_container">#0C288D</color>
Expand Down Expand Up @@ -112,4 +114,6 @@
<color name="dark_avatars_warning">#B64E07</color>
<color name="dark_avatars_error">#AD0000</color>
<color name="dark_elevations_on_surface_neutral_lv0">#121721</color>
<color name="dark_outline_border_outline">#FF7F90B3</color>
<color name="dark_outline_border_outline_variant">#FF364463</color>
</resources>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class VoicesColorScheme extends ThemeExtension<VoicesColorScheme> {
final Color? avatarsWarning;
final Color? avatarsError;
final Color? elevationsOnSurfaceNeutralLv0;
final Color? outlineBorder;
final Color? outlineBorderVariant;

const VoicesColorScheme({
required this.textPrimary,
Expand Down Expand Up @@ -93,6 +95,8 @@ class VoicesColorScheme extends ThemeExtension<VoicesColorScheme> {
required this.avatarsWarning,
required this.avatarsError,
required this.elevationsOnSurfaceNeutralLv0,
required this.outlineBorder,
required this.outlineBorderVariant,
});

@override
Expand Down Expand Up @@ -139,6 +143,8 @@ class VoicesColorScheme extends ThemeExtension<VoicesColorScheme> {
Color? avatarsWarning,
Color? avatarsError,
Color? elevationsOnSurfaceNeutralLv0,
Color? outlineBorder,
Color? outlineBorderVariant,
}) {
return VoicesColorScheme(
textPrimary: textPrimary ?? this.textPrimary,
Expand Down Expand Up @@ -191,6 +197,8 @@ class VoicesColorScheme extends ThemeExtension<VoicesColorScheme> {
avatarsError: avatarsError ?? this.avatarsError,
elevationsOnSurfaceNeutralLv0:
elevationsOnSurfaceNeutralLv0 ?? this.elevationsOnSurfaceNeutralLv0,
outlineBorder: outlineBorder ?? this.outlineBorder,
outlineBorderVariant: outlineBorderVariant ?? this.outlineBorderVariant,
);
}

Expand Down Expand Up @@ -279,6 +287,9 @@ class VoicesColorScheme extends ThemeExtension<VoicesColorScheme> {
other.elevationsOnSurfaceNeutralLv0,
t,
),
outlineBorder: Color.lerp(outlineBorder, other.outlineBorder, t),
outlineBorderVariant:
Color.lerp(outlineBorderVariant, other.outlineBorderVariant, t),
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ const VoicesColorScheme lightVoicesColorScheme = VoicesColorScheme(
avatarsError: VoicesColors.lightAvatarsError,
elevationsOnSurfaceNeutralLv0:
VoicesColors.lightElevationsOnSurfaceNeutralLv0,
outlineBorder: VoicesColors.lightOutlineBorderOutline,
outlineBorderVariant: VoicesColors.lightOutlineBorderOutlineVariant,
);

const ColorScheme darkColorScheme = ColorScheme.dark(
Expand Down Expand Up @@ -278,6 +280,8 @@ const VoicesColorScheme darkVoicesColorScheme = VoicesColorScheme(
avatarsWarning: VoicesColors.darkAvatarsWarning,
avatarsError: VoicesColors.darkAvatarsError,
elevationsOnSurfaceNeutralLv0: VoicesColors.darkElevationsOnSurfaceNeutralLv0,
outlineBorder: VoicesColors.darkOutlineBorderOutline,
outlineBorderVariant: VoicesColors.darkOutlineBorderOutlineVariant,
);

final BrandAssets lightBrandAssets = BrandAssets(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import 'package:catalyst_voices/widgets/chips/voices_chip.dart';
import 'package:catalyst_voices_assets/catalyst_voices_assets.dart';
import 'package:flutter/material.dart';

class VoicesChipExample extends StatelessWidget {
static const String route = '/chips-example';

const VoicesChipExample({super.key});

@override
Widget build(BuildContext context) {
final backgrounds = [
null,
Theme.of(context).colorScheme.primaryContainer,
];

final leadings = [
null,
const Icon(CatalystVoicesIcons.library_icon),
];

final trailings = [
null,
const Icon(CatalystVoicesIcons.x),
];

return Scaffold(
body: Padding(
padding: const EdgeInsets.all(32),
child: Wrap(
spacing: 16,
runSpacing: 16,
children: [
for (final background in backgrounds)
for (final leading in leadings)
for (final trailing in trailings) ...[
VoicesChip.round(
content: const Text('Label'),
leading: leading,
trailing: trailing,
backgroundColor: background,
onTap: () {},
),
VoicesChip.rectangular(
content: const Text('Label'),
leading: leading,
trailing: trailing,
backgroundColor: background,
onTap: () {},
),
],
],
),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:catalyst_voices/pages/widgets/menu/voices_expandable_list_tile.dart';
import 'package:catalyst_voices/pages/widgets/menu/voices_list_tile.dart';
import 'package:catalyst_voices/pages/widgets/voices_app_bar/actions/voices_app_bar_actions.dart';
import 'package:catalyst_voices/pages/widgets/voices_app_bar/voices_app_bar.dart';
import 'package:catalyst_voices/pages/widgets/voices_drawer/voices_drawer.dart';
import 'package:catalyst_voices/widgets/menu/voices_expandable_list_tile.dart';
import 'package:catalyst_voices/widgets/menu/voices_list_tile.dart';
import 'package:catalyst_voices/widgets/voices_app_bar/actions/voices_app_bar_actions.dart';
import 'package:catalyst_voices/widgets/voices_app_bar/voices_app_bar.dart';
import 'package:catalyst_voices/widgets/voices_drawer/voices_drawer.dart';
import 'package:catalyst_voices_assets/catalyst_voices_assets.dart';
import 'package:flutter/material.dart';

Expand Down
8 changes: 7 additions & 1 deletion catalyst_voices/uikit_example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import 'dart:async';

import 'package:catalyst_voices/pages/widgets/menu/voices_list_tile.dart';
import 'package:catalyst_voices/widgets/menu/voices_list_tile.dart';
import 'package:catalyst_voices_brands/catalyst_voices_brands.dart';
import 'package:catalyst_voices_localization/generated/catalyst_voices_localizations.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localized_locales/flutter_localized_locales.dart';
import 'package:uikit_example/examples/voices_chip_example.dart';
import 'package:uikit_example/examples/voices_navigation_example.dart';

void main() {
Expand All @@ -29,6 +30,7 @@ class UIKitExampleApp extends StatelessWidget {
routes: {
Navigator.defaultRouteName: (_) => const _ExamplesList(),
VoicesNavigationExample.route: (_) => const VoicesNavigationExample(),
VoicesChipExample.route: (_) => const VoicesChipExample(),
},
);
}
Expand Down Expand Up @@ -59,6 +61,10 @@ class _ExamplesList extends StatelessWidget {
title: 'VoicesNavigation (AppBar + Drawer)',
route: VoicesNavigationExample.route,
),
_Example(
title: 'Voices Chips',
route: VoicesChipExample.route,
),
];
}
}
Expand Down
Loading