-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
206 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
part of 'tabs.dart'; | ||
|
||
final class FTabContent extends StatelessWidget { | ||
final String? title; | ||
final String? subtitle; | ||
final Widget? child; | ||
final FCardContentStyle? style; | ||
|
||
const FTabContent({this.title, this.subtitle, this.child, this.style, super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final font = context.theme.font; | ||
final style = this.style ?? context.theme.cardStyle.content; | ||
return Padding( | ||
padding: style.padding, | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
if (title != null) Text(title!, style: style.title.withFont(font)), | ||
if (subtitle != null) Text(subtitle!, style: style.subtitle.withFont(font)), | ||
if (child != null) | ||
Padding( | ||
padding: (title == null && subtitle == null) ? const EdgeInsets.only(top: 4) : const EdgeInsets.only(top: 10), | ||
child: child!, | ||
), | ||
], | ||
), | ||
); | ||
} | ||
|
||
@override | ||
void debugFillProperties(DiagnosticPropertiesBuilder properties) { | ||
super.debugFillProperties(properties); | ||
properties | ||
..add(StringProperty('title', title)) | ||
..add(StringProperty('subtitle', subtitle)) | ||
..add(DiagnosticsProperty('style', style)); | ||
} | ||
} | ||
|
||
/// A card content's style. | ||
final class FTabContentStyle with Diagnosticable { | ||
|
||
/// The padding. | ||
final EdgeInsets padding; | ||
|
||
/// The title. | ||
final TextStyle title; | ||
|
||
/// The subtitle. | ||
final TextStyle subtitle; | ||
|
||
/// Creates a [FTabContentStyle]. | ||
const FTabContentStyle({required this.padding, required this.title, required this.subtitle}); | ||
|
||
/// Creates a [FCardContentStyle] that inherits its properties from [colorScheme] and [font]. | ||
FTabContentStyle.inherit({required FColorScheme colorScheme, required FFont font}): | ||
padding = const EdgeInsets.fromLTRB(16, 12, 16, 16), | ||
title = TextStyle( | ||
fontSize: font.base, | ||
fontWeight: FontWeight.w600, | ||
color: colorScheme.foreground, | ||
), | ||
subtitle = TextStyle( | ||
fontSize: font.sm, | ||
color: colorScheme.mutedForeground, | ||
); | ||
|
||
/// Creates a copy of this [FCardContentStyle] with the given properties replaced. | ||
FTabContentStyle copyWith({EdgeInsets? padding, TextStyle? title, TextStyle? subtitle}) => FTabContentStyle( | ||
padding: padding ?? this.padding, | ||
title: title ?? this.title, | ||
subtitle: subtitle ?? this.subtitle, | ||
); | ||
|
||
@override | ||
void debugFillProperties(DiagnosticPropertiesBuilder properties) { | ||
super.debugFillProperties(properties); | ||
properties | ||
..add(DiagnosticsProperty('padding', padding)) | ||
..add(DiagnosticsProperty('title', title)) | ||
..add(DiagnosticsProperty('subtitle', subtitle)); | ||
} | ||
|
||
@override | ||
bool operator ==(Object other) => identical(this, other) || other is FCardContentStyle && | ||
runtimeType == other.runtimeType && | ||
padding == other.padding && | ||
title == other.title && | ||
subtitle == other.subtitle; | ||
|
||
@override | ||
int get hashCode => padding.hashCode ^ title.hashCode ^ subtitle.hashCode; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.