Skip to content

Commit

Permalink
fix: Added SquareAvatar.
Browse files Browse the repository at this point in the history
  • Loading branch information
mathrunet committed Oct 26, 2023
1 parent 6712c90 commit 6ee12d2
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/katana_ui/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -353,14 +353,14 @@ packages:
path: "../../katana"
relative: true
source: path
version: "2.4.1"
version: "2.4.2"
katana_ui:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "2.4.5"
version: "2.5.2"
lints:
dependency: transitive
description:
Expand Down
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 @@ -31,3 +31,4 @@ part 'ui/periodic_scope.dart';
part 'ui/chat_tile.dart';
part 'ui/shimmer.dart';
part 'ui/avatar_tile.dart';
part 'ui/square_avatar.dart';
53 changes: 53 additions & 0 deletions packages/katana_ui/lib/ui/square_avatar.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
part of katana_ui;

/// Square version of [CircleAvatar].
///
/// Can be used in place of [CircleAvatar].
///
/// 四角版の[CircleAvatar]
///
/// [CircleAvatar]の代わりに使用できます。
class SquareAvatar extends StatelessWidget {
/// Square version of [CircleAvatar].
///
/// Can be used in place of [CircleAvatar].
///
/// 四角版の[CircleAvatar]
///
/// [CircleAvatar]の代わりに使用できます。
const SquareAvatar({
super.key,
this.radius,
this.backgroundColor,
this.backgroundImage,
});

/// Rounded corners.
///
/// 角丸。
final double? radius;

/// Background color.
///
/// 背景色。
final Color? backgroundColor;

/// Background image.
///
/// 背景画像。
final ImageProvider<Object>? backgroundImage;

@override
Widget build(BuildContext context) {
return ClipRRect(
borderRadius: BorderRadius.circular(radius ?? 0),
child: Stack(
fit: StackFit.expand,
children: [
if (backgroundImage != null) Image(image: backgroundImage!),
if (backgroundColor != null) ColoredBox(color: backgroundColor!),
],
),
);
}
}
2 changes: 1 addition & 1 deletion packages/katana_ui/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ packages:
path: "../katana"
relative: true
source: path
version: "2.4.1"
version: "2.4.3"
lints:
dependency: transitive
description:
Expand Down

0 comments on commit 6ee12d2

Please sign in to comment.