mirror of
https://github.com/pd4d10/git-touch.git
synced 2026-03-11 17:49:27 -05:00
refactor: push method as extension
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class ActionEntry extends StatelessWidget {
|
||||
@@ -16,7 +17,7 @@ class ActionEntry extends StatelessWidget {
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: () {
|
||||
if (onTap != null) onTap!();
|
||||
if (url != null) theme.push(context, url!);
|
||||
if (url != null) context.pushUrl(url!);
|
||||
},
|
||||
child: Icon(iconData, size: 22),
|
||||
);
|
||||
|
||||
@@ -14,7 +14,6 @@ class AvatarSize {
|
||||
}
|
||||
|
||||
class Avatar extends StatelessWidget {
|
||||
|
||||
const Avatar({
|
||||
required this.url,
|
||||
this.size = AvatarSize.medium,
|
||||
@@ -56,7 +55,7 @@ class Avatar extends StatelessWidget {
|
||||
return LinkWidget(
|
||||
child: widget,
|
||||
onTap: () {
|
||||
context.read<ThemeModel>().push(context, linkUrl!);
|
||||
context.pushUrl(linkUrl!);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class EventItem extends StatelessWidget {
|
||||
style: TextStyle(color: theme.palette.primary),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
theme.push(context, url!);
|
||||
context.pushUrl(url!);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import 'package:provider/provider.dart';
|
||||
|
||||
// TODO:
|
||||
class CupertinoLink extends StatefulWidget {
|
||||
|
||||
const CupertinoLink({this.child, this.onTap});
|
||||
final Widget? child;
|
||||
final Function? onTap;
|
||||
@@ -48,7 +47,6 @@ class _CupertinoLinkState extends State<CupertinoLink> {
|
||||
}
|
||||
|
||||
class LinkWidget extends StatelessWidget {
|
||||
|
||||
const LinkWidget({
|
||||
required this.child,
|
||||
this.url,
|
||||
@@ -69,7 +67,7 @@ class LinkWidget extends StatelessWidget {
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: () async {
|
||||
if (onTap != null) onTap!();
|
||||
if (url != null) theme.push(context, url!);
|
||||
if (url != null) context.pushUrl(url!);
|
||||
},
|
||||
child: child,
|
||||
);
|
||||
|
||||
@@ -82,7 +82,6 @@ html {
|
||||
}
|
||||
|
||||
class MarkdownFlutterView extends StatelessWidget {
|
||||
|
||||
const MarkdownFlutterView(
|
||||
this.text, {
|
||||
this.basePaths,
|
||||
@@ -134,7 +133,7 @@ class MarkdownFlutterView extends StatelessWidget {
|
||||
var y = path.join(x, url);
|
||||
if (y.startsWith('/')) y = y.substring(1);
|
||||
|
||||
return theme.push(context,
|
||||
return context.pushUrl(
|
||||
'/${basePaths![0]}/${basePaths![1]}/${basePaths![2]}?path=${y.urlencode}');
|
||||
}
|
||||
|
||||
@@ -149,7 +148,7 @@ class MarkdownFlutterView extends StatelessWidget {
|
||||
for (var p in matchedPaths) {
|
||||
final m = matchPattern(url, p);
|
||||
if (m != null) {
|
||||
return theme.push(context,
|
||||
return context.pushUrl(
|
||||
url.replaceFirst(RegExp(r'https://github.com'), '/github'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ AntListItem createObjectTreeItem({
|
||||
}) {
|
||||
return AntListItem(
|
||||
prefix: _buildIcon(type, name),
|
||||
child: Text(name),
|
||||
extra: size == null ? null : Text(filesize(size)),
|
||||
onClick: () async {
|
||||
final finalUrl = [
|
||||
@@ -51,5 +50,6 @@ AntListItem createObjectTreeItem({
|
||||
await launchStringUrl(finalUrl);
|
||||
},
|
||||
arrow: size == null ? const Icon(AntIcons.rightOutline) : null,
|
||||
child: Text(name),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ class ReleaseItem extends StatelessWidget {
|
||||
AntListItem(
|
||||
extra: IconButton(
|
||||
onPressed: () {
|
||||
theme.push(context, asset.downloadUrl);
|
||||
context.pushUrl(asset.downloadUrl);
|
||||
},
|
||||
icon: const Icon(Ionicons.download_outline),
|
||||
),
|
||||
|
||||
@@ -6,7 +6,6 @@ import 'package:git_touch/widgets/mutation_button.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class UserHeader extends StatelessWidget {
|
||||
|
||||
const UserHeader({
|
||||
super.key,
|
||||
required this.avatarUrl,
|
||||
@@ -33,7 +32,7 @@ class UserHeader extends StatelessWidget {
|
||||
MutationButton(
|
||||
text: 'Switch accounts',
|
||||
onTap: () {
|
||||
theme.push(context, '/login');
|
||||
context.pushUrl('/login');
|
||||
},
|
||||
)
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user