-
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
11 changed files
with
189 additions
and
32 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
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,38 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
import 'package:forui/forui.dart'; | ||
|
||
part 'card_content.dart'; | ||
part 'card_style.dart'; | ||
part 'card_content_style.dart'; | ||
|
||
/// Represents a card widget. | ||
class FCard extends StatelessWidget { | ||
/// The child. | ||
final Widget child; | ||
|
||
/// The style. | ||
final FCardStyle? style; | ||
|
||
/// Creates a [FCard]. | ||
FCard({ | ||
String? title, | ||
String? subtitle, | ||
Widget? content, | ||
this.style, | ||
super.key, | ||
}) : child = FCardContent(title: title, subtitle: subtitle, content: content); | ||
|
||
/// Creates a [FCard]. | ||
const FCard.raw({required this.child, this.style, super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final style = this.style ?? FTheme.of(context).widgets.card; | ||
|
||
return DecoratedBox( | ||
decoration: style.decoration, | ||
child: child, | ||
); | ||
} | ||
} |
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,40 @@ | ||
part of 'card.dart'; | ||
|
||
/// Represents a content for [FCard]. | ||
final class FCardContent extends StatelessWidget { | ||
/// The title. | ||
final String? title; | ||
|
||
/// The subtitle. | ||
final String? subtitle; | ||
|
||
/// The child. | ||
final Widget? content; | ||
|
||
/// The style. | ||
final FCardContentStyle? style; | ||
|
||
/// Creates a [FCardContent]. | ||
const FCardContent({this.title, this.subtitle, this.content, this.style, super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final style = this.style ?? FTheme.of(context).widgets.card.content; | ||
|
||
return Padding( | ||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 16), | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
if (title != null) Text(title!, style: style.title), | ||
if (subtitle != null) Text(subtitle!, style: style.subtitle), | ||
if (content != null) | ||
Padding( | ||
padding: (title != null || subtitle != null) ? const EdgeInsets.only(top: 10) : const EdgeInsets.only(top: 4), | ||
child: content!, | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
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,35 @@ | ||
part of 'card.dart'; | ||
|
||
/// [FCardContent]'s style. | ||
class FCardContentStyle { | ||
/// The padding. | ||
final EdgeInsets padding; | ||
|
||
/// The title. | ||
final TextStyle title; | ||
|
||
/// The subtitle. | ||
final TextStyle subtitle; | ||
|
||
/// Creates a [FCardContentStyle]. | ||
const FCardContentStyle({required this.padding, required this.title, required this.subtitle}); | ||
|
||
/// Creates a [FCardContentStyle] that inherits its properties from [style] and [font]. | ||
FCardContentStyle.inherit({required FStyleData style, required FFontData font}) | ||
: padding = const EdgeInsets.all(20), | ||
title = ScaledTextStyle( | ||
TextStyle( | ||
fontSize: 16, | ||
fontWeight: FontWeight.w600, | ||
color: style.foreground, | ||
), | ||
font, | ||
), | ||
subtitle = ScaledTextStyle( | ||
TextStyle( | ||
fontSize: 12, | ||
color: style.mutedForeground, | ||
), | ||
font, | ||
); | ||
} |
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,21 @@ | ||
part of 'card.dart'; | ||
|
||
/// [FCard]'s style. | ||
class FCardStyle { | ||
/// The decoration. | ||
final BoxDecoration decoration; | ||
|
||
/// The [FCardContent] style. | ||
final FCardContentStyle content; | ||
|
||
/// Creates a [FCardStyle]. | ||
FCardStyle({required this.decoration, required this.content}); | ||
|
||
/// Creates a [FCardStyle] that inherits its properties from [style] and [font]. | ||
FCardStyle.inherit({required FStyleData style, required FFontData font}) | ||
: decoration = BoxDecoration( | ||
border: Border.all(color: style.border), | ||
borderRadius: style.borderRadius, | ||
), | ||
content = FCardContentStyle.inherit(style: style, font: font); | ||
} |
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