Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Add CosmosTheme support for more components #269

Merged
merged 6 commits into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'package:cosmos_ui_components/cosmos_text_theme.dart';
import 'package:cosmos_ui_components/cosmos_ui_components.dart';
import 'package:cosmos_utils/app_info_provider.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
Expand All @@ -16,7 +18,10 @@ class AppVersionText extends StatelessWidget {
future: appInfoProvider.getAppVersion(),
builder: (context, snapshot) => Text(
snapshot.data ?? '',
style: style,
style: style ??
CosmosTextTheme.copyMinus1Normal.copyWith(
color: CosmosTheme.of(context).colors.text,
),
),
);

Expand Down
3 changes: 2 additions & 1 deletion packages/cosmos_ui_components/lib/components/chip_text.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:cosmos_ui_components/cosmos_text_theme.dart';
import 'package:cosmos_ui_components/cosmos_ui_components.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
Expand All @@ -24,7 +25,7 @@ class ChipText extends StatelessWidget {
),
child: Text(
title,
style: style,
style: style ?? CosmosTextTheme.copyMinus1Normal.copyWith(color: theme.colors.text),
),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ContentLoadingIndicator extends StatelessWidget {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const CircularProgressIndicator(),
CircularProgressIndicator(color: CosmosTheme.of(context).colors.text),
SizedBox(height: CosmosTheme.of(context).spacingM),
if (message.isNotEmpty) Text(message),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ class CosmosAppBar extends StatelessWidget implements PreferredSizeWidget {
SizedBox(height: theme.spacingL),
Padding(
padding: EdgeInsets.symmetric(horizontal: theme.spacingL),
child: Text(title!, style: CosmosTextTheme.titleSans2Bold),
child: Text(
title!,
style: CosmosTextTheme.titleSans2Bold.copyWith(
color: theme.colors.text,
),
),
),
]
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ class CosmosTextButton extends StatelessWidget {

@override
Widget build(BuildContext context) {
final theme = CosmosTheme.of(context);
return TextButton(
onPressed: onTap,
style: TextButton.styleFrom(
fixedSize: Size.fromHeight(height),
shape: RoundedRectangleBorder(borderRadius: CosmosTheme.of(context).borderRadiusM),
shape: RoundedRectangleBorder(borderRadius: theme.borderRadiusM),
onSurface: color,
),
child: Row(
Expand All @@ -48,16 +49,19 @@ class CosmosTextButton extends StatelessWidget {
padding: EdgeInsets.only(top: iconTopSpacing ?? 0.0),
child: leadingIcon,
),
if (text.isNotEmpty) SizedBox(width: CosmosTheme.of(context).spacingM),
if (text.isNotEmpty) SizedBox(width: theme.spacingM),
],
Text(
text,
maxLines: maxLines,
overflow: overflow,
style: textStyle ?? CosmosTextTheme.elevatedButton.copyWith(color: color),
style: textStyle ??
CosmosTextTheme.elevatedButton.copyWith(
color: color ?? theme.colors.text,
),
),
if (suffixIcon != null) ...[
if (text.isNotEmpty) SizedBox(width: CosmosTheme.of(context).spacingS),
if (text.isNotEmpty) SizedBox(width: theme.spacingS),
Padding(
padding: EdgeInsets.only(top: iconTopSpacing ?? 0.0),
child: suffixIcon,
Expand Down