mirror of
https://github.com/git-touch/git-touch
synced 2025-03-11 08:40:06 +01:00
refactor: action entry
This commit is contained in:
parent
af7d31711a
commit
d02b4800ca
@ -1,7 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:git_touch/models/auth.dart';
|
||||
import 'package:git_touch/models/gitea.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/scaffolds/refresh_stateful.dart';
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:git_touch/widgets/action_entry.dart';
|
||||
@ -39,12 +38,9 @@ class GiteaObjectScreen extends StatelessWidget {
|
||||
if (p is List) {
|
||||
return null;
|
||||
} else {
|
||||
final theme = Provider.of<ThemeModel>(context);
|
||||
return ActionEntry(
|
||||
iconData: Icons.settings,
|
||||
onTap: () {
|
||||
theme.push(context, '/choose-code-theme');
|
||||
},
|
||||
url: '/choose-code-theme',
|
||||
);
|
||||
}
|
||||
},
|
||||
|
@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:git_touch/models/auth.dart';
|
||||
import 'package:git_touch/models/gitea.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/scaffolds/refresh_stateful.dart';
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:git_touch/widgets/action_entry.dart';
|
||||
@ -40,10 +39,7 @@ class GiteaUserScreen extends StatelessWidget {
|
||||
action: isViewer
|
||||
? ActionEntry(
|
||||
iconData: Icons.settings,
|
||||
onTap: () {
|
||||
final theme = Provider.of<ThemeModel>(context);
|
||||
theme.push(context, '/settings');
|
||||
},
|
||||
url: '/settings',
|
||||
)
|
||||
: null,
|
||||
bodyBuilder: (data, _) {
|
||||
|
@ -1,7 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:git_touch/models/auth.dart';
|
||||
import 'package:git_touch/models/gitlab.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/scaffolds/refresh_stateful.dart';
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:git_touch/widgets/action_entry.dart';
|
||||
@ -29,13 +28,7 @@ class GitlabBlobScreen extends StatelessWidget {
|
||||
'/projects/$id/repository/files/${path.urlencode}?ref=master'); // TODO:
|
||||
return GitlabBlob.fromJson(res);
|
||||
},
|
||||
action: ActionEntry(
|
||||
iconData: Icons.settings,
|
||||
onTap: () {
|
||||
final theme = Provider.of<ThemeModel>(context);
|
||||
theme.push(context, '/choose-code-theme');
|
||||
},
|
||||
),
|
||||
action: ActionEntry(iconData: Icons.settings, url: '/choose-code-theme'),
|
||||
bodyBuilder: (data, _) {
|
||||
return BlobView(path, base64Text: data.content);
|
||||
},
|
||||
|
@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:git_touch/models/auth.dart';
|
||||
import 'package:git_touch/models/gitlab.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/scaffolds/refresh_stateful.dart';
|
||||
import 'package:git_touch/widgets/action_entry.dart';
|
||||
import 'package:git_touch/widgets/repository_item.dart';
|
||||
@ -42,10 +41,7 @@ class GitlabUserScreen extends StatelessWidget {
|
||||
action: isViewer
|
||||
? ActionEntry(
|
||||
iconData: Icons.settings,
|
||||
onTap: () {
|
||||
final theme = Provider.of<ThemeModel>(context);
|
||||
theme.push(context, '/settings');
|
||||
},
|
||||
url: '/settings',
|
||||
)
|
||||
: null,
|
||||
bodyBuilder: (data, _) {
|
||||
|
@ -1,7 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:git_touch/graphql/gh.dart';
|
||||
import 'package:git_touch/models/auth.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/scaffolds/list_stateful.dart';
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:git_touch/widgets/action_entry.dart';
|
||||
@ -43,11 +42,9 @@ class IssuesScreen extends StatelessWidget {
|
||||
return ListStatefulScaffold<GhIssuesIssue, String>(
|
||||
title: AppBarTitle('Issues'),
|
||||
actionBuilder: () => ActionEntry(
|
||||
iconData: Octicons.plus,
|
||||
onTap: () {
|
||||
Provider.of<ThemeModel>(context)
|
||||
.push(context, '/$owner/$name/issues/new');
|
||||
}),
|
||||
iconData: Octicons.plus,
|
||||
url: '/$owner/$name/issues/new',
|
||||
),
|
||||
onRefresh: () => _query(context),
|
||||
onLoadMore: (cursor) => _query(context, cursor),
|
||||
itemBuilder: (p) => IssueItem(
|
||||
|
@ -1,6 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:git_touch/models/github.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/scaffolds/refresh_stateful.dart';
|
||||
import 'package:git_touch/widgets/action_entry.dart';
|
||||
import 'package:git_touch/widgets/app_bar_title.dart';
|
||||
@ -40,12 +39,9 @@ class ObjectScreen extends StatelessWidget {
|
||||
},
|
||||
actionBuilder: (data, _) {
|
||||
if (data is Map) {
|
||||
final theme = Provider.of<ThemeModel>(context);
|
||||
return ActionEntry(
|
||||
iconData: Icons.settings,
|
||||
onTap: () {
|
||||
theme.push(context, '/choose-code-theme');
|
||||
},
|
||||
url: '/choose-code-theme',
|
||||
);
|
||||
}
|
||||
},
|
||||
|
@ -8,7 +8,6 @@ import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:git_touch/widgets/action_entry.dart';
|
||||
import 'package:git_touch/widgets/app_bar_title.dart';
|
||||
import 'package:git_touch/screens/repositories.dart';
|
||||
import 'package:git_touch/widgets/avatar.dart';
|
||||
import 'package:git_touch/widgets/mutation_button.dart';
|
||||
import 'package:git_touch/widgets/entry_item.dart';
|
||||
import 'package:git_touch/widgets/repository_item.dart';
|
||||
@ -332,9 +331,7 @@ class UserScreen extends StatelessWidget {
|
||||
action: isViewer
|
||||
? ActionEntry(
|
||||
iconData: Icons.settings,
|
||||
onTap: () {
|
||||
theme.push(context, '/settings');
|
||||
},
|
||||
url: '/settings',
|
||||
)
|
||||
: null,
|
||||
actionBuilder: isViewer
|
||||
|
@ -5,23 +5,31 @@ import 'package:provider/provider.dart';
|
||||
|
||||
class ActionEntry extends StatelessWidget {
|
||||
final IconData iconData;
|
||||
final String url;
|
||||
final VoidCallback onTap;
|
||||
ActionEntry({this.iconData, this.onTap});
|
||||
ActionEntry({this.url, this.iconData, this.onTap});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
switch (Provider.of<ThemeModel>(context).theme) {
|
||||
final theme = Provider.of<ThemeModel>(context);
|
||||
switch (theme.theme) {
|
||||
case AppThemeType.cupertino:
|
||||
return CupertinoButton(
|
||||
minSize: 0,
|
||||
child: Icon(iconData, size: 22),
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: onTap,
|
||||
onPressed: () {
|
||||
if (onTap != null) onTap();
|
||||
if (url != null) theme.push(context, url);
|
||||
},
|
||||
);
|
||||
default:
|
||||
return IconButton(
|
||||
icon: Icon(iconData),
|
||||
onPressed: onTap,
|
||||
onPressed: () {
|
||||
if (onTap != null) onTap();
|
||||
if (url != null) theme.push(context, url);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user