Skip to content

Commit

Permalink
feat: Added AvatarTile.
Browse files Browse the repository at this point in the history
  • Loading branch information
mathrunet committed Aug 28, 2023
1 parent 8cf2920 commit dc544a6
Show file tree
Hide file tree
Showing 4 changed files with 239 additions and 31 deletions.
46 changes: 27 additions & 19 deletions packages/katana_ui/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ packages:
dependency: transitive
description:
name: _fe_analyzer_shared
sha256: "58826e40314219b223f4723dd4205845040161cdc2df3e6a1cdceed5d8165084"
sha256: eb376e9acf6938204f90eb3b1f00b578640d3188b4c8a8ec054f9f479af8d051
url: "https://pub.dev"
source: hosted
version: "63.0.0"
version: "64.0.0"
analyzer:
dependency: transitive
description:
name: analyzer
sha256: f85566ec7b3d25cbea60f7dd4f157c5025f2f19233ca4feeed33b616c78a26a3
sha256: "69f54f967773f6c26c7dcb13e93d7ccee8b17a641689da39e878d5cf13b06893"
url: "https://pub.dev"
source: hosted
version: "6.1.0"
version: "6.2.0"
args:
dependency: transitive
description:
Expand Down Expand Up @@ -109,10 +109,10 @@ packages:
dependency: transitive
description:
name: built_value
sha256: "598a2a682e2a7a90f08ba39c0aaa9374c5112340f0a2e275f61b59389543d166"
sha256: ff627b645b28fb8bdb69e645f910c2458fd6b65f6585c3a53e0626024897dedf
url: "https://pub.dev"
source: hosted
version: "8.6.1"
version: "8.6.2"
characters:
dependency: transitive
description:
Expand Down Expand Up @@ -149,10 +149,10 @@ packages:
dependency: transitive
description:
name: collection
sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c"
sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687
url: "https://pub.dev"
source: hosted
version: "1.17.1"
version: "1.17.2"
convert:
dependency: transitive
description:
Expand Down Expand Up @@ -353,14 +353,14 @@ packages:
path: "../../katana"
relative: true
source: path
version: "2.3.3"
version: "2.4.1"
katana_ui:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "2.3.0"
version: "2.4.5"
lints:
dependency: transitive
description:
Expand All @@ -381,18 +381,18 @@ packages:
dependency: transitive
description:
name: matcher
sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb"
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
url: "https://pub.dev"
source: hosted
version: "0.12.15"
version: "0.12.16"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
url: "https://pub.dev"
source: hosted
version: "0.2.0"
version: "0.5.0"
meta:
dependency: transitive
description:
Expand Down Expand Up @@ -514,10 +514,10 @@ packages:
dependency: transitive
description:
name: source_span
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.dev"
source: hosted
version: "1.9.1"
version: "1.10.0"
sprintf:
dependency: transitive
description:
Expand Down Expand Up @@ -570,10 +570,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb
sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8"
url: "https://pub.dev"
source: hosted
version: "0.5.1"
version: "0.6.0"
timing:
dependency: transitive
description:
Expand Down Expand Up @@ -630,6 +630,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.1.0"
web:
dependency: transitive
description:
name: web
sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10
url: "https://pub.dev"
source: hosted
version: "0.1.4-beta"
web_socket_channel:
dependency: transitive
description:
Expand All @@ -647,5 +655,5 @@ packages:
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.0.0 <4.0.0"
dart: ">=3.1.0-185.0.dev <4.0.0"
flutter: ">=1.9.1"
1 change: 1 addition & 0 deletions packages/katana_ui/lib/katana_ui.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ part 'ui/line_tile.dart';
part 'ui/periodic_scope.dart';
part 'ui/chat_tile.dart';
part 'ui/shimmer.dart';
part 'ui/avatar_tile.dart';
191 changes: 191 additions & 0 deletions packages/katana_ui/lib/ui/avatar_tile.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
part of katana_ui;

/// Default height of [AvatarTile].
///
/// [AvatarTile]のデフォルトの高さ。
const kAvatarTileHeight = 128.0;

/// Tiles for displaying profiles and other overviews.
///
/// You can set a large image for [avatar].
///
/// You can set large text for [title] and small text or tags for [subtitle].
///
/// The [description] field allows you to set a description.
///
/// プロフィールなどの概要を表示するためのタイル。
///
/// [avatar]に大きな画像を設定することができます。
///
/// [title]には大きな文字を、[subtitle]には小さな文字やタグを設定することができます。
///
/// [description]には説明文を設定することができます。
class AvatarTile extends StatelessWidget {
/// Tiles for displaying profiles and other overviews.
///
/// You can set a large image for [avatar].
///
/// You can set large text for [title] and small text or tags for [subtitle].
///
/// The [description] field allows you to set a description.
///
/// プロフィールなどの概要を表示するためのタイル。
///
/// [avatar]に大きな画像を設定することができます。
///
/// [title]には大きな文字を、[subtitle]には小さな文字やタグを設定することができます。
///
/// [description]には説明文を設定することができます。
const AvatarTile({
super.key,
this.height = kAvatarTileHeight,
this.avatar,
this.titleTextStyle,
this.title,
this.subtitle,
this.subtitleTextStyle,
this.description,
this.descriptionTextStyle,
this.backgroundColor,
this.border,
this.borderRadius,
this.foregroundColor,
this.padding = const EdgeInsets.symmetric(horizontal: 16),
});

/// Tile Height.
///
/// タイルの高さ。
final double height;

/// Tile padding.
///
/// タイルのパディング。
final EdgeInsetsGeometry padding;

/// Widget to be placed in the avatar image section.
///
/// アバター画像部分に入れるウィジェット。
final Widget? avatar;

/// Widget to be placed in the title section.
///
/// タイトル部分に入れるウィジェット。
final Widget? title;

/// Widget to be placed in the subtitle section.
///
/// サブタイトル部分に入れるウィジェット。
final Widget? subtitle;

/// Widget to be placed in the description section.
///
/// 説明部分に入れるウィジェット。
final Widget? description;

/// Text style for title.
///
/// タイトルのテキストスタイル。
final TextStyle? titleTextStyle;

/// Text style for subtitle.
///
/// サブタイトルのテキストスタイル。
final TextStyle? subtitleTextStyle;

/// Text style for description.
///
/// 説明のテキストスタイル。
final TextStyle? descriptionTextStyle;

/// Tile background color.
///
/// タイルの背景色。
final Color? backgroundColor;

/// Tile foreground view.
///
/// タイルの前景色。
final Color? foregroundColor;

/// Tile corner rounding.
///
/// タイルの角丸。
final BorderRadiusGeometry? borderRadius;

/// Tile borders.
///
/// タイルのボーダー。
final BoxBorder? border;

@override
Widget build(BuildContext context) {
final titleTextStyle = this.titleTextStyle ??
Theme.of(context).textTheme.displaySmall ??
const TextStyle(fontSize: 36);
final descriptionTextStyle = this.descriptionTextStyle ??
Theme.of(context).textTheme.bodyMedium ??
const TextStyle(fontSize: 14);
final subtitleTextStyle = this.subtitleTextStyle ??
Theme.of(context).textTheme.labelSmall ??
const TextStyle(fontSize: 11);

return IconTheme(
data: IconThemeData(
color: foregroundColor ?? Theme.of(context).colorScheme.onSurface),
child: DefaultTextStyle(
style: TextStyle(
color: foregroundColor ?? Theme.of(context).colorScheme.onSurface),
child: Container(
margin: padding,
height: height,
decoration: BoxDecoration(
color: backgroundColor ?? Theme.of(context).colorScheme.surface,
borderRadius: borderRadius,
border: border,
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (avatar != null) ...[
SizedBox(
width: height,
height: height,
child: avatar!,
),
const SizedBox(width: 32),
],
Flexible(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
if (title != null) ...[
DefaultTextStyle(
style: titleTextStyle,
child: title!,
),
],
if (subtitle != null) ...[
DefaultTextStyle(
style: subtitleTextStyle,
child: subtitle!,
),
],
if (description != null) ...[
const Spacer(),
DefaultTextStyle(
style: descriptionTextStyle,
child: description!,
),
],
],
),
)
],
),
),
),
);
}
}

0 comments on commit dc544a6

Please sign in to comment.