Skip to content

Commit

Permalink
feat: Add LineTileGroup.
Browse files Browse the repository at this point in the history
  • Loading branch information
mathrunet committed May 15, 2024
1 parent afd1cc9 commit d85a22e
Show file tree
Hide file tree
Showing 6 changed files with 167 additions and 37 deletions.
38 changes: 19 additions & 19 deletions packages/katana_ui/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ packages:
dependency: transitive
description:
name: asn1lib
sha256: c9c85fedbe2188b95133cbe960e16f5f448860f7133330e272edbbca5893ddc6
sha256: "58082b3f0dca697204dbab0ef9ff208bfaea7767ea771076af9a343488428dda"
url: "https://pub.dev"
source: hosted
version: "1.5.2"
version: "1.5.3"
async:
dependency: transitive
description:
Expand Down Expand Up @@ -353,38 +353,38 @@ packages:
path: "../../katana"
relative: true
source: path
version: "2.13.2"
version: "2.14.0"
katana_ui:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "2.7.0"
version: "2.8.3"
leak_tracker:
dependency: transitive
description:
name: leak_tracker
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a"
url: "https://pub.dev"
source: hosted
version: "10.0.0"
version: "10.0.4"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
version: "3.0.3"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
version: "3.0.1"
lints:
dependency: transitive
description:
Expand Down Expand Up @@ -421,10 +421,10 @@ packages:
dependency: transitive
description:
name: meta
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
url: "https://pub.dev"
source: hosted
version: "1.11.0"
version: "1.12.0"
mime:
dependency: transitive
description:
Expand Down Expand Up @@ -453,10 +453,10 @@ packages:
dependency: transitive
description:
name: pointycastle
sha256: "79fbafed02cfdbe85ef3fd06c7f4bc2cbcba0177e61b765264853d4253b21744"
sha256: "4be0097fcf3fd3e8449e53730c631200ebc7b88016acecab2b0da2f0149222fe"
url: "https://pub.dev"
source: hosted
version: "3.9.0"
version: "3.9.1"
pool:
dependency: transitive
description:
Expand Down Expand Up @@ -594,10 +594,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
url: "https://pub.dev"
source: hosted
version: "0.6.1"
version: "0.7.0"
timing:
dependency: transitive
description:
Expand Down Expand Up @@ -650,10 +650,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec"
url: "https://pub.dev"
source: hosted
version: "13.0.0"
version: "14.2.1"
watcher:
dependency: transitive
description:
Expand Down Expand Up @@ -688,4 +688,4 @@ packages:
version: "3.1.2"
sdks:
dart: ">=3.3.0 <4.0.0"
flutter: ">=1.9.1"
flutter: ">=3.18.0-18.0.pre.54"
2 changes: 2 additions & 0 deletions packages/katana_ui/lib/katana_ui.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'dart:async';

// Flutter imports:
import 'package:flutter/material.dart' hide Scaffold;
import 'package:katana/katana.dart';

// Package imports:
import 'package:shimmer/shimmer.dart' as sm;
Expand All @@ -33,3 +34,4 @@ part 'ui/shimmer.dart';
part 'ui/avatar_tile.dart';
part 'ui/message_box.dart';
part 'ui/square_avatar.dart';
part 'ui/list_tile_group.dart';
5 changes: 4 additions & 1 deletion packages/katana_ui/lib/ui/label.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ class Label extends StatelessWidget {

@override
Widget build(BuildContext context) {
final textTheme = textStyle ?? Theme.of(context).textTheme.titleLarge;
final textTheme = textStyle ??
Theme.of(context).textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.bold,
);

return Container(
padding: padding,
Expand Down
17 changes: 11 additions & 6 deletions packages/katana_ui/lib/ui/line_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class LineTile extends ListTile {

@override
Widget build(BuildContext context) {
final scope = _LineTileGroupScope.of(context);
if (shimmer) {
return sm.Shimmer.fromColors(
baseColor: shimmerBaseColor ?? Theme.of(context).colorScheme.surface,
Expand All @@ -136,7 +137,8 @@ class LineTile extends ListTile {
trailing: trailing,
isThreeLine: isThreeLine,
dense: dense,
visualDensity: visualDensity,
visualDensity:
visualDensity ?? (scope != null ? VisualDensity.compact : null),
shape: shape,
style: style,
selectedColor: selectedColor,
Expand All @@ -154,8 +156,9 @@ class LineTile extends ListTile {
splashColor: splashColor,
focusNode: focusNode,
autofocus: autofocus,
tileColor: tileColor,
selectedTileColor: selectedTileColor,
tileColor: scope?.tileColor != null ? Colors.transparent : tileColor,
selectedTileColor:
scope?.tileColor != null ? Colors.transparent : selectedTileColor,
enableFeedback: enableFeedback,
horizontalTitleGap: horizontalTitleGap,
minVerticalPadding: minVerticalPadding,
Expand All @@ -170,7 +173,8 @@ class LineTile extends ListTile {
trailing: trailing,
isThreeLine: isThreeLine,
dense: dense,
visualDensity: visualDensity,
visualDensity:
visualDensity ?? (scope != null ? VisualDensity.compact : null),
shape: shape,
style: style,
selectedColor: selectedColor,
Expand All @@ -188,8 +192,9 @@ class LineTile extends ListTile {
splashColor: splashColor,
focusNode: focusNode,
autofocus: autofocus,
tileColor: tileColor,
selectedTileColor: selectedTileColor,
tileColor: scope?.tileColor != null ? Colors.transparent : tileColor,
selectedTileColor:
scope?.tileColor != null ? Colors.transparent : selectedTileColor,
enableFeedback: enableFeedback,
horizontalTitleGap: horizontalTitleGap,
minVerticalPadding: minVerticalPadding,
Expand Down
120 changes: 120 additions & 0 deletions packages/katana_ui/lib/ui/list_tile_group.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
part of '/katana_ui.dart';

/// A widget that groups [ListTile] and [LineTile] for display.
///
/// Specify each tile in [children].
///
/// [ListTile][LineTile]をグループ化して表示するウィジェット。
///
/// [children]にそれぞれのタイルを指定します。
class LineTileGroup extends StatelessWidget {
/// A widget that groups [ListTile] and [LineTile] for display.
///
/// Specify each tile in [children].
///
/// [ListTile][LineTile]をグループ化して表示するウィジェット。
///
/// [children]にそれぞれのタイルを指定します。
const LineTileGroup({
super.key,
required this.children,
this.shape,
this.tileColor,
this.divider,
this.borderRadius,
this.margin = const EdgeInsets.symmetric(vertical: 8),
this.padding = const EdgeInsets.symmetric(vertical: 8),
});

/// Shape of the tile.
///
/// タイルの形。
final ShapeBorder? shape;

/// Radius of rounded tile corners.
///
/// タイルの角丸の半径。
final BorderRadiusGeometry? borderRadius;

/// List of [ListTile] to be displayed.
///
/// 表示する[ListTile]のリスト。
final List<Widget> children;

/// Color of the tile.
///
/// タイルの色。
final Color? tileColor;

/// Divider to be displayed between tiles.
///
/// タイル間に表示される区切り線。
final Widget? divider;

/// Margin of the tile.
///
/// タイルのマージン。
final EdgeInsetsGeometry margin;

/// Content Padding.
///
/// コンテンツのパディング。
final EdgeInsetsGeometry padding;

@override
Widget build(BuildContext context) {
if (children.isEmpty) {
return const SizedBox.shrink();
}

return _LineTileGroupScope(
tileColor: tileColor,
child: Container(
margin: margin,
padding: padding,
decoration: ShapeDecoration(
shape: RoundedRectangleBorder(
borderRadius: borderRadius ?? BorderRadius.circular(12),
),
color: tileColor ?? Theme.of(context).colorScheme.surface,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: divider != null
? children.insertEvery(divider!, 1).toList()
: children,
),
),
);
}
}

/// A widget that groups [ListTile] and [LineTile] for display.
///
/// Specify each tile in [children].
///
/// [ListTile][LineTile]をグループ化して表示するウィジェット。
///
/// [children]にそれぞれのタイルを指定します。
typedef ListTileGroup = LineTileGroup;

class _LineTileGroupScope extends InheritedWidget {
const _LineTileGroupScope({
required super.child,
this.tileColor,
});

final Color? tileColor;

static _LineTileGroupScope? of(BuildContext context) {
return context
.getElementForInheritedWidgetOfExactType<_LineTileGroupScope>()
?.widget as _LineTileGroupScope?;
}

@override
bool updateShouldNotify(covariant InheritedWidget oldWidget) {
return false;
}
}
22 changes: 11 additions & 11 deletions packages/katana_ui/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ packages:
dependency: transitive
description:
name: asn1lib
sha256: c9c85fedbe2188b95133cbe960e16f5f448860f7133330e272edbbca5893ddc6
sha256: "58082b3f0dca697204dbab0ef9ff208bfaea7767ea771076af9a343488428dda"
url: "https://pub.dev"
source: hosted
version: "1.5.2"
version: "1.5.3"
async:
dependency: transitive
description:
Expand Down Expand Up @@ -85,10 +85,10 @@ packages:
dependency: transitive
description:
name: coverage
sha256: "8acabb8306b57a409bf4c83522065672ee13179297a6bb0cb9ead73948df7c76"
sha256: "3945034e86ea203af7a056d98e98e42a5518fff200d6e8e6647e1886b07e936e"
url: "https://pub.dev"
source: hosted
version: "1.7.2"
version: "1.8.0"
crypto:
dependency: transitive
description:
Expand Down Expand Up @@ -212,7 +212,7 @@ packages:
path: "../katana"
relative: true
source: path
version: "2.13.2"
version: "2.14.0"
katana_test:
dependency: "direct dev"
description:
Expand Down Expand Up @@ -256,10 +256,10 @@ packages:
dependency: transitive
description:
name: meta
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
url: "https://pub.dev"
source: hosted
version: "1.11.0"
version: "1.12.0"
mime:
dependency: transitive
description:
Expand Down Expand Up @@ -296,10 +296,10 @@ packages:
dependency: transitive
description:
name: pointycastle
sha256: "79fbafed02cfdbe85ef3fd06c7f4bc2cbcba0177e61b765264853d4253b21744"
sha256: "4be0097fcf3fd3e8449e53730c631200ebc7b88016acecab2b0da2f0149222fe"
url: "https://pub.dev"
source: hosted
version: "3.9.0"
version: "3.9.1"
pool:
dependency: transitive
description:
Expand Down Expand Up @@ -501,10 +501,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec"
sha256: "7475cb4dd713d57b6f7464c0e13f06da0d535d8b2067e188962a59bac2cf280b"
url: "https://pub.dev"
source: hosted
version: "14.2.1"
version: "14.2.2"
watcher:
dependency: transitive
description:
Expand Down

0 comments on commit d85a22e

Please sign in to comment.