Parcourir la source

tambah bunit

master
jefry il y a 4 ans
Parent
révision
9c7e5d5705
5 fichiers modifiés avec 112 ajouts et 60 suppressions
  1. +2
    -0
      android/app/src/main/AndroidManifest.xml
  2. +4
    -0
      android/app/src/main/res/xml/network_security_config.xml
  3. +1
    -1
      android/build.gradle
  4. +1
    -1
      android/gradle/wrapper/gradle-wrapper.properties
  5. +104
    -58
      lib/home.dart

+ 2
- 0
android/app/src/main/AndroidManifest.xml Voir le fichier

@@ -9,6 +9,8 @@
<application
android:name="io.flutter.app.FlutterApplication"
android:label="assetstock"
android:usesCleartextTraffic="true"
android:networkSecurityConfig="@xml/network_security_config"
android:icon="@mipmap/launcher_icon">
<activity
android:name=".MainActivity"


+ 4
- 0
android/app/src/main/res/xml/network_security_config.xml Voir le fichier

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>

+ 1
- 1
android/build.gradle Voir le fichier

@@ -6,7 +6,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.android.tools.build:gradle:4.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}


+ 1
- 1
android/gradle/wrapper/gradle-wrapper.properties Voir le fichier

@@ -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

+ 104
- 58
lib/home.dart Voir le fichier

@@ -216,62 +216,103 @@ class _HomeState extends State<Home> {
children: [
InkWell(
onTap: ()async{
// await Future.delayed(Duration(milliseconds: 300));
String Address = prefs.getString(keyClass.hostAddress);
// await Future.delayed(Duration(milliseconds: 300));
util.showLoading(context,dissmissable: false);
var result = await util.JsonDataPostRaw({}, "${Address??"https://asset.thamringroup.web.id"}/admin/getDbList");
var bUnits = await util.JsonDataPostRaw({}, "${Address??"https://asset.thamringroup.web.id"}/admin/getBisnisList");
Navigator.pop(context);
if(result['STATUS']==1){
bool isClear = await clearData(context);
if(isClear??false){
String selected = result['DATA'][0];
bool res =await showDialog(context: context,builder: (context)=>StatefulBuilder(
builder: (context,setState)=>AlertDialog(
title: Text('Pick Database'),
content: DropdownButtonFormField(
onChanged: (value){
setState(() {
selected = value;
});
if(bUnits["STATUS"]==1){
var selectedBisnis= bUnits["DATA"][0]["id"];
var bisnisPicked = await showDialog(context: context,builder: (context)=>StatefulBuilder(
builder: (context,setState)=>AlertDialog(
title: Text('Pick Bisnis Unit'),
content: DropdownButtonFormField(
onChanged: (value)async{
setState(() {
selectedBisnis = value;
});
},
value: selectedBisnis,
items: new List<DropdownMenuItem<dynamic>>.from(bUnits['DATA'].map((value){
String showText = value["name"];
if(showText.length>30) showText = showText.substring(0,30);
return DropdownMenuItem(
child: Text(showText),
value: value["id"],
);
})),
),
actions: <Widget>[
FlatButton(
onPressed: ()async{
Navigator.pop(context,true);
},
value: selected,
items: new List<DropdownMenuItem<dynamic>>.from(result['DATA'].map((value){
String showText = value;
if(showText.length>30) showText = showText.substring(0,30);
return DropdownMenuItem(
child: Text(showText),
value: value,
);
})),
child: Text('Next'),
),
actions: <Widget>[
FlatButton(
onPressed: ()async{
Navigator.pop(context,true);
},
child: Text('Get'),
FlatButton(
onPressed: ()async{
Navigator.pop(context,false);
},
child: Text('Cancel'),
)
],
),
));
if(bisnisPicked??false){
util.showLoading(context,dissmissable: false);
var result = await util.JsonDataPostRaw({"bUnit":selectedBisnis}, "${Address??"https://asset.thamringroup.web.id"}/admin/getDbList");
Navigator.pop(context);
if(result['STATUS']==1){
bool isClear = await clearData(context);
if(isClear??false){
String selected = result['DATA'][0]["fullName"];
bool res =await showDialog(context: context,builder: (context)=>StatefulBuilder(
builder: (context,setState)=>AlertDialog(
title: Text('Pick Database'),
content: DropdownButtonFormField(
onChanged: (value){
setState(() {
selected = value;
});
},
value: selected,
items: new List<DropdownMenuItem<dynamic>>.from(result['DATA'].map((value){
String showText = value["name"];
if(showText.length>30) showText = showText.substring(0,30);
return DropdownMenuItem(
child: Text(showText),
value: value["fullName"],
);
})),
),
actions: <Widget>[
FlatButton(
onPressed: ()async{
Navigator.pop(context,true);
},
child: Text('Get'),
),
FlatButton(
onPressed: ()async{
Navigator.pop(context,false);
},
child: Text('Cancel'),
)
],
),
FlatButton(
onPressed: ()async{
Navigator.pop(context,false);
},
child: Text('Cancel'),
)
],
),
));
if(res??false){
));
if(res??false){
// util.showLoading(context,dissmissable: false);
await prefs.setString(keyClass.dbName,selected);
file_Trans_Handler trans = new file_Trans_Handler();
await trans.downloadFile("assets.db", "${Address??"https://asset.thamringroup.web.id"}/admin/downloadDb/$selected");
_dlulStream = trans.progress.listen((value)async {
setState(() {
progressDL = (value!=-1.0)?value:null;
});
if(value!=null&&value >= 1.0) {
_dlulStream.cancel();
progressDL = null;
await prefs.setString(keyClass.dbName,selected);
file_Trans_Handler trans = new file_Trans_Handler();
await trans.downloadFile("assets.db", "${Address??"https://asset.thamringroup.web.id"}/admin/downloadDb/$selectedBisnis/$selected");
_dlulStream = trans.progress.listen((value)async {
setState(() {
progressDL = (value!=-1.0)?value:null;
});
if(value!=null&&value >= 1.0) {
_dlulStream.cancel();
progressDL = null;
// setState(() {
// lastDownload = DateTime.now().toIso8601String();
// });
@@ -281,21 +322,26 @@ class _HomeState extends State<Home> {
// await DBHelper.database.closeDb();
// var allUnits = await DBHelper.database.getAllAsset();
// print('${allUnits.length} Units');
util.showToast('ALERT','Data Downloaded');
}
if(value==-1.0){
util.showToast('ALERT','Data Error ${trans.error}');
}
});
util.showToast('ALERT','Data Downloaded');
}
if(value==-1.0){
util.showToast('ALERT','Data Error ${trans.error}');
}
});
// Navigator.pop(context);
setState(() {
setState(() {

});
});
}
}
}
else{
await util.showToast("ERROR",result['ERROR']??"Database tidak ditemukan");
}
}
}
else{
await util.showToast("ERROR",result['ERROR']);
await util.showToast("ERROR",bUnits['DATA']);
}
},
child: Padding(


Chargement…
Annuler
Enregistrer