Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:launch_review/launch_review.dart';
- import 'package:meeberian_client/components/models/auth.dart';
- import 'package:meeberian_client/components/models/version.dart';
- import 'package:meeberian_client/constants.dart';
- import 'package:meeberian_client/routes.dart';
- import 'package:meeberian_client/components/auth_provider.dart';
- import 'package:meeberian_client/components/cart_provider.dart';
- import 'package:meeberian_client/components/cart_bloc.dart';
- import 'package:package_info/package_info.dart';
- void main() => runApp(new MyApp());
- class MyApp extends StatelessWidget {
- final BaseAuth _auth = Auth();
- final CartBloc _cartBloc = CartBloc();
- Future<bool> _confirm(BuildContext context, String dialogTitle, String dialogContent, [bool prompt = false]) async {
- return await showDialog(
- context: context,
- builder: (BuildContext ctx) {
- return AlertDialog(
- title: (dialogTitle.trim().length == 0) ? null : Text(dialogTitle, style: TextStyle(fontWeight: FontWeight.bold)),
- content: Text(
- dialogContent,
- textAlign: TextAlign.center,
- ),
- actions: <Widget>[
- prompt ?
- FlatButton(
- child: new Text("CANCEL", style: TextStyle(color: Colors.red)),
- onPressed: () {
- Navigator.pop(ctx, false);
- },
- ) : null,
- FlatButton(
- child: new Text("OK", style: TextStyle(color: Colors.red)),
- onPressed: () {
- Navigator.pop(ctx, true);
- },
- ),
- ],
- );
- }
- );
- }
- @override
- Widget build(BuildContext context) {
- PackageInfo.fromPlatform().then((PackageInfo packageInfo) {
- List<String> sTemp = packageInfo.version.split(".");
- List<int> _ver = sTemp.map((v) => int.parse(v));
- appVersion = _ver[0] .toString()+ "." + _ver[1].toString() + (_ver[2] > 9 ? _ver[2].toString() : "0" + _ver[2].toString());
- VersioningController vc = VersioningController();
- vc.checkUpdate().then((_data) {
- if (_data != null) {
- WidgetsBinding.instance.addPostFrameCallback((_) async {
- if (_data.needupdate) {
- _confirm(context, "Info", _data.message).then((onValue) {
- LaunchReview.launch(androidAppId: "com.meeber.meeberian", iOSAppId: "1459505870");
- });
- } else {
- _confirm(context, "Info", _data.message, true).then((onValue){
- if (onValue) {
- LaunchReview.launch(androidAppId: "com.pasaronline.pembeli", iOSAppId: "1459505870");
- }
- });
- }
- });
- }
- });
- });
- SystemChrome.setEnabledSystemUIOverlays([]);
- return AuthProvider (
- auth: _auth,
- child: CartProvider(
- cartBloc: _cartBloc,
- child: MaterialApp(
- initialRoute: '/switcher',
- routes: getRoutes(),
- debugShowCheckedModeBanner: false,
- showPerformanceOverlay: false,
- title: 'Meeberian',
- theme: new ThemeData(
- primaryColor: Colors.white,
- hintColor: Colors.black,
- ),
- ),
- )
- );
- }
- }
- enum AuthStatus {
- notSignedIn,
- signedIn
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement