initial for web
This commit is contained in:
+4
-4
@@ -27,13 +27,13 @@ class MyApp extends StatelessWidget {
|
||||
return MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider<ThemeState>(
|
||||
builder: (_) => ThemeState(),
|
||||
create: (_) => ThemeState(),
|
||||
),
|
||||
ChangeNotifierProvider<LoginState>(
|
||||
builder: (BuildContext context) => GetIt.instance(),
|
||||
create: (BuildContext context) => GetIt.instance(),
|
||||
),
|
||||
ProxyProvider<LoginState, ExpensesRepository>(
|
||||
builder: (_, LoginState value, __) {
|
||||
update: (_, LoginState value, __) {
|
||||
if (value.isLoggedIn()) {
|
||||
return ExpensesRepository(value
|
||||
.currentUser()
|
||||
@@ -73,7 +73,7 @@ class MyApp extends StatelessWidget {
|
||||
},
|
||||
routes: {
|
||||
'/': (BuildContext context) {
|
||||
var state = Provider.of<LoginState>(context);
|
||||
var state = Provider.of<LoginState>(context, listen: false);
|
||||
if (state.isLoggedIn()) {
|
||||
return HomePage();
|
||||
} else {
|
||||
|
||||
+25
-16
@@ -45,7 +45,9 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
|
||||
_localAth = LocalAuthentication();
|
||||
_localAth.canCheckBiometrics.then((b) async {
|
||||
var methods = await _localAth.getAvailableBiometrics();
|
||||
var hasFingerprint = Platform.isIOS ? methods.any((m) => m == BiometricType.fingerprint) : true;
|
||||
var hasFingerprint = Platform.isIOS
|
||||
? methods.any((m) => m == BiometricType.fingerprint)
|
||||
: true;
|
||||
|
||||
setState(() {
|
||||
_isBiometricAvailable = b && hasFingerprint;
|
||||
@@ -307,7 +309,9 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(
|
||||
buttonWidth * (1 - _buttonAnimation.value)),
|
||||
color: Theme.of(context).floatingActionButtonTheme.backgroundColor ?? Theme.of(context).primaryColor,
|
||||
color:
|
||||
Theme.of(context).floatingActionButtonTheme.backgroundColor ??
|
||||
Theme.of(context).primaryColor,
|
||||
),
|
||||
child: MaterialButton(
|
||||
onPressed: () {},
|
||||
@@ -329,7 +333,11 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
|
||||
right: 0,
|
||||
child: Builder(builder: (BuildContext context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(color: Theme.of(context).floatingActionButtonTheme.backgroundColor ?? Theme.of(context).primaryColor),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context)
|
||||
.floatingActionButtonTheme
|
||||
.backgroundColor ??
|
||||
Theme.of(context).primaryColor),
|
||||
child: MaterialButton(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
@@ -350,10 +358,12 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
|
||||
],
|
||||
),
|
||||
onPressed: () async {
|
||||
var db = Provider.of<ExpensesRepository>(context);
|
||||
var db =
|
||||
Provider.of<ExpensesRepository>(context, listen: false);
|
||||
if (value > 0 && category != "") {
|
||||
if (_isBiometricAvailable) {
|
||||
bool didAuthenticate = await _localAth.authenticateWithBiometrics(
|
||||
bool didAuthenticate =
|
||||
await _localAth.authenticateWithBiometrics(
|
||||
localizedReason: "Please identify yourself!",
|
||||
);
|
||||
if (didAuthenticate) {
|
||||
@@ -362,17 +372,16 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
content: Text(
|
||||
"You need to identify yourself."),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
child: Text('Ok'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
));
|
||||
content: Text("You need to identify yourself."),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
child: Text('Ok'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
));
|
||||
}
|
||||
} else {
|
||||
_saveAndBack(db);
|
||||
|
||||
@@ -18,7 +18,8 @@ class LoginState with ChangeNotifier {
|
||||
LoginState({
|
||||
@required SharedPreferences preferences,
|
||||
@required FirebaseAuth firebaseAuth,
|
||||
AuthenticationProviderFactory authenticationProviderFactory = const AuthenticationProviderFactory(),
|
||||
AuthenticationProviderFactory authenticationProviderFactory =
|
||||
const AuthenticationProviderFactory(),
|
||||
}) {
|
||||
_prefs = preferences;
|
||||
_auth = firebaseAuth;
|
||||
@@ -42,9 +43,10 @@ class LoginState with ChangeNotifier {
|
||||
var authCredentials = await _authenticationProvider.handleSignIn();
|
||||
|
||||
if (authCredentials != null) {
|
||||
_user = await _auth.signInWithCredential(
|
||||
authCredentials);
|
||||
|
||||
var authResult = await _auth.signInWithCredential(authCredentials);
|
||||
if (authResult != null) {
|
||||
_user = authResult.user;
|
||||
}
|
||||
if (_user != null) {
|
||||
print("signed in " + _user.displayName);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user