add web support
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// Generated file. Do not edit.
|
||||
//
|
||||
|
||||
// ignore: unused_import
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:cloud_firestore_web/cloud_firestore_web.dart';
|
||||
import 'package:firebase_auth_web/firebase_auth_web.dart';
|
||||
import 'package:firebase_core_web/firebase_core_web.dart';
|
||||
import 'package:google_sign_in_web/google_sign_in_web.dart';
|
||||
import 'package:shared_preferences_web/shared_preferences_web.dart';
|
||||
|
||||
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
|
||||
|
||||
// ignore: public_member_api_docs
|
||||
void registerPlugins(PluginRegistry registry) {
|
||||
FirestoreWeb.registerWith(registry.registrarFor(FirestoreWeb));
|
||||
FirebaseAuthWeb.registerWith(registry.registrarFor(FirebaseAuthWeb));
|
||||
FirebaseCoreWeb.registerWith(registry.registrarFor(FirebaseCoreWeb));
|
||||
GoogleSignInPlugin.registerWith(registry.registrarFor(GoogleSignInPlugin));
|
||||
SharedPreferencesPlugin.registerWith(registry.registrarFor(SharedPreferencesPlugin));
|
||||
registry.registerMessageHandler();
|
||||
}
|
||||
+47
-47
@@ -35,9 +35,7 @@ class MyApp extends StatelessWidget {
|
||||
ProxyProvider<LoginState, ExpensesRepository>(
|
||||
update: (_, LoginState value, __) {
|
||||
if (value.isLoggedIn()) {
|
||||
return ExpensesRepository(value
|
||||
.currentUser()
|
||||
.uid);
|
||||
return ExpensesRepository(value.currentUser().uid);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
@@ -45,53 +43,55 @@ class MyApp extends StatelessWidget {
|
||||
],
|
||||
child: Consumer<ThemeState>(
|
||||
builder: (context, state, child) {
|
||||
return MaterialApp(
|
||||
title: 'Flutter Demo',
|
||||
theme: state.currentTheme,
|
||||
onGenerateRoute: (settings) {
|
||||
if (settings.name == '/details') {
|
||||
DetailsParams params = settings.arguments;
|
||||
return MaterialPageRoute(builder: (BuildContext context) {
|
||||
return DetailsPageContainer(
|
||||
params: params,
|
||||
);
|
||||
});
|
||||
} else if (settings.name == '/add') {
|
||||
Rect buttonRect = settings.arguments;
|
||||
return Consumer<LoginState>(
|
||||
builder: (context, loginProvider, child1) {
|
||||
return MaterialApp(
|
||||
title: 'Flutter Demo',
|
||||
theme: state.currentTheme,
|
||||
onGenerateRoute: (settings) {
|
||||
if (settings.name == '/details') {
|
||||
DetailsParams params = settings.arguments;
|
||||
return MaterialPageRoute(builder: (BuildContext context) {
|
||||
return DetailsPageContainer(
|
||||
params: params,
|
||||
);
|
||||
});
|
||||
} else if (settings.name == '/add') {
|
||||
Rect buttonRect = settings.arguments;
|
||||
|
||||
return AddPageTransition(
|
||||
page: AddPage(
|
||||
buttonRect: buttonRect,
|
||||
),
|
||||
);
|
||||
} else if (settings.name == '/settings') {
|
||||
return MaterialPageRoute(builder: (BuildContext context) {
|
||||
return SettingsPage();
|
||||
});
|
||||
}
|
||||
return null;
|
||||
},
|
||||
routes: {
|
||||
'/': (BuildContext context) {
|
||||
var state = Provider.of<LoginState>(context, listen: false);
|
||||
if (state.isLoggedIn()) {
|
||||
return HomePage();
|
||||
} else {
|
||||
return LoginPage();
|
||||
return AddPageTransition(
|
||||
page: AddPage(
|
||||
buttonRect: buttonRect,
|
||||
),
|
||||
);
|
||||
} else if (settings.name == '/settings') {
|
||||
return MaterialPageRoute(builder: (BuildContext context) {
|
||||
return SettingsPage();
|
||||
});
|
||||
}
|
||||
return null;
|
||||
},
|
||||
},
|
||||
supportedLocales: [
|
||||
Locale('en'),
|
||||
Locale('es'),
|
||||
],
|
||||
localizationsDelegates: [
|
||||
ComoGastoLocalizations.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
);
|
||||
routes: {
|
||||
'/': (BuildContext context) {
|
||||
if (loginProvider.isLoggedIn()) {
|
||||
return HomePage();
|
||||
} else {
|
||||
return LoginPage();
|
||||
}
|
||||
},
|
||||
},
|
||||
supportedLocales: [
|
||||
Locale('en'),
|
||||
Locale('es'),
|
||||
],
|
||||
localizationsDelegates: [
|
||||
ComoGastoLocalizations.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
);
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
+12
-9
@@ -2,6 +2,7 @@ import 'dart:io';
|
||||
|
||||
import 'package:como_gasto/como_gasto_localizations.dart';
|
||||
import 'package:como_gasto/others/category_selection_widget.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
@@ -42,17 +43,19 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_localAth = LocalAuthentication();
|
||||
_localAth.canCheckBiometrics.then((b) async {
|
||||
var methods = await _localAth.getAvailableBiometrics();
|
||||
var hasFingerprint = Platform.isIOS
|
||||
? methods.any((m) => m == BiometricType.fingerprint)
|
||||
: true;
|
||||
if (kIsWeb) {
|
||||
_localAth = LocalAuthentication();
|
||||
_localAth.canCheckBiometrics.then((b) async {
|
||||
var methods = await _localAth.getAvailableBiometrics();
|
||||
var hasFingerprint = Platform.isIOS
|
||||
? methods.any((m) => m == BiometricType.fingerprint)
|
||||
: true;
|
||||
|
||||
setState(() {
|
||||
_isBiometricAvailable = b && hasFingerprint;
|
||||
setState(() {
|
||||
_isBiometricAvailable = b && hasFingerprint;
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
_controller = AnimationController(
|
||||
vsync: this,
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:como_gasto/como_gasto_icons.dart';
|
||||
import 'package:como_gasto/como_gasto_localizations.dart';
|
||||
import 'package:como_gasto/others/month_widget.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:rect_getter/rect_getter.dart';
|
||||
@@ -74,7 +75,6 @@ class _HomePageState extends State<HomePage> {
|
||||
SizedBox(width: 48.0),
|
||||
_bottomAction(ComoGastoIcons.cart, () {}),
|
||||
_bottomAction(ComoGastoIcons.settings, () {
|
||||
|
||||
Navigator.pushNamed(context, '/settings');
|
||||
}),
|
||||
],
|
||||
@@ -98,7 +98,9 @@ class _HomePageState extends State<HomePage> {
|
||||
}
|
||||
|
||||
Widget _body() {
|
||||
ComoGastoLocalizations localizations = Localizations.of<ComoGastoLocalizations>(context, ComoGastoLocalizations);
|
||||
ComoGastoLocalizations localizations =
|
||||
Localizations.of<ComoGastoLocalizations>(
|
||||
context, ComoGastoLocalizations);
|
||||
return SafeArea(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
@@ -205,6 +207,9 @@ class _HomePageState extends State<HomePage> {
|
||||
}
|
||||
|
||||
void setupNotificationPlugin() {
|
||||
if (kIsWeb) {
|
||||
return;
|
||||
}
|
||||
flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin();
|
||||
|
||||
// initialise the plugin. app_icon needs to be a added as a drawable resource to the Android head project
|
||||
|
||||
@@ -21,10 +21,7 @@ class LoginPage extends StatelessWidget {
|
||||
children: <Widget>[
|
||||
Text(
|
||||
localizations.t('login.title'),
|
||||
style: Theme
|
||||
.of(context)
|
||||
.textTheme
|
||||
.display1,
|
||||
style: Theme.of(context).textTheme.display1,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(32.0),
|
||||
@@ -38,10 +35,7 @@ class LoginPage extends StatelessWidget {
|
||||
),
|
||||
Text(
|
||||
localizations.t('login.subtitle'),
|
||||
style: Theme
|
||||
.of(context)
|
||||
.textTheme
|
||||
.caption,
|
||||
style: Theme.of(context).textTheme.caption,
|
||||
),
|
||||
Consumer<LoginState>(
|
||||
builder: (BuildContext context, LoginState value, Widget child) {
|
||||
@@ -64,7 +58,7 @@ class LoginPage extends StatelessWidget {
|
||||
backgroundColor: Color(0xff4285F4),
|
||||
child: Icon(FontAwesomeIcons.google),
|
||||
onPressed: () {
|
||||
Provider.of<LoginState>(context)
|
||||
Provider.of<LoginState>(context, listen: false)
|
||||
.login(LoginProvider.GOOGLE);
|
||||
},
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user