git-touch-android-ios-app/lib/widgets/link.dart

37 lines
849 B
Dart
Raw Normal View History

2019-01-31 07:37:25 +01:00
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:provider/provider.dart';
import 'package:git_touch/models/theme.dart';
2019-01-31 07:37:25 +01:00
class Link extends StatelessWidget {
final Widget child;
final String url;
final Function onTap;
2019-01-31 07:37:25 +01:00
Link({
2019-02-08 16:20:28 +01:00
this.child,
this.url,
this.onTap,
});
2019-01-31 07:37:25 +01:00
@override
Widget build(BuildContext context) {
2019-12-26 07:10:52 +01:00
final theme = Provider.of<ThemeModel>(context);
2019-11-05 14:22:41 +01:00
2019-01-31 07:37:25 +01:00
return Material(
child: Ink(
2019-11-05 14:22:41 +01:00
color: CupertinoTheme.of(context).scaffoldBackgroundColor,
2019-01-31 07:37:25 +01:00
child: InkWell(
child: child,
2019-11-05 14:22:41 +01:00
splashColor:
2019-12-26 07:10:52 +01:00
theme.theme == AppThemeType.cupertino ? Colors.transparent : null,
onTap: () async {
2019-12-27 03:24:15 +01:00
if (onTap != null) onTap();
2019-12-26 07:10:52 +01:00
theme.push(context, url);
},
2019-01-31 07:37:25 +01:00
),
),
);
}
}