Skip to content

Commit

Permalink
Merge pull request #24 from nuilewis/main
Browse files Browse the repository at this point in the history
Added Splash Screen with Permission and Location Service handling
  • Loading branch information
DSCUBa2020 committed Apr 23, 2021
2 parents 4e929a2 + 341e237 commit 9ca3034
Show file tree
Hide file tree
Showing 12 changed files with 370 additions and 35 deletions.
2 changes: 2 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ android {
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
vectorDrawables.useSupportLibrary = true

}


Expand Down
11 changes: 6 additions & 5 deletions android/app/src/main/res/drawable-v21/launch_background.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="?android:colorBackground" />
<item android:drawable="@android:color/white" />

<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
<item

android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
android:drawable="@drawable/flow_logo_svg">
</item>

</layer-list>
18 changes: 18 additions & 0 deletions android/app/src/main/res/drawable/flow_logo_svg.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="200dp"
android:height="200dp"
android:viewportWidth="200"
android:viewportHeight="200">
<path
android:pathData="M175.39,95.81l-5.5,18.87L159.78,83.77H146.5l-10.12,30.94L130.87,96a17,17 0,0 0,-16.34 -12.22h-2.4L129.61,138H142.7l10.2,-31.69L163.18,138h13.19l17.47,-54.19h-2.4A16.73,16.73 0,0 0,175.39 95.81Z"
android:fillColor="#12a4ef"/>
<path
android:pathData="M114.64,119.92c0,11 -9.48,20 -21.06,19.68 -10.84,-0.28 -19.67,-8.79 -19.92,-19.2a19,19 0,0 1,2.56 -10l0.33,-0.55 0.07,-0.11L91.24,85.38a3.4,3.4 0,0 1,5.81 0l14.62,24.34 0.07,0.11 0.33,0.55A19,19 0,0 1,114.64 119.92Z"
android:fillColor="#12a4ef"/>
<path
android:pathData="M82.49,109.82a14.79,14.79 0,0 1,-0.57 2.36l-0.36,1.11 -0.16,0.53 -0.15,0.53a28.7,28.7 0,0 0,-0.85 4.18,20.36 20.36,0 0,0 -0.15,2.08c0,0.35 0,0.7 0,1.06s0,0.71 0,1.07c0,0.72 0.11,1.45 0.21,2.21s0.22,1.52 0.33,2.35a8.9,8.9 0,0 1,-2.91 -4.08,10.87 10.87,0 0,1 -0.57,-5A11.88,11.88 0,0 1,79 113.42c0.23,-0.35 0.48,-0.7 0.74,-1s0.55,-0.62 0.83,-0.92A15.85,15.85 0,0 1,82.49 109.82Z"
android:fillColor="#fff"/>
<path
android:pathData="M64.47,74.81V138H50.05V64a0.11,0.11 0,0 0,-0.22 0A13.83,13.83 0,0 1,36.46 74.22H34.71a4.49,4.49 0,0 0,-3.48 1.49,6.37 6.37,0 0,0 -1.47,4.48v3.59h12.8v0.82a12.8,12.8 0,0 1,-12.8 12.79V138H15.35V97.39H6.16V83.78h9.19V79.29a18.23,18.23 0,0 1,5.44 -13.66,17.48 17.48,0 0,1 2.27,-1.87 19.65,19.65 0,0 1,11.49 -3.37H50.29A14.42,14.42 0,0 1,64.46 74.22C64.47,74.41 64.47,74.61 64.47,74.81Z"
android:fillColor="#12a4ef"/>
</vector>
9 changes: 8 additions & 1 deletion android/app/src/main/res/drawable/launch_background.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@

<item>
<bitmap
android:antialias="true"
android:gravity="center"
android:src="@mipmap/flow_logo" />
android:src="@drawable/flow_logo" />
</item>
<item>
<bitmap
android:antialias="true"
android:gravity="bottom"
android:src="@drawable/flow_splash" />
</item>
</layer-list>
2 changes: 1 addition & 1 deletion android/app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="background_color">#12A4EF</color>color>
<color name="background_color">#12A4EF</color>
</resources>
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.android.tools.build:gradle:4.1.2'
classpath 'com.google.gms:google-services:4.3.5'
}
}
Expand Down
33 changes: 33 additions & 0 deletions lib/Components/Permissions.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import 'dart:core';
import 'package:flutter/material.dart';
import 'package:location/location.dart';

Location location = Location();
PermissionStatus permissionStatus;
bool serviceEnabled;

///Checking if location service is enabled
Future<bool> checkServiceEnabled() async {
serviceEnabled = await location.serviceEnabled();
return serviceEnabled;
}

// requestServiceEnabled() async {
// if (!serviceEnabled) {
// serviceEnabled = await location.requestService();
// }
// }
requestServiceEnabled() async {
serviceEnabled = await location.requestService();
}

///Checking if location permsissions have been granted
Future<PermissionStatus> getPermissionStatus() async {
permissionStatus = await location.hasPermission();

return permissionStatus;
}

requestPermissions() async {
permissionStatus = await location.requestPermission();
}
106 changes: 106 additions & 0 deletions lib/Screens/FlowAskEnableLocationScreen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import 'package:flow/constants.dart';
import 'package:flutter/material.dart';
import 'package:flow/Components/Permissions.dart';

class FlowAskEnableLocation extends StatefulWidget {
@override
_FlowAskEnableLocationState createState() => _FlowAskEnableLocationState();
}

class _FlowAskEnableLocationState extends State<FlowAskEnableLocation> {
@override
Widget build(BuildContext context) {
screenWidth = MediaQuery.of(context).size.width;
screenHeight = MediaQuery.of(context).size.width;
return Scaffold(
backgroundColor: Colors.white,
body: SafeArea(
child: Column(
children: [
Spacer(),

/// Image and text Area
Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: screenWidth * .2),
child: Image(
image: AssetImage('Assets/images/placeholder_image.png'),
),
),
SizedBox(height: 20),
// Padding(
// padding: EdgeInsets.symmetric(horizontal: screenWidth * .1),
// child: Text(
// 'Flow needs access to your location for certain features to work properly',
// textAlign: TextAlign.center,
// style: TextStyle(
// color: Colors.white,
// fontSize: 16,
// ),
// ),
// ),
SizedBox(height: 20),
Padding(
padding: EdgeInsets.symmetric(horizontal: screenWidth * .1),
child: Text(
'It seems your location isn\'t turned on',
textAlign: TextAlign.center,
style: TextStyle(
color: primarycolor,
fontWeight: FontWeight.bold,
fontSize: 18,
),
),
),
SizedBox(
height: 10,
),
],
),

///Allow Permissions Buttons
Container(
width: double.infinity,
margin: const EdgeInsets.all(20),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30),
color: primarycolor,
),
// ignore: deprecated_member_use
child: FlatButton(
child: HeadlineTextBold(
title: 'Turn it on',
color: Colors.white,
),
onPressed: () {
WidgetsBinding.instance.addPostFrameCallback((_) {
Navigator.of(context).pop(requestServiceEnabled());
});
},
),
),
SizedBox(
height: 5,
),
// ignore: deprecated_member_use
FlatButton(
onPressed: () {
WidgetsBinding.instance.addPostFrameCallback((_) {
Navigator.of(context).pop();
});
},
color: Colors.transparent,
child: HeadlineText(
title: 'Leave off',
color: primarycolor,
),
),
Spacer(),
],
),
),
);
}
}
101 changes: 101 additions & 0 deletions lib/Screens/FlowAskPermissionsScreen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import 'package:flow/constants.dart';
import 'package:flutter/material.dart';
import 'package:flow/Components/Permissions.dart';

class FlowAskPermissions extends StatefulWidget {
@override
_FlowAskPermissionsState createState() => _FlowAskPermissionsState();
}

class _FlowAskPermissionsState extends State<FlowAskPermissions> {
@override
Widget build(BuildContext context) {
screenWidth = MediaQuery.of(context).size.width;
screenHeight = MediaQuery.of(context).size.width;
return Scaffold(
backgroundColor: primarycolor,
body: SafeArea(
child: Column(
children: [
Spacer(),

/// Image and text Area
Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: screenWidth * .2),
child: Image(
image:
AssetImage('Assets/images/placeholder_image_white.png'),
),
),
SizedBox(height: 20),
Padding(
padding: EdgeInsets.symmetric(horizontal: screenWidth * .1),
child: Text(
'Flow needs access to your location for certain features to work properly',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontSize: 16,
),
),
),
SizedBox(height: 20),
Padding(
padding: EdgeInsets.symmetric(horizontal: screenWidth * .1),
child: HeadlineTextBold(
title: 'Allow Flow to access your location?',
color: Colors.white),
),
SizedBox(
height: 10,
),
],
),

///Allow Permissions Buttons
Container(
width: double.infinity,
margin: const EdgeInsets.all(20),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30),
color: Colors.white,
),
// ignore: deprecated_member_use
child: FlatButton(
child: HeadlineTextBold(
title: 'Allow Permissions',
color: primarycolor,
),
onPressed: () {
WidgetsBinding.instance.addPostFrameCallback((_) {
Navigator.of(context).pop(requestPermissions());
});
},
),
),
SizedBox(
height: 5,
),
// ignore: deprecated_member_use
FlatButton(
onPressed: () {
WidgetsBinding.instance.addPostFrameCallback((_) {
Navigator.of(context).pop();
});
},
color: Colors.transparent,
child: HeadlineText(
title: 'Deny',
color: Colors.white,
),
),
Spacer(),
],
),
),
);
}
}

0 comments on commit 9ca3034

Please sign in to comment.