From 1dd44ad0f59c9a836c77cd945ae67076e733325b Mon Sep 17 00:00:00 2001 From: rajivmanivannan Date: Wed, 24 May 2023 14:16:48 +0530 Subject: [PATCH] Renamed prefix to TUI Updated the fluent icon library --- example/lib/main.dart | 94 ++++---- example/pubspec.lock | 38 ++-- .../{tk_avatar.dart => tui_avatar.dart} | 104 ++++----- lib/components/button/tk_button.dart | 200 ------------------ lib/components/button/tui_button.dart | 200 ++++++++++++++++++ .../{tk_colors.dart => tui_colors.dart} | 4 +- .../{tk_spacing.dart => tui_spacing.dart} | 4 +- .../{tk_symbols.dart => tui_symbols.dart} | 4 +- ...tk_text_style.dart => tui_text_style.dart} | 4 +- lib/tarka_ui.dart | 10 +- pubspec.lock | 4 +- pubspec.yaml | 4 +- 12 files changed, 335 insertions(+), 335 deletions(-) rename lib/components/avatar/{tk_avatar.dart => tui_avatar.dart} (64%) delete mode 100644 lib/components/button/tk_button.dart create mode 100644 lib/components/button/tui_button.dart rename lib/styles/{tk_colors.dart => tui_colors.dart} (98%) rename lib/styles/{tk_spacing.dart => tui_spacing.dart} (93%) rename lib/styles/{tk_symbols.dart => tui_symbols.dart} (92%) rename lib/styles/{tk_text_style.dart => tui_text_style.dart} (97%) diff --git a/example/lib/main.dart b/example/lib/main.dart index 95a6452..2b41fbc 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -33,86 +33,86 @@ class _HomePageState extends State { body: ListView( padding: const EdgeInsets.symmetric(horizontal: 25, vertical: 30), children: [ - TKAvatar( - avatarSize: TKAvatarSize.xxl, - avatarContent: TKAvatarContent( + TUIAvatar( + avatarSize: TUIAvatarSize.xxl, + avatarContent: TUIAvatarContent( text: "IH", - type: TKAvatarContentType.text, + type: TUIAvatarContentType.text, ), ), - TKAvatar( - avatarSize: TKAvatarSize.xl, - avatarContent: TKAvatarContent( + TUIAvatar( + avatarSize: TUIAvatarSize.xl, + avatarContent: TUIAvatarContent( text: "IH", - type: TKAvatarContentType.text, + type: TUIAvatarContentType.text, ), ), - TKAvatar( - avatarSize: TKAvatarSize.m, - avatarContent: TKAvatarContent( - type: TKAvatarContentType.icon, - icon: Icon(Icons.construction), + TUIAvatar( + avatarSize: TUIAvatarSize.m, + avatarContent: TUIAvatarContent( + type: TUIAvatarContentType.icon, + icon: const Icon(Icons.construction), ), isBadged: true, ), - TKAvatar( - avatarSize: TKAvatarSize.xxl, - avatarContent: TKAvatarContent( - type: TKAvatarContentType.image, - image: const TKImage( + TUIAvatar( + avatarSize: TUIAvatarSize.xxl, + avatarContent: TUIAvatarContent( + type: TUIAvatarContentType.image, + image: const TUIImage( imageUrl: "https://avatars.githubusercontent.com/u/16992520?v=4", ), ), isBadged: true, ), - const Text("Heading1", style: TKTextStyle.heading1), - const Text("Heading2", style: TKTextStyle.heading2), - const Text("Heading3", style: TKTextStyle.heading3), - const Text("Heading4", style: TKTextStyle.heading4), - const Text("Heading5", style: TKTextStyle.heading5), - const Text("Heading6", style: TKTextStyle.heading6), - const Text("Heading7", style: TKTextStyle.heading7), - const Text("Body5", style: TKTextStyle.body5), - const Text("Body6", style: TKTextStyle.body6), - const Text("Body7", style: TKTextStyle.body7), - const Text("Body8", style: TKTextStyle.body8), - const Text("Button6", style: TKTextStyle.button6), - const Text("Button7", style: TKTextStyle.button7), - const Text("Button8", style: TKTextStyle.button8), + const Text("Heading1", style: TUITextStyle.heading1), + const Text("Heading2", style: TUITextStyle.heading2), + const Text("Heading3", style: TUITextStyle.heading3), + const Text("Heading4", style: TUITextStyle.heading4), + const Text("Heading5", style: TUITextStyle.heading5), + const Text("Heading6", style: TUITextStyle.heading6), + const Text("Heading7", style: TUITextStyle.heading7), + const Text("Body5", style: TUITextStyle.body5), + const Text("Body6", style: TUITextStyle.body6), + const Text("Body7", style: TUITextStyle.body7), + const Text("Body8", style: TUITextStyle.body8), + const Text("Button6", style: TUITextStyle.button6), + const Text("Button7", style: TUITextStyle.button7), + const Text("Button8", style: TUITextStyle.button8), const SizedBox(height: 8), - TKButton( + TUIButton( label: "Primary Button", - type: TKButtonType.primary, - size: TKButtonSize.xs, + type: TUIButtonType.primary, + size: TUIButtonSize.xs, onPressed: () {}, ), - TKButton( + TUIButton( label: "Secondary Button", icon: Symbol.chevronDown.value, - type: TKButtonType.secondary, - size: TKButtonSize.s, - iconAlignment: TKButtonIconAlignment.right, + type: TUIButtonType.secondary, + size: TUIButtonSize.s, + iconAlignment: TUIButtonIconAlignment.right, onPressed: () {}, ), - TKButton( + TUIButton( label: "Outlined Button", icon: Symbol.chevronDown.value, - type: TKButtonType.outlined, - size: TKButtonSize.m, + type: TUIButtonType.outlined, + size: TUIButtonSize.m, onPressed: () {}, ), - TKButton( + TUIButton( label: "Ghost Button", icon: Symbol.chevronDown.value, - type: TKButtonType.ghost, + type: TUIButtonType.ghost, onPressed: () {}, ), - TKButton( + TUIButton( label: "Danger Button", icon: Symbol.chevronDown.value, - type: TKButtonType.danger, - size: TKButtonSize.l, + type: TUIButtonType.danger, + size: TUIButtonSize.l, onPressed: () {}, ) ])); diff --git a/example/pubspec.lock b/example/pubspec.lock index 7597640..eb40b80 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -5,10 +5,10 @@ packages: dependency: transitive description: name: async - sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" url: "https://pub.dev" source: hosted - version: "2.10.0" + version: "2.11.0" boolean_selector: dependency: transitive description: @@ -21,10 +21,10 @@ packages: dependency: transitive description: name: characters - sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.3.0" clock: dependency: transitive description: @@ -37,10 +37,10 @@ packages: dependency: transitive description: name: collection - sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 + sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" url: "https://pub.dev" source: hosted - version: "1.17.0" + version: "1.17.1" cupertino_icons: dependency: "direct main" description: @@ -61,10 +61,10 @@ packages: dependency: "direct main" description: name: fluentui_system_icons - sha256: ae3685648c572fa8011cec8d59a36278fa500d29f7164d4e769551d48b3ce8af + sha256: "745d58831bba404532bebce20286fb1920c650a4cc74678990251a16fb4d2600" url: "https://pub.dev" source: hosted - version: "1.1.200" + version: "1.1.201" flutter: dependency: "direct main" description: flutter @@ -87,10 +87,10 @@ packages: dependency: transitive description: name: js - sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 url: "https://pub.dev" source: hosted - version: "0.6.5" + version: "0.6.7" lints: dependency: transitive description: @@ -103,10 +103,10 @@ packages: dependency: transitive description: name: matcher - sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" + sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" url: "https://pub.dev" source: hosted - version: "0.12.13" + version: "0.12.15" material_color_utilities: dependency: transitive description: @@ -119,18 +119,18 @@ packages: dependency: transitive description: name: meta - sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.9.1" path: dependency: transitive description: name: path - sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" url: "https://pub.dev" source: hosted - version: "1.8.2" + version: "1.8.3" sky_engine: dependency: transitive description: flutter @@ -187,10 +187,10 @@ packages: dependency: transitive description: name: test_api - sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 + sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb url: "https://pub.dev" source: hosted - version: "0.4.16" + version: "0.5.1" vector_math: dependency: transitive description: @@ -200,5 +200,5 @@ packages: source: hosted version: "2.1.4" sdks: - dart: ">=2.19.6 <3.0.0" + dart: ">=3.0.0-0 <4.0.0" flutter: ">=1.17.0" diff --git a/lib/components/avatar/tk_avatar.dart b/lib/components/avatar/tui_avatar.dart similarity index 64% rename from lib/components/avatar/tk_avatar.dart rename to lib/components/avatar/tui_avatar.dart index fb4c500..f31cb54 100644 --- a/lib/components/avatar/tk_avatar.dart +++ b/lib/components/avatar/tui_avatar.dart @@ -1,14 +1,14 @@ import 'package:flutter/material.dart'; -import 'package:tarka_ui/styles/tk_colors.dart'; -import 'package:tarka_ui/styles/tk_text_style.dart'; +import 'package:tarka_ui/styles/tui_colors.dart'; +import 'package:tarka_ui/styles/tui_text_style.dart'; -/// TKAvatar is used to create a Avatar with content, size and badge flag. -class TKAvatar extends StatelessWidget { - final TKAvatarSize avatarSize; - final TKAvatarContent avatarContent; +/// TUIAvatar is used to create a Avatar with content, size and badge flag. +class TUIAvatar extends StatelessWidget { + final TUIAvatarSize avatarSize; + final TUIAvatarContent avatarContent; final bool isBadged; - const TKAvatar({ + const TUIAvatar({ super.key, required this.avatarSize, required this.avatarContent, @@ -23,11 +23,11 @@ class TKAvatar extends StatelessWidget { circleChild = Icon( avatarContent.icon!.icon, size: avatarSize._getAvatarSize() / 2, - color: TKColors.constantLight, + color: TUIColors.constantLight, ); } else if (avatarContent.text != null) { TextStyle textStyle = avatarSize._getTextStyle().copyWith( - color: TKColors.onTertiary, + color: TUIColors.onTertiary, ); circleChild = Text( @@ -40,7 +40,7 @@ class TKAvatar extends StatelessWidget { CircleAvatar circleAvatar = CircleAvatar( radius: avatarSize._getAvatarSize() / 2, - backgroundColor: TKColors.tertiary, + backgroundColor: TUIColors.tertiary, child: circleChild, ); @@ -58,7 +58,7 @@ class TKAvatar extends StatelessWidget { width: avatarSize._getBadgeSize(), decoration: const BoxDecoration( shape: BoxShape.circle, - color: TKColors.success, + color: TUIColors.success, ), ), ); @@ -71,7 +71,7 @@ class TKAvatar extends StatelessWidget { width: avatarSize._getBadgeSize(), decoration: const BoxDecoration( shape: BoxShape.circle, - color: TKColors.success, + color: TUIColors.success, ), ), ); @@ -98,21 +98,21 @@ class TKAvatar extends StatelessWidget { } } -/// TKAvatarContent stores the content type and the content for the Avatar. -class TKAvatarContent { - final TKAvatarContentType type; +/// TUIAvatarContent stores the content type and the content for the Avatar. +class TUIAvatarContent { + final TUIAvatarContentType type; final Icon? icon; - final TKImage? image; + final TUIImage? image; final String? text; - TKAvatarContent({required this.type, this.icon, this.image, this.text}); + TUIAvatarContent({required this.type, this.icon, this.image, this.text}); } -/// TKAvatarContentType is used to define the content type of Avatar. -enum TKAvatarContentType { image, icon, text } +/// TUIAvatarContentType is used to define the content type of Avatar. +enum TUIAvatarContentType { image, icon, text } -/// TKAvatarSize is used to define the size of Avatar. -enum TKAvatarSize { +/// TUIAvatarSize is used to define the size of Avatar. +enum TUIAvatarSize { xxs, xs, s, @@ -123,64 +123,64 @@ enum TKAvatarSize { double _getAvatarSize() { switch (this) { - case TKAvatarSize.xxs: + case TUIAvatarSize.xxs: return 24; - case TKAvatarSize.xs: + case TUIAvatarSize.xs: return 32; - case TKAvatarSize.s: + case TUIAvatarSize.s: return 40; - case TKAvatarSize.m: + case TUIAvatarSize.m: return 48; - case TKAvatarSize.l: + case TUIAvatarSize.l: return 64; - case TKAvatarSize.xl: + case TUIAvatarSize.xl: return 80; - case TKAvatarSize.xxl: + case TUIAvatarSize.xxl: return 96; } } double _getBadgeSize() { switch (this) { - case TKAvatarSize.xxs: - case TKAvatarSize.xs: - case TKAvatarSize.s: - case TKAvatarSize.m: + case TUIAvatarSize.xxs: + case TUIAvatarSize.xs: + case TUIAvatarSize.s: + case TUIAvatarSize.m: return 12; - case TKAvatarSize.l: + case TUIAvatarSize.l: return 16; - case TKAvatarSize.xl: - case TKAvatarSize.xxl: + case TUIAvatarSize.xl: + case TUIAvatarSize.xxl: return 24; } } TextStyle _getTextStyle() { switch (this) { - case TKAvatarSize.xxs: - return TKTextStyle.body8; - case TKAvatarSize.xs: - return TKTextStyle.heading7; - case TKAvatarSize.s: - return TKTextStyle.heading6; - case TKAvatarSize.m: - return TKTextStyle.heading5; - case TKAvatarSize.l: - return TKTextStyle.heading4; - case TKAvatarSize.xl: - return TKTextStyle.heading3; - case TKAvatarSize.xxl: - return TKTextStyle.heading2; + case TUIAvatarSize.xxs: + return TUITextStyle.body8; + case TUIAvatarSize.xs: + return TUITextStyle.heading7; + case TUIAvatarSize.s: + return TUITextStyle.heading6; + case TUIAvatarSize.m: + return TUITextStyle.heading5; + case TUIAvatarSize.l: + return TUITextStyle.heading4; + case TUIAvatarSize.xl: + return TUITextStyle.heading3; + case TUIAvatarSize.xxl: + return TUITextStyle.heading2; } } } -/// TKImage is used as an abstraction to handle asset and network image. -class TKImage extends StatelessWidget { +/// TUIImage is used as an abstraction to handle asset and network image. +class TUIImage extends StatelessWidget { final String? _imageUrl; final String? _assetPath; - const TKImage({ + const TUIImage({ super.key, String? imageUrl, String? assetPath, diff --git a/lib/components/button/tk_button.dart b/lib/components/button/tk_button.dart deleted file mode 100644 index 9ed837a..0000000 --- a/lib/components/button/tk_button.dart +++ /dev/null @@ -1,200 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:tarka_ui/styles/tk_colors.dart'; -import 'package:tarka_ui/styles/tk_text_style.dart'; - -/// TKButtonType is used to define the type of button. -enum TKButtonType { primary, secondary, outlined, ghost, danger } -/// TKButtonSize is used to define the size of button. -enum TKButtonSize { xs, s, m, l } -/// TKButtonIconAlignment is used to define the alignment of icon in button. -enum TKButtonIconAlignment { left, right, none } - -/// TKButton is used to create a button with different types, sizes and icon alignment. -class TKButton extends StatelessWidget { - final String? label; - final TKButtonType type; - final TKButtonSize size; - final IconData? icon; - final TKButtonIconAlignment iconAlignment; - final Color? foregroundColor; - final Color? backgroundColor; - final Color? borderSideColor; - final void Function()? onPressed; - final void Function()? onLongPressed; - - /// Creates a button with the given [label] and [icon]. - const TKButton({ - super.key, - required this.label, - this.type = TKButtonType.primary, - this.size = TKButtonSize.m, - this.icon, - this.iconAlignment = TKButtonIconAlignment.none, - this.foregroundColor, - this.backgroundColor, - this.borderSideColor, - this.onPressed, - this.onLongPressed, - }) : assert( - label != null || icon != null, - 'Label or icon must be provided.', - ); - - @override - Widget build(BuildContext context) { - final child = Row( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.center, - children: getIconAndLabel(), - ); - switch (type) { - case TKButtonType.primary: - return TextButton( - style: TextButton.styleFrom( - minimumSize: getSize(), - backgroundColor: backgroundColor ?? getBackgroundColor(), - foregroundColor: foregroundColor ?? getForegroundColor(), - textStyle: getTextStyle(), - shape: const StadiumBorder()), - onPressed: onPressed, - onLongPress: onLongPressed, - child: child, - ); - case TKButtonType.secondary: - return TextButton( - style: TextButton.styleFrom( - minimumSize: getSize(), - backgroundColor: backgroundColor ?? getBackgroundColor(), - foregroundColor: foregroundColor ?? getForegroundColor(), - textStyle: getTextStyle(), - shape: const StadiumBorder()), - onPressed: onPressed, - onLongPress: onLongPressed, - child: child, - ); - case TKButtonType.outlined: - return OutlinedButton( - style: OutlinedButton.styleFrom( - minimumSize: getSize(), - backgroundColor: backgroundColor ?? getBackgroundColor(), - foregroundColor: foregroundColor ?? getForegroundColor(), - textStyle: getTextStyle(), - shape: const StadiumBorder(), - side: BorderSide(color: borderSideColor ?? TKColors.onSurface)), - onPressed: onPressed, - onLongPress: onLongPressed, - child: child, - ); - case TKButtonType.ghost: - return TextButton( - style: TextButton.styleFrom( - minimumSize: getSize(), - backgroundColor: backgroundColor ?? getBackgroundColor(), - foregroundColor: foregroundColor ?? getForegroundColor(), - textStyle: getTextStyle(), - shape: const StadiumBorder()), - onPressed: onPressed, - onLongPress: onLongPressed, - child: child, - ); - case TKButtonType.danger: - return TextButton( - style: TextButton.styleFrom( - minimumSize: getSize(), - backgroundColor: backgroundColor ?? getBackgroundColor(), - foregroundColor: foregroundColor ?? getForegroundColor(), - textStyle: getTextStyle(), - shape: const StadiumBorder()), - onPressed: onPressed, - onLongPress: onLongPressed, - child: child, - ); - } - } - - getIconAndLabel() { - switch (iconAlignment) { - case TKButtonIconAlignment.left: - case TKButtonIconAlignment.none: - return [ - if (icon != null) Icon(icon, size: getIconSize()), - if (icon != null && label != null) const SizedBox(width: 8), - if (label != null) Text(label!, textAlign: TextAlign.center), - ]; - - case TKButtonIconAlignment.right: - return [ - if (label != null) Text(label!, textAlign: TextAlign.center), - if (icon != null && label != null) const SizedBox(width: 8), - if (icon != null) Icon(icon, size: getIconSize()), - ]; - default: - } - } - - Color getForegroundColor() { - switch (type) { - case TKButtonType.primary: - return TKColors.onPrimary; - case TKButtonType.secondary: - return TKColors.onSecondary; - case TKButtonType.outlined: - return TKColors.onSurface; - case TKButtonType.ghost: - return TKColors.secondary; - case TKButtonType.danger: - return TKColors.onPrimary; - } - } - - Color getBackgroundColor() { - switch (type) { - case TKButtonType.primary: - return TKColors.primary; - case TKButtonType.secondary: - return TKColors.secondary; - case TKButtonType.outlined: - return TKColors.surfaceHover; - case TKButtonType.ghost: - return TKColors.transparent; - case TKButtonType.danger: - return TKColors.error; - } - } - - double getIconSize() { - switch (size) { - case TKButtonSize.xs: - case TKButtonSize.s: - return 12; - case TKButtonSize.m: - case TKButtonSize.l: - return 18; - } - } - - Size getSize() { - switch (size) { - case TKButtonSize.xs: - return const Size.fromHeight(24); - case TKButtonSize.s: - return const Size.fromHeight(32); - case TKButtonSize.m: - return const Size.fromHeight(40); - case TKButtonSize.l: - return const Size.fromHeight(48); - } - } - - TextStyle getTextStyle() { - switch (size) { - case TKButtonSize.xs: - return TKTextStyle.button8; - case TKButtonSize.s: - return TKTextStyle.button7; - case TKButtonSize.m: - case TKButtonSize.l: - return TKTextStyle.button6; - } - } -} diff --git a/lib/components/button/tui_button.dart b/lib/components/button/tui_button.dart new file mode 100644 index 0000000..68bee1e --- /dev/null +++ b/lib/components/button/tui_button.dart @@ -0,0 +1,200 @@ +import 'package:flutter/material.dart'; +import 'package:tarka_ui/styles/tui_colors.dart'; +import 'package:tarka_ui/styles/tui_text_style.dart'; + +/// TUIButtonType is used to define the type of button. +enum TUIButtonType { primary, secondary, outlined, ghost, danger } +/// TUIButtonSize is used to define the size of button. +enum TUIButtonSize { xs, s, m, l } +/// TUIButtonIconAlignment is used to define the alignment of icon in button. +enum TUIButtonIconAlignment { left, right, none } + +/// TUIButton is used to create a button with different types, sizes and icon alignment. +class TUIButton extends StatelessWidget { + final String? label; + final TUIButtonType type; + final TUIButtonSize size; + final IconData? icon; + final TUIButtonIconAlignment iconAlignment; + final Color? foregroundColor; + final Color? backgroundColor; + final Color? borderSideColor; + final void Function()? onPressed; + final void Function()? onLongPressed; + + /// Creates a button with the given [label] and [icon]. + const TUIButton({ + super.key, + required this.label, + this.type = TUIButtonType.primary, + this.size = TUIButtonSize.m, + this.icon, + this.iconAlignment = TUIButtonIconAlignment.none, + this.foregroundColor, + this.backgroundColor, + this.borderSideColor, + this.onPressed, + this.onLongPressed, + }) : assert( + label != null || icon != null, + 'Label or icon must be provided.', + ); + + @override + Widget build(BuildContext context) { + final child = Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + children: _getIconAndLabel(), + ); + switch (type) { + case TUIButtonType.primary: + return TextButton( + style: TextButton.styleFrom( + minimumSize: _getSize(), + backgroundColor: backgroundColor ?? _getBackgroundColor(), + foregroundColor: foregroundColor ?? _getForegroundColor(), + textStyle: _getTextStyle(), + shape: const StadiumBorder()), + onPressed: onPressed, + onLongPress: onLongPressed, + child: child, + ); + case TUIButtonType.secondary: + return TextButton( + style: TextButton.styleFrom( + minimumSize: _getSize(), + backgroundColor: backgroundColor ?? _getBackgroundColor(), + foregroundColor: foregroundColor ?? _getForegroundColor(), + textStyle: _getTextStyle(), + shape: const StadiumBorder()), + onPressed: onPressed, + onLongPress: onLongPressed, + child: child, + ); + case TUIButtonType.outlined: + return OutlinedButton( + style: OutlinedButton.styleFrom( + minimumSize: _getSize(), + backgroundColor: backgroundColor ?? _getBackgroundColor(), + foregroundColor: foregroundColor ?? _getForegroundColor(), + textStyle: _getTextStyle(), + shape: const StadiumBorder(), + side: BorderSide(color: borderSideColor ?? TUIColors.onSurface)), + onPressed: onPressed, + onLongPress: onLongPressed, + child: child, + ); + case TUIButtonType.ghost: + return TextButton( + style: TextButton.styleFrom( + minimumSize: _getSize(), + backgroundColor: backgroundColor ?? _getBackgroundColor(), + foregroundColor: foregroundColor ?? _getForegroundColor(), + textStyle: _getTextStyle(), + shape: const StadiumBorder()), + onPressed: onPressed, + onLongPress: onLongPressed, + child: child, + ); + case TUIButtonType.danger: + return TextButton( + style: TextButton.styleFrom( + minimumSize: _getSize(), + backgroundColor: backgroundColor ?? _getBackgroundColor(), + foregroundColor: foregroundColor ?? _getForegroundColor(), + textStyle: _getTextStyle(), + shape: const StadiumBorder()), + onPressed: onPressed, + onLongPress: onLongPressed, + child: child, + ); + } + } + + _getIconAndLabel() { + switch (iconAlignment) { + case TUIButtonIconAlignment.left: + case TUIButtonIconAlignment.none: + return [ + if (icon != null) Icon(icon, size: _getIconSize()), + if (icon != null && label != null) const SizedBox(width: 8), + if (label != null) Text(label!, textAlign: TextAlign.center), + ]; + + case TUIButtonIconAlignment.right: + return [ + if (label != null) Text(label!, textAlign: TextAlign.center), + if (icon != null && label != null) const SizedBox(width: 8), + if (icon != null) Icon(icon, size: _getIconSize()), + ]; + default: + } + } + + Color _getForegroundColor() { + switch (type) { + case TUIButtonType.primary: + return TUIColors.onPrimary; + case TUIButtonType.secondary: + return TUIColors.onSecondary; + case TUIButtonType.outlined: + return TUIColors.onSurface; + case TUIButtonType.ghost: + return TUIColors.secondary; + case TUIButtonType.danger: + return TUIColors.onPrimary; + } + } + + Color _getBackgroundColor() { + switch (type) { + case TUIButtonType.primary: + return TUIColors.primary; + case TUIButtonType.secondary: + return TUIColors.secondary; + case TUIButtonType.outlined: + return TUIColors.surfaceHover; + case TUIButtonType.ghost: + return TUIColors.transparent; + case TUIButtonType.danger: + return TUIColors.error; + } + } + + double _getIconSize() { + switch (size) { + case TUIButtonSize.xs: + case TUIButtonSize.s: + return 12; + case TUIButtonSize.m: + case TUIButtonSize.l: + return 18; + } + } + + Size _getSize() { + switch (size) { + case TUIButtonSize.xs: + return const Size.fromHeight(24); + case TUIButtonSize.s: + return const Size.fromHeight(32); + case TUIButtonSize.m: + return const Size.fromHeight(40); + case TUIButtonSize.l: + return const Size.fromHeight(48); + } + } + + TextStyle _getTextStyle() { + switch (size) { + case TUIButtonSize.xs: + return TUITextStyle.button8; + case TUIButtonSize.s: + return TUITextStyle.button7; + case TUIButtonSize.m: + case TUIButtonSize.l: + return TUITextStyle.button6; + } + } +} diff --git a/lib/styles/tk_colors.dart b/lib/styles/tui_colors.dart similarity index 98% rename from lib/styles/tk_colors.dart rename to lib/styles/tui_colors.dart index 3291071..9d9f3e5 100644 --- a/lib/styles/tk_colors.dart +++ b/lib/styles/tui_colors.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; -class TKColors { - TKColors._(); +class TUIColors { + TUIColors._(); // Base static const Color primary = Color(0xff0052D6); static const Color secondary = Color(0xff4D80B3); diff --git a/lib/styles/tk_spacing.dart b/lib/styles/tui_spacing.dart similarity index 93% rename from lib/styles/tk_spacing.dart rename to lib/styles/tui_spacing.dart index e0e3c0c..fd50967 100644 --- a/lib/styles/tk_spacing.dart +++ b/lib/styles/tui_spacing.dart @@ -1,6 +1,6 @@ -class TKSpacing { - TKSpacing._(); +class TUISpacing { + TUISpacing._(); static const double none = 0; static const double baseVertical = 4; diff --git a/lib/styles/tk_symbols.dart b/lib/styles/tui_symbols.dart similarity index 92% rename from lib/styles/tk_symbols.dart rename to lib/styles/tui_symbols.dart index c81f939..e8cf0eb 100644 --- a/lib/styles/tk_symbols.dart +++ b/lib/styles/tui_symbols.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:fluentui_system_icons/fluentui_system_icons.dart'; -class TKSymbol { - TKSymbol._(); +class TUISymbol { + TUISymbol._(); static const IconData chevronDown = FluentIcons.chevron_down_48_regular; static const IconData chevronRight = FluentIcons.chevron_right_48_regular; diff --git a/lib/styles/tk_text_style.dart b/lib/styles/tui_text_style.dart similarity index 97% rename from lib/styles/tk_text_style.dart rename to lib/styles/tui_text_style.dart index 7119adc..2b79c1e 100644 --- a/lib/styles/tk_text_style.dart +++ b/lib/styles/tui_text_style.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; -class TKTextStyle { - TKTextStyle._(); +class TUITextStyle { + TUITextStyle._(); static const TextStyle heading1 = TextStyle( fontSize: 30, diff --git a/lib/tarka_ui.dart b/lib/tarka_ui.dart index bb29a6a..a3e3f49 100644 --- a/lib/tarka_ui.dart +++ b/lib/tarka_ui.dart @@ -1,8 +1,8 @@ library tarka_ui; -export 'package:tarka_ui/components/avatar/tk_avatar.dart'; -export 'package:tarka_ui/components/button/tk_button.dart'; +export 'package:tarka_ui/components/avatar/tui_avatar.dart'; +export 'package:tarka_ui/components/button/tui_button.dart'; // exports component -export 'package:tarka_ui/styles/tk_colors.dart'; -export 'package:tarka_ui/styles/tk_symbols.dart'; -export 'package:tarka_ui/styles/tk_text_style.dart'; +export 'package:tarka_ui/styles/tui_colors.dart'; +export 'package:tarka_ui/styles/tui_symbols.dart'; +export 'package:tarka_ui/styles/tui_text_style.dart'; diff --git a/pubspec.lock b/pubspec.lock index e0e135b..935901f 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -53,10 +53,10 @@ packages: dependency: "direct main" description: name: fluentui_system_icons - sha256: ae3685648c572fa8011cec8d59a36278fa500d29f7164d4e769551d48b3ce8af + sha256: "745d58831bba404532bebce20286fb1920c650a4cc74678990251a16fb4d2600" url: "https://pub.dev" source: hosted - version: "1.1.200" + version: "1.1.201" flutter: dependency: "direct main" description: flutter diff --git a/pubspec.yaml b/pubspec.yaml index e42a83a..b46cfab 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,13 +4,13 @@ version: 0.0.1 homepage: https://github.com/tarkalabs/tarka-ui-kit-flutter.git environment: - sdk: '>=2.19.6 <3.0.0' + sdk: '>=2.19.6 <4.0.0' flutter: ">=1.17.0" dependencies: flutter: sdk: flutter - fluentui_system_icons: ^1.1.200 + fluentui_system_icons: ^1.1.201 dev_dependencies: flutter_test: