Skip to content

Commit

Permalink
feat: Add LineTile.
Browse files Browse the repository at this point in the history
  • Loading branch information
mathrunet committed Jun 10, 2023
1 parent aee0231 commit df27401
Show file tree
Hide file tree
Showing 4 changed files with 203 additions and 51 deletions.
58 changes: 29 additions & 29 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: "405666cd3cf0ee0a48d21ec67e65406aad2c726d9fa58840d3375e7bdcd32a07"
sha256: ae92f5d747aee634b87f89d9946000c2de774be1d6ac3e58268224348cd0101a
url: "https://pub.dev"
source: hosted
version: "60.0.0"
version: "61.0.0"
analyzer:
dependency: transitive
description:
name: analyzer
sha256: "1952250bd005bacb895a01bf1b4dc00e3ba1c526cf47dca54dfe24979c65f5b3"
sha256: ea3d8652bda62982addfd92fdc2d0214e5f82e43325104990d4f4c4a2a313562
url: "https://pub.dev"
source: hosted
version: "5.12.0"
version: "5.13.0"
args:
dependency: transitive
description:
Expand Down Expand Up @@ -85,18 +85,18 @@ packages:
dependency: "direct dev"
description:
name: build_runner
sha256: "87e06c939450b9b94e3e1bb2d46e0e9780adbff5500d3969f2ba2de6bbb860cb"
sha256: "220ae4553e50d7c21a17c051afc7b183d28a24a420502e842f303f8e4e6edced"
url: "https://pub.dev"
source: hosted
version: "2.4.2"
version: "2.4.4"
build_runner_core:
dependency: transitive
description:
name: build_runner_core
sha256: "30859c90e9ddaccc484f56303931f477b1f1ba2bab74aa32ed5d6ce15870f8cf"
sha256: "88a57f2ac99849362e73878334caa9f06ee25f31d2adced882b8337838c84e1e"
url: "https://pub.dev"
source: hosted
version: "7.2.8"
version: "7.2.9"
built_collection:
dependency: transitive
description:
Expand All @@ -109,10 +109,10 @@ packages:
dependency: transitive
description:
name: built_value
sha256: "2f17434bd5d52a26762043d6b43bb53b3acd029b4d9071a329f46d67ef297e6d"
sha256: "7dd62d9faf105c434f3d829bbe9c4be02ec67f5ed94832222116122df67c5452"
url: "https://pub.dev"
source: hosted
version: "8.5.0"
version: "8.6.0"
characters:
dependency: transitive
description:
Expand Down Expand Up @@ -205,10 +205,10 @@ packages:
dependency: transitive
description:
name: file
sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d"
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
url: "https://pub.dev"
source: hosted
version: "6.1.4"
version: "7.0.0"
fixnum:
dependency: transitive
description:
Expand Down Expand Up @@ -239,10 +239,10 @@ packages:
dependency: "direct dev"
description:
name: freezed
sha256: "73b58fe836dc05594451d8f740d97d5167886962d628b9f60a1fe945aa0a891f"
sha256: "2edb9ef971d0f803860ecd9084afd48c717d002141ad77b69be3e976bee7190e"
url: "https://pub.dev"
source: hosted
version: "2.3.3"
version: "2.3.4"
freezed_annotation:
dependency: transitive
description:
Expand All @@ -263,18 +263,18 @@ packages:
dependency: transitive
description:
name: glob
sha256: "4515b5b6ddb505ebdd242a5f2cc5d22d3d6a80013789debfbda7777f47ea308c"
sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
version: "2.1.2"
graphs:
dependency: transitive
description:
name: graphs
sha256: "772db3d53d23361d4ffcf5a9bb091cf3ee9b22f2be52cd107cd7a2683a89ba0e"
sha256: aedc5a15e78fc65a6e23bcd927f24c64dd995062bcd1ca6eda65a3cff92a4d19
url: "https://pub.dev"
source: hosted
version: "2.3.0"
version: "2.3.1"
http:
dependency: transitive
description:
Expand Down Expand Up @@ -343,24 +343,24 @@ packages:
dependency: "direct dev"
description:
name: json_serializable
sha256: "43793352f90efa5d8b251893a63d767b2f7c833120e3cc02adad55eefec04dc7"
sha256: "61a60716544392a82726dd0fa1dd6f5f1fd32aec66422b6e229e7b90d52325c4"
url: "https://pub.dev"
source: hosted
version: "6.6.2"
version: "6.7.0"
katana:
dependency: "direct overridden"
description:
path: "../../katana"
relative: true
source: path
version: "2.0.0"
version: "2.1.0"
katana_ui:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "2.0.0"
version: "2.0.3"
lints:
dependency: transitive
description:
Expand All @@ -373,10 +373,10 @@ packages:
dependency: transitive
description:
name: logging
sha256: "04094f2eb032cbb06c6f6e8d3607edcfcb0455e2bb6cbc010cb01171dcb64e6d"
sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340"
url: "https://pub.dev"
source: hosted
version: "1.1.1"
version: "1.2.0"
matcher:
dependency: transitive
description:
Expand Down Expand Up @@ -490,10 +490,10 @@ packages:
dependency: transitive
description:
name: source_gen
sha256: "378a173055cd1fcd2a36e94bf254786d6812688b5f53b6038a2fd180a5a5e210"
sha256: "373f96cf5a8744bc9816c1ff41cf5391bbdbe3d7a96fe98c622b6738a8a7bd33"
url: "https://pub.dev"
source: hosted
version: "1.3.1"
version: "1.3.2"
source_helper:
dependency: transitive
description:
Expand Down Expand Up @@ -618,10 +618,10 @@ packages:
dependency: transitive
description:
name: watcher
sha256: "6a7f46926b01ce81bfc339da6a7f20afbe7733eff9846f6d6a5466aa4c6667c0"
sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8"
url: "https://pub.dev"
source: hosted
version: "1.0.2"
version: "1.1.0"
web_socket_channel:
dependency: transitive
description:
Expand All @@ -639,4 +639,4 @@ packages:
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.0.0-417 <4.0.0"
dart: ">=3.0.0 <4.0.0"
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 @@ -25,3 +25,4 @@ part 'ui/scroll_builder.dart';
part 'ui/indent.dart';
part 'ui/card_tile.dart';
part 'ui/label.dart';
part 'ui/line_tile.dart';
151 changes: 151 additions & 0 deletions packages/katana_ui/lib/ui/line_tile.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
part of katana_ui;

/// Items can be listed on the left and right [ListTile].
///
/// If [text] is specified, the widget can be placed to the right of [title].
///
/// The size can be adjusted by specifying [titleFlex] and [textFlex].
///
/// The spacing can be adjusted by specifying [space].
///
/// 左右に項目を記載可能な[ListTile]
///
/// [text]を指定すると[title]の右側にウィジェットを配置できます。
///
/// [titleFlex][textFlex]を指定してサイズを調整することが可能です。
///
/// [space]を指定すると間隔を調整することが可能です。
@immutable
class LineTile extends ListTile {
/// Items can be listed on the left and right [ListTile].
///
/// If [text] is specified, the widget can be placed to the right of [title].
///
/// The size can be adjusted by specifying [titleFlex] and [textFlex].
///
/// The spacing can be adjusted by specifying [space].
///
/// 左右に項目を記載可能な[ListTile]
///
/// [text]を指定すると[title]の右側にウィジェットを配置できます。
///
/// [titleFlex][textFlex]を指定してサイズを調整することが可能です。
///
/// [space]を指定すると間隔を調整することが可能です。
const LineTile({
super.key,
super.leading,
super.title,
this.text,
this.space = 8.0,
this.titleFlex = 1,
this.textFlex = 1,
super.subtitle,
super.trailing,
super.isThreeLine = false,
super.dense,
super.visualDensity,
super.shape,
super.style,
super.selectedColor,
super.iconColor,
super.textColor,
super.contentPadding,
super.enabled = true,
super.onTap,
super.onLongPress,
super.onFocusChange,
super.mouseCursor,
super.selected = false,
super.focusColor,
super.hoverColor,
super.splashColor,
super.focusNode,
super.autofocus = false,
super.tileColor,
super.selectedTileColor,
super.enableFeedback,
super.horizontalTitleGap,
super.minVerticalPadding,
super.minLeadingWidth,
});

/// Widget to display next to the title.
///
/// タイトルの横に表示するためのウィジェット。
final Widget? text;

/// Flex. in the title section.
///
/// タイトル部分のflex.
final int titleFlex;

/// Flex. in the text section.
///
/// テキスト部分のflex.
final int textFlex;

/// Space between title and text.
///
/// タイトルとテキスト間のスペース。
final double space;

@override
Widget build(BuildContext context) {
return ListTile(
leading: leading,
title: _buildTitle(context),
subtitle: subtitle,
trailing: trailing,
isThreeLine: isThreeLine,
dense: dense,
visualDensity: visualDensity,
shape: shape,
style: style,
selectedColor: selectedColor,
iconColor: iconColor,
textColor: textColor,
contentPadding: contentPadding,
enabled: enabled,
onTap: onTap,
onLongPress: onLongPress,
onFocusChange: onFocusChange,
mouseCursor: mouseCursor,
selected: selected,
focusColor: focusColor,
hoverColor: hoverColor,
splashColor: splashColor,
focusNode: focusNode,
autofocus: autofocus,
tileColor: tileColor,
selectedTileColor: selectedTileColor,
enableFeedback: enableFeedback,
horizontalTitleGap: horizontalTitleGap,
minVerticalPadding: minVerticalPadding,
minLeadingWidth: minLeadingWidth,
);
}

Widget? _buildTitle(BuildContext context) {
if (title != null) {
if (text == null) {
return title;
}
return Row(
children: [
Expanded(
flex: titleFlex,
child: title!,
),
SizedBox(width: space),
Flexible(
flex: textFlex,
child: text!,
),
],
);
} else {
return text;
}
}
}

0 comments on commit df27401

Please sign in to comment.