add web support

This commit is contained in:
Ricardo Markiewicz
2020-07-14 15:01:53 -03:00
parent ce541cea23
commit 47fc06afca
15 changed files with 260 additions and 67 deletions
+11
View File
@@ -0,0 +1,11 @@
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java
# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
key.properties
+32
View File
@@ -0,0 +1,32 @@
*.mode1v3
*.mode2v3
*.moved-aside
*.pbxuser
*.perspectivev3
**/*sync/
.sconsign.dblite
.tags*
**/.vagrant/
**/DerivedData/
Icon?
**/Pods/
**/.symlinks/
profile
xcuserdata
**/.generated/
Flutter/App.framework
Flutter/Flutter.framework
Flutter/Flutter.podspec
Flutter/Generated.xcconfig
Flutter/app.flx
Flutter/app.zip
Flutter/flutter_assets/
Flutter/flutter_export_environment.sh
ServiceDefinitions.json
Runner/GeneratedPluginRegistrant.*
# Exceptions to above rules.
!default.mode1v3
!default.mode2v3
!default.pbxuser
!default.perspectivev3
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PreviewsEnabled</key>
<false/>
</dict>
</plist>
+24
View File
@@ -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
View File
@@ -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
View File
@@ -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,
+7 -2
View File
@@ -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
+3 -9
View File
@@ -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);
},
),
+30
View File
@@ -0,0 +1,30 @@
// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:como_gasto/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 917 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

+55
View File
@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
<meta name="description" content="A new Flutter project.">
<!-- iOS meta tags & icons -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="como_gasto">
<link rel="apple-touch-icon" href="icons/Icon-192.png">
<!-- Favicon -->
<link rel="shortcut icon" type="image/png" href="favicon.png"/>
<title>como_gasto</title>
<link rel="manifest" href="manifest.json">
<!-- Firebase App (the core Firebase SDK) is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/7.16.0/firebase-app.js"></script>
<!-- Add Firebase products that you want to use -->
<script src="https://www.gstatic.com/firebasejs/7.16.0/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.16.0/firebase-firestore.js"></script>
<script>
// Your web app's Firebase configuration
var firebaseConfig = {
apiKey: "AIzaSyCZt25YKH0FkBmV4NpcvmcNRwlRpGhazUc",
authDomain: "comogastoyt-bf4bb.firebaseapp.com",
databaseURL: "https://comogastoyt-bf4bb.firebaseio.com",
projectId: "comogastoyt-bf4bb",
storageBucket: "comogastoyt-bf4bb.appspot.com",
messagingSenderId: "173215752753",
appId: "1:173215752753:web:7bec11880a8a4c50906b10"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
</script>
<meta name="google-signin-client_id" content="173215752753-p598t2irnttla6j6j1lqpverrtomlccg.apps.googleusercontent.com">
</head>
<body>
<!-- This script installs service_worker.js to provide PWA functionality to
application. For more information, see:
https://developers.google.com/web/fundamentals/primers/service-workers -->
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', function () {
navigator.serviceWorker.register('flutter_service_worker.js');
});
}
</script>
<script src="main.dart.js" type="application/javascript"></script>
</body>
</html>
+23
View File
@@ -0,0 +1,23 @@
{
"name": "como_gasto",
"short_name": "como_gasto",
"start_url": ".",
"display": "standalone",
"background_color": "#0175C2",
"theme_color": "#0175C2",
"description": "A new Flutter project.",
"orientation": "portrait-primary",
"prefer_related_applications": false,
"icons": [
{
"src": "icons/Icon-192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "icons/Icon-512.png",
"sizes": "512x512",
"type": "image/png"
}
]
}