Files
GitJournal/lib/widgets/pro_overlay.dart
Vishesh Handa 9d55b449d3 Settings: Access it through the Provider
Make it a ChageNotifier and try to access it through the Provider
instead of like a global variable. This way, the state is better
managed and it'll be easier to split out Settings into smaller classes.
2020-08-09 01:29:22 +02:00

34 lines
826 B
Dart

import 'package:flutter/material.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:provider/provider.dart';
import 'package:gitjournal/settings.dart';
class ProOverlay extends StatelessWidget {
final Widget child;
ProOverlay({@required this.child});
@override
Widget build(BuildContext context) {
var settings = Provider.of<Settings>(context);
if (settings.proMode) {
return child;
}
return GestureDetector(
behavior: HitTestBehavior.opaque,
child: Banner(
message: tr('pro'),
location: BannerLocation.topEnd,
color: Theme.of(context).accentColor,
child: IgnorePointer(child: Opacity(opacity: 0.5, child: child)),
),
onTap: () {
Navigator.pushNamed(context, "/purchase");
},
);
}
}