diff --git a/lib/main.dart b/lib/main.dart index 8923172..32707d4 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,11 +1,11 @@ import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; +import 'package:git_touch/models/settings.dart'; import 'package:git_touch/models/theme.dart'; import 'package:git_touch/screens/repo.dart'; import 'package:primer/primer.dart'; import 'package:provider/provider.dart'; import 'package:git_touch/models/notification.dart'; -import 'providers/settings.dart'; import 'screens/news.dart'; import 'screens/notifications.dart'; import 'screens/search.dart'; @@ -32,6 +32,7 @@ class _HomeState extends State { nextTick(() { // FIXME: Provider.of(context).init(); + Provider.of(context).init(); }); } @@ -114,7 +115,7 @@ class _HomeState extends State { @override Widget build(BuildContext context) { - var settings = SettingsProvider.of(context); + var settings = Provider.of(context); var themData = ThemeData( // primaryColor: HSLColor.fromColor(Palette.primary) // .withLightness(0.3) @@ -179,8 +180,9 @@ class App extends StatelessWidget { providers: [ ChangeNotifierProvider(builder: (context) => NotificationModel()), ChangeNotifierProvider(builder: (context) => ThemeModel()), + ChangeNotifierProvider(builder: (context) => SettingsModel()), ], - child: SettingsProvider(child: Home()), + child: Home(), ); } } diff --git a/lib/providers/settings.dart b/lib/models/settings.dart similarity index 80% rename from lib/providers/settings.dart rename to lib/models/settings.dart index 4b5a01c..b87e517 100644 --- a/lib/providers/settings.dart +++ b/lib/models/settings.dart @@ -12,7 +12,7 @@ import 'package:shared_preferences/shared_preferences.dart'; // import '../utils/utils.dart'; import '../utils/constants.dart'; import '../utils/utils.dart'; -import '../models/account.dart'; +import 'account.dart'; class PlatformType { static const github = 'github'; @@ -21,7 +21,7 @@ class PlatformType { // abstract class Model { // Future query(BuildContext context) { -// var settings = SettingsProvider.of(context); +// var settings = Provider.of(context); // switch (settings.platformType) { // case PlatformType.github: @@ -37,22 +37,7 @@ class PlatformType { // Future queryGitlab(SettingsProviderState settings); // } -class SettingsProvider extends StatefulWidget { - final Widget child; - - SettingsProvider({@required this.child}); - - static SettingsProviderState of(BuildContext context) { - return (context.inheritFromWidgetOfExactType(_InheritedSettingsProvider) - as _InheritedSettingsProvider) - .data; - } - - @override - SettingsProviderState createState() => SettingsProviderState(); -} - -class SettingsProviderState extends State { +class SettingsModel with ChangeNotifier { bool ready = false; Map githubAccountMap; @@ -67,7 +52,7 @@ class SettingsProviderState extends State { // PlatformType platformType; - String prefix = 'https://api.github.com'; + String _apiPrefix = 'https://api.github.com'; String get token { if (activeLogin == null) return null; @@ -80,29 +65,12 @@ class SettingsProviderState extends State { } } - @override - void initState() { - super.initState(); - _initDataFromPref(); - - _sub = getUriLinksStream().listen(_onSchemeDetected, onError: (err) { - print(err); - }); - } - - @override - void dispose() { - super.dispose(); - _sub.cancel(); - } - // https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps/#web-application-flow Future _onSchemeDetected(Uri uri) async { await closeWebView(); - setState(() { - loading = true; - }); + loading = true; + notifyListeners(); // get token by code var code = uri.queryParameters['code']; @@ -147,15 +115,13 @@ class SettingsProviderState extends State { json.encode(githubAccountMap .map((login, account) => MapEntry(login, account.toJson())))); - setState(() { - loading = false; - }); + loading = false; + notifyListeners(); } Future loginToGitlab(String domain, String token) async { - setState(() { - loading = true; - }); + loading = true; + notifyListeners(); try { var res = await http @@ -191,13 +157,16 @@ class SettingsProviderState extends State { print(err); // TODO: show errors } finally { - setState(() { - loading = false; - }); + loading = false; + notifyListeners(); } } - void _initDataFromPref() async { + void init() async { + _sub = getUriLinksStream().listen(_onSchemeDetected, onError: (err) { + print(err); + }); + var prefs = await SharedPreferences.getInstance(); // read GitHub accounts @@ -245,17 +214,15 @@ class SettingsProviderState extends State { accountMap = {}; } - setState(() { - ready = true; - }); + ready = true; + notifyListeners(); } void setActiveAccount(String platform, String domain, String login) { - setState(() { - activePlatform = platform; - activeDomain = domain; - activeLogin = login; - }); + activePlatform = platform; + activeDomain = domain; + activeLogin = login; + notifyListeners(); } Map get _headers => @@ -274,7 +241,7 @@ class SettingsProviderState extends State { } final res = await http - .post(prefix + '/graphql', + .post(_apiPrefix + '/graphql', headers: { HttpHeaders.authorizationHeader: 'token $_token', HttpHeaders.contentTypeHeader: 'application/json' @@ -299,7 +266,7 @@ class SettingsProviderState extends State { headers[HttpHeaders.contentTypeHeader] = contentType; } final res = await http - .get(prefix + url, headers: headers) + .get(_apiPrefix + url, headers: headers) .timeout(_timeoutDuration); // print(res.body); final data = json.decode(res.body); @@ -307,27 +274,29 @@ class SettingsProviderState extends State { } Future patchWithCredentials(String url) async { - await http.patch(prefix + url, headers: _headers).timeout(_timeoutDuration); + await http + .patch(_apiPrefix + url, headers: _headers) + .timeout(_timeoutDuration); } Future putWithCredentials(String url, {String contentType, String body}) async { await http - .put(prefix + url, headers: _headers, body: body ?? {}) + .put(_apiPrefix + url, headers: _headers, body: body ?? {}) .timeout(_timeoutDuration); } Future postWithCredentials(String url, {String contentType, String body}) async { final res = await http - .post(prefix + url, headers: _headers, body: body ?? {}) + .post(_apiPrefix + url, headers: _headers, body: body ?? {}) .timeout(_timeoutDuration); // print(res.body); } Future deleteWithCredentials(String url) async { await http - .delete(prefix + url, headers: _headers) + .delete(_apiPrefix + url, headers: _headers) .timeout(_timeoutDuration); } @@ -338,25 +307,4 @@ class SettingsProviderState extends State { 'https://github.com/login/oauth/authorize?client_id=$clientId&redirect_uri=gittouch://login&scope=user%20repo&state=$_oauthState', ); } - - @override - Widget build(BuildContext context) { - return _InheritedSettingsProvider( - data: this, - child: widget.child, - ); - } -} - -class _InheritedSettingsProvider extends InheritedWidget { - final SettingsProviderState data; - - _InheritedSettingsProvider({ - Key key, - @required this.data, - @required Widget child, - }) : super(key: key, child: child); - - @override - bool updateShouldNotify(_InheritedSettingsProvider old) => true; } diff --git a/lib/screens/commits.dart b/lib/screens/commits.dart index dca8c08..2bb2a35 100644 --- a/lib/screens/commits.dart +++ b/lib/screens/commits.dart @@ -1,8 +1,9 @@ import 'package:flutter/material.dart'; +import 'package:git_touch/models/settings.dart'; import 'package:git_touch/utils/utils.dart'; import 'package:git_touch/widgets/link.dart'; +import 'package:provider/provider.dart'; import 'package:timeago/timeago.dart' as timeago; -import 'package:git_touch/providers/settings.dart'; import 'package:git_touch/scaffolds/list.dart'; import 'package:git_touch/widgets/avatar.dart'; import 'package:primer/primer.dart'; @@ -18,7 +19,7 @@ class CommitsScreen extends StatelessWidget { if (cursor != null) { params += ', after: "$cursor"'; } - var data = await SettingsProvider.of(context).query(''' + var data = await Provider.of(context).query(''' { repository(owner: "$owner", name: "$name") { ref(qualifiedName: "master") { diff --git a/lib/screens/issue.dart b/lib/screens/issue.dart index 424a8e6..931af2e 100644 --- a/lib/screens/issue.dart +++ b/lib/screens/issue.dart @@ -1,13 +1,14 @@ import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; +import 'package:git_touch/models/settings.dart'; import 'package:primer/primer.dart'; +import 'package:provider/provider.dart'; import 'package:share/share.dart'; import 'package:url_launcher/url_launcher.dart'; import '../utils/utils.dart'; import '../scaffolds/long_list.dart'; import '../widgets/timeline_item.dart'; import '../widgets/comment_item.dart'; -import '../providers/settings.dart'; import '../widgets/action.dart'; var reactionChunk = emojiMap.entries.map((entry) { @@ -272,7 +273,7 @@ __typename } } - var data = await SettingsProvider.of(context).query(''' + var data = await Provider.of(context).query(''' { repository(owner: "$owner", name: "$name") { $resource(number: $number) { @@ -322,7 +323,7 @@ __typename var id = payload['id'] as String; var operation = isRemove ? 'remove' : 'add'; - await SettingsProvider.of(context).query(''' + await Provider.of(context).query(''' mutation { ${operation}Reaction(input: {subjectId: "$id", content: $emojiKey}) { clientMutationId diff --git a/lib/screens/issues.dart b/lib/screens/issues.dart index 2891401..66bc5c1 100644 --- a/lib/screens/issues.dart +++ b/lib/screens/issues.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; +import 'package:git_touch/models/settings.dart'; +import 'package:provider/provider.dart'; import '../scaffolds/list.dart'; -import '../providers/settings.dart'; import '../utils/utils.dart'; import '../widgets/link.dart'; import '../screens/issue.dart'; @@ -29,7 +30,7 @@ class _IssuesScreenState extends State { var cursorChunk = cursor == null ? '' : ', after: "$cursor"'; var resource = isPullRequest ? 'pullRequests' : 'issues'; - var data = await SettingsProvider.of(context).query(''' + var data = await Provider.of(context).query(''' { repository(owner: "$owner", name: "$name") { $resource(states: OPEN, first: $pageSize$cursorChunk) { diff --git a/lib/screens/login.dart b/lib/screens/login.dart index 84948e7..3c18552 100644 --- a/lib/screens/login.dart +++ b/lib/screens/login.dart @@ -1,8 +1,7 @@ import 'package:flutter/material.dart'; -import 'package:url_launcher/url_launcher.dart'; -import '../providers/settings.dart'; +import 'package:git_touch/models/settings.dart'; +import 'package:provider/provider.dart'; import '../scaffolds/simple.dart'; -import '../utils/constants.dart'; import '../widgets/link.dart'; import '../widgets/loading.dart'; import '../models/account.dart'; @@ -16,7 +15,7 @@ class LoginScreen extends StatefulWidget { class _LoginScreenState extends State { Widget _buildAccountItem(AccountModel account) { - var settings = SettingsProvider.of(context); + var settings = Provider.of(context); return Link( onTap: () { @@ -75,7 +74,7 @@ class _LoginScreenState extends State { @override Widget build(BuildContext context) { - var settings = SettingsProvider.of(context); + var settings = Provider.of(context); List accounts = []; settings.accountMap.forEach((platform, v0) { diff --git a/lib/screens/login_gitlab.dart b/lib/screens/login_gitlab.dart index 8175603..8b4f0d6 100644 --- a/lib/screens/login_gitlab.dart +++ b/lib/screens/login_gitlab.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; +import 'package:git_touch/models/settings.dart'; +import 'package:provider/provider.dart'; import '../scaffolds/simple.dart'; -import '../providers/settings.dart'; class LoginGitlabScreen extends StatefulWidget { @override @@ -32,7 +33,8 @@ class _LoginGitlabScreenState extends State { MaterialButton( child: Text('Login'), onPressed: () { - SettingsProvider.of(context).loginToGitlab(_domain, _token); + Provider.of(context) + .loginToGitlab(_domain, _token); Navigator.of(context).pop(); }, ) diff --git a/lib/screens/me.dart b/lib/screens/me.dart index e33c400..dac7ac8 100644 --- a/lib/screens/me.dart +++ b/lib/screens/me.dart @@ -1,13 +1,14 @@ import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; -import '../providers/settings.dart'; +import 'package:git_touch/models/settings.dart'; +import 'package:provider/provider.dart'; import '../screens/user.dart'; class MeScreen extends StatelessWidget { @override Widget build(BuildContext context) { return UserScreen( - SettingsProvider.of(context).activeLogin, + Provider.of(context).activeLogin, showSettings: true, ); } diff --git a/lib/screens/news.dart b/lib/screens/news.dart index eba7951..8b5f589 100644 --- a/lib/screens/news.dart +++ b/lib/screens/news.dart @@ -5,7 +5,7 @@ import 'package:git_touch/utils/utils.dart'; import 'package:provider/provider.dart'; import '../scaffolds/list.dart'; import '../widgets/event_item.dart'; -import '../providers/settings.dart'; +import 'package:git_touch/models/settings.dart'; class NewsFilter { static const all = 'all'; @@ -31,7 +31,7 @@ class NewsScreenState extends State { nextTick(() async { // Check if there are unread notification items. // 1 item is enough since count is not displayed for now. - var items = await SettingsProvider.of(context) + var items = await Provider.of(context) .getWithCredentials('/notifications?per_page=1'); if (items is List && items.isNotEmpty) { @@ -48,7 +48,7 @@ class NewsScreenState extends State { } Future> fetchEvents([int page = 1]) async { - var settings = SettingsProvider.of(context); + var settings = Provider.of(context); var login = settings.activeLogin; List data = await settings.getWithCredentials( '/users/$login/received_events?page=$page&per_page=$pageSize'); diff --git a/lib/screens/notifications.dart b/lib/screens/notifications.dart index 051186d..a98f979 100644 --- a/lib/screens/notifications.dart +++ b/lib/screens/notifications.dart @@ -4,7 +4,7 @@ import 'package:provider/provider.dart'; import '../scaffolds/refresh_stateless.dart'; import 'package:git_touch/models/notification.dart'; import 'package:git_touch/models/theme.dart'; -import '../providers/settings.dart'; +import 'package:git_touch/models/settings.dart'; import '../widgets/notification_item.dart'; import '../widgets/list_group.dart'; import '../widgets/link.dart'; @@ -29,7 +29,7 @@ class NotificationScreenState extends State { } Future> fetchNotifications(int index) async { - List items = await SettingsProvider.of(context).getWithCredentials( + List items = await Provider.of(context).getWithCredentials( '/notifications?all=${index == 2}&participating=${index == 1}'); var ns = items.map((item) => NotificationPayload.fromJson(item)).toList(); @@ -88,7 +88,7 @@ $key: pullRequest(number: ${item.number}) { schema += '}'; // print(schema); - var data = await SettingsProvider.of(context).query(schema); + var data = await Provider.of(context).query(schema); _groupMap.forEach((repo, group) { group.items.forEach((item) { var groupData = data[group.key]; @@ -123,7 +123,7 @@ $key: pullRequest(number: ${item.number}) { Link( material: false, onTap: () async { - await SettingsProvider.of(context) + await Provider.of(context) .putWithCredentials('/repos/$repo/notifications'); await _onSwitchTab(); }, @@ -204,7 +204,8 @@ $key: pullRequest(number: ${item.number}) { var value = await Provider.of(context) .showConfirm(context, 'Mark all as read?'); if (value) { - await SettingsProvider.of(context).putWithCredentials('/notifications'); + await Provider.of(context) + .putWithCredentials('/notifications'); await _onSwitchTab(); } } diff --git a/lib/screens/object.dart b/lib/screens/object.dart index d3a404b..ba17723 100644 --- a/lib/screens/object.dart +++ b/lib/screens/object.dart @@ -3,7 +3,8 @@ import 'package:git_touch/screens/image_view.dart'; import 'package:path/path.dart' as path; import 'package:flutter/material.dart'; import 'package:flutter_highlight/flutter_highlight.dart'; -import 'package:git_touch/providers/settings.dart'; +import 'package:git_touch/models/settings.dart'; +import 'package:provider/provider.dart'; import 'package:git_touch/scaffolds/refresh.dart'; import 'package:git_touch/utils/utils.dart'; import 'package:git_touch/widgets/link.dart'; @@ -126,7 +127,7 @@ class ObjectScreen extends StatelessWidget { return RefreshScaffold( title: Text(paths.join('/')), onRefresh: () async { - var data = await SettingsProvider.of(context).query('''{ + var data = await Provider.of(context).query('''{ repository(owner: "$owner", name: "$name") { object(expression: "$expression") { $_subQuery diff --git a/lib/screens/organization.dart b/lib/screens/organization.dart index 91e2533..8e64f33 100644 --- a/lib/screens/organization.dart +++ b/lib/screens/organization.dart @@ -2,7 +2,8 @@ import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:share/share.dart'; -import '../providers/settings.dart'; +import 'package:git_touch/models/settings.dart'; +import 'package:provider/provider.dart'; import '../scaffolds/refresh.dart'; import '../widgets/avatar.dart'; import '../widgets/entry_item.dart'; @@ -23,7 +24,7 @@ class OrganizationScreen extends StatefulWidget { class _OrganizationScreenState extends State { Future query() async { var login = widget.login; - var data = await SettingsProvider.of(context).query(''' + var data = await Provider.of(context).query(''' { organization(login: "$login") { name diff --git a/lib/screens/repo.dart b/lib/screens/repo.dart index e73aa0b..349bc93 100644 --- a/lib/screens/repo.dart +++ b/lib/screens/repo.dart @@ -1,14 +1,14 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; +import 'package:git_touch/models/settings.dart'; +import 'package:provider/provider.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; import 'package:git_touch/models/theme.dart'; import 'package:git_touch/screens/commits.dart'; import 'package:git_touch/screens/object.dart'; -import 'package:provider/provider.dart'; import 'package:share/share.dart'; import 'package:url_launcher/url_launcher.dart'; -import '../providers/settings.dart'; import '../scaffolds/refresh.dart'; import '../widgets/repo_item.dart'; import '../widgets/entry_item.dart'; @@ -33,7 +33,7 @@ class _RepoScreenState extends State { String get name => widget.name; Future queryRepo(BuildContext context) async { - var data = await SettingsProvider.of(context).query(''' + var data = await Provider.of(context).query(''' { repository(owner: "$owner", name: "$name") { id @@ -85,7 +85,7 @@ class _RepoScreenState extends State { Future fetchReadme(BuildContext context) async { var owner = widget.owner; var name = widget.name; - var data = await SettingsProvider.of(context) + var data = await Provider.of(context) .getWithCredentials('/repos/$owner/$name/readme'); if (data['content'] == null) { @@ -132,11 +132,11 @@ class _RepoScreenState extends State { text: payload['viewerHasStarred'] ? 'Unstar' : 'Star', onPress: () async { if (payload['viewerHasStarred']) { - await SettingsProvider.of(context) + await Provider.of(context) .deleteWithCredentials('/user/starred/$owner/$name'); payload['viewerHasStarred'] = false; } else { - SettingsProvider.of(context) + Provider.of(context) .putWithCredentials('/user/starred/$owner/$name'); payload['viewerHasStarred'] = true; } diff --git a/lib/screens/repos.dart b/lib/screens/repos.dart index 522353d..8eca3c9 100644 --- a/lib/screens/repos.dart +++ b/lib/screens/repos.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import '../scaffolds/list.dart'; -import '../providers/settings.dart'; +import 'package:git_touch/models/settings.dart'; +import 'package:provider/provider.dart'; import '../utils/utils.dart'; import '../widgets/repo_item.dart'; @@ -32,7 +33,7 @@ class _ReposScreenState extends State { Future _queryRepos([String cursor]) async { var cursorChunk = cursor == null ? '' : ', after: "$cursor"'; - var data = await SettingsProvider.of(context).query(''' + var data = await Provider.of(context).query(''' { $scope(login: "$login") { $resource(first: $pageSize$cursorChunk, orderBy: {field: $fieldOrderBy, direction: DESC}) { diff --git a/lib/screens/search.dart b/lib/screens/search.dart index a6580f9..e9a5239 100644 --- a/lib/screens/search.dart +++ b/lib/screens/search.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:git_touch/models/theme.dart'; import 'package:provider/provider.dart'; -import '../providers/settings.dart'; +import 'package:git_touch/models/settings.dart'; import '../scaffolds/simple.dart'; import '../utils/utils.dart'; import '../widgets/repo_item.dart'; @@ -24,7 +24,7 @@ class _SearchScreenState extends State { }); try { // TODO: search other types - var data = await SettingsProvider.of(context).query(''' + var data = await Provider.of(context).query(''' { search(first: $pageSize, type: REPOSITORY, query: "$value") { nodes { diff --git a/lib/screens/user.dart b/lib/screens/user.dart index bbfaa5d..a165676 100644 --- a/lib/screens/user.dart +++ b/lib/screens/user.dart @@ -6,7 +6,8 @@ import 'package:url_launcher/url_launcher.dart'; import 'package:share/share.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:github_contributions/github_contributions.dart'; -import '../providers/settings.dart'; +import 'package:git_touch/models/settings.dart'; +import 'package:provider/provider.dart'; import '../scaffolds/refresh.dart'; import '../widgets/avatar.dart'; import '../widgets/entry_item.dart'; @@ -31,7 +32,7 @@ class UserScreen extends StatefulWidget { class _UserScreenState extends State { Future query() async { var login = widget.login; - var data = await SettingsProvider.of(context).query(''' + var data = await Provider.of(context).query(''' { user(login: "$login") { name @@ -149,11 +150,11 @@ class _UserScreenState extends State { text: payload['viewerIsFollowing'] ? 'Unfollow' : 'Follow', onPress: () async { if (payload['viewerIsFollowing']) { - await SettingsProvider.of(context) + await Provider.of(context) .deleteWithCredentials('/user/following/${widget.login}'); payload['viewerIsFollowing'] = false; } else { - SettingsProvider.of(context) + Provider.of(context) .putWithCredentials('/user/following/${widget.login}'); payload['viewerIsFollowing'] = true; } diff --git a/lib/screens/users.dart b/lib/screens/users.dart index 29b2d52..ad9071f 100644 --- a/lib/screens/users.dart +++ b/lib/screens/users.dart @@ -1,7 +1,8 @@ import 'package:flutter/material.dart'; import 'package:primer/primer.dart'; import '../scaffolds/list.dart'; -import '../providers/settings.dart'; +import 'package:git_touch/models/settings.dart'; +import 'package:provider/provider.dart'; import '../utils/utils.dart'; import '../widgets/link.dart'; import '../screens/user.dart'; @@ -38,7 +39,7 @@ class _UsersScreenState extends State { Future _queryUsers([String cursor]) async { var cursorChunk = cursor == null ? '' : ', after: "$cursor"'; - var data = await SettingsProvider.of(context).query(''' + var data = await Provider.of(context).query(''' { $scope(login: "$login") { $resource(first: $pageSize$cursorChunk) { diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index 94d922e..c1da43b 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -3,7 +3,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/gestures.dart'; import 'package:git_touch/screens/user.dart'; import 'package:primer/primer.dart'; -import '../providers/settings.dart'; import '../screens/repo.dart'; export 'package:flutter_vector_icons/flutter_vector_icons.dart'; diff --git a/lib/widgets/notification_item.dart b/lib/widgets/notification_item.dart index a3cb844..607bdfd 100644 --- a/lib/widgets/notification_item.dart +++ b/lib/widgets/notification_item.dart @@ -6,7 +6,8 @@ import 'package:url_launcher/url_launcher.dart'; import '../utils/utils.dart'; import '../screens/issue.dart'; // import '../screens/not_found.dart'; -import '../providers/settings.dart'; +import 'package:git_touch/models/settings.dart'; +import 'package:provider/provider.dart'; import 'link.dart'; class NotificationItem extends StatefulWidget { @@ -80,7 +81,7 @@ class _NotificationItemState extends State { loading = true; }); try { - await SettingsProvider.of(context) + await Provider.of(context) .patchWithCredentials('/notifications/threads/' + payload.id); widget.markAsRead(); } finally {