diff --git a/lib/screens/repository.dart b/lib/screens/repository.dart index af5f020..3e5a94f 100644 --- a/lib/screens/repository.dart +++ b/lib/screens/repository.dart @@ -157,7 +157,7 @@ class RepositoryScreen extends StatelessWidget { Provider.of(context).pushRoute(context, builder); }, ), - if (data != null) + if (data != null) ...[ MyAction( text: data[0]['viewerHasStarred'] ? 'Unstar' : 'Star', onPress: () async { @@ -172,7 +172,24 @@ class RepositoryScreen extends StatelessWidget { } }, ), - // TODO: watch + MyAction( + text: data[0]['viewerSubscription'] == 'SUBSCRIBED' + ? 'Unwatch' + : 'Watch', + onPress: () async { + if (data[0]['viewerSubscription'] == 'SUBSCRIBED') { + await Provider.of(context) + .deleteWithCredentials( + '/repos/$owner/$name/subscription'); + data[0]['viewerSubscription'] = 'UNSUBSCRIBED'; + } else { + Provider.of(context) + .putWithCredentials('/repos/$owner/$name/subscription'); + data[0]['viewerSubscription'] = 'SUBSCRIBED'; + } + }, + ), + ], MyAction( text: 'Share', onPress: () {