refactor: using palette

This commit is contained in:
Rongjian Zhang 2019-12-21 17:26:26 +08:00
parent 23983fb556
commit 891ca417cd
4 changed files with 19 additions and 18 deletions

View File

@ -21,7 +21,6 @@ import 'package:git_touch/screens/settings.dart';
import 'package:git_touch/screens/stargazers.dart';
import 'package:git_touch/screens/user.dart';
import 'package:git_touch/screens/watchers.dart';
import 'package:primer/primer.dart';
import 'package:provider/provider.dart';
import 'package:git_touch/models/notification.dart';
import 'package:fluro/fluro.dart';
@ -43,6 +42,7 @@ class _HomeState extends State<Home> {
// String login;
Widget _buildNotificationIcon(BuildContext context, bool isActive) {
final theme = Provider.of<ThemeModel>(context);
final iconData = isActive ? Icons.notifications : Icons.notifications_none;
int count = Provider.of<NotificationModel>(context).count;
if (count == 0) {
@ -57,7 +57,7 @@ class _HomeState extends State<Home> {
right: -2,
top: -2,
child: Icon(Octicons.primitive_dot,
color: PrimerColors.red500, size: 14))
color: theme.palette.primary, size: 14))
],
);
}
@ -150,8 +150,7 @@ class _HomeState extends State<Home> {
final themData = ThemeData(
brightness: theme.brightness,
primaryColor: PrimerColors.white,
accentColor: PrimerColors.blue500,
primaryColor: Colors.white,
);
// TODO:
@ -169,7 +168,7 @@ class _HomeState extends State<Home> {
return CupertinoApp(
theme: CupertinoThemeData(
brightness: theme.brightness,
primaryColor: PrimerColors.blue500,
primaryColor: theme.palette.primary,
),
home: CupertinoTabScaffold(
tabBar: CupertinoTabBar(items: _navigationItems),
@ -189,7 +188,7 @@ class _HomeState extends State<Home> {
body: _buildScreen(active),
bottomNavigationBar: BottomNavigationBar(
backgroundColor: Colors.white,
selectedItemColor: PrimerColors.blue500,
selectedItemColor: theme.palette.primary,
items: _navigationItems,
currentIndex: active,
type: BottomNavigationBarType.fixed,

View File

@ -117,7 +117,7 @@ class ThemeModel with ChangeNotifier {
);
case Brightness.dark:
return Palette(
primary: PrimerColors.blue400,
primary: PrimerColors.blue500,
text: PrimerColors.gray300,
secondaryText: PrimerColors.gray400,
tertiaryText: PrimerColors.gray500,

View File

@ -63,15 +63,16 @@ TextSpan createLinkSpan(
String text,
String url,
) {
final theme = Provider.of<ThemeModel>(context);
return TextSpan(
text: text,
style: TextStyle(
color: PrimerColors.blue500,
color: theme.palette.primary,
fontWeight: FontWeight.w600,
),
recognizer: TapGestureRecognizer()
..onTap = () {
Provider.of<ThemeModel>(context).push(context, url);
theme.push(context, url);
},
);
}
@ -149,6 +150,7 @@ class PrimerBranchName extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Provider.of<ThemeModel>(context);
return Container(
padding: EdgeInsets.symmetric(vertical: 2, horizontal: 4),
height: 16,
@ -159,7 +161,7 @@ class PrimerBranchName extends StatelessWidget {
child: Text(
name,
style: TextStyle(
color: PrimerColors.blue500,
color: theme.palette.primary,
fontSize: 14,
height: 1,
fontFamily: CommonStyle.monospace,

View File

@ -3,7 +3,6 @@ import 'package:flutter/cupertino.dart';
import 'package:git_touch/models/theme.dart';
import 'package:git_touch/utils/utils.dart';
import 'package:git_touch/widgets/border_view.dart';
import 'package:primer/primer.dart';
import 'package:provider/provider.dart';
import 'link.dart';
@ -14,11 +13,12 @@ class TableViewHeader extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Provider.of<ThemeModel>(context);
return Container(
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 6),
child: Text(
title.toUpperCase(),
style: TextStyle(color: PrimerColors.gray600, fontSize: 13),
style: TextStyle(color: theme.palette.secondaryText, fontSize: 13),
),
);
}
@ -55,7 +55,7 @@ class TableView extends StatelessWidget {
@override
Widget build(BuildContext context) {
final themeModel = Provider.of<ThemeModel>(context);
final theme = Provider.of<ThemeModel>(context);
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
@ -74,18 +74,18 @@ class TableView extends StatelessWidget {
height: 24,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: PrimerColors.blue500,
color: theme.palette.primary,
),
child: Icon(
item.leftIconData,
color: themeModel.palette.background,
color: theme.palette.background,
size: 14,
),
);
}
final widget = DefaultTextStyle(
style: TextStyle(fontSize: 17, color: themeModel.palette.text),
style: TextStyle(fontSize: 17, color: theme.palette.text),
overflow: TextOverflow.ellipsis,
child: Container(
height: 44,
@ -100,7 +100,7 @@ class TableView extends StatelessWidget {
DefaultTextStyle(
style: TextStyle(
fontSize: 16,
color: themeModel.palette.tertiaryText,
color: theme.palette.tertiaryText,
),
child: item.rightWidget,
),
@ -109,7 +109,7 @@ class TableView extends StatelessWidget {
if ((item.onTap != null || item.url != null) &&
!item.hideRightChevron)
Icon(CupertinoIcons.right_chevron,
size: 20, color: themeModel.palette.tertiaryText)
size: 20, color: theme.palette.tertiaryText)
else
SizedBox(width: 2),
SizedBox(width: 8),