mirror of
https://github.com/git-touch/git-touch
synced 2025-01-31 08:04:51 +01:00
refactor: common styles
This commit is contained in:
parent
141b80adaa
commit
e6a6b026f6
@ -27,7 +27,7 @@ class CodeModel with ChangeNotifier {
|
||||
int get fontSize => _fontSize;
|
||||
String get fontFamily => _fontFamily;
|
||||
String get fontFamilyUsed =>
|
||||
_fontFamily == 'System' ? monospaceFont : _fontFamily;
|
||||
_fontFamily == 'System' ? CommonStyle.monospace : _fontFamily;
|
||||
|
||||
init() async {
|
||||
var prefs = await SharedPreferences.getInstance();
|
||||
|
@ -142,7 +142,7 @@ class _ListStatefulScaffoldState<T, K>
|
||||
}
|
||||
|
||||
if (index % 2 == 1) {
|
||||
return borderView;
|
||||
return CommonStyle.border;
|
||||
}
|
||||
|
||||
return widget.itemBuilder(items[index ~/ 2]);
|
||||
|
@ -103,7 +103,7 @@ class _LongListScaffoldState<T, K> extends State<LongListScaffold<T, K>> {
|
||||
|
||||
Widget _buildItem(BuildContext context, int index) {
|
||||
if (index % 2 == 1) {
|
||||
return borderView;
|
||||
return CommonStyle.border;
|
||||
}
|
||||
|
||||
int realIndex = index ~/ 2;
|
||||
@ -115,7 +115,7 @@ class _LongListScaffoldState<T, K> extends State<LongListScaffold<T, K>> {
|
||||
payload.leadingItems.length +
|
||||
payload.trailingItems.length;
|
||||
return Container(
|
||||
padding: commonItemPadding,
|
||||
padding: CommonStyle.padding,
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: ExactAssetImage('images/progressive-disclosure-line.png',
|
||||
@ -127,7 +127,7 @@ class _LongListScaffoldState<T, K> extends State<LongListScaffold<T, K>> {
|
||||
child: Link(
|
||||
onTap: _loadMore,
|
||||
child: Container(
|
||||
padding: commonItemPadding,
|
||||
padding: CommonStyle.padding,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.black12),
|
||||
),
|
||||
|
@ -4,12 +4,14 @@ import 'package:git_touch/scaffolds/common.dart';
|
||||
class SingleScaffold extends StatelessWidget {
|
||||
final Widget title;
|
||||
final Widget body;
|
||||
final Widget trailing;
|
||||
final Widget action;
|
||||
final Color backgroundColor;
|
||||
|
||||
SingleScaffold({
|
||||
@required this.title,
|
||||
@required this.body,
|
||||
this.trailing,
|
||||
this.action,
|
||||
this.backgroundColor,
|
||||
});
|
||||
|
||||
@override
|
||||
@ -17,7 +19,8 @@ class SingleScaffold extends StatelessWidget {
|
||||
return CommonScaffold(
|
||||
title: title,
|
||||
body: Scrollbar(child: SingleChildScrollView(child: body)),
|
||||
action: trailing,
|
||||
action: action,
|
||||
backgroundColor: backgroundColor,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ class CodeThemeScreen extends StatelessWidget {
|
||||
fontSize: codeProvider.fontSize.toDouble(),
|
||||
fontFamily: codeProvider.fontFamilyUsed,
|
||||
),
|
||||
padding: commonItemPadding,
|
||||
padding: CommonStyle.padding,
|
||||
),
|
||||
)
|
||||
],
|
||||
|
@ -90,7 +90,7 @@ class CommitsScreen extends StatelessWidget {
|
||||
return Link(
|
||||
url: payload['url'],
|
||||
child: Container(
|
||||
padding: commonItemPadding,
|
||||
padding: CommonStyle.padding,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
|
@ -44,7 +44,7 @@ class CreditsScreen extends StatelessWidget {
|
||||
title: Text('Credits'),
|
||||
body: Column(
|
||||
children: <Widget>[
|
||||
verticalGap,
|
||||
CommonStyle.verticalGap,
|
||||
TableView(
|
||||
headerText: 'packages',
|
||||
items: projects.map((t) {
|
||||
@ -54,7 +54,7 @@ class CreditsScreen extends StatelessWidget {
|
||||
);
|
||||
}),
|
||||
),
|
||||
verticalGap,
|
||||
CommonStyle.verticalGap,
|
||||
TableView(
|
||||
headerText: 'fonts',
|
||||
items: fonts.map((font) {
|
||||
|
@ -355,7 +355,7 @@ mutation {
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: commonItemPadding,
|
||||
padding: CommonStyle.padding,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
@ -383,7 +383,7 @@ mutation {
|
||||
],
|
||||
),
|
||||
),
|
||||
borderView,
|
||||
CommonStyle.border,
|
||||
],
|
||||
);
|
||||
},
|
||||
|
@ -25,7 +25,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
settings.setActiveAccountIndex(index);
|
||||
},
|
||||
child: Container(
|
||||
padding: commonItemPadding,
|
||||
padding: CommonStyle.padding,
|
||||
decoration: BoxDecoration(
|
||||
border: Border(bottom: BorderSide(color: Colors.black12)),
|
||||
),
|
||||
|
@ -116,7 +116,7 @@ class ObjectScreen extends StatelessWidget {
|
||||
case 'md':
|
||||
case 'markdown':
|
||||
return Padding(
|
||||
padding: commonItemPadding,
|
||||
padding: CommonStyle.padding,
|
||||
child: MarkdownView(payload['text']),
|
||||
);
|
||||
case 'png':
|
||||
@ -133,7 +133,7 @@ class ObjectScreen extends StatelessWidget {
|
||||
payload['text'],
|
||||
language: _language,
|
||||
theme: themeMap[codeProvider.theme],
|
||||
padding: commonItemPadding,
|
||||
padding: CommonStyle.padding,
|
||||
textStyle: TextStyle(
|
||||
fontSize: codeProvider.fontSize.toDouble(),
|
||||
fontFamily: codeProvider.fontFamilyUsed),
|
||||
|
@ -39,10 +39,10 @@ class OrganizationScreen extends StatelessWidget {
|
||||
if (items.isEmpty) return [];
|
||||
|
||||
return [
|
||||
verticalGap,
|
||||
CommonStyle.verticalGap,
|
||||
if (title != null) TableViewHeader(title),
|
||||
...join(
|
||||
borderView,
|
||||
CommonStyle.border,
|
||||
items.map((item) {
|
||||
return RepositoryItem(item);
|
||||
}).toList(),
|
||||
@ -112,7 +112,7 @@ class OrganizationScreen extends StatelessWidget {
|
||||
avatarUrl: data['avatarUrl'],
|
||||
bio: data['description'],
|
||||
),
|
||||
borderView,
|
||||
CommonStyle.border,
|
||||
Row(children: <Widget>[
|
||||
EntryItem(
|
||||
count: data['pinnableItems']['totalCount'],
|
||||
@ -126,7 +126,7 @@ class OrganizationScreen extends StatelessWidget {
|
||||
screenBuilder: (context) => UsersScreen.members(login),
|
||||
),
|
||||
]),
|
||||
verticalGap,
|
||||
CommonStyle.verticalGap,
|
||||
TableView(
|
||||
hasIcon: true,
|
||||
items: [
|
||||
|
@ -211,8 +211,8 @@ class RepositoryScreen extends StatelessWidget {
|
||||
var readme = payload.data[1] as String;
|
||||
|
||||
final langWidth = MediaQuery.of(context).size.width -
|
||||
commonItemPadding.left -
|
||||
commonItemPadding.right -
|
||||
CommonStyle.padding.left -
|
||||
CommonStyle.padding.right -
|
||||
(data['languages']['edges'] as List).length +
|
||||
1;
|
||||
|
||||
@ -220,7 +220,7 @@ class RepositoryScreen extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
RepositoryItem(data, inRepoScreen: true),
|
||||
borderView,
|
||||
CommonStyle.border,
|
||||
Row(
|
||||
children: <Widget>[
|
||||
EntryItem(
|
||||
@ -241,11 +241,11 @@ class RepositoryScreen extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
verticalGap,
|
||||
CommonStyle.verticalGap,
|
||||
if ((data['languages']['edges'] as List).isNotEmpty)
|
||||
Container(
|
||||
color: Colors.white,
|
||||
padding: commonItemPadding.copyWith(top: 8, bottom: 8),
|
||||
padding: CommonStyle.padding.copyWith(top: 8, bottom: 8),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
child: SizedBox(
|
||||
@ -304,7 +304,7 @@ class RepositoryScreen extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
verticalGap,
|
||||
CommonStyle.verticalGap,
|
||||
TableView(
|
||||
hasIcon: true,
|
||||
items: [
|
||||
@ -366,14 +366,14 @@ class RepositoryScreen extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
verticalGap,
|
||||
CommonStyle.verticalGap,
|
||||
if (readme != null)
|
||||
Container(
|
||||
padding: commonItemPadding,
|
||||
padding: CommonStyle.padding,
|
||||
color: Colors.white,
|
||||
child: MarkdownView(readme),
|
||||
),
|
||||
verticalGap,
|
||||
CommonStyle.verticalGap,
|
||||
],
|
||||
);
|
||||
},
|
||||
|
@ -6,6 +6,7 @@ import 'package:git_touch/screens/credits.dart';
|
||||
import 'package:git_touch/screens/repository.dart';
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:git_touch/widgets/app_bar_title.dart';
|
||||
import 'package:primer/primer.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:launch_review/launch_review.dart';
|
||||
import '../widgets/table_view.dart';
|
||||
@ -23,16 +24,17 @@ class SettingsScreen extends StatelessWidget {
|
||||
|
||||
return SingleScaffold(
|
||||
title: AppBarTitle('Settings'),
|
||||
backgroundColor: PrimerColors.gray000,
|
||||
body: Column(
|
||||
children: <Widget>[
|
||||
verticalGap,
|
||||
CommonStyle.verticalGap,
|
||||
TableView(headerText: 'ACCOUNTS', items: [
|
||||
TableViewItem(
|
||||
text: Text('Switch to another account'),
|
||||
screenBuilder: (_) => LoginScreen(),
|
||||
),
|
||||
]),
|
||||
verticalGap,
|
||||
CommonStyle.verticalGap,
|
||||
TableView(headerText: 'THEME', items: [
|
||||
TableViewItem(
|
||||
text: Text('Material'),
|
||||
@ -57,7 +59,7 @@ class SettingsScreen extends StatelessWidget {
|
||||
hideRightChevron: true,
|
||||
),
|
||||
]),
|
||||
verticalGap,
|
||||
CommonStyle.verticalGap,
|
||||
TableView(headerText: 'ABOUT', items: [
|
||||
TableViewItem(
|
||||
text: Text('Source Code'),
|
||||
|
@ -23,7 +23,7 @@ class TrendingScreen extends StatelessWidget {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: join(
|
||||
borderView,
|
||||
CommonStyle.border,
|
||||
payload.map<Widget>((item) {
|
||||
switch (activeTab) {
|
||||
case 0:
|
||||
|
@ -87,7 +87,7 @@ class _TrendingScreenState extends State<TrendingScreen> {
|
||||
onRefresh: _refresh,
|
||||
body: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: join(borderView, _buildItems()).toList(),
|
||||
children: join(CommonStyle.border, _buildItems()).toList(),
|
||||
),
|
||||
activeTab: _activeTab,
|
||||
onTabSwitch: (int index) {
|
||||
|
@ -86,10 +86,10 @@ class UserScreen extends StatelessWidget {
|
||||
if (items.isEmpty) return [];
|
||||
|
||||
return [
|
||||
verticalGap,
|
||||
CommonStyle.verticalGap,
|
||||
if (title != null) TableViewHeader(title),
|
||||
...join(
|
||||
borderView,
|
||||
CommonStyle.border,
|
||||
items.map((item) {
|
||||
return RepositoryItem(item);
|
||||
}).toList(),
|
||||
@ -127,7 +127,7 @@ class UserScreen extends StatelessWidget {
|
||||
|
||||
return Container(
|
||||
color: Colors.white,
|
||||
padding: commonItemPadding,
|
||||
padding: CommonStyle.padding,
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
reverse: true,
|
||||
@ -191,7 +191,7 @@ class UserScreen extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
UserItem.fromData(data, inUserScreen: true),
|
||||
borderView,
|
||||
CommonStyle.border,
|
||||
Row(children: <Widget>[
|
||||
EntryItem(
|
||||
count: data['repositories']['totalCount'],
|
||||
@ -214,9 +214,9 @@ class UserScreen extends StatelessWidget {
|
||||
screenBuilder: (context) => UsersScreen.following(login),
|
||||
),
|
||||
]),
|
||||
verticalGap,
|
||||
CommonStyle.verticalGap,
|
||||
_buildContributions(contributions),
|
||||
verticalGap,
|
||||
CommonStyle.verticalGap,
|
||||
TableView(
|
||||
hasIcon: true,
|
||||
items: [
|
||||
@ -261,7 +261,7 @@ class UserScreen extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
..._buildRepos(data),
|
||||
verticalGap,
|
||||
CommonStyle.verticalGap,
|
||||
],
|
||||
);
|
||||
},
|
||||
|
@ -12,8 +12,6 @@ import 'package:provider/provider.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
export 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||
|
||||
final monospaceFont = Platform.isIOS ? 'Menlo' : 'monospace'; // FIXME:
|
||||
|
||||
class StorageKeys {
|
||||
static const accounts = 'accounts';
|
||||
static const account = 'account';
|
||||
@ -22,6 +20,13 @@ class StorageKeys {
|
||||
static const newsFilter = 'news.filter';
|
||||
}
|
||||
|
||||
class CommonStyle {
|
||||
static const padding = EdgeInsets.all(12);
|
||||
static const border = BorderView();
|
||||
static const verticalGap = SizedBox(height: 18);
|
||||
static final monospace = Platform.isIOS ? 'Menlo' : 'monospace'; // FIXME:
|
||||
}
|
||||
|
||||
Color convertColor(String cssHex) {
|
||||
if (cssHex == null) {
|
||||
return Color(0xffcccccc); // Default color
|
||||
@ -124,9 +129,6 @@ bool isNotNullOrEmpty(String text) {
|
||||
return text != null && text.isNotEmpty;
|
||||
}
|
||||
|
||||
const borderView = BorderView();
|
||||
const verticalGap = SizedBox(height: 18);
|
||||
|
||||
String getBranchQueryKey(String branch, {bool withParams = false}) {
|
||||
if (branch == null) return 'defaultBranchRef';
|
||||
return 'ref' + (withParams ? '(qualifiedName: "$branch")' : '');
|
||||
@ -155,7 +157,7 @@ class PrimerBranchName extends StatelessWidget {
|
||||
color: PrimerColors.blue500,
|
||||
fontSize: 12,
|
||||
height: 1,
|
||||
fontFamily: monospaceFont,
|
||||
fontFamily: CommonStyle.monospace,
|
||||
),
|
||||
),
|
||||
);
|
||||
@ -171,5 +173,3 @@ launchUrl(String url) async {
|
||||
// TODO: fallback
|
||||
}
|
||||
}
|
||||
|
||||
const commonItemPadding = EdgeInsets.all(12);
|
||||
|
@ -72,7 +72,7 @@ class EventItem extends StatelessWidget {
|
||||
screenBuilder: screenBuilder,
|
||||
url: url,
|
||||
child: Container(
|
||||
padding: commonItemPadding,
|
||||
padding: CommonStyle.padding,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
@ -309,7 +309,7 @@ class EventItem extends StatelessWidget {
|
||||
style: TextStyle(
|
||||
color: PrimerColors.blue500,
|
||||
fontSize: 13,
|
||||
fontFamily: monospaceFont,
|
||||
fontFamily: CommonStyle.monospace,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 6),
|
||||
|
@ -49,7 +49,7 @@ class IssueItem extends StatelessWidget {
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: commonItemPadding,
|
||||
padding: CommonStyle.padding,
|
||||
// color: payload.unread ? Colors.white : Colors.black12,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
@ -78,7 +78,7 @@ class MarkdownView extends StatelessWidget {
|
||||
code: _basicStyle.copyWith(
|
||||
fontSize: 16 * 0.85,
|
||||
height: 1.45,
|
||||
fontFamily: monospaceFont,
|
||||
fontFamily: CommonStyle.monospace,
|
||||
),
|
||||
h1: _hStyle.copyWith(fontSize: 32),
|
||||
h2: _hStyle.copyWith(fontSize: 24),
|
||||
|
@ -126,7 +126,7 @@ class RepositoryItem extends StatelessWidget {
|
||||
? null
|
||||
: (_) => RepositoryScreen(payload['owner']['login'], payload['name']),
|
||||
child: Container(
|
||||
padding: commonItemPadding,
|
||||
padding: CommonStyle.padding,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
|
@ -13,7 +13,6 @@ class TableViewHeader extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
color: PrimerColors.gray100,
|
||||
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
child: Text(
|
||||
title.toUpperCase(),
|
||||
@ -117,10 +116,10 @@ class TableView extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
if (headerText != null) TableViewHeader(headerText),
|
||||
borderView,
|
||||
CommonStyle.border,
|
||||
...join(BorderView(leftPadding: _leftPadding),
|
||||
items.map(_buildItem).toList()),
|
||||
borderView,
|
||||
CommonStyle.border,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
@ -302,7 +302,7 @@ class TimelineItem extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: commonItemPadding,
|
||||
padding: CommonStyle.padding,
|
||||
child: _buildByType(context),
|
||||
);
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ class UserItem extends StatelessWidget {
|
||||
: (_) =>
|
||||
isOrganization ? OrganizationScreen(login) : UserScreen(login),
|
||||
child: Container(
|
||||
padding: commonItemPadding,
|
||||
padding: CommonStyle.padding,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
|
Loading…
x
Reference in New Issue
Block a user