mirror of
https://github.com/pd4d10/git-touch.git
synced 2026-04-29 19:13:36 -05:00
style: dart fix apply
This commit is contained in:
@@ -13,6 +13,7 @@ class MyApp extends StatelessWidget {
|
|||||||
final auth = Provider.of<AuthModel>(context);
|
final auth = Provider.of<AuthModel>(context);
|
||||||
final theme = Provider.of<ThemeModel>(context);
|
final theme = Provider.of<ThemeModel>(context);
|
||||||
|
|
||||||
|
// ignore: prefer_function_declarations_over_variables
|
||||||
final LocaleListResolutionCallback localeListResolutionCallback =
|
final LocaleListResolutionCallback localeListResolutionCallback =
|
||||||
(locales, supportedLocales) {
|
(locales, supportedLocales) {
|
||||||
// 1. user set locale
|
// 1. user set locale
|
||||||
@@ -60,13 +61,12 @@ class MyApp extends StatelessWidget {
|
|||||||
brightness: theme.brightness,
|
brightness: theme.brightness,
|
||||||
primaryColor:
|
primaryColor:
|
||||||
theme.brightness == Brightness.dark ? null : Colors.white,
|
theme.brightness == Brightness.dark ? null : Colors.white,
|
||||||
accentColor: theme.palette.primary,
|
|
||||||
scaffoldBackgroundColor: theme.palette.background,
|
scaffoldBackgroundColor: theme.palette.background,
|
||||||
pageTransitionsTheme: PageTransitionsTheme(
|
pageTransitionsTheme: const PageTransitionsTheme(
|
||||||
builders: {
|
builders: {
|
||||||
TargetPlatform.android: ZoomPageTransitionsBuilder(),
|
TargetPlatform.android: ZoomPageTransitionsBuilder(),
|
||||||
},
|
},
|
||||||
),
|
), colorScheme: ColorScheme.fromSwatch().copyWith(secondary: theme.palette.primary),
|
||||||
),
|
),
|
||||||
home: Home(),
|
home: Home(),
|
||||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class _HomeState extends State<Home> {
|
|||||||
@override
|
@override
|
||||||
initState() {
|
initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
Future.delayed(Duration(seconds: 5), () async {
|
Future.delayed(const Duration(seconds: 5), () async {
|
||||||
final latest = await GitHub()
|
final latest = await GitHub()
|
||||||
.repositories
|
.repositories
|
||||||
.getLatestRelease(RepositorySlug.full('git-touch/git-touch'));
|
.getLatestRelease(RepositorySlug.full('git-touch/git-touch'));
|
||||||
@@ -57,7 +57,7 @@ class _HomeState extends State<Home> {
|
|||||||
.compareTo(Version.parse(current)) ==
|
.compareTo(Version.parse(current)) ==
|
||||||
1) {
|
1) {
|
||||||
final res = await context.read<ThemeModel>().showConfirm(context,
|
final res = await context.read<ThemeModel>().showConfirm(context,
|
||||||
Text('New version released. Would you like to download it?'));
|
const Text('New version released. Would you like to download it?'));
|
||||||
if (res == true) {
|
if (res == true) {
|
||||||
if (Platform.isIOS) {
|
if (Platform.isIOS) {
|
||||||
// go to app store
|
// go to app store
|
||||||
@@ -103,7 +103,7 @@ class _HomeState extends State<Home> {
|
|||||||
case 2:
|
case 2:
|
||||||
return GlSearchScreen();
|
return GlSearchScreen();
|
||||||
case 3:
|
case 3:
|
||||||
return GlUserScreen(null);
|
return const GlUserScreen(null);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PlatformType.bitbucket:
|
case PlatformType.bitbucket:
|
||||||
@@ -113,13 +113,13 @@ class _HomeState extends State<Home> {
|
|||||||
case 1:
|
case 1:
|
||||||
return BbTeamsScreen();
|
return BbTeamsScreen();
|
||||||
case 2:
|
case 2:
|
||||||
return BbUserScreen(null);
|
return const BbUserScreen(null);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PlatformType.gitea:
|
case PlatformType.gitea:
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0:
|
case 0:
|
||||||
return GtOrgsScreen();
|
return const GtOrgsScreen();
|
||||||
case 1:
|
case 1:
|
||||||
return GtUserScreen(auth.activeAccount!.login, isViewer: true);
|
return GtUserScreen(auth.activeAccount!.login, isViewer: true);
|
||||||
}
|
}
|
||||||
@@ -180,23 +180,23 @@ class _HomeState extends State<Home> {
|
|||||||
|
|
||||||
List<BottomNavigationBarItem> _buildNavigationItems(String platform) {
|
List<BottomNavigationBarItem> _buildNavigationItems(String platform) {
|
||||||
final search = BottomNavigationBarItem(
|
final search = BottomNavigationBarItem(
|
||||||
icon: Icon(Ionicons.search_outline),
|
icon: const Icon(Ionicons.search_outline),
|
||||||
activeIcon: Icon(Ionicons.search),
|
activeIcon: const Icon(Ionicons.search),
|
||||||
label: AppLocalizations.of(context)!.search,
|
label: AppLocalizations.of(context)!.search,
|
||||||
);
|
);
|
||||||
final group = BottomNavigationBarItem(
|
final group = BottomNavigationBarItem(
|
||||||
icon: Icon(Ionicons.people_outline),
|
icon: const Icon(Ionicons.people_outline),
|
||||||
activeIcon: Icon(Ionicons.people),
|
activeIcon: const Icon(Ionicons.people),
|
||||||
label: AppLocalizations.of(context)!.organizations,
|
label: AppLocalizations.of(context)!.organizations,
|
||||||
);
|
);
|
||||||
final me = BottomNavigationBarItem(
|
final me = BottomNavigationBarItem(
|
||||||
icon: Icon(Ionicons.person_outline),
|
icon: const Icon(Ionicons.person_outline),
|
||||||
activeIcon: Icon(Ionicons.person),
|
activeIcon: const Icon(Ionicons.person),
|
||||||
label: AppLocalizations.of(context)!.me,
|
label: AppLocalizations.of(context)!.me,
|
||||||
);
|
);
|
||||||
final explore = BottomNavigationBarItem(
|
final explore = BottomNavigationBarItem(
|
||||||
icon: Icon(Ionicons.compass_outline),
|
icon: const Icon(Ionicons.compass_outline),
|
||||||
activeIcon: Icon(Ionicons.compass),
|
activeIcon: const Icon(Ionicons.compass),
|
||||||
label: AppLocalizations.of(context)!.explore,
|
label: AppLocalizations.of(context)!.explore,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -204,8 +204,8 @@ class _HomeState extends State<Home> {
|
|||||||
case PlatformType.github:
|
case PlatformType.github:
|
||||||
return [
|
return [
|
||||||
BottomNavigationBarItem(
|
BottomNavigationBarItem(
|
||||||
icon: Icon(Ionicons.newspaper_outline),
|
icon: const Icon(Ionicons.newspaper_outline),
|
||||||
activeIcon: Icon(Ionicons.newspaper),
|
activeIcon: const Icon(Ionicons.newspaper),
|
||||||
label: AppLocalizations.of(context)!.news,
|
label: AppLocalizations.of(context)!.news,
|
||||||
),
|
),
|
||||||
BottomNavigationBarItem(
|
BottomNavigationBarItem(
|
||||||
@@ -215,8 +215,8 @@ class _HomeState extends State<Home> {
|
|||||||
label: AppLocalizations.of(context)!.notification,
|
label: AppLocalizations.of(context)!.notification,
|
||||||
),
|
),
|
||||||
BottomNavigationBarItem(
|
BottomNavigationBarItem(
|
||||||
icon: Icon(Ionicons.flame_outline),
|
icon: const Icon(Ionicons.flame_outline),
|
||||||
activeIcon: Icon(Ionicons.flame),
|
activeIcon: const Icon(Ionicons.flame),
|
||||||
label: AppLocalizations.of(context)!.trending,
|
label: AppLocalizations.of(context)!.trending,
|
||||||
),
|
),
|
||||||
search,
|
search,
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
|
||||||
import 'package:git_touch/models/theme.dart';
|
import 'package:git_touch/models/theme.dart';
|
||||||
import 'package:git_touch/utils/utils.dart';
|
import 'package:git_touch/utils/utils.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
@@ -36,7 +35,7 @@ class LongListStatefulScaffold<T, K> extends StatefulWidget {
|
|||||||
final Future<LongListPayload<T, K>> Function() onRefresh;
|
final Future<LongListPayload<T, K>> Function() onRefresh;
|
||||||
final Future<LongListPayload<T, K>> Function(String? cursor) onLoadMore;
|
final Future<LongListPayload<T, K>> Function(String? cursor) onLoadMore;
|
||||||
|
|
||||||
LongListStatefulScaffold({
|
const LongListStatefulScaffold({
|
||||||
required this.title,
|
required this.title,
|
||||||
this.trailingBuilder,
|
this.trailingBuilder,
|
||||||
required this.headerBuilder,
|
required this.headerBuilder,
|
||||||
@@ -74,7 +73,7 @@ class _LongListStatefulScaffoldState<T, K>
|
|||||||
payload = await widget.onRefresh();
|
payload = await widget.onRefresh();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
error = err.toString();
|
error = err.toString();
|
||||||
throw err;
|
rethrow;
|
||||||
} finally {
|
} finally {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setState(() {
|
setState(() {
|
||||||
@@ -90,11 +89,10 @@ class _LongListStatefulScaffoldState<T, K>
|
|||||||
loadingMore = true;
|
loadingMore = true;
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
LongListPayload<T?, K> _payload =
|
LongListPayload<T?, K> p = await widget.onLoadMore(payload!.cursor);
|
||||||
await widget.onLoadMore(payload!.cursor);
|
payload!.totalCount = p.totalCount;
|
||||||
payload!.totalCount = _payload.totalCount;
|
payload!.cursor = p.cursor;
|
||||||
payload!.cursor = _payload.cursor;
|
payload!.leadingItems.addAll(p.leadingItems);
|
||||||
payload!.leadingItems.addAll(_payload.leadingItems);
|
|
||||||
} finally {
|
} finally {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setState(() {
|
setState(() {
|
||||||
@@ -134,9 +132,9 @@ class _LongListStatefulScaffoldState<T, K>
|
|||||||
Text('$count hidden items',
|
Text('$count hidden items',
|
||||||
style:
|
style:
|
||||||
TextStyle(color: theme.palette.text, fontSize: 15)),
|
TextStyle(color: theme.palette.text, fontSize: 15)),
|
||||||
Padding(padding: EdgeInsets.only(top: 4)),
|
const Padding(padding: EdgeInsets.only(top: 4)),
|
||||||
loadingMore
|
loadingMore
|
||||||
? CupertinoActivityIndicator()
|
? const CupertinoActivityIndicator()
|
||||||
: Text(
|
: Text(
|
||||||
'Load more...',
|
'Load more...',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
@@ -168,7 +166,7 @@ class _LongListStatefulScaffoldState<T, K>
|
|||||||
child: ErrorReload(text: error, onTap: _refresh));
|
child: ErrorReload(text: error, onTap: _refresh));
|
||||||
} else if (loading) {
|
} else if (loading) {
|
||||||
// TODO:
|
// TODO:
|
||||||
return SliverToBoxAdapter(child: Loading(more: false));
|
return const SliverToBoxAdapter(child: Loading(more: false));
|
||||||
} else {
|
} else {
|
||||||
return SliverList(
|
return SliverList(
|
||||||
delegate:
|
delegate:
|
||||||
|
|||||||
@@ -13,14 +13,14 @@ import 'package:git_touch/utils/utils.dart';
|
|||||||
class BbUserScreen extends StatelessWidget {
|
class BbUserScreen extends StatelessWidget {
|
||||||
final String? login;
|
final String? login;
|
||||||
final bool isTeam;
|
final bool isTeam;
|
||||||
BbUserScreen(this.login, {this.isTeam = false});
|
const BbUserScreen(this.login, {this.isTeam = false});
|
||||||
bool get isViewer => login == null;
|
bool get isViewer => login == null;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final auth = Provider.of<AuthModel>(context);
|
final auth = Provider.of<AuthModel>(context);
|
||||||
final _accountId = auth.activeAccount!.accountId;
|
final accountId = auth.activeAccount!.accountId;
|
||||||
final _login = login ?? auth.activeAccount!.login;
|
final finalLogin = login ?? auth.activeAccount!.login;
|
||||||
return RefreshStatefulScaffold<Tuple2<BbUser, Iterable<BbRepo>>>(
|
return RefreshStatefulScaffold<Tuple2<BbUser, Iterable<BbRepo>>>(
|
||||||
title: Text(isViewer
|
title: Text(isViewer
|
||||||
? 'Me'
|
? 'Me'
|
||||||
@@ -30,16 +30,16 @@ class BbUserScreen extends StatelessWidget {
|
|||||||
fetch: () async {
|
fetch: () async {
|
||||||
final res = await Future.wait([
|
final res = await Future.wait([
|
||||||
auth
|
auth
|
||||||
.fetchBbJson('/${isTeam ? 'teams' : 'users'}/$_accountId')
|
.fetchBbJson('/${isTeam ? 'teams' : 'users'}/$accountId')
|
||||||
.then((value) => BbUser.fromJson(value)),
|
.then((value) => BbUser.fromJson(value)),
|
||||||
auth
|
auth
|
||||||
.fetchBbWithPage('/repositories/$_login')
|
.fetchBbWithPage('/repositories/$finalLogin')
|
||||||
.then((value) => [for (var v in value.items) BbRepo.fromJson(v)]),
|
.then((value) => [for (var v in value.items) BbRepo.fromJson(v)]),
|
||||||
]);
|
]);
|
||||||
return Tuple2(res[0] as BbUser, res[1] as Iterable<BbRepo>);
|
return Tuple2(res[0] as BbUser, res[1] as Iterable<BbRepo>);
|
||||||
},
|
},
|
||||||
action: isViewer
|
action: isViewer
|
||||||
? ActionEntry(
|
? const ActionEntry(
|
||||||
iconData: Ionicons.cog,
|
iconData: Ionicons.cog,
|
||||||
url: '/settings',
|
url: '/settings',
|
||||||
)
|
)
|
||||||
@@ -50,7 +50,7 @@ class BbUserScreen extends StatelessWidget {
|
|||||||
return Column(
|
return Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
UserHeader(
|
UserHeader(
|
||||||
login: _login,
|
login: finalLogin,
|
||||||
avatarUrl: user.avatarUrl,
|
avatarUrl: user.avatarUrl,
|
||||||
name: user.displayName,
|
name: user.displayName,
|
||||||
createdAt: user.createdOn,
|
createdAt: user.createdOn,
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class _GlSearchScreenState extends State<GlSearchScreen> {
|
|||||||
color: theme.palette.background,
|
color: theme.palette.background,
|
||||||
child: CupertinoTextField(
|
child: CupertinoTextField(
|
||||||
prefix: Row(
|
prefix: Row(
|
||||||
children: <Widget>[
|
children: const <Widget>[
|
||||||
SizedBox(width: 8),
|
SizedBox(width: 8),
|
||||||
Icon(Octicons.search, size: 20, color: PrimerColors.gray400),
|
Icon(Octicons.search, size: 20, color: PrimerColors.gray400),
|
||||||
],
|
],
|
||||||
@@ -104,16 +104,16 @@ class _GlSearchScreenState extends State<GlSearchScreen> {
|
|||||||
|
|
||||||
static const tabs = ['Projects', 'Users'];
|
static const tabs = ['Projects', 'Users'];
|
||||||
|
|
||||||
Widget _buildItem(_p) {
|
Widget _buildItem(project) {
|
||||||
if (_activeTab == 0) {
|
if (_activeTab == 0) {
|
||||||
final p = _p as GitlabProject;
|
final p = project as GitlabProject;
|
||||||
final updatedAt = timeago.format(p.lastActivityAt!);
|
final updatedAt = timeago.format(p.lastActivityAt!);
|
||||||
return RepositoryItem.gl(
|
return RepositoryItem.gl(
|
||||||
payload: p,
|
payload: p,
|
||||||
note: 'Updated $updatedAt',
|
note: 'Updated $updatedAt',
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
final p = _p as GitlabUser;
|
final p = project as GitlabUser;
|
||||||
return UserItem.gitlab(
|
return UserItem.gitlab(
|
||||||
login: p.username,
|
login: p.username,
|
||||||
name: p.name,
|
name: p.name,
|
||||||
@@ -136,7 +136,7 @@ class _GlSearchScreenState extends State<GlSearchScreen> {
|
|||||||
if (theme == AppThemeType.cupertino)
|
if (theme == AppThemeType.cupertino)
|
||||||
Center(
|
Center(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.symmetric(vertical: 8),
|
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||||
child: CupertinoSlidingSegmentedControl(
|
child: CupertinoSlidingSegmentedControl(
|
||||||
groupValue: _activeTab,
|
groupValue: _activeTab,
|
||||||
onValueChanged: _onTabSwitch,
|
onValueChanged: _onTabSwitch,
|
||||||
@@ -144,13 +144,13 @@ class _GlSearchScreenState extends State<GlSearchScreen> {
|
|||||||
key,
|
key,
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||||
child: Text(text, style: TextStyle(fontSize: 14)),
|
child: Text(text, style: const TextStyle(fontSize: 14)),
|
||||||
))),
|
))),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (_loading)
|
if (_loading)
|
||||||
Loading()
|
const Loading()
|
||||||
else if (_activeTab == 0)
|
else if (_activeTab == 0)
|
||||||
..._projects.map(_buildItem).toList()
|
..._projects.map(_buildItem).toList()
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import 'package:flutter_gen/gen_l10n/S.dart';
|
|||||||
|
|
||||||
class GlUserScreen extends StatelessWidget {
|
class GlUserScreen extends StatelessWidget {
|
||||||
final int? id;
|
final int? id;
|
||||||
GlUserScreen(this.id);
|
const GlUserScreen(this.id);
|
||||||
bool get isViewer => id == null;
|
bool get isViewer => id == null;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -25,10 +25,10 @@ class GlUserScreen extends StatelessWidget {
|
|||||||
: AppLocalizations.of(context)!.user),
|
: AppLocalizations.of(context)!.user),
|
||||||
fetch: () async {
|
fetch: () async {
|
||||||
final auth = context.read<AuthModel>();
|
final auth = context.read<AuthModel>();
|
||||||
final _id = id ?? auth.activeAccount!.gitlabId;
|
final finalId = id ?? auth.activeAccount!.gitlabId;
|
||||||
final res = await Future.wait([
|
final res = await Future.wait([
|
||||||
auth.fetchGitlab('/users/$_id'),
|
auth.fetchGitlab('/users/$finalId'),
|
||||||
auth.fetchGitlab('/users/$_id/projects'),
|
auth.fetchGitlab('/users/$finalId/projects'),
|
||||||
]);
|
]);
|
||||||
return Tuple2(
|
return Tuple2(
|
||||||
GitlabUser.fromJson(res[0]),
|
GitlabUser.fromJson(res[0]),
|
||||||
@@ -36,7 +36,7 @@ class GlUserScreen extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
action: isViewer
|
action: isViewer
|
||||||
? ActionEntry(
|
? const ActionEntry(
|
||||||
iconData: Ionicons.cog,
|
iconData: Ionicons.cog,
|
||||||
url: '/settings',
|
url: '/settings',
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ class MyLabel extends StatelessWidget {
|
|||||||
final String? cssColor;
|
final String? cssColor;
|
||||||
final Color? textColor;
|
final Color? textColor;
|
||||||
|
|
||||||
MyLabel({
|
const MyLabel({
|
||||||
required this.name,
|
required this.name,
|
||||||
this.color,
|
this.color,
|
||||||
this.cssColor,
|
this.cssColor,
|
||||||
@@ -16,18 +16,18 @@ class MyLabel extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final _color = color ?? convertColor(cssColor);
|
final finalColor = color ?? convertColor(cssColor);
|
||||||
return Container(
|
return Container(
|
||||||
padding: EdgeInsets.symmetric(vertical: 2, horizontal: 6),
|
padding: const EdgeInsets.symmetric(vertical: 2, horizontal: 6),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: _color,
|
color: finalColor,
|
||||||
borderRadius: BorderRadius.all(Radius.circular(4)),
|
borderRadius: const BorderRadius.all(Radius.circular(4)),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
name!,
|
name!,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
color: textColor ?? getFontColorByBrightness(_color),
|
color: textColor ?? getFontColorByBrightness(finalColor),
|
||||||
// fontWeight: FontWeight.w600,
|
// fontWeight: FontWeight.w600,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user