mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-29 18:38:36 +08:00
FeatureTimeline: Refactor
This commit is contained in:
@ -33,6 +33,41 @@ class FeatureTile extends StatelessWidget {
|
|||||||
subtitle += ' - ' + feature.subtitle;
|
subtitle += ' - ' + feature.subtitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Color color;
|
||||||
|
var theme = Theme.of(context);
|
||||||
|
|
||||||
|
if (feature.pro) {
|
||||||
|
if (theme.brightness == Brightness.light) {
|
||||||
|
color = theme.primaryColor;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
color = theme.accentColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _Tile(
|
||||||
|
title: feature.title,
|
||||||
|
subTitle: subtitle,
|
||||||
|
iconText: feature.pro ? 'PRO' : "FREE",
|
||||||
|
iconColor: color,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _Tile extends StatelessWidget {
|
||||||
|
final String title;
|
||||||
|
final String subTitle;
|
||||||
|
final String iconText;
|
||||||
|
final Color iconColor;
|
||||||
|
|
||||||
|
_Tile({
|
||||||
|
@required this.title,
|
||||||
|
@required this.subTitle,
|
||||||
|
@required this.iconText,
|
||||||
|
@required this.iconColor,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
var theme = Theme.of(context);
|
var theme = Theme.of(context);
|
||||||
var textTheme = theme.textTheme;
|
var textTheme = theme.textTheme;
|
||||||
var titleTextStyle = textTheme.subtitle1.copyWith();
|
var titleTextStyle = textTheme.subtitle1.copyWith();
|
||||||
@ -49,16 +84,16 @@ class FeatureTile extends StatelessWidget {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Container(
|
Container(
|
||||||
width: 56.0,
|
width: 56.0,
|
||||||
child: feature.pro ? _Sign('PRO') : _Sign("FREE"),
|
child: _Sign(iconText, iconColor),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Text(feature.title, style: titleTextStyle),
|
Text(title, style: titleTextStyle),
|
||||||
const SizedBox(height: 4.0),
|
const SizedBox(height: 4.0),
|
||||||
Flexible(
|
Flexible(
|
||||||
child: Text(
|
child: Text(
|
||||||
subtitle,
|
subTitle,
|
||||||
style: subTitleTextStyle,
|
style: subTitleTextStyle,
|
||||||
overflow: TextOverflow.clip,
|
overflow: TextOverflow.clip,
|
||||||
softWrap: true,
|
softWrap: true,
|
||||||
@ -80,18 +115,16 @@ class FeatureTile extends StatelessWidget {
|
|||||||
|
|
||||||
class _Sign extends StatelessWidget {
|
class _Sign extends StatelessWidget {
|
||||||
final String text;
|
final String text;
|
||||||
_Sign(this.text);
|
final Color color;
|
||||||
|
|
||||||
|
_Sign(this.text, this.color);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var theme = Theme.of(context);
|
var theme = Theme.of(context);
|
||||||
var textStyle = theme.textTheme.subtitle2;
|
var textStyle = theme.textTheme.subtitle2;
|
||||||
if (text == 'PRO') {
|
if (color != null) {
|
||||||
if (theme.brightness == Brightness.light) {
|
textStyle = textStyle.copyWith(color: color);
|
||||||
textStyle = textStyle.copyWith(color: theme.primaryColor);
|
|
||||||
} else {
|
|
||||||
textStyle = textStyle.copyWith(color: theme.accentColor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Text(text, style: textStyle);
|
return Text(text, style: textStyle);
|
||||||
|
Reference in New Issue
Block a user