1
0
mirror of https://github.com/git-touch/git-touch synced 2024-12-20 04:05:26 +01:00

improvement: drop inkwell widget in cupertino style

This commit is contained in:
Rongjian Zhang 2019-12-31 19:52:00 +08:00
parent 4e7ac48664
commit cdd8876657

View File

@ -3,6 +3,50 @@ import 'package:flutter/cupertino.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:git_touch/models/theme.dart'; import 'package:git_touch/models/theme.dart';
// TODO:
class CupertinoLink extends StatefulWidget {
final Widget child;
final Function onTap;
CupertinoLink({this.child, this.onTap});
@override
_CupertinoLinkState createState() => _CupertinoLinkState();
}
class _CupertinoLinkState extends State<CupertinoLink> {
Color _color;
@override
Widget build(BuildContext context) {
return Container(
color: _color,
child: GestureDetector(
onTap: widget.onTap,
onTapDown: (_) {
print('down');
setState(() {
_color = Colors.black12;
});
},
onTapUp: (_) {
print('up');
setState(() {
_color = null;
});
},
onTapCancel: () {
print('cacnel');
setState(() {
_color = null;
});
},
child: widget.child,
),
);
}
}
class Link extends StatelessWidget { class Link extends StatelessWidget {
final Widget child; final Widget child;
final String url; final String url;
@ -18,19 +62,24 @@ class Link extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final theme = Provider.of<ThemeModel>(context); final theme = Provider.of<ThemeModel>(context);
return Material( switch (theme.theme) {
child: Ink( case AppThemeType.cupertino:
color: CupertinoTheme.of(context).scaffoldBackgroundColor, return CupertinoButton(
child: InkWell( child: child,
padding: EdgeInsets.all(0),
onPressed: () async {
if (onTap != null) onTap();
theme.push(context, url);
},
);
default:
return InkWell(
child: child, child: child,
splashColor:
theme.theme == AppThemeType.cupertino ? Colors.transparent : null,
onTap: () async { onTap: () async {
if (onTap != null) onTap(); if (onTap != null) onTap();
theme.push(context, url); theme.push(context, url);
}, },
),
),
); );
} }
} }
}