Skip to content

Commit

Permalink
August update (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
iqfareez authored Aug 4, 2021
1 parent aa5fa40 commit 367017a
Show file tree
Hide file tree
Showing 54 changed files with 1,834 additions and 1,224 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,8 @@ app.*.map.json
# key file
key.properties

#scratch file
# secret file
SECRETS.dart

# scratch file
scratch.dart
30 changes: 30 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
file_names: false
# library_prefixes: false
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
13 changes: 1 addition & 12 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@ android {

defaultConfig {
applicationId "live.iqfareez.waktusolatmalaysia"
minSdkVersion 16
minSdkVersion 19
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true

}

signingConfigs {
Expand All @@ -70,15 +69,5 @@ flutter {
}

dependencies {
// Import the Firebase BoM
// implementation platform('com.google.firebase:firebase-bom:26.1.1')

// Add the dependency for the Firebase SDK for Google Analytics
// When using the BoM, don't specify versions in Firebase dependencies
// implementation 'com.google.firebase:firebase-analytics'
implementation 'androidx.multidex:multidex:2.0.1'


// Add the dependencies for any other desired Firebase products
// https://firebase.google.com/docs/android/setup#available-libraries
}
8 changes: 6 additions & 2 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,17 @@
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
android:resource="@drawable/launch_background"/>

<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- AdMob App ID -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-1896379146653594~4724495912"/>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
Expand Down
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:3.5.0'
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.google.gms:google-services:4.3.4'
}
}
Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
1 change: 1 addition & 0 deletions android/settings_aar.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ':app'
4 changes: 4 additions & 0 deletions lib/CONSTANTS.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ const kDiscoveredDeveloperOption = "storedDevDiscovered";
const kSharingFormat = "storedSharingFormat";
const kFontSize = "storedFontSize";
const kHijriOffset = "storedHijriOffset";
const kJsonCache = "jsonCache";
const kAppLaunchCount = "appLaunchCount";
const kHasOpenSharingDialog = "openedSharedDialog";
const kShowNotifPrompt = "notifPrompt";

//Network image
const kAppIconUrl =
Expand Down
18 changes: 6 additions & 12 deletions lib/locationUtil/LocationData.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,12 @@ class LocationData {
static Position _position;

static Future<Position> getCurrentLocation() async {
try {
Position position = await Geolocator.getCurrentPosition(
desiredAccuracy:
LocationAccuracy.low); //on Android, low is in 500m radius
_position = position;
print('[LocationData] Sucess getting $position');
return position;
} catch (e) {
print('[LocationData] Error is $e');
throw 'Error occured: $e';
}
Position position = await Geolocator.getCurrentPosition(
desiredAccuracy:
LocationAccuracy.low); //on Android, low is in 500m radius
_position = position;
return position;
}

static get position => _position;
static Position get position => _position;
}
3 changes: 1 addition & 2 deletions lib/locationUtil/locationDatabase.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import 'location.dart';

class LocationDatabase {
static List<Location> _locationDatabase = [
static final List<Location> _locationDatabase = [
//JOHOR
Location(
jakimCode: 'JHR01',
Expand Down Expand Up @@ -387,7 +387,6 @@ class LocationDatabase {
var jakimCaps = jakimCode.toUpperCase();
var index = _locationDatabase
.indexWhere((element) => element.jakimCode == jakimCaps);
print('index of $jakimCaps is at $index');
return index;
}

Expand Down
3 changes: 1 addition & 2 deletions lib/locationUtil/location_coordinate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:geolocator/geolocator.dart';
import 'location_coordinate_model.dart';

class LocationCoordinate {
static List<LocationCoordinateData> _locationCoordinate = [
static final List<LocationCoordinateData> _locationCoordinate = [
LocationCoordinateData(
zone: "JHR01",
negeri: "Johor",
Expand Down Expand Up @@ -1563,7 +1563,6 @@ class LocationCoordinate {
tempIndex.add(i);
}
}
print('tempIndex is $tempIndex');

for (var index in tempIndex) {
// calculate distance each of indexes location with user location
Expand Down
1 change: 0 additions & 1 deletion lib/locationUtil/location_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class LocationProvider with ChangeNotifier {
int _currentLocationIndex = GetStorage().read(kStoredGlobalIndex);

set currentLocationIndex(int value) {
print('inside provider: $value');
_currentLocationIndex = value;
GetStorage().write(kStoredGlobalIndex, value);
notifyListeners();
Expand Down
50 changes: 38 additions & 12 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import 'package:flutter/services.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:get_storage/get_storage.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:google_mobile_ads/google_mobile_ads.dart';
import 'package:in_app_review/in_app_review.dart';
import 'package:provider/provider.dart';
import 'package:timezone/data/latest.dart' as tz;
import 'package:timezone/timezone.dart' as tz;
Expand All @@ -18,27 +20,35 @@ import 'views/bottomAppBar.dart';
import 'views/onboarding_page.dart';

NotificationAppLaunchDetails notifLaunch;
final FlutterLocalNotificationsPlugin notifsPlugin =
FlutterLocalNotificationsPlugin();

void main() async {
WidgetsFlutterBinding.ensureInitialized();

await GetStorage.init();
await Firebase.initializeApp();
MobileAds.instance.initialize();

final FlutterLocalNotificationsPlugin notifsPlugin =
FlutterLocalNotificationsPlugin();
await _configureLocalTimeZone();
notifLaunch = await notifsPlugin.getNotificationAppLaunchDetails();
await initNotifications(notifsPlugin);
// requestIOSPermissions(notifsPlugin);

await Firebase.initializeApp();
initGetStorage();
// readAllGetStorage();
/// Increment app launch counter
GetStorage().write(kAppLaunchCount, GetStorage().read(kAppLaunchCount) + 1);

SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.light);

runApp(MyApp());
runApp(const MyApp());

showReviewPrompt();
}

class MyApp extends StatelessWidget {
const MyApp({Key key}) : super(key: key);
final _primaryColour = Colors.teal;

@override
Expand Down Expand Up @@ -68,10 +78,9 @@ class MyApp extends StatelessWidget {
visualDensity: VisualDensity.adaptivePlatformDensity,
appBarTheme: AppBarTheme(color: _primaryColour.shade800)),
themeMode: value.themeMode,
// home: OnboardingPage(),
home: GetStorage().read(kIsFirstRun)
? OnboardingPage()
: MyHomePage(),
? const OnboardingPage()
: const MyHomePage(),
);
},
),
Expand All @@ -80,6 +89,8 @@ class MyApp extends StatelessWidget {
}

class MyHomePage extends StatelessWidget {
const MyHomePage({Key key}) : super(key: key);

@override
Widget build(BuildContext context) {
return Scaffold(
Expand All @@ -92,17 +103,19 @@ class MyHomePage extends StatelessWidget {
centerTitle: true,
toolbarHeight: 50,
),
bottomNavigationBar: MyBottomAppBar(),
floatingActionButton: ShareFAB(),
floatingActionButtonLocation: FloatingActionButtonLocation.endDocked,
body: SingleChildScrollView(child: AppBody()),
bottomNavigationBar: const MyBottomAppBar(),
floatingActionButton: const ShareFAB(),
floatingActionButtonLocation: FloatingActionButtonLocation.miniEndDocked,
body: const SingleChildScrollView(child: AppBody()),
);
}
}

void initGetStorage() {
// init default settings
GetStorage _get = GetStorage();
_get.writeIfNull(kShowNotifPrompt, true);
_get.writeIfNull(kAppLaunchCount, 0);
_get.writeIfNull(kIsFirstRun, true);
_get.writeIfNull(kStoredGlobalIndex, 0);
_get.writeIfNull(kStoredTimeIs12, true);
Expand All @@ -121,10 +134,11 @@ void initGetStorage() {
Future<void> _configureLocalTimeZone() async {
// use for notification
tz.initializeTimeZones();
final String timeZoneName = 'Asia/Kuala_Lumpur';
const String timeZoneName = 'Asia/Kuala_Lumpur';
tz.setLocalLocation(tz.getLocation(timeZoneName));
}

// ignore_for_file: avoid_print
void readAllGetStorage() {
// print (almost) all GetStorage item to the console
print("-----All GET STORAGE-----");
Expand All @@ -143,3 +157,15 @@ void readAllGetStorage() {
'kDiscoveredDeveloperOption is ${_get.read(kDiscoveredDeveloperOption)}');
print('-----------------------');
}

/// Show InAppReview if all conditions are met
void showReviewPrompt() async {
final InAppReview inAppReview = InAppReview.instance;

int _appLaunchCount = GetStorage().read(kAppLaunchCount);

if (_appLaunchCount == 10 && await inAppReview.isAvailable()) {
await Future.delayed(const Duration(seconds: 2));
inAppReview.requestReview();
}
}
Loading

0 comments on commit 367017a

Please sign in to comment.