1
0
mirror of https://github.com/git-touch/git-touch synced 2024-12-18 03:09:36 +01:00

improvement: action button style

This commit is contained in:
Rongjian Zhang 2020-02-06 14:23:54 +08:00
parent 940ea5c1bf
commit cccf56d944
3 changed files with 25 additions and 14 deletions

View File

@ -164,6 +164,8 @@ class RepositoryScreen extends StatelessWidget {
Row( Row(
children: <Widget>[ children: <Widget>[
MutationButton( MutationButton(
active: repo.viewerSubscription ==
GhRepoSubscriptionState.SUBSCRIBED,
text: _buildWatchState(repo.viewerSubscription), text: _buildWatchState(repo.viewerSubscription),
onPressed: () async { onPressed: () async {
final vs = GhWatchSubscriptionState.values.where((v) => final vs = GhWatchSubscriptionState.values.where((v) =>
@ -207,6 +209,7 @@ class RepositoryScreen extends StatelessWidget {
), ),
SizedBox(width: 8), SizedBox(width: 8),
MutationButton( MutationButton(
active: repo.viewerHasStarred,
text: repo.viewerHasStarred ? 'Unstar' : 'Star', text: repo.viewerHasStarred ? 'Unstar' : 'Star',
onPressed: () async { onPressed: () async {
final res = await auth.gqlClient.execute( final res = await auth.gqlClient.execute(

View File

@ -74,6 +74,7 @@ class UserScreen extends StatelessWidget {
bio: p.bio, bio: p.bio,
followWidget: p.viewerCanFollow == true followWidget: p.viewerCanFollow == true
? MutationButton( ? MutationButton(
active: p.viewerIsFollowing,
text: p.viewerIsFollowing ? 'Unfollow' : 'Follow', text: p.viewerIsFollowing ? 'Unfollow' : 'Follow',
onPressed: () async { onPressed: () async {
final res = await auth.gqlClient.execute( final res = await auth.gqlClient.execute(

View File

@ -1,12 +1,15 @@
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/widgets/link.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class MutationButton extends StatelessWidget { class MutationButton extends StatelessWidget {
final bool active;
final String text; final String text;
final VoidCallback onPressed; final VoidCallback onPressed;
MutationButton({ MutationButton({
@required this.active,
@required this.text, @required this.text,
@required this.onPressed, @required this.onPressed,
}); });
@ -14,20 +17,24 @@ class MutationButton extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final theme = Provider.of<ThemeModel>(context); final theme = Provider.of<ThemeModel>(context);
return CupertinoButton( final textColor = active ? theme.palette.background : theme.palette.primary;
onPressed: onPressed, final backgroundColor =
minSize: 0, active ? theme.palette.primary : theme.palette.background;
color: theme.palette.primary, return Link(
padding: EdgeInsets.symmetric( onTap: onPressed,
horizontal: 12, child: Container(
vertical: 4, padding: EdgeInsets.symmetric(
), horizontal: 12,
borderRadius: BorderRadius.all(Radius.circular(20)), vertical: 4,
child: Text( ),
text, decoration: BoxDecoration(
style: TextStyle( color: backgroundColor,
fontSize: 17, borderRadius: BorderRadius.all(Radius.circular(20)),
color: theme.palette.background, border: Border.all(color: theme.palette.primary),
),
child: Text(
text,
style: TextStyle(fontSize: 17, color: textColor),
), ),
), ),
); );