refactor: push method as extension
This commit is contained in:
parent
988cdbfe45
commit
cf6871ce20
|
@ -62,7 +62,7 @@ class _HomeState extends State<Home> {
|
||||||
// go to app store
|
// go to app store
|
||||||
LaunchReview.launch(writeReview: false);
|
LaunchReview.launch(writeReview: false);
|
||||||
} else {
|
} else {
|
||||||
context.read<ThemeModel>().push(context, latest.htmlUrl!);
|
context.pushUrl(latest.htmlUrl!);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/S.dart';
|
import 'package:flutter_gen/gen_l10n/S.dart';
|
||||||
import 'package:git_touch/utils/utils.dart';
|
import 'package:git_touch/utils/utils.dart';
|
||||||
import 'package:git_touch/widgets/action_button.dart';
|
import 'package:git_touch/widgets/action_button.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
|
||||||
import 'package:primer/primer.dart';
|
import 'package:primer/primer.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:universal_io/io.dart';
|
import 'package:universal_io/io.dart';
|
||||||
|
@ -36,7 +35,6 @@ class PickerItem<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
class PickerGroupItem<T> {
|
class PickerGroupItem<T> {
|
||||||
|
|
||||||
PickerGroupItem({
|
PickerGroupItem({
|
||||||
required this.value,
|
required this.value,
|
||||||
required this.items,
|
required this.items,
|
||||||
|
@ -75,7 +73,6 @@ class StaticRoute extends PageRouteBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
class Palette {
|
class Palette {
|
||||||
|
|
||||||
const Palette({
|
const Palette({
|
||||||
required this.primary,
|
required this.primary,
|
||||||
required this.text,
|
required this.text,
|
||||||
|
@ -219,19 +216,6 @@ class ThemeModel with ChangeNotifier {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
push(BuildContext context, String url, {bool replace = false}) {
|
|
||||||
// Fimber.d(url);
|
|
||||||
if (url.startsWith('/')) {
|
|
||||||
if (replace) {
|
|
||||||
context.replace(url);
|
|
||||||
} else {
|
|
||||||
context.push(url);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
launchStringUrl(url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<bool?> showConfirm(BuildContext context, Widget content) {
|
Future<bool?> showConfirm(BuildContext context, Widget content) {
|
||||||
return showCupertinoDialog(
|
return showCupertinoDialog(
|
||||||
context: context,
|
context: context,
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter_gen/gen_l10n/S.dart';
|
||||||
import 'package:git_touch/models/auth.dart';
|
import 'package:git_touch/models/auth.dart';
|
||||||
import 'package:git_touch/models/theme.dart';
|
import 'package:git_touch/models/theme.dart';
|
||||||
import 'package:git_touch/scaffolds/common.dart';
|
import 'package:git_touch/scaffolds/common.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';
|
||||||
import 'package:flutter_gen/gen_l10n/S.dart';
|
|
||||||
|
|
||||||
class BbIssueCommentScreen extends StatefulWidget {
|
class BbIssueCommentScreen extends StatefulWidget {
|
||||||
const BbIssueCommentScreen(this.owner, this.name, this.number);
|
const BbIssueCommentScreen(this.owner, this.name, this.number);
|
||||||
|
@ -51,8 +51,7 @@ class _BbIssueCommentScreenState extends State<BbIssueCommentScreen> {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
Navigator.pop(context, true);
|
Navigator.pop(context, true);
|
||||||
await theme.push(
|
await context.pushUrl(
|
||||||
context,
|
|
||||||
'/bitbucket/${widget.owner}/${widget.name}/issues/${widget.number}',
|
'/bitbucket/${widget.owner}/${widget.name}/issues/${widget.number}',
|
||||||
replace: true,
|
replace: true,
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter_gen/gen_l10n/S.dart';
|
||||||
import 'package:git_touch/models/auth.dart';
|
import 'package:git_touch/models/auth.dart';
|
||||||
import 'package:git_touch/models/bitbucket.dart';
|
import 'package:git_touch/models/bitbucket.dart';
|
||||||
import 'package:git_touch/models/theme.dart';
|
import 'package:git_touch/models/theme.dart';
|
||||||
import 'package:git_touch/scaffolds/common.dart';
|
import 'package:git_touch/scaffolds/common.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';
|
||||||
import 'package:flutter_gen/gen_l10n/S.dart';
|
|
||||||
|
|
||||||
class BbIssueFormScreen extends StatefulWidget {
|
class BbIssueFormScreen extends StatefulWidget {
|
||||||
const BbIssueFormScreen(this.owner, this.name);
|
const BbIssueFormScreen(this.owner, this.name);
|
||||||
|
@ -64,8 +64,7 @@ class _BbIssueFormScreenState extends State<BbIssueFormScreen> {
|
||||||
return BbIssues.fromJson(v);
|
return BbIssues.fromJson(v);
|
||||||
});
|
});
|
||||||
Navigator.pop(context, true);
|
Navigator.pop(context, true);
|
||||||
await theme.push(
|
await context.pushUrl(
|
||||||
context,
|
|
||||||
'/bitbucket/${widget.owner}/${widget.name}/issues',
|
'/bitbucket/${widget.owner}/${widget.name}/issues',
|
||||||
replace: true,
|
replace: true,
|
||||||
);
|
);
|
||||||
|
|
|
@ -106,8 +106,8 @@ class BbRepoScreen extends StatelessWidget {
|
||||||
.toList(),
|
.toList(),
|
||||||
onClose: (ref) {
|
onClose: (ref) {
|
||||||
if (ref != branch) {
|
if (ref != branch) {
|
||||||
theme.push(
|
context.pushUrl(
|
||||||
context, '/bitbucket/$owner/$name?branch=$ref',
|
'/bitbucket/$owner/$name?branch=$ref',
|
||||||
replace: true);
|
replace: true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -14,7 +14,6 @@ import 'package:provider/provider.dart';
|
||||||
import 'package:tuple/tuple.dart';
|
import 'package:tuple/tuple.dart';
|
||||||
|
|
||||||
class GeIssueScreen extends StatelessWidget {
|
class GeIssueScreen extends StatelessWidget {
|
||||||
|
|
||||||
const GeIssueScreen(this.owner, this.name, this.number, {this.isPr = false});
|
const GeIssueScreen(this.owner, this.name, this.number, {this.isPr = false});
|
||||||
final String owner;
|
final String owner;
|
||||||
final String name;
|
final String name;
|
||||||
|
@ -36,7 +35,7 @@ class GeIssueScreen extends StatelessWidget {
|
||||||
'id': comment.id.toString(),
|
'id': comment.id.toString(),
|
||||||
},
|
},
|
||||||
).toString();
|
).toString();
|
||||||
theme.push(context, uri);
|
context.pushUrl(uri);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
ActionItem(
|
ActionItem(
|
||||||
|
@ -45,7 +44,7 @@ class GeIssueScreen extends StatelessWidget {
|
||||||
await auth.fetchGitee(
|
await auth.fetchGitee(
|
||||||
'/repos/$owner/$name/issues/comments/${comment.id}',
|
'/repos/$owner/$name/issues/comments/${comment.id}',
|
||||||
requestType: 'DELETE');
|
requestType: 'DELETE');
|
||||||
await theme.push(context, '/gitee/$owner/$name/issues/$number',
|
await context.pushUrl('/gitee/$owner/$name/issues/$number',
|
||||||
replace: true);
|
replace: true);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter_gen/gen_l10n/S.dart';
|
||||||
import 'package:git_touch/models/auth.dart';
|
import 'package:git_touch/models/auth.dart';
|
||||||
import 'package:git_touch/models/theme.dart';
|
import 'package:git_touch/models/theme.dart';
|
||||||
import 'package:git_touch/scaffolds/common.dart';
|
import 'package:git_touch/scaffolds/common.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';
|
||||||
import 'package:flutter_gen/gen_l10n/S.dart';
|
|
||||||
|
|
||||||
class GeIssueCommentScreen extends StatefulWidget {
|
class GeIssueCommentScreen extends StatefulWidget {
|
||||||
const GeIssueCommentScreen(this.owner, this.name, this.number,
|
const GeIssueCommentScreen(this.owner, this.name, this.number,
|
||||||
|
@ -67,8 +67,7 @@ class _GeIssueCommentScreenState extends State<GeIssueCommentScreen> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Navigator.pop(context, '');
|
Navigator.pop(context, '');
|
||||||
await theme.push(
|
await context.pushUrl(
|
||||||
context,
|
|
||||||
'/gitee/${widget.owner}/${widget.name}/${widget.isPr ? 'pulls' : 'issues'}/${widget.number}',
|
'/gitee/${widget.owner}/${widget.name}/${widget.isPr ? 'pulls' : 'issues'}/${widget.number}',
|
||||||
replace: true,
|
replace: true,
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter_gen/gen_l10n/S.dart';
|
||||||
import 'package:git_touch/models/auth.dart';
|
import 'package:git_touch/models/auth.dart';
|
||||||
import 'package:git_touch/models/gitee.dart';
|
import 'package:git_touch/models/gitee.dart';
|
||||||
import 'package:git_touch/models/theme.dart';
|
import 'package:git_touch/models/theme.dart';
|
||||||
import 'package:git_touch/scaffolds/common.dart';
|
import 'package:git_touch/scaffolds/common.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';
|
||||||
import 'package:flutter_gen/gen_l10n/S.dart';
|
|
||||||
|
|
||||||
class GeIssueFormScreen extends StatefulWidget {
|
class GeIssueFormScreen extends StatefulWidget {
|
||||||
const GeIssueFormScreen(this.owner, this.name);
|
const GeIssueFormScreen(this.owner, this.name);
|
||||||
|
@ -63,8 +63,7 @@ class _GeIssueFormScreenState extends State<GeIssueFormScreen> {
|
||||||
).then((v) {
|
).then((v) {
|
||||||
return GiteeIssue.fromJson(v);
|
return GiteeIssue.fromJson(v);
|
||||||
});
|
});
|
||||||
await theme.push(
|
await context.pushUrl(
|
||||||
context,
|
|
||||||
'/gitee/${widget.owner}/${widget.name}/issues/${res.number}',
|
'/gitee/${widget.owner}/${widget.name}/issues/${res.number}',
|
||||||
replace: true,
|
replace: true,
|
||||||
);
|
);
|
||||||
|
|
|
@ -14,7 +14,6 @@ import 'package:provider/provider.dart';
|
||||||
import 'package:tuple/tuple.dart';
|
import 'package:tuple/tuple.dart';
|
||||||
|
|
||||||
class GePullScreen extends StatelessWidget {
|
class GePullScreen extends StatelessWidget {
|
||||||
|
|
||||||
const GePullScreen(this.owner, this.name, this.number, {this.isPr = false});
|
const GePullScreen(this.owner, this.name, this.number, {this.isPr = false});
|
||||||
final String owner;
|
final String owner;
|
||||||
final String name;
|
final String name;
|
||||||
|
@ -36,7 +35,7 @@ class GePullScreen extends StatelessWidget {
|
||||||
'id': comment.id.toString(),
|
'id': comment.id.toString(),
|
||||||
},
|
},
|
||||||
).toString();
|
).toString();
|
||||||
theme.push(context, uri);
|
context.pushUrl(uri);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
ActionItem(
|
ActionItem(
|
||||||
|
@ -45,7 +44,7 @@ class GePullScreen extends StatelessWidget {
|
||||||
await auth.fetchGitee(
|
await auth.fetchGitee(
|
||||||
'/repos/$owner/$name/pulls/comments/${comment.id}',
|
'/repos/$owner/$name/pulls/comments/${comment.id}',
|
||||||
requestType: 'DELETE');
|
requestType: 'DELETE');
|
||||||
await theme.push(context, '/gitee/$owner/$name/pulls/$number',
|
await context.pushUrl('/gitee/$owner/$name/pulls/$number',
|
||||||
replace: true);
|
replace: true);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
@ -184,8 +184,7 @@ class GeRepoScreen extends StatelessWidget {
|
||||||
.toList(),
|
.toList(),
|
||||||
onClose: (ref) {
|
onClose: (ref) {
|
||||||
if (ref != branch) {
|
if (ref != branch) {
|
||||||
theme.push(
|
context.pushUrl('/gitee/$owner/$name?branch=$ref',
|
||||||
context, '/gitee/$owner/$name?branch=$ref',
|
|
||||||
replace: true);
|
replace: true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter_gen/gen_l10n/S.dart';
|
||||||
import 'package:git_touch/models/auth.dart';
|
import 'package:git_touch/models/auth.dart';
|
||||||
import 'package:git_touch/models/theme.dart';
|
import 'package:git_touch/models/theme.dart';
|
||||||
import 'package:git_touch/scaffolds/common.dart';
|
import 'package:git_touch/scaffolds/common.dart';
|
||||||
import 'package:git_touch/utils/utils.dart';
|
import 'package:git_touch/utils/utils.dart';
|
||||||
import 'package:github/github.dart';
|
import 'package:github/github.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/S.dart';
|
|
||||||
|
|
||||||
class GhIssueFormScreen extends StatefulWidget {
|
class GhIssueFormScreen extends StatefulWidget {
|
||||||
const GhIssueFormScreen(this.owner, this.name);
|
const GhIssueFormScreen(this.owner, this.name);
|
||||||
|
@ -62,8 +62,7 @@ class _GhIssueFormScreenState extends State<GhIssueFormScreen> {
|
||||||
.ghClient
|
.ghClient
|
||||||
.issues
|
.issues
|
||||||
.create(slug, IssueRequest(title: _title, body: _body));
|
.create(slug, IssueRequest(title: _title, body: _body));
|
||||||
await theme.push(
|
await context.pushUrl(
|
||||||
context,
|
|
||||||
'/github/${widget.owner}/${widget.name}/issues/${res.number}',
|
'/github/${widget.owner}/${widget.name}/issues/${res.number}',
|
||||||
replace: true,
|
replace: true,
|
||||||
);
|
);
|
||||||
|
|
|
@ -300,8 +300,7 @@ class GhRepoScreen extends StatelessWidget {
|
||||||
.toList(),
|
.toList(),
|
||||||
onClose: (ref) {
|
onClose: (ref) {
|
||||||
if (ref != branch) {
|
if (ref != branch) {
|
||||||
theme.push(
|
context.pushUrl('/github/$owner/$name?ref=$ref',
|
||||||
context, '/github/$owner/$name?ref=$ref',
|
|
||||||
replace: true);
|
replace: true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter_gen/gen_l10n/S.dart';
|
||||||
import 'package:git_touch/models/auth.dart';
|
import 'package:git_touch/models/auth.dart';
|
||||||
import 'package:git_touch/models/gitlab.dart';
|
import 'package:git_touch/models/gitlab.dart';
|
||||||
import 'package:git_touch/models/theme.dart';
|
import 'package:git_touch/models/theme.dart';
|
||||||
import 'package:git_touch/scaffolds/common.dart';
|
import 'package:git_touch/scaffolds/common.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';
|
||||||
import 'package:flutter_gen/gen_l10n/S.dart';
|
|
||||||
|
|
||||||
class GlIssueFormScreen extends StatefulWidget {
|
class GlIssueFormScreen extends StatefulWidget {
|
||||||
const GlIssueFormScreen(this.id);
|
const GlIssueFormScreen(this.id);
|
||||||
|
@ -62,8 +62,7 @@ class _GlIssueFormScreenState extends State<GlIssueFormScreen> {
|
||||||
).then((v) {
|
).then((v) {
|
||||||
return GitlabIssue.fromJson(v);
|
return GitlabIssue.fromJson(v);
|
||||||
});
|
});
|
||||||
await theme.push(
|
await context.pushUrl(
|
||||||
context,
|
|
||||||
'/gitlab/projects/${widget.id}/issues/${res.iid}',
|
'/gitlab/projects/${widget.id}/issues/${res.iid}',
|
||||||
replace: true,
|
replace: true,
|
||||||
);
|
);
|
||||||
|
|
|
@ -227,8 +227,7 @@ class GlProjectScreen extends StatelessWidget {
|
||||||
.toList(),
|
.toList(),
|
||||||
onClose: (ref) {
|
onClose: (ref) {
|
||||||
if (ref != branch) {
|
if (ref != branch) {
|
||||||
theme.push(
|
context.pushUrl('/gitlab/projects/$id?branch=$ref',
|
||||||
context, '/gitlab/projects/$id?branch=$ref',
|
|
||||||
replace: true);
|
replace: true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -135,8 +135,7 @@ class GoRepoScreen extends StatelessWidget {
|
||||||
.toList(),
|
.toList(),
|
||||||
onClose: (ref) {
|
onClose: (ref) {
|
||||||
if (ref != branch) {
|
if (ref != branch) {
|
||||||
theme.push(
|
context.pushUrl('/gogs/$owner/$name?branch=$ref',
|
||||||
context, '/gogs/$owner/$name?branch=$ref',
|
|
||||||
replace: true);
|
replace: true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -14,7 +14,6 @@ import 'package:provider/provider.dart';
|
||||||
import 'package:tuple/tuple.dart';
|
import 'package:tuple/tuple.dart';
|
||||||
|
|
||||||
class GtIssueScreen extends StatelessWidget {
|
class GtIssueScreen extends StatelessWidget {
|
||||||
|
|
||||||
const GtIssueScreen(this.owner, this.name, this.number, {this.isPr = false});
|
const GtIssueScreen(this.owner, this.name, this.number, {this.isPr = false});
|
||||||
final String owner;
|
final String owner;
|
||||||
final String name;
|
final String name;
|
||||||
|
@ -36,7 +35,7 @@ class GtIssueScreen extends StatelessWidget {
|
||||||
'id': comment.id.toString(),
|
'id': comment.id.toString(),
|
||||||
},
|
},
|
||||||
).toString();
|
).toString();
|
||||||
theme.push(context, uri);
|
context.pushUrl(uri);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
ActionItem(
|
ActionItem(
|
||||||
|
@ -45,7 +44,7 @@ class GtIssueScreen extends StatelessWidget {
|
||||||
await auth.fetchGitea(
|
await auth.fetchGitea(
|
||||||
'/repos/$owner/$name/issues/comments/${comment.id}',
|
'/repos/$owner/$name/issues/comments/${comment.id}',
|
||||||
requestType: 'DELETE');
|
requestType: 'DELETE');
|
||||||
await theme.push(context, '/gitea/$owner/$name/issues/$number',
|
await context.pushUrl('/gitea/$owner/$name/issues/$number',
|
||||||
replace: true);
|
replace: true);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter_gen/gen_l10n/S.dart';
|
||||||
import 'package:git_touch/models/auth.dart';
|
import 'package:git_touch/models/auth.dart';
|
||||||
import 'package:git_touch/models/theme.dart';
|
import 'package:git_touch/models/theme.dart';
|
||||||
import 'package:git_touch/scaffolds/common.dart';
|
import 'package:git_touch/scaffolds/common.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';
|
||||||
import 'package:flutter_gen/gen_l10n/S.dart';
|
|
||||||
|
|
||||||
class GtIssueCommentScreen extends StatefulWidget {
|
class GtIssueCommentScreen extends StatefulWidget {
|
||||||
const GtIssueCommentScreen(this.owner, this.name, this.number,
|
const GtIssueCommentScreen(this.owner, this.name, this.number,
|
||||||
|
@ -67,8 +67,7 @@ class _GtIssueCommentScreenState extends State<GtIssueCommentScreen> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Navigator.pop(context, '');
|
Navigator.pop(context, '');
|
||||||
await theme.push(
|
await context.pushUrl(
|
||||||
context,
|
|
||||||
'/gitea/${widget.owner}/${widget.name}/${widget.isPr ? 'pulls' : 'issues'}/${widget.number}',
|
'/gitea/${widget.owner}/${widget.name}/${widget.isPr ? 'pulls' : 'issues'}/${widget.number}',
|
||||||
replace: true,
|
replace: true,
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter_gen/gen_l10n/S.dart';
|
||||||
import 'package:git_touch/models/auth.dart';
|
import 'package:git_touch/models/auth.dart';
|
||||||
import 'package:git_touch/models/gitea.dart';
|
import 'package:git_touch/models/gitea.dart';
|
||||||
import 'package:git_touch/models/theme.dart';
|
import 'package:git_touch/models/theme.dart';
|
||||||
import 'package:git_touch/scaffolds/common.dart';
|
import 'package:git_touch/scaffolds/common.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';
|
||||||
import 'package:flutter_gen/gen_l10n/S.dart';
|
|
||||||
|
|
||||||
class GtIssueFormScreen extends StatefulWidget {
|
class GtIssueFormScreen extends StatefulWidget {
|
||||||
const GtIssueFormScreen(this.owner, this.name);
|
const GtIssueFormScreen(this.owner, this.name);
|
||||||
|
@ -64,8 +64,7 @@ class _GtIssueFormScreenState extends State<GtIssueFormScreen> {
|
||||||
return GiteaIssue.fromJson(v);
|
return GiteaIssue.fromJson(v);
|
||||||
});
|
});
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
await theme.push(
|
await context.pushUrl(
|
||||||
context,
|
|
||||||
'/gitea/${widget.owner}/${widget.name}/issues',
|
'/gitea/${widget.owner}/${widget.name}/issues',
|
||||||
replace: true,
|
replace: true,
|
||||||
);
|
);
|
||||||
|
|
|
@ -261,7 +261,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||||
TextStyle(color: theme.palette.primary),
|
TextStyle(color: theme.palette.primary),
|
||||||
recognizer: TapGestureRecognizer()
|
recognizer: TapGestureRecognizer()
|
||||||
..onTap = () {
|
..onTap = () {
|
||||||
theme.push(context,
|
context.pushUrl(
|
||||||
'https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/');
|
'https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/');
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
@ -3,6 +3,7 @@ import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:git_touch/models/theme.dart';
|
import 'package:git_touch/models/theme.dart';
|
||||||
import 'package:git_touch/widgets/border_view.dart';
|
import 'package:git_touch/widgets/border_view.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:primer/primer.dart';
|
import 'package:primer/primer.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
@ -68,7 +69,7 @@ TextSpan createLinkSpan(
|
||||||
),
|
),
|
||||||
recognizer: TapGestureRecognizer()
|
recognizer: TapGestureRecognizer()
|
||||||
..onTap = () {
|
..onTap = () {
|
||||||
theme.push(context, url);
|
context.pushUrl(url);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -158,3 +159,18 @@ class ListPayload<T, K> {
|
||||||
bool hasMore;
|
bool hasMore;
|
||||||
Iterable<T> items;
|
Iterable<T> items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension MyHelper on BuildContext {
|
||||||
|
pushUrl(String url, {bool replace = false}) {
|
||||||
|
// Fimber.d(url);
|
||||||
|
if (url.startsWith('/')) {
|
||||||
|
if (replace) {
|
||||||
|
this.replace(url);
|
||||||
|
} else {
|
||||||
|
push(url);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
launchStringUrl(url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:git_touch/models/theme.dart';
|
import 'package:git_touch/models/theme.dart';
|
||||||
|
import 'package:git_touch/utils/utils.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class ActionEntry extends StatelessWidget {
|
class ActionEntry extends StatelessWidget {
|
||||||
|
@ -16,7 +17,7 @@ class ActionEntry extends StatelessWidget {
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (onTap != null) onTap!();
|
if (onTap != null) onTap!();
|
||||||
if (url != null) theme.push(context, url!);
|
if (url != null) context.pushUrl(url!);
|
||||||
},
|
},
|
||||||
child: Icon(iconData, size: 22),
|
child: Icon(iconData, size: 22),
|
||||||
);
|
);
|
||||||
|
|
|
@ -14,7 +14,6 @@ class AvatarSize {
|
||||||
}
|
}
|
||||||
|
|
||||||
class Avatar extends StatelessWidget {
|
class Avatar extends StatelessWidget {
|
||||||
|
|
||||||
const Avatar({
|
const Avatar({
|
||||||
required this.url,
|
required this.url,
|
||||||
this.size = AvatarSize.medium,
|
this.size = AvatarSize.medium,
|
||||||
|
@ -56,7 +55,7 @@ class Avatar extends StatelessWidget {
|
||||||
return LinkWidget(
|
return LinkWidget(
|
||||||
child: widget,
|
child: widget,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.read<ThemeModel>().push(context, linkUrl!);
|
context.pushUrl(linkUrl!);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ class EventItem extends StatelessWidget {
|
||||||
style: TextStyle(color: theme.palette.primary),
|
style: TextStyle(color: theme.palette.primary),
|
||||||
recognizer: TapGestureRecognizer()
|
recognizer: TapGestureRecognizer()
|
||||||
..onTap = () {
|
..onTap = () {
|
||||||
theme.push(context, url!);
|
context.pushUrl(url!);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import 'package:provider/provider.dart';
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
class CupertinoLink extends StatefulWidget {
|
class CupertinoLink extends StatefulWidget {
|
||||||
|
|
||||||
const CupertinoLink({this.child, this.onTap});
|
const CupertinoLink({this.child, this.onTap});
|
||||||
final Widget? child;
|
final Widget? child;
|
||||||
final Function? onTap;
|
final Function? onTap;
|
||||||
|
@ -48,7 +47,6 @@ class _CupertinoLinkState extends State<CupertinoLink> {
|
||||||
}
|
}
|
||||||
|
|
||||||
class LinkWidget extends StatelessWidget {
|
class LinkWidget extends StatelessWidget {
|
||||||
|
|
||||||
const LinkWidget({
|
const LinkWidget({
|
||||||
required this.child,
|
required this.child,
|
||||||
this.url,
|
this.url,
|
||||||
|
@ -69,7 +67,7 @@ class LinkWidget extends StatelessWidget {
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
if (onTap != null) onTap!();
|
if (onTap != null) onTap!();
|
||||||
if (url != null) theme.push(context, url!);
|
if (url != null) context.pushUrl(url!);
|
||||||
},
|
},
|
||||||
child: child,
|
child: child,
|
||||||
);
|
);
|
||||||
|
|
|
@ -82,7 +82,6 @@ html {
|
||||||
}
|
}
|
||||||
|
|
||||||
class MarkdownFlutterView extends StatelessWidget {
|
class MarkdownFlutterView extends StatelessWidget {
|
||||||
|
|
||||||
const MarkdownFlutterView(
|
const MarkdownFlutterView(
|
||||||
this.text, {
|
this.text, {
|
||||||
this.basePaths,
|
this.basePaths,
|
||||||
|
@ -134,7 +133,7 @@ class MarkdownFlutterView extends StatelessWidget {
|
||||||
var y = path.join(x, url);
|
var y = path.join(x, url);
|
||||||
if (y.startsWith('/')) y = y.substring(1);
|
if (y.startsWith('/')) y = y.substring(1);
|
||||||
|
|
||||||
return theme.push(context,
|
return context.pushUrl(
|
||||||
'/${basePaths![0]}/${basePaths![1]}/${basePaths![2]}?path=${y.urlencode}');
|
'/${basePaths![0]}/${basePaths![1]}/${basePaths![2]}?path=${y.urlencode}');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +148,7 @@ class MarkdownFlutterView extends StatelessWidget {
|
||||||
for (var p in matchedPaths) {
|
for (var p in matchedPaths) {
|
||||||
final m = matchPattern(url, p);
|
final m = matchPattern(url, p);
|
||||||
if (m != null) {
|
if (m != null) {
|
||||||
return theme.push(context,
|
return context.pushUrl(
|
||||||
url.replaceFirst(RegExp(r'https://github.com'), '/github'));
|
url.replaceFirst(RegExp(r'https://github.com'), '/github'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,6 @@ AntListItem createObjectTreeItem({
|
||||||
}) {
|
}) {
|
||||||
return AntListItem(
|
return AntListItem(
|
||||||
prefix: _buildIcon(type, name),
|
prefix: _buildIcon(type, name),
|
||||||
child: Text(name),
|
|
||||||
extra: size == null ? null : Text(filesize(size)),
|
extra: size == null ? null : Text(filesize(size)),
|
||||||
onClick: () async {
|
onClick: () async {
|
||||||
final finalUrl = [
|
final finalUrl = [
|
||||||
|
@ -51,5 +50,6 @@ AntListItem createObjectTreeItem({
|
||||||
await launchStringUrl(finalUrl);
|
await launchStringUrl(finalUrl);
|
||||||
},
|
},
|
||||||
arrow: size == null ? const Icon(AntIcons.rightOutline) : null,
|
arrow: size == null ? const Icon(AntIcons.rightOutline) : null,
|
||||||
|
child: Text(name),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,7 @@ class ReleaseItem extends StatelessWidget {
|
||||||
AntListItem(
|
AntListItem(
|
||||||
extra: IconButton(
|
extra: IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
theme.push(context, asset.downloadUrl);
|
context.pushUrl(asset.downloadUrl);
|
||||||
},
|
},
|
||||||
icon: const Icon(Ionicons.download_outline),
|
icon: const Icon(Ionicons.download_outline),
|
||||||
),
|
),
|
||||||
|
|
|
@ -6,7 +6,6 @@ import 'package:git_touch/widgets/mutation_button.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class UserHeader extends StatelessWidget {
|
class UserHeader extends StatelessWidget {
|
||||||
|
|
||||||
const UserHeader({
|
const UserHeader({
|
||||||
super.key,
|
super.key,
|
||||||
required this.avatarUrl,
|
required this.avatarUrl,
|
||||||
|
@ -33,7 +32,7 @@ class UserHeader extends StatelessWidget {
|
||||||
MutationButton(
|
MutationButton(
|
||||||
text: 'Switch accounts',
|
text: 'Switch accounts',
|
||||||
onTap: () {
|
onTap: () {
|
||||||
theme.push(context, '/login');
|
context.pushUrl('/login');
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue