Skip to content

Commit

Permalink
Splash screen for IOS Added
Browse files Browse the repository at this point in the history
  • Loading branch information
theindianappguy committed Feb 8, 2020
1 parent d7eedae commit 7357a58
Show file tree
Hide file tree
Showing 13 changed files with 137 additions and 18 deletions.
1 change: 1 addition & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,5 @@ dependencies {
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.google.firebase:firebase-analytics:17.2.2'
api "androidx.core:core:1.1.0-alpha03"
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.theindianappguy.rest_app

import androidx.annotation.NonNull;
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugins.GeneratedPluginRegistrant
import io.flutter.app.FlutterFragmentActivity

class MainActivity: FlutterActivity() {
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
class MainActivity: FlutterFragmentActivity() {
fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
GeneratedPluginRegistrant.registerWith(flutterEngine);
}
}
8 changes: 4 additions & 4 deletions ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
"images" : [
{
"idiom" : "universal",
"filename" : "LaunchImage.png",
"filename" : "Group 3.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "LaunchImage@2x.png",
"filename" : "Group 3@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "LaunchImage@3x.png",
"filename" : "Group 3@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
16 changes: 10 additions & 6 deletions ios/Runner/Base.lproj/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16G29" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15705" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
Expand All @@ -14,12 +16,14 @@
<viewControllerLayoutGuide type="bottom" id="xbc-2k-c8Z"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" image="LaunchImage" translatesAutoresizingMaskIntoConstraints="NO" id="YRO-k0-Ey4">
<rect key="frame" x="109" y="377.5" width="196" height="141"/>
</imageView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="YRO-k0-Ey4" firstAttribute="centerX" secondItem="Ze5-6b-2t3" secondAttribute="centerX" id="1a2-6s-vTC"/>
<constraint firstItem="YRO-k0-Ey4" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="centerY" id="4X2-HB-R7a"/>
Expand All @@ -28,10 +32,10 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
<point key="canvasLocation" x="76.811594202898561" y="251.11607142857142"/>
</scene>
</scenes>
<resources>
<image name="LaunchImage" width="168" height="185"/>
<image name="LaunchImage" width="98" height="70.5"/>
</resources>
</document>
109 changes: 104 additions & 5 deletions lib/screens/authenticate/signin.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import 'dart:async';
import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:rest_app/screens/home.dart';
import 'package:rest_app/screens/authenticate/signup.dart';
import 'package:rest_app/services/auth_services.dart';
import 'package:local_auth/local_auth.dart';
import 'package:flutter/services.dart';

class SignIn extends StatefulWidget {

Expand All @@ -21,9 +19,68 @@ class _SignInState extends State<SignIn> {
final _formKey = GlobalKey<FormState>();
String email = "", password = "";

/// For Fingerprint & FaceId Local Auth
final LocalAuthentication _localAuthentication = LocalAuthentication();
String _authorizedOrNot = "Not Authorized";
List<BiometricType> _availableBiometricTypes = List<BiometricType>();
bool _canCheckBiometric = false;

bool _loading = false;
String error;

Future<void> checkBiometrics() async{
bool canCheckBiometric = false;
try {
canCheckBiometric = await _localAuthentication.canCheckBiometrics;
} on PlatformException catch (e) {
print(e);
}

if (!mounted) return;

setState(() {
_canCheckBiometric = canCheckBiometric;
});
}

Future<void> _getListOfBiometricTypes() async {
List<BiometricType> listofBiometrics;
try {
listofBiometrics = await _localAuthentication.getAvailableBiometrics();
} on PlatformException catch (e) {
print(e);
}

if (!mounted) return;

setState(() {
_availableBiometricTypes = listofBiometrics;
});
}

Future<void> _authorizeNow() async {
bool isAuthorized = false;
try {
isAuthorized = await _localAuthentication.authenticateWithBiometrics(
localizedReason: "Please authenticate to complete your transaction",
useErrorDialogs: true,
stickyAuth: true,
);
} on PlatformException catch (e) {
print(e);
}

if (!mounted) return;

setState(() {
if (isAuthorized) {
_authorizedOrNot = "Authorized";
} else {
_authorizedOrNot = "Not Authorized";
}
});
}

@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down Expand Up @@ -173,7 +230,22 @@ class _SignInState extends State<SignIn> {
color: Colors.white60
),),
SizedBox(height: 20,),
Image.asset("assets/fingerprint.png", height: 36, width: 36,),
GestureDetector(
onTap: () async {
checkBiometrics();
if(_canCheckBiometric){
await _authorizeNow();
if(_authorizedOrNot == "Authorized"){
_authService.signInAnom();
}else{
cantCheckBiometricsDialog(context);
}
}else{
cantCheckBiometricsDialog(context);
}
},
child: Image.asset("assets/fingerprint.png", height: 36, width: 36,)
),
SizedBox(height: 30,),
GestureDetector(
onTap: (){
Expand All @@ -199,5 +271,32 @@ class _SignInState extends State<SignIn> {
}
}

Future<void> cantCheckBiometricsDialog(BuildContext context) async {
return showDialog<void>(
context: context,
barrierDismissible: false, // user must tap button!
builder: (BuildContext context) {
return AlertDialog(
title: Text('No Biometrics Found'),
content: SingleChildScrollView(
child: ListBody(
children: <Widget>[
Text('Can not login with Biometrics'),
],
),
),
actions: <Widget>[
FlatButton(
child: Text('Ok'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
}



14 changes: 14 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,27 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
intl:
dependency: transitive
description:
name: intl
url: "https://pub.dartlang.org"
source: hosted
version: "0.16.1"
js:
dependency: transitive
description:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.1+1"
local_auth:
dependency: "direct main"
description:
name: local_auth
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.1"
matcher:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dependencies:
google_fonts: ^0.3.5
provider: ^4.0.2
firebase_auth: ^0.15.4
local_auth: ^0.6.1

# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
Expand Down

0 comments on commit 7357a58

Please sign in to comment.