Skip to content

Commit

Permalink
update to flutter 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Yogabayu committed Jul 18, 2023
1 parent 87218f2 commit bd1c1d8
Show file tree
Hide file tree
Showing 10 changed files with 414 additions and 209 deletions.
7 changes: 4 additions & 3 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ apply plugin: 'com.google.gms.google-services'
}

android {
compileSdkVersion 31
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -51,8 +52,8 @@ apply plugin: 'com.google.gms.google-services'
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.yogadev.tracking"
minSdkVersion 20
targetSdkVersion 30
minSdkVersion 26
targetSdkVersion 33
versionCode 9
versionName "2.2.3"
}
Expand Down
8 changes: 4 additions & 4 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
buildscript {
ext.kotlin_version = '1.6.10'
ext.kotlin_version = '1.7.10'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.android.tools.build:gradle:7.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.google.gms:google-services:4.3.14'
}
}

Expand All @@ -27,6 +27,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
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-6.7-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
3 changes: 3 additions & 0 deletions lib/controller/tracking_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ class TrackingController extends GetxController {
},
);
if (response.statusCode == 200) {
// print(response.body);
// print(namaSVG);
// print(jKirim);
alamat = jsonDecode(response.body)['data']['detail']['destination'];
await SQLHelper.createItem(
receipt,
Expand Down
26 changes: 24 additions & 2 deletions lib/helper/sql_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,30 @@ class SQLHelper {
'namaSVG': namaSVG,
'jk': jk,
};
final id = await db.insert('items', data,
conflictAlgorithm: sql.ConflictAlgorithm.replace);
// final id = await db.insert('items', data,
// conflictAlgorithm: sql.ConflictAlgorithm.replace);
final id = await db.transaction<int>((txn) async {
final existingData = await txn.rawQuery(
'SELECT * FROM items WHERE receipt = ?',
[data['receipt']],
);

if (existingData.isNotEmpty) {
return -1; // Jika data dengan receipt yang sama sudah ada, kembalikan nilai -1
}

final rawQuery = '''
INSERT INTO items(receipt, alamat, namaSVG, jk)
VALUES(?, ?, ?, ?)
''';
final values = [
data['receipt'],
data['alamat'],
data['namaSVG'],
data['jk'],
];
return await txn.rawInsert(rawQuery, values);
});

return id;
}
Expand Down
132 changes: 106 additions & 26 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// ignore_for_file: import_of_legacy_library_into_null_safe

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:splashscreen/splashscreen.dart';
import 'package:tracking/view/dashboard.dart';

void main() {
Expand All @@ -18,32 +19,111 @@ class MyApp extends StatelessWidget {
return GetMaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData.light(),
home: SplashScreen(
loadingText: new Text(
'Developed by Yoga Dev.',
textAlign: TextAlign.center,
style: GoogleFonts.roboto(
fontWeight: FontWeight.bold,
fontSize: 12.0,
color: Color.fromARGB(255, 5, 78, 94),
),
),
seconds: 4,
navigateAfterSeconds: Dashboard(),
title: new Text(
'PaketKU',
textAlign: TextAlign.center,
style: GoogleFonts.roboto(
fontWeight: FontWeight.bold,
fontSize: 30.0,
color: Color.fromARGB(255, 246, 142, 37),
),
home: Splash(),
// home: SplashScreen(
// loadingText: new Text(
// 'Developed by Yoga Dev.',
// textAlign: TextAlign.center,
// style: GoogleFonts.roboto(
// fontWeight: FontWeight.bold,
// fontSize: 12.0,
// color: Color.fromARGB(255, 5, 78, 94),
// ),
// ),
// seconds: 4,
// navigateAfterSeconds: Dashboard(),
// title: new Text(
// 'PaketKU',
// textAlign: TextAlign.center,
// style: GoogleFonts.roboto(
// fontWeight: FontWeight.bold,
// fontSize: 30.0,
// color: Color.fromARGB(255, 246, 142, 37),
// ),
// ),
// image: new Image.asset('assets/image/logo1.png'),
// photoSize: 100.0,
// backgroundColor: Color.fromARGB(255, 255, 255, 255),
// styleTextUnderTheLoader: new TextStyle(),
// loaderColor: Color.fromARGB(255, 246, 142, 37),
// ),
);
}
}

class Splash extends StatefulWidget {
const Splash({Key? key}) : super(key: key);

@override
_SplashState createState() => _SplashState();
}

class _SplashState extends State<Splash> {
void startTimeout() {
Timer(Duration(seconds: 2), handleTimeout);
}

void handleTimeout() {
changeScreen();
}

void changeScreen() {
Get.offAll(
Dashboard(),
transition: Transition.fadeIn,
duration: Duration(seconds: 1),
);
}

@override
void initState() {
super.initState();
startTimeout();
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: 100,
height: 100,
child: Image.asset('assets/image/logo1.png'),
),
Text(
'PaketKU',
textAlign: TextAlign.center,
style: GoogleFonts.roboto(
fontWeight: FontWeight.bold,
fontSize: 30.0,
color: Color.fromARGB(255, 246, 142, 37),
),
),
Text(
'Developed by Yoga Dev.',
textAlign: TextAlign.center,
style: GoogleFonts.roboto(
fontWeight: FontWeight.bold,
fontSize: 12.0,
color: Color.fromARGB(255, 5, 78, 94),
),
),
SizedBox(
height: 50,
),
SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(
color: Color.fromARGB(255, 246, 142, 37),
),
),
],
),
image: new Image.asset('assets/image/logo1.png'),
photoSize: 100.0,
backgroundColor: Color.fromARGB(255, 255, 255, 255),
styleTextUnderTheLoader: new TextStyle(),
loaderColor: Color.fromARGB(255, 246, 142, 37),
),
);
}
Expand Down
2 changes: 2 additions & 0 deletions lib/view/dashboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class _DashboardState extends State<Dashboard> {
setState(() {
_journals = data;
});

print(_journals);
}

void _deleteItem(int id) async {
Expand Down
2 changes: 1 addition & 1 deletion lib/view/tracking.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class _Tracking2State extends State<Tracking2> {
@override
void initState() {
super.initState();
print(widget.jk);
// print(widget.jk);
futureReceipt = controller.fetchData("${widget.receipt}", "${widget.jk}");
}

Expand Down
Loading

0 comments on commit bd1c1d8

Please sign in to comment.