diff --git a/lib/widgets/link.dart b/lib/widgets/link.dart index 97fb095..9a03690 100644 --- a/lib/widgets/link.dart +++ b/lib/widgets/link.dart @@ -7,25 +7,16 @@ class Link extends StatelessWidget { final Widget child; final String url; final Function onTap; - final VoidCallback onLongPress; Link({ this.child, this.url, this.onTap, - this.onLongPress, }); - void _onTap(BuildContext context) { - if (onTap != null) { - return onTap(); - } - Provider.of(context).push(context, url); - } - @override Widget build(BuildContext context) { - final theme = Provider.of(context).theme; + final theme = Provider.of(context); return Material( child: Ink( @@ -33,9 +24,13 @@ class Link extends StatelessWidget { child: InkWell( child: child, splashColor: - theme == AppThemeType.cupertino ? Colors.transparent : null, - onTap: () => _onTap(context), - onLongPress: onLongPress, + theme.theme == AppThemeType.cupertino ? Colors.transparent : null, + onTap: () async { + if (onTap != null) { + await onTap(); + } + theme.push(context, url); + }, ), ), ); diff --git a/lib/widgets/notification_item.dart b/lib/widgets/notification_item.dart index 9f6e107..bb9169d 100644 --- a/lib/widgets/notification_item.dart +++ b/lib/widgets/notification_item.dart @@ -2,7 +2,6 @@ import 'package:fimber/fimber.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:git_touch/models/notification.dart'; -import 'package:git_touch/models/theme.dart'; import 'package:git_touch/widgets/issue_icon.dart'; import '../utils/utils.dart'; import 'package:git_touch/models/auth.dart'; @@ -93,31 +92,26 @@ class _NotificationItemState extends State { } } + String get _url { + switch (payload.type) { + case 'Issue': + case 'PullRequest': + final resource = payload.type == 'PullRequest' ? 'pulls' : 'issues'; + return '/${payload.owner}/${payload.name}/$resource/${payload.number}'; + case 'Release': + return 'https://github.com/${payload.owner}/${payload.name}/releases/tag/${payload.title}'; + case 'Commit': + return ''; + default: + return null; + } + } + @override Widget build(BuildContext context) { return Link( - onTap: () { - _markAsRead(); - - switch (payload.type) { - case 'Issue': - case 'PullRequest': - final resource = payload.type == 'PullRequest' ? 'pulls' : 'issues'; - Provider.of(context).push(context, - '/${payload.owner}/${payload.name}/$resource/${payload.number}'); - break; - case 'Release': - launchUrl( - 'https://github.com/${payload.owner}/${payload.name}/releases/tag/${payload.title}'); - break; - case 'Commit': - // TODO: - // onTap = () { - // launch('urlString'); - // }; - break; - } - }, + url: _url, + onTap: _markAsRead, child: Opacity( opacity: payload.unread ? 1 : 0.5, child: Container(