Compare commits
2 Commits
main
...
step/impro
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b3c9ac534d | ||
|
|
e7685e8576 |
@@ -52,7 +52,6 @@ android {
|
|||||||
targetSdkVersion flutter.targetSdkVersion
|
targetSdkVersion flutter.targetSdkVersion
|
||||||
versionCode flutterVersionCode.toInteger()
|
versionCode flutterVersionCode.toInteger()
|
||||||
versionName flutterVersionName
|
versionName flutterVersionName
|
||||||
multiDexEnabled true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
@@ -70,5 +69,4 @@ flutter {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||||
implementation 'com.android.support:multidex:1.0.3'
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,8 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
|
||||||
<application
|
<application
|
||||||
android:label="PettyCash"
|
android:label="app_petty_cash"
|
||||||
android:name="${applicationName}"
|
android:name="${applicationName}"
|
||||||
android:icon="@mipmap/launcher_icon"
|
android:icon="@mipmap/ic_launcher">
|
||||||
android:usesCleartextTraffic="true"
|
|
||||||
android:requestLegacyExternalStorage="true"
|
|
||||||
>
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
@@ -16,9 +10,7 @@
|
|||||||
android:theme="@style/LaunchTheme"
|
android:theme="@style/LaunchTheme"
|
||||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
||||||
android:hardwareAccelerated="true"
|
android:hardwareAccelerated="true"
|
||||||
android:windowSoftInputMode="adjustResize"
|
android:windowSoftInputMode="adjustResize">
|
||||||
android:screenOrientation="portrait"
|
|
||||||
>
|
|
||||||
<!-- Specifies an Android theme to apply to this Activity as soon as
|
<!-- Specifies an Android theme to apply to this Activity as soon as
|
||||||
the Android process has started. This theme is visible to the user
|
the Android process has started. This theme is visible to the user
|
||||||
while the Flutter UI initializes. After that, this theme continues
|
while the Flutter UI initializes. After that, this theme continues
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 7.8 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 20 KiB |
@@ -1,5 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<external-path name="external_storage_directory" path="." />
|
<external-path name="external_storage_directory" path="." />
|
||||||
<external-path name="external_files" path="."/>
|
|
||||||
</resources>
|
</resources>
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
<network-security-config>
|
|
||||||
<base-config cleartextTrafficPermitted="true">
|
|
||||||
<trust-anchors>
|
|
||||||
<certificates src="system" />
|
|
||||||
</trust-anchors>
|
|
||||||
</base-config>
|
|
||||||
</network-security-config>
|
|
||||||
|
Before Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 99 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 167 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 880 B After Width: | Height: | Size: 295 B |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 406 B |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 450 B |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 282 B |
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 462 B |
|
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 704 B |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 406 B |
|
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 586 B |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 862 B |
|
Before Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 8.4 KiB |
|
Before Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 862 B |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 762 B |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 1.4 KiB |
@@ -10,10 +10,7 @@ class Constant {
|
|||||||
static double designWidthPhone = 390;
|
static double designWidthPhone = 390;
|
||||||
|
|
||||||
static String bearerName = "petty-cash";
|
static String bearerName = "petty-cash";
|
||||||
// static String version = "1.00";
|
static String version = "1.00";
|
||||||
|
|
||||||
// NOTE VERSI HARUS SAMA DENGAN PUBSPEC.YAML
|
|
||||||
static String version = "1.2.0";
|
|
||||||
|
|
||||||
// static String baseUrl = "https://devregonline.pramita.co.id/one-api/xdoc/";
|
// static String baseUrl = "https://devregonline.pramita.co.id/one-api/xdoc/";
|
||||||
|
|
||||||
@@ -21,10 +18,7 @@ class Constant {
|
|||||||
static String baseUrlDevoneReport = "devone.aplikasi.web.id";
|
static String baseUrlDevoneReport = "devone.aplikasi.web.id";
|
||||||
|
|
||||||
static String baseUrlDevone =
|
static String baseUrlDevone =
|
||||||
"https://devone.aplikasi.web.id/one-api-pettycash/pettycash/";
|
"http://devone.aplikasi.web.id/one-api-pettycash/pettycash/";
|
||||||
// "http://devone.aplikasi.web.id/one-api-pettycash/pettycash/";
|
|
||||||
static String baseUrlFile =
|
|
||||||
"https://devone.aplikasi.web.id/pettycash-media/attachment/";
|
|
||||||
|
|
||||||
// static String baseUrl_appdoctor =
|
// static String baseUrl_appdoctor =
|
||||||
// "http://devbandungraya.aplikasi.web.id/one-api/app_doctor/";
|
// "http://devbandungraya.aplikasi.web.id/one-api/app_doctor/";
|
||||||
@@ -288,13 +282,6 @@ class Constant {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static TextStyle titleH6_700({required BuildContext context}) {
|
|
||||||
return TextStyle(
|
|
||||||
fontSize: Constant.getActualYPhone(context: context, y: 18),
|
|
||||||
fontWeight: FontWeight.w700,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TextStyle titleH3_700({required BuildContext context}) {
|
static TextStyle titleH3_700({required BuildContext context}) {
|
||||||
return TextStyle(
|
return TextStyle(
|
||||||
fontSize: Constant.getActualYPhone(context: context, y: 24),
|
fontSize: Constant.getActualYPhone(context: context, y: 24),
|
||||||
@@ -366,13 +353,6 @@ class Constant {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static TextStyle H4_700V3({required BuildContext context}) {
|
|
||||||
return TextStyle(
|
|
||||||
fontSize: Constant.getActualYPhone(context: context, y: 16),
|
|
||||||
fontWeight: FontWeight.w700,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TextStyle titleH5({required BuildContext context}) {
|
static TextStyle titleH5({required BuildContext context}) {
|
||||||
return TextStyle(
|
return TextStyle(
|
||||||
fontSize: Constant.getActualYPhone(context: context, y: 18),
|
fontSize: Constant.getActualYPhone(context: context, y: 18),
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
import '../screen/change_company/change_company.dart';
|
import '../screen/change_company/change_company.dart';
|
||||||
import 'package:app_petty_cash/screen/camera/coba_camera.dart';
|
|
||||||
import 'package:app_petty_cash/screen/camera/example.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../screen/change_password/change_password_screen.dart';
|
|
||||||
import '../screen/home/home_screen.dart';
|
import '../screen/home/home_screen.dart';
|
||||||
import '../screen/transaksi/history_transaksi_screen.dart';
|
import '../screen/transaksi/history_transaksi_screen.dart';
|
||||||
import '../screen/transaksi/transaksi_screen.dart';
|
import '../screen/transaksi/transaksi_screen.dart';
|
||||||
@@ -22,30 +19,12 @@ const userRoute = "/userRoute";
|
|||||||
const reportRoute = "/reportRoute";
|
const reportRoute = "/reportRoute";
|
||||||
const changeCompanyRoute = "/changeCompanyRoute";
|
const changeCompanyRoute = "/changeCompanyRoute";
|
||||||
const historyTransaksiRoute = "/historyTransaksiRoute";
|
const historyTransaksiRoute = "/historyTransaksiRoute";
|
||||||
const cameraExampleRoute = "/cameraExampleRoute";
|
|
||||||
const cobaCameraRoute = "/cobaCameraRoute";
|
|
||||||
|
|
||||||
// test screen
|
// test screen
|
||||||
const testFilePickerRoute = "/testFilePickerRoute";
|
const testFilePickerRoute = "/testFilePickerRoute";
|
||||||
|
|
||||||
const changePasswordRoute = "/changePasswordRoute";
|
|
||||||
|
|
||||||
class AppRoute {
|
class AppRoute {
|
||||||
static Route<dynamic> generateRoute(RouteSettings settings) {
|
static Route<dynamic> generateRoute(RouteSettings settings) {
|
||||||
|
|
||||||
// change password
|
|
||||||
if (settings.name == changePasswordRoute) {
|
|
||||||
return MaterialPageRoute(builder: (context) {
|
|
||||||
return MediaQuery(
|
|
||||||
data: MediaQuery.of(context).copyWith(
|
|
||||||
textScaleFactor: 1.0,
|
|
||||||
padding: EdgeInsets.all(0),
|
|
||||||
),
|
|
||||||
child: ChangePasswordScreen(),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// splash screen
|
// splash screen
|
||||||
if (settings.name == splashScreen) {
|
if (settings.name == splashScreen) {
|
||||||
return MaterialPageRoute(builder: (context) {
|
return MaterialPageRoute(builder: (context) {
|
||||||
@@ -149,30 +128,6 @@ class AppRoute {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Camera example route
|
|
||||||
if (settings.name == cameraExampleRoute) {
|
|
||||||
return MaterialPageRoute(builder: (context) {
|
|
||||||
return MediaQuery(
|
|
||||||
data: MediaQuery.of(context).copyWith(
|
|
||||||
textScaleFactor: 1.0,
|
|
||||||
padding: EdgeInsets.all(0),
|
|
||||||
),
|
|
||||||
child: CamerExample(),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// Coba Camera route
|
|
||||||
if (settings.name == cobaCameraRoute) {
|
|
||||||
return MaterialPageRoute(builder: (context) {
|
|
||||||
return MediaQuery(
|
|
||||||
data: MediaQuery.of(context).copyWith(
|
|
||||||
textScaleFactor: 1.0,
|
|
||||||
padding: EdgeInsets.all(0),
|
|
||||||
),
|
|
||||||
child: CobaCamera(),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// default
|
// default
|
||||||
return MaterialPageRoute(builder: (context) {
|
return MaterialPageRoute(builder: (context) {
|
||||||
|
|||||||
@@ -2,15 +2,10 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:intl/date_symbol_data_local.dart';
|
|
||||||
import 'app/route.dart';
|
import 'app/route.dart';
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
initializeDateFormatting();
|
|
||||||
await SystemChrome.setPreferredOrientations([
|
|
||||||
DeviceOrientation.portraitUp,
|
|
||||||
]);
|
|
||||||
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
|
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
|
||||||
statusBarIconBrightness:
|
statusBarIconBrightness:
|
||||||
Brightness.dark, // this will change the brightness of the icons
|
Brightness.dark, // this will change the brightness of the icons
|
||||||
@@ -43,8 +38,8 @@ class MyApp extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
// initialRoute: loginRoute,
|
initialRoute: loginRoute,
|
||||||
initialRoute: splashScreen,
|
// initialRoute: splashScreen,
|
||||||
// initialRoute: transaksiRoute,
|
// initialRoute: transaksiRoute,
|
||||||
// initialRoute: reportRoute,
|
// initialRoute: reportRoute,
|
||||||
// initialRoute: testFilePickerRoute,
|
// initialRoute: testFilePickerRoute,
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
class CompanyModel {
|
|
||||||
String? companyid;
|
|
||||||
String? companyname;
|
|
||||||
String? mUserDefaultCompany;
|
|
||||||
|
|
||||||
CompanyModel({this.companyid, this.companyname, this.mUserDefaultCompany});
|
|
||||||
|
|
||||||
CompanyModel.fromJson(Map<String, dynamic> json) {
|
|
||||||
companyid = json['companyid'];
|
|
||||||
companyname = json['companyname'];
|
|
||||||
mUserDefaultCompany = json['M_UserDefaultCompany'];
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
|
||||||
data['companyid'] = this.companyid;
|
|
||||||
data['companyname'] = this.companyname;
|
|
||||||
data['M_UserDefaultCompany'] = this.mUserDefaultCompany;
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
class HistoryTotalModel {
|
|
||||||
String? totalAll;
|
|
||||||
|
|
||||||
HistoryTotalModel({
|
|
||||||
this.totalAll,
|
|
||||||
});
|
|
||||||
|
|
||||||
HistoryTotalModel.fromJson(Map<String, dynamic> json) {
|
|
||||||
totalAll = json['total_all'];
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
|
||||||
data['total_all'] = this.totalAll;
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -12,7 +12,6 @@ class HistoryTransaksiModel {
|
|||||||
String? tanggalconfirm;
|
String? tanggalconfirm;
|
||||||
String? usertransaksi;
|
String? usertransaksi;
|
||||||
String? userconfirm;
|
String? userconfirm;
|
||||||
String? tanggalcreated;
|
|
||||||
|
|
||||||
HistoryTransaksiModel(
|
HistoryTransaksiModel(
|
||||||
{this.id,
|
{this.id,
|
||||||
@@ -27,9 +26,7 @@ class HistoryTransaksiModel {
|
|||||||
this.isconfirm,
|
this.isconfirm,
|
||||||
this.tanggalconfirm,
|
this.tanggalconfirm,
|
||||||
this.usertransaksi,
|
this.usertransaksi,
|
||||||
this.userconfirm,
|
this.userconfirm});
|
||||||
this.tanggalcreated
|
|
||||||
});
|
|
||||||
|
|
||||||
HistoryTransaksiModel.fromJson(Map<String, dynamic> json) {
|
HistoryTransaksiModel.fromJson(Map<String, dynamic> json) {
|
||||||
id = json['id'];
|
id = json['id'];
|
||||||
@@ -45,7 +42,6 @@ class HistoryTransaksiModel {
|
|||||||
tanggalconfirm = json['tanggalconfirm'];
|
tanggalconfirm = json['tanggalconfirm'];
|
||||||
usertransaksi = json['usertransaksi'];
|
usertransaksi = json['usertransaksi'];
|
||||||
userconfirm = json['userconfirm'];
|
userconfirm = json['userconfirm'];
|
||||||
tanggalcreated = json['tanggalcreated'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
@@ -63,7 +59,6 @@ class HistoryTransaksiModel {
|
|||||||
data['tanggalconfirm'] = this.tanggalconfirm;
|
data['tanggalconfirm'] = this.tanggalconfirm;
|
||||||
data['usertransaksi'] = this.usertransaksi;
|
data['usertransaksi'] = this.usertransaksi;
|
||||||
data['userconfirm'] = this.userconfirm;
|
data['userconfirm'] = this.userconfirm;
|
||||||
data['tanggalcreated'] = this.tanggalcreated;
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
class InfoAccountBalanceModel {
|
|
||||||
String? totalAll;
|
|
||||||
String? kredit;
|
|
||||||
String? debit;
|
|
||||||
|
|
||||||
InfoAccountBalanceModel({this.totalAll, this.kredit, this.debit});
|
|
||||||
|
|
||||||
InfoAccountBalanceModel.fromJson(Map<String, dynamic> json) {
|
|
||||||
totalAll = json['total_all'];
|
|
||||||
kredit = json['kredit'];
|
|
||||||
debit = json['debit'];
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
|
||||||
data['total_all'] = this.totalAll;
|
|
||||||
data['kredit'] = this.kredit;
|
|
||||||
data['debit'] = this.debit;
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
class ListTransaksiHomeModel {
|
|
||||||
String? id;
|
|
||||||
String? tanggaltransaksi;
|
|
||||||
String? tipe;
|
|
||||||
String? kategoriid;
|
|
||||||
String? kategoriname;
|
|
||||||
String? note;
|
|
||||||
String? amount;
|
|
||||||
String? sender;
|
|
||||||
String? imgurl;
|
|
||||||
String? isconfirm;
|
|
||||||
String? tanggalconfirm;
|
|
||||||
String? usertransaksi;
|
|
||||||
String? userconfirm;
|
|
||||||
String? tanggalcreated;
|
|
||||||
|
|
||||||
ListTransaksiHomeModel({
|
|
||||||
this.id,
|
|
||||||
this.tanggaltransaksi,
|
|
||||||
this.tipe,
|
|
||||||
this.kategoriid,
|
|
||||||
this.kategoriname,
|
|
||||||
this.note,
|
|
||||||
this.amount,
|
|
||||||
this.sender,
|
|
||||||
this.imgurl,
|
|
||||||
this.isconfirm,
|
|
||||||
this.tanggalconfirm,
|
|
||||||
this.usertransaksi,
|
|
||||||
this.userconfirm,
|
|
||||||
this.tanggalcreated,
|
|
||||||
});
|
|
||||||
|
|
||||||
ListTransaksiHomeModel.fromJson(Map<String, dynamic> json) {
|
|
||||||
id = json['id'];
|
|
||||||
tanggaltransaksi = json['tanggaltransaksi'];
|
|
||||||
tipe = json['tipe'];
|
|
||||||
kategoriid = json['kategoriid'];
|
|
||||||
kategoriname = json['kategoriname'];
|
|
||||||
note = json['note'];
|
|
||||||
amount = json['amount'];
|
|
||||||
sender = json['sender'];
|
|
||||||
imgurl = json['imgurl'];
|
|
||||||
isconfirm = json['isconfirm'];
|
|
||||||
tanggalconfirm = json['tanggalconfirm'];
|
|
||||||
usertransaksi = json['usertransaksi'];
|
|
||||||
userconfirm = json['userconfirm'];
|
|
||||||
tanggalcreated = json['tanggalcreated'];
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
|
||||||
data['id'] = this.id;
|
|
||||||
data['tanggaltransaksi'] = this.tanggaltransaksi;
|
|
||||||
data['tipe'] = this.tipe;
|
|
||||||
data['kategoriid'] = this.kategoriid;
|
|
||||||
data['kategoriname'] = this.kategoriname;
|
|
||||||
data['note'] = this.note;
|
|
||||||
data['amount'] = this.amount;
|
|
||||||
data['sender'] = this.sender;
|
|
||||||
data['imgurl'] = this.imgurl;
|
|
||||||
data['isconfirm'] = this.isconfirm;
|
|
||||||
data['tanggalconfirm'] = this.tanggalconfirm;
|
|
||||||
data['usertransaksi'] = this.usertransaksi;
|
|
||||||
data['userconfirm'] = this.userconfirm;
|
|
||||||
data['tanggalcreated'] = this.tanggalcreated;
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
||||||
|
|
||||||
import '../model/info_account_balance.dart';
|
|
||||||
|
|
||||||
final currentInfoAccountBalanceProvider = StateProvider<InfoAccountBalanceModel>(
|
|
||||||
((ref) => InfoAccountBalanceModel(
|
|
||||||
debit: "0",
|
|
||||||
kredit: "0",
|
|
||||||
totalAll: "0",
|
|
||||||
)),
|
|
||||||
);
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
||||||
|
|
||||||
import '../model/history_total_model.dart';
|
|
||||||
|
|
||||||
final currentHistoryTotalProvider = StateProvider<HistoryTotalModel>(
|
|
||||||
((ref) => HistoryTotalModel(
|
|
||||||
totalAll: "0",
|
|
||||||
)),
|
|
||||||
);
|
|
||||||
@@ -95,32 +95,4 @@ class AuthRepository extends BaseRepository {
|
|||||||
return resp['message'];
|
return resp['message'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> changePassword({
|
|
||||||
required String userID,
|
|
||||||
required String token,
|
|
||||||
required String tokenx,
|
|
||||||
required String oldPassword,
|
|
||||||
required String newPassword,
|
|
||||||
required String confirmPassword,
|
|
||||||
}) async {
|
|
||||||
final param = {
|
|
||||||
"tokenx": tokenx,
|
|
||||||
"token": token,
|
|
||||||
"M_UserID": userID,
|
|
||||||
"old_password": oldPassword,
|
|
||||||
"new_password": newPassword,
|
|
||||||
"confirm_password": confirmPassword
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
final service = "${Constant.baseUrlDevone}auth/change_password";
|
|
||||||
final resp = await post(param: param, service: service, token: token);
|
|
||||||
|
|
||||||
if (resp["status"] == "OK") {
|
|
||||||
return resp['message'];
|
|
||||||
} else {
|
|
||||||
return resp['message'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
import 'package:app_petty_cash/model/company_model.dart';
|
|
||||||
import 'package:app_petty_cash/model/list_type_model.dart';
|
|
||||||
|
|
||||||
import '../app/constant.dart';
|
|
||||||
import '../model/history_transaksi_model.dart';
|
|
||||||
import '../model/list_category_model.dart';
|
|
||||||
import 'base_repository.dart';
|
|
||||||
|
|
||||||
class CompanyRepository extends BaseRepository {
|
|
||||||
CompanyRepository({required super.dio});
|
|
||||||
|
|
||||||
// list company
|
|
||||||
Future<List<CompanyModel>> getListCompany({required String userID}) async {
|
|
||||||
// https: //devone.aplikasi.web.id/one-api-pettycash/pettycash/Usercompany/list_company?M_UserID=2
|
|
||||||
final service =
|
|
||||||
"${Constant.baseUrlDevone}Usercompany/list_company?M_UserID=${userID}";
|
|
||||||
final resp = await get(
|
|
||||||
service: service,
|
|
||||||
);
|
|
||||||
|
|
||||||
print("url list type : $service");
|
|
||||||
|
|
||||||
final result = List<CompanyModel>.empty(growable: true);
|
|
||||||
resp['data'].forEach((e) {
|
|
||||||
final model = CompanyModel.fromJson(e);
|
|
||||||
result.add(model);
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
import 'package:app_petty_cash/model/list_type_model.dart';
|
|
||||||
|
|
||||||
import '../app/constant.dart';
|
|
||||||
import '../model/info_account_balance.dart';
|
|
||||||
import '../model/list_transaksi_model.dart';
|
|
||||||
import 'base_repository.dart';
|
|
||||||
|
|
||||||
class HomeRepository extends BaseRepository {
|
|
||||||
HomeRepository({required super.dio});
|
|
||||||
|
|
||||||
// list transaksi home
|
|
||||||
Future<List<ListTransaksiHomeModel>> getTransaksiListHome(
|
|
||||||
String companyid,
|
|
||||||
) async {
|
|
||||||
final service =
|
|
||||||
"${Constant.baseUrlDevone}homescreen/list_transaction/?companyid=$companyid";
|
|
||||||
final resp = await get(
|
|
||||||
// param: {
|
|
||||||
// "": "",
|
|
||||||
// },
|
|
||||||
service: service,
|
|
||||||
);
|
|
||||||
|
|
||||||
print("url list transaksi home : $service");
|
|
||||||
|
|
||||||
final result = List<ListTransaksiHomeModel>.empty(growable: true);
|
|
||||||
resp['data'].forEach((e) {
|
|
||||||
final model = ListTransaksiHomeModel.fromJson(e);
|
|
||||||
result.add(model);
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// info account balance
|
|
||||||
Future<InfoAccountBalanceModel> getInfoAccountBalance(
|
|
||||||
String companyid,
|
|
||||||
) async {
|
|
||||||
final service =
|
|
||||||
"${Constant.baseUrlDevone}homescreen/list_total/?companyid=$companyid";
|
|
||||||
final resp = await get(
|
|
||||||
// param: {
|
|
||||||
// "": "",
|
|
||||||
// },
|
|
||||||
service: service,
|
|
||||||
);
|
|
||||||
|
|
||||||
print("url card info account balance home : $service");
|
|
||||||
|
|
||||||
InfoAccountBalanceModel result = InfoAccountBalanceModel(
|
|
||||||
debit: "0",
|
|
||||||
kredit: "0",
|
|
||||||
totalAll: "0",
|
|
||||||
);
|
|
||||||
|
|
||||||
print(resp['data']);
|
|
||||||
|
|
||||||
final model = InfoAccountBalanceModel.fromJson(resp['data']);
|
|
||||||
result = model;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,6 @@
|
|||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
import 'package:app_petty_cash/model/list_type_model.dart';
|
import 'package:app_petty_cash/model/list_type_model.dart';
|
||||||
|
|
||||||
import '../app/constant.dart';
|
import '../app/constant.dart';
|
||||||
import '../model/history_total_model.dart';
|
|
||||||
import '../model/history_transaksi_model.dart';
|
import '../model/history_transaksi_model.dart';
|
||||||
import '../model/list_category_model.dart';
|
import '../model/list_category_model.dart';
|
||||||
import 'base_repository.dart';
|
import 'base_repository.dart';
|
||||||
@@ -60,69 +57,34 @@ class TransaksiRepository extends BaseRepository {
|
|||||||
String catatan,
|
String catatan,
|
||||||
String userid,
|
String userid,
|
||||||
String sender,
|
String sender,
|
||||||
String base64file,
|
|
||||||
String fileName,
|
|
||||||
String fileSize,
|
|
||||||
String fileExtension,
|
|
||||||
String url) async {
|
String url) async {
|
||||||
// String paramPostInUrl = "";
|
String paramPostInUrl = "";
|
||||||
Map<String, dynamic> prm = {};
|
|
||||||
String M_CompanyID = await getCompanyID();
|
String M_CompanyID = await getCompanyID();
|
||||||
if (tipe == "DEBIT") {
|
if (tipe == "DEBIT") {
|
||||||
sender = "";
|
sender = "";
|
||||||
prm = {
|
paramPostInUrl =
|
||||||
'tanggal': tanggal,
|
"?tanggal=$tanggal&tipe=$tipe&kategoriid=$kategoriid&jumlah=$jumlah&catatan=$catatan&url=$url&userid=$userid&sender=$sender";
|
||||||
'tipe': tipe,
|
|
||||||
'kategoriid': kategoriid,
|
|
||||||
'jumlah': jumlah,
|
|
||||||
'catatan': catatan,
|
|
||||||
'url': url,
|
|
||||||
'userid': userid,
|
|
||||||
'sender': sender,
|
|
||||||
'companyid': M_CompanyID,
|
|
||||||
'base64File': base64file,
|
|
||||||
'fileName': fileName,
|
|
||||||
'fileSize': fileSize,
|
|
||||||
'fileEkstension': fileExtension
|
|
||||||
};
|
|
||||||
|
|
||||||
// paramPostInUrl =
|
|
||||||
// "?tanggal=$tanggal&tipe=$tipe&kategoriid=$kategoriid&jumlah=$jumlah&catatan=$catatan&url=$url&userid=$userid&sender=$sender";
|
|
||||||
} else {
|
} else {
|
||||||
if (tipe == "KREDIT") {
|
if (tipe == "KREDIT") {
|
||||||
kategoriid = "0";
|
kategoriid = "0";
|
||||||
prm = {
|
paramPostInUrl =
|
||||||
'tanggal': tanggal,
|
"?tanggal=$tanggal&tipe=$tipe&kategoriid=$kategoriid&jumlah=$jumlah&catatan=$catatan&url=$url&userid=$userid&sender=$sender";
|
||||||
'tipe': tipe,
|
|
||||||
'kategoriid': kategoriid,
|
|
||||||
'jumlah': jumlah,
|
|
||||||
'catatan': catatan,
|
|
||||||
'url': url,
|
|
||||||
'userid': userid,
|
|
||||||
'sender': sender,
|
|
||||||
'companyid': M_CompanyID,
|
|
||||||
'base64File': base64file,
|
|
||||||
'fileName': fileName,
|
|
||||||
'fileSize': fileSize,
|
|
||||||
'fileEkstension': fileExtension
|
|
||||||
};
|
|
||||||
// paramPostInUrl =
|
|
||||||
// "?tanggal=$tanggal&tipe=$tipe&kategoriid=$kategoriid&jumlah=$jumlah&catatan=$catatan&url=$url&userid=$userid&sender=$sender";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// paramPostInUrl += "&companyid=$M_CompanyID";
|
paramPostInUrl += "&companyid=$M_CompanyID";
|
||||||
// /?tanggal=2023-12-29&tipe=KREDIT&kategoriid=3&jumlah=5000&catatan=Lakban%20Besar&url=&userid=1&sender=
|
// /?tanggal=2023-12-29&tipe=KREDIT&kategoriid=3&jumlah=5000&catatan=Lakban%20Besar&url=&userid=1&sender=
|
||||||
|
|
||||||
final service = "${Constant.baseUrlDevone}transaction/addtransaction";
|
final service =
|
||||||
final resp = await post(
|
"${Constant.baseUrlDevone}transaction/addtransaction/$paramPostInUrl";
|
||||||
// param: {
|
final resp = await get(
|
||||||
// "": "",
|
// param: {
|
||||||
// },
|
// "": "",
|
||||||
service: service,
|
// },
|
||||||
param: prm);
|
service: service,
|
||||||
|
);
|
||||||
|
|
||||||
print("prm insert transaksi : ${jsonEncode(prm)}");
|
print("url insert transaksi : $service");
|
||||||
|
|
||||||
// final result = List<ListCategory>.empty(growable: true);
|
// final result = List<ListCategory>.empty(growable: true);
|
||||||
// resp['data'].forEach((e) {
|
// resp['data'].forEach((e) {
|
||||||
@@ -141,7 +103,7 @@ class TransaksiRepository extends BaseRepository {
|
|||||||
String categoryid,
|
String categoryid,
|
||||||
) async {
|
) async {
|
||||||
final service =
|
final service =
|
||||||
"${Constant.baseUrlDevone}/history/list_transaction/?companyid=$companyid&startdate=$tglAwal&enddate=$tglAkhir&kategoriid=$categoryid";
|
"${Constant.baseUrlDevone}/homescreen/list_transaction/?companyid=$companyid&startdate=$tglAwal&enddate=$tglAkhir&kategoriid=$categoryid";
|
||||||
// https://devone.aplikasi.web.id/one-api-pettycash/pettycash/history/list_transaction/?companyid=1&startdate=2023-12-01&enddate=2023-12-30&kategoriid=0
|
// https://devone.aplikasi.web.id/one-api-pettycash/pettycash/history/list_transaction/?companyid=1&startdate=2023-12-01&enddate=2023-12-30&kategoriid=0
|
||||||
final resp = await get(
|
final resp = await get(
|
||||||
// param: {
|
// param: {
|
||||||
@@ -165,6 +127,7 @@ class TransaksiRepository extends BaseRepository {
|
|||||||
String id,
|
String id,
|
||||||
String userid,
|
String userid,
|
||||||
) async {
|
) async {
|
||||||
|
|
||||||
final service =
|
final service =
|
||||||
"${Constant.baseUrlDevone}transaction/deletetransaction/?id=$id&userid=$userid";
|
"${Constant.baseUrlDevone}transaction/deletetransaction/?id=$id&userid=$userid";
|
||||||
final resp = await get(
|
final resp = await get(
|
||||||
@@ -182,68 +145,10 @@ class TransaksiRepository extends BaseRepository {
|
|||||||
// result.add(model);
|
// result.add(model);
|
||||||
// });
|
// });
|
||||||
|
|
||||||
if (resp['status'] != "OK") {
|
if(resp['status'] != "OK"){
|
||||||
return resp['message'];
|
return resp['message'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp['status'];
|
return resp['status'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// confirm transaksi
|
|
||||||
Future<String> confirmTransaksi(
|
|
||||||
String id,
|
|
||||||
String userid,
|
|
||||||
) async {
|
|
||||||
final service =
|
|
||||||
"${Constant.baseUrlDevone}transaction/confirmtransaction/?id=$id&userid=$userid";
|
|
||||||
final resp = await get(
|
|
||||||
// param: {
|
|
||||||
// "": "",
|
|
||||||
// },
|
|
||||||
service: service,
|
|
||||||
);
|
|
||||||
|
|
||||||
print("url confirm transaksi : $service");
|
|
||||||
|
|
||||||
// final result = List<ListCategory>.empty(growable: true);
|
|
||||||
// resp['data'].forEach((e) {
|
|
||||||
// final model = ListCategory.fromJson(e);
|
|
||||||
// result.add(model);
|
|
||||||
// });
|
|
||||||
|
|
||||||
if (resp['status'] != "OK") {
|
|
||||||
return resp['message'];
|
|
||||||
}
|
|
||||||
|
|
||||||
return resp['status'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// total by category di history
|
|
||||||
Future<HistoryTotalModel> getHistoryTotal(
|
|
||||||
String companyid,
|
|
||||||
String tglAwal,
|
|
||||||
String tglAkhir,
|
|
||||||
String categoryid,
|
|
||||||
) async {
|
|
||||||
final service =
|
|
||||||
"${Constant.baseUrlDevone}history/list_total/?companyid=$companyid&startdate=$tglAwal&enddate=$tglAkhir&kategoriid=$categoryid";
|
|
||||||
final resp = await get(
|
|
||||||
// param: {
|
|
||||||
// "": "",
|
|
||||||
// },
|
|
||||||
service: service,
|
|
||||||
);
|
|
||||||
|
|
||||||
print("url total History Transaksi : $service");
|
|
||||||
|
|
||||||
HistoryTotalModel result = HistoryTotalModel(
|
|
||||||
totalAll: "0",
|
|
||||||
);
|
|
||||||
|
|
||||||
// print(resp['data']);
|
|
||||||
|
|
||||||
final model = HistoryTotalModel.fromJson(resp['data']);
|
|
||||||
result = model;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,128 +0,0 @@
|
|||||||
import 'dart:convert';
|
|
||||||
import 'dart:io';
|
|
||||||
import 'dart:io' as io;
|
|
||||||
|
|
||||||
import 'package:app_petty_cash/app/constant.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
||||||
import 'package:image_picker/image_picker.dart';
|
|
||||||
import 'package:mime/mime.dart';
|
|
||||||
|
|
||||||
class CobaCamera extends HookConsumerWidget {
|
|
||||||
const CobaCamera({super.key});
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
|
||||||
final photo = useState<XFile?>(null);
|
|
||||||
final photoBase64 = useState<String>("");
|
|
||||||
final previewLoading = useState(false);
|
|
||||||
getBase64() async {
|
|
||||||
// List<int> imageBytes = await photo.value?.readAsBytes();
|
|
||||||
if (photo.value != null) {
|
|
||||||
final bytes = io.File(photo.value!.path).readAsBytesSync();
|
|
||||||
String base64Image = base64Encode(bytes);
|
|
||||||
photoBase64.value = base64Image;
|
|
||||||
final file = File(photo.value!.path);
|
|
||||||
print(file.lengthSync() / 1000000);
|
|
||||||
print(await photo.value!.length());
|
|
||||||
|
|
||||||
// await getExternalStorageDirectory();
|
|
||||||
// print(await photo.value!.saveTo(path));
|
|
||||||
print(base64Image);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final ImagePicker _picker = ImagePicker();
|
|
||||||
pickImage() async {
|
|
||||||
previewLoading.value = true;
|
|
||||||
final XFile? pickedFile = await _picker.pickImage(
|
|
||||||
source: ImageSource.camera,
|
|
||||||
);
|
|
||||||
photo.value = pickedFile;
|
|
||||||
// final Directory appDocumentsDir =
|
|
||||||
// await getApplicationDocumentsDirectory();
|
|
||||||
// print(appDocumentsDir);
|
|
||||||
// await pickedFile!.saveTo(appDocumentsDir.path);
|
|
||||||
await getBase64();
|
|
||||||
previewLoading.value = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
browseImage() async {
|
|
||||||
previewLoading.value = true;
|
|
||||||
|
|
||||||
final XFile? pickedFile = await _picker.pickImage(
|
|
||||||
source: ImageSource.gallery,
|
|
||||||
);
|
|
||||||
photo.value = pickedFile;
|
|
||||||
getBase64();
|
|
||||||
previewLoading.value = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Scaffold(
|
|
||||||
body: SingleChildScrollView(
|
|
||||||
child: SafeArea(
|
|
||||||
minimum: const EdgeInsets.all(20),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
height: Constant.getActualYPhone(context: context, y: 500),
|
|
||||||
width: MediaQuery.of(context).size.width,
|
|
||||||
color: Colors.red,
|
|
||||||
child: LayoutBuilder(
|
|
||||||
builder: (context, constraints) {
|
|
||||||
final String? mime =
|
|
||||||
lookupMimeType(photo.value?.path ?? "");
|
|
||||||
|
|
||||||
return Semantics(
|
|
||||||
label: 'image_picker_example_picked_image',
|
|
||||||
child: (mime != null
|
|
||||||
? (mime.startsWith('image/'))
|
|
||||||
? Image.file(
|
|
||||||
// image: AssetImage(photo.value!.path),
|
|
||||||
File(photo.value!.path),
|
|
||||||
frameBuilder: (context, child, frame,
|
|
||||||
wasSynchronouslyLoaded) {
|
|
||||||
return (wasSynchronouslyLoaded)
|
|
||||||
? Center(
|
|
||||||
child: Text("Loadinga"),
|
|
||||||
)
|
|
||||||
: Container(
|
|
||||||
child: child,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
errorBuilder: (BuildContext context,
|
|
||||||
Object error, StackTrace? stackTrace) {
|
|
||||||
return const Center(
|
|
||||||
child: Text(
|
|
||||||
'This image type is not supported'));
|
|
||||||
},
|
|
||||||
)
|
|
||||||
: null
|
|
||||||
: null));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// photo.value != null
|
|
||||||
// ? PhotoView(imageProvider: AssetImage(photo.value!.path))
|
|
||||||
// : Container(),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: () {
|
|
||||||
pickImage();
|
|
||||||
},
|
|
||||||
child: Text("Take a picture")),
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: () {
|
|
||||||
browseImage();
|
|
||||||
},
|
|
||||||
child: Text("Browse a picture"))
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,542 +0,0 @@
|
|||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:image_picker/image_picker.dart';
|
|
||||||
import 'package:mime/mime.dart';
|
|
||||||
import 'package:video_player/video_player.dart';
|
|
||||||
|
|
||||||
class CamerExample extends StatefulWidget {
|
|
||||||
const CamerExample({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<CamerExample> createState() => _CamerExampleState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _CamerExampleState extends State<CamerExample> {
|
|
||||||
List<XFile>? _mediaFileList;
|
|
||||||
|
|
||||||
void _setImageFileListFromFile(XFile? value) {
|
|
||||||
_mediaFileList = value == null ? null : <XFile>[value];
|
|
||||||
}
|
|
||||||
|
|
||||||
dynamic _pickImageError;
|
|
||||||
bool isVideo = false;
|
|
||||||
|
|
||||||
VideoPlayerController? _controller;
|
|
||||||
VideoPlayerController? _toBeDisposed;
|
|
||||||
String? _retrieveDataError;
|
|
||||||
|
|
||||||
final ImagePicker _picker = ImagePicker();
|
|
||||||
final TextEditingController maxWidthController = TextEditingController();
|
|
||||||
final TextEditingController maxHeightController = TextEditingController();
|
|
||||||
final TextEditingController qualityController = TextEditingController();
|
|
||||||
|
|
||||||
Future<void> _playVideo(XFile? file) async {
|
|
||||||
if (file != null && mounted) {
|
|
||||||
await _disposeVideoController();
|
|
||||||
late VideoPlayerController controller;
|
|
||||||
if (kIsWeb) {
|
|
||||||
controller = VideoPlayerController.networkUrl(Uri.parse(file.path));
|
|
||||||
} else {
|
|
||||||
controller = VideoPlayerController.file(File(file.path));
|
|
||||||
}
|
|
||||||
_controller = controller;
|
|
||||||
// In web, most browsers won't honor a programmatic call to .play
|
|
||||||
// if the video has a sound track (and is not muted).
|
|
||||||
// Mute the video so it auto-plays in web!
|
|
||||||
// This is not needed if the call to .play is the result of user
|
|
||||||
// interaction (clicking on a "play" button, for example).
|
|
||||||
const double volume = kIsWeb ? 0.0 : 1.0;
|
|
||||||
await controller.setVolume(volume);
|
|
||||||
await controller.initialize();
|
|
||||||
await controller.setLooping(true);
|
|
||||||
await controller.play();
|
|
||||||
setState(() {});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _onImageButtonPressed(
|
|
||||||
ImageSource source, {
|
|
||||||
required BuildContext context,
|
|
||||||
bool isMultiImage = false,
|
|
||||||
bool isMedia = false,
|
|
||||||
}) async {
|
|
||||||
if (_controller != null) {
|
|
||||||
await _controller!.setVolume(0.0);
|
|
||||||
}
|
|
||||||
if (context.mounted) {
|
|
||||||
if (isVideo) {
|
|
||||||
final XFile? file = await _picker.pickVideo(
|
|
||||||
source: source, maxDuration: const Duration(seconds: 10));
|
|
||||||
await _playVideo(file);
|
|
||||||
} else if (isMultiImage) {
|
|
||||||
await _displayPickImageDialog(context,
|
|
||||||
(double? maxWidth, double? maxHeight, int? quality) async {
|
|
||||||
try {
|
|
||||||
final List<XFile> pickedFileList = isMedia
|
|
||||||
? await _picker.pickMultipleMedia(
|
|
||||||
maxWidth: maxWidth,
|
|
||||||
maxHeight: maxHeight,
|
|
||||||
imageQuality: quality,
|
|
||||||
)
|
|
||||||
: await _picker.pickMultiImage(
|
|
||||||
maxWidth: maxWidth,
|
|
||||||
maxHeight: maxHeight,
|
|
||||||
imageQuality: quality,
|
|
||||||
);
|
|
||||||
setState(() {
|
|
||||||
_mediaFileList = pickedFileList;
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
setState(() {
|
|
||||||
_pickImageError = e;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else if (isMedia) {
|
|
||||||
await _displayPickImageDialog(context,
|
|
||||||
(double? maxWidth, double? maxHeight, int? quality) async {
|
|
||||||
try {
|
|
||||||
final List<XFile> pickedFileList = <XFile>[];
|
|
||||||
final XFile? media = await _picker.pickMedia(
|
|
||||||
maxWidth: maxWidth,
|
|
||||||
maxHeight: maxHeight,
|
|
||||||
imageQuality: quality,
|
|
||||||
);
|
|
||||||
if (media != null) {
|
|
||||||
pickedFileList.add(media);
|
|
||||||
setState(() {
|
|
||||||
_mediaFileList = pickedFileList;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
setState(() {
|
|
||||||
_pickImageError = e;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await _displayPickImageDialog(context,
|
|
||||||
(double? maxWidth, double? maxHeight, int? quality) async {
|
|
||||||
try {
|
|
||||||
final XFile? pickedFile = await _picker.pickImage(
|
|
||||||
source: source,
|
|
||||||
maxWidth: maxWidth,
|
|
||||||
maxHeight: maxHeight,
|
|
||||||
imageQuality: quality,
|
|
||||||
);
|
|
||||||
setState(() {
|
|
||||||
_setImageFileListFromFile(pickedFile);
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
setState(() {
|
|
||||||
_pickImageError = e;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void deactivate() {
|
|
||||||
if (_controller != null) {
|
|
||||||
_controller!.setVolume(0.0);
|
|
||||||
_controller!.pause();
|
|
||||||
}
|
|
||||||
super.deactivate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_disposeVideoController();
|
|
||||||
maxWidthController.dispose();
|
|
||||||
maxHeightController.dispose();
|
|
||||||
qualityController.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _disposeVideoController() async {
|
|
||||||
if (_toBeDisposed != null) {
|
|
||||||
await _toBeDisposed!.dispose();
|
|
||||||
}
|
|
||||||
_toBeDisposed = _controller;
|
|
||||||
_controller = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _previewVideo() {
|
|
||||||
final Text? retrieveError = _getRetrieveErrorWidget();
|
|
||||||
if (retrieveError != null) {
|
|
||||||
return retrieveError;
|
|
||||||
}
|
|
||||||
if (_controller == null) {
|
|
||||||
return const Text(
|
|
||||||
'You have not yet picked a video',
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.all(10.0),
|
|
||||||
child: AspectRatioVideo(_controller),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _previewImages() {
|
|
||||||
final Text? retrieveError = _getRetrieveErrorWidget();
|
|
||||||
if (retrieveError != null) {
|
|
||||||
return retrieveError;
|
|
||||||
}
|
|
||||||
if (_mediaFileList != null) {
|
|
||||||
return Semantics(
|
|
||||||
label: 'image_picker_example_picked_images',
|
|
||||||
child: ListView.builder(
|
|
||||||
key: UniqueKey(),
|
|
||||||
itemBuilder: (BuildContext context, int index) {
|
|
||||||
final String? mime = lookupMimeType(_mediaFileList![index].path);
|
|
||||||
|
|
||||||
// Why network for web?
|
|
||||||
// See https://pub.dev/packages/image_picker_for_web#limitations-on-the-web-platform
|
|
||||||
return Semantics(
|
|
||||||
label: 'image_picker_example_picked_image',
|
|
||||||
child: kIsWeb
|
|
||||||
? Image.network(_mediaFileList![index].path)
|
|
||||||
: (mime == null || mime.startsWith('image/')
|
|
||||||
? Image.file(
|
|
||||||
File(_mediaFileList![index].path),
|
|
||||||
errorBuilder: (BuildContext context, Object error,
|
|
||||||
StackTrace? stackTrace) {
|
|
||||||
return const Center(
|
|
||||||
child:
|
|
||||||
Text('This image type is not supported'));
|
|
||||||
},
|
|
||||||
)
|
|
||||||
: _buildInlineVideoPlayer(index)),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
itemCount: _mediaFileList!.length,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else if (_pickImageError != null) {
|
|
||||||
return Text(
|
|
||||||
'Pick image error: $_pickImageError',
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return const Text(
|
|
||||||
'You have not yet picked an image.',
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildInlineVideoPlayer(int index) {
|
|
||||||
final VideoPlayerController controller =
|
|
||||||
VideoPlayerController.file(File(_mediaFileList![index].path));
|
|
||||||
const double volume = kIsWeb ? 0.0 : 1.0;
|
|
||||||
controller.setVolume(volume);
|
|
||||||
controller.initialize();
|
|
||||||
controller.setLooping(true);
|
|
||||||
controller.play();
|
|
||||||
return Center(child: AspectRatioVideo(controller));
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _handlePreview() {
|
|
||||||
if (isVideo) {
|
|
||||||
return _previewVideo();
|
|
||||||
} else {
|
|
||||||
return _previewImages();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> retrieveLostData() async {
|
|
||||||
final LostDataResponse response = await _picker.retrieveLostData();
|
|
||||||
if (response.isEmpty) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (response.file != null) {
|
|
||||||
if (response.type == RetrieveType.video) {
|
|
||||||
isVideo = true;
|
|
||||||
await _playVideo(response.file);
|
|
||||||
} else {
|
|
||||||
isVideo = false;
|
|
||||||
setState(() {
|
|
||||||
if (response.files == null) {
|
|
||||||
_setImageFileListFromFile(response.file);
|
|
||||||
} else {
|
|
||||||
_mediaFileList = response.files;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
_retrieveDataError = response.exception!.code;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: Text("Camera example"),
|
|
||||||
),
|
|
||||||
body: Center(
|
|
||||||
child: !kIsWeb && defaultTargetPlatform == TargetPlatform.android
|
|
||||||
? FutureBuilder<void>(
|
|
||||||
future: retrieveLostData(),
|
|
||||||
builder: (BuildContext context, AsyncSnapshot<void> snapshot) {
|
|
||||||
switch (snapshot.connectionState) {
|
|
||||||
case ConnectionState.none:
|
|
||||||
case ConnectionState.waiting:
|
|
||||||
return const Text(
|
|
||||||
'You have not yet picked an image.',
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
);
|
|
||||||
case ConnectionState.done:
|
|
||||||
return _handlePreview();
|
|
||||||
case ConnectionState.active:
|
|
||||||
if (snapshot.hasError) {
|
|
||||||
return Text(
|
|
||||||
'Pick image/video error: ${snapshot.error}}',
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return const Text(
|
|
||||||
'You have not yet picked an image.',
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
|
||||||
: _handlePreview(),
|
|
||||||
),
|
|
||||||
floatingActionButton: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
|
||||||
children: <Widget>[
|
|
||||||
Semantics(
|
|
||||||
label: 'image_picker_example_from_gallery',
|
|
||||||
child: FloatingActionButton(
|
|
||||||
onPressed: () {
|
|
||||||
isVideo = false;
|
|
||||||
_onImageButtonPressed(ImageSource.gallery, context: context);
|
|
||||||
},
|
|
||||||
heroTag: 'image0',
|
|
||||||
tooltip: 'Pick Image from gallery',
|
|
||||||
child: const Icon(Icons.photo),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(top: 16.0),
|
|
||||||
child: FloatingActionButton(
|
|
||||||
onPressed: () {
|
|
||||||
isVideo = false;
|
|
||||||
_onImageButtonPressed(
|
|
||||||
ImageSource.gallery,
|
|
||||||
context: context,
|
|
||||||
isMultiImage: true,
|
|
||||||
isMedia: true,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
heroTag: 'multipleMedia',
|
|
||||||
tooltip: 'Pick Multiple Media from gallery',
|
|
||||||
child: const Icon(Icons.photo_library),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(top: 16.0),
|
|
||||||
child: FloatingActionButton(
|
|
||||||
onPressed: () {
|
|
||||||
isVideo = false;
|
|
||||||
_onImageButtonPressed(
|
|
||||||
ImageSource.gallery,
|
|
||||||
context: context,
|
|
||||||
isMedia: true,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
heroTag: 'media',
|
|
||||||
tooltip: 'Pick Single Media from gallery',
|
|
||||||
child: const Icon(Icons.photo_library),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(top: 16.0),
|
|
||||||
child: FloatingActionButton(
|
|
||||||
onPressed: () {
|
|
||||||
isVideo = false;
|
|
||||||
_onImageButtonPressed(
|
|
||||||
ImageSource.gallery,
|
|
||||||
context: context,
|
|
||||||
isMultiImage: true,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
heroTag: 'image1',
|
|
||||||
tooltip: 'Pick Multiple Image from gallery',
|
|
||||||
child: const Icon(Icons.photo_library),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (_picker.supportsImageSource(ImageSource.camera))
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(top: 16.0),
|
|
||||||
child: FloatingActionButton(
|
|
||||||
onPressed: () {
|
|
||||||
isVideo = false;
|
|
||||||
_onImageButtonPressed(ImageSource.camera, context: context);
|
|
||||||
},
|
|
||||||
heroTag: 'image2',
|
|
||||||
tooltip: 'Take a Photo',
|
|
||||||
child: const Icon(Icons.camera_alt),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(top: 16.0),
|
|
||||||
child: FloatingActionButton(
|
|
||||||
backgroundColor: Colors.red,
|
|
||||||
onPressed: () {
|
|
||||||
isVideo = true;
|
|
||||||
_onImageButtonPressed(ImageSource.gallery, context: context);
|
|
||||||
},
|
|
||||||
heroTag: 'video0',
|
|
||||||
tooltip: 'Pick Video from gallery',
|
|
||||||
child: const Icon(Icons.video_library),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (_picker.supportsImageSource(ImageSource.camera))
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(top: 16.0),
|
|
||||||
child: FloatingActionButton(
|
|
||||||
backgroundColor: Colors.red,
|
|
||||||
onPressed: () {
|
|
||||||
isVideo = true;
|
|
||||||
_onImageButtonPressed(ImageSource.camera, context: context);
|
|
||||||
},
|
|
||||||
heroTag: 'video1',
|
|
||||||
tooltip: 'Take a Video',
|
|
||||||
child: const Icon(Icons.videocam),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Text? _getRetrieveErrorWidget() {
|
|
||||||
if (_retrieveDataError != null) {
|
|
||||||
final Text result = Text(_retrieveDataError!);
|
|
||||||
_retrieveDataError = null;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _displayPickImageDialog(
|
|
||||||
BuildContext context, OnPickImageCallback onPick) async {
|
|
||||||
return showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return AlertDialog(
|
|
||||||
title: const Text('Add optional parameters'),
|
|
||||||
content: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: <Widget>[
|
|
||||||
TextField(
|
|
||||||
controller: maxWidthController,
|
|
||||||
keyboardType:
|
|
||||||
const TextInputType.numberWithOptions(decimal: true),
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
hintText: 'Enter maxWidth if desired'),
|
|
||||||
),
|
|
||||||
TextField(
|
|
||||||
controller: maxHeightController,
|
|
||||||
keyboardType:
|
|
||||||
const TextInputType.numberWithOptions(decimal: true),
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
hintText: 'Enter maxHeight if desired'),
|
|
||||||
),
|
|
||||||
TextField(
|
|
||||||
controller: qualityController,
|
|
||||||
keyboardType: TextInputType.number,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
hintText: 'Enter quality if desired'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
actions: <Widget>[
|
|
||||||
TextButton(
|
|
||||||
child: const Text('CANCEL'),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
child: const Text('PICK'),
|
|
||||||
onPressed: () {
|
|
||||||
final double? width = maxWidthController.text.isNotEmpty
|
|
||||||
? double.parse(maxWidthController.text)
|
|
||||||
: null;
|
|
||||||
final double? height = maxHeightController.text.isNotEmpty
|
|
||||||
? double.parse(maxHeightController.text)
|
|
||||||
: null;
|
|
||||||
final int? quality = qualityController.text.isNotEmpty
|
|
||||||
? int.parse(qualityController.text)
|
|
||||||
: null;
|
|
||||||
onPick(width, height, quality);
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef OnPickImageCallback = void Function(
|
|
||||||
double? maxWidth, double? maxHeight, int? quality);
|
|
||||||
|
|
||||||
class AspectRatioVideo extends StatefulWidget {
|
|
||||||
const AspectRatioVideo(this.controller, {super.key});
|
|
||||||
|
|
||||||
final VideoPlayerController? controller;
|
|
||||||
|
|
||||||
@override
|
|
||||||
AspectRatioVideoState createState() => AspectRatioVideoState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class AspectRatioVideoState extends State<AspectRatioVideo> {
|
|
||||||
VideoPlayerController? get controller => widget.controller;
|
|
||||||
bool initialized = false;
|
|
||||||
|
|
||||||
void _onVideoControllerUpdate() {
|
|
||||||
if (!mounted) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (initialized != controller!.value.isInitialized) {
|
|
||||||
initialized = controller!.value.isInitialized;
|
|
||||||
setState(() {});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
controller!.addListener(_onVideoControllerUpdate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
controller!.removeListener(_onVideoControllerUpdate);
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
if (initialized) {
|
|
||||||
return Center(
|
|
||||||
child: AspectRatio(
|
|
||||||
aspectRatio: controller!.value.aspectRatio,
|
|
||||||
child: VideoPlayer(controller!),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return Container();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +1,6 @@
|
|||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
import 'package:app_petty_cash/model/auth_model.dart';
|
|
||||||
import 'package:app_petty_cash/model/company_model.dart';
|
|
||||||
import 'package:app_petty_cash/screen/change_company/list_company_provider.dart';
|
|
||||||
import 'package:app_petty_cash/widget/sankbar_widget.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
|
||||||
|
|
||||||
import '../../app/constant.dart';
|
import '../../app/constant.dart';
|
||||||
import '../../app/route.dart';
|
import '../../app/route.dart';
|
||||||
@@ -19,14 +12,6 @@ class ChangeCompanyScreen extends HookConsumerWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final listCompany = useState<List<CompanyModel>>([
|
|
||||||
CompanyModel(companyid: "1", companyname: "SAS"),
|
|
||||||
CompanyModel(companyid: "2", companyname: "SIM")
|
|
||||||
]);
|
|
||||||
final isLoading = useState(false);
|
|
||||||
final selectedCompanyID = useState("0");
|
|
||||||
final selectedCompanyName = useState("");
|
|
||||||
final auth = ref.watch(currentUserProvider);
|
|
||||||
useEffect(() {
|
useEffect(() {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
||||||
final userID = ref.read(currentUserProvider)?.model.M_UserID ?? "0";
|
final userID = ref.read(currentUserProvider)?.model.M_UserID ?? "0";
|
||||||
@@ -38,29 +23,9 @@ class ChangeCompanyScreen extends HookConsumerWidget {
|
|||||||
// Navigator.popAndPushNamed(context, loginRoute);
|
// Navigator.popAndPushNamed(context, loginRoute);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ref.read(ListCompanyProvider.notifier).getListCompany(userID: userID);
|
|
||||||
});
|
});
|
||||||
return () {};
|
return () {};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
ref.listen(
|
|
||||||
ListCompanyProvider,
|
|
||||||
(previous, next) {
|
|
||||||
if (next is ListCompanyStateLoading) {
|
|
||||||
isLoading.value = true;
|
|
||||||
} else if (next is ListCompanyStateError) {
|
|
||||||
// print(next.message);
|
|
||||||
isLoading.value = false;
|
|
||||||
SanckbarWidget(context, next.message, snackbarType.error);
|
|
||||||
} else if (next is ListCompanyStateDone) {
|
|
||||||
print(jsonEncode(next.model));
|
|
||||||
// print(next.model.length);
|
|
||||||
listCompany.value = next.model;
|
|
||||||
selectedCompanyID.value = auth?.model.M_CompanyID ?? "0";
|
|
||||||
isLoading.value = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
top: Constant.getActualYPhone(context: context, y: 30),
|
top: Constant.getActualYPhone(context: context, y: 30),
|
||||||
@@ -78,131 +43,7 @@ class ChangeCompanyScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
drawer: CustomDrawer(),
|
drawer: CustomDrawer(),
|
||||||
body: SingleChildScrollView(
|
body: Text('Under Construction'),
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.all(20),
|
|
||||||
child: isLoading.value
|
|
||||||
? Container(
|
|
||||||
height: MediaQuery.of(context).size.height,
|
|
||||||
child: Center(
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: Column(
|
|
||||||
children: listCompany.value
|
|
||||||
.map((e) => Container(
|
|
||||||
margin: EdgeInsets.only(bottom: 20),
|
|
||||||
child: InkWell(
|
|
||||||
onTap: () async {
|
|
||||||
selectedCompanyID.value = e.companyid ?? "0";
|
|
||||||
selectedCompanyName.value =
|
|
||||||
e.companyname ?? "0";
|
|
||||||
final shared =
|
|
||||||
await SharedPreferences.getInstance();
|
|
||||||
final oldData = jsonDecode(
|
|
||||||
shared.getString(Constant.bearerName) ??
|
|
||||||
"");
|
|
||||||
print(oldData['token']);
|
|
||||||
|
|
||||||
final newModel = AuthDoctorModel.fromJson(
|
|
||||||
oldData['model']);
|
|
||||||
newModel.M_CompanyID = e.companyid ?? "0";
|
|
||||||
newModel.M_CompanyName = e.companyname ?? "";
|
|
||||||
final token = jsonEncode({
|
|
||||||
"date": oldData['date'],
|
|
||||||
"model": newModel,
|
|
||||||
"token": oldData['token']
|
|
||||||
});
|
|
||||||
final newAuthData = AuthModel(
|
|
||||||
token: oldData['token'], model: newModel);
|
|
||||||
await shared.setString(
|
|
||||||
Constant.bearerName, token);
|
|
||||||
ref.read(currentUserProvider.notifier).state =
|
|
||||||
newAuthData;
|
|
||||||
Navigator.pushNamed(context, homeRoute);
|
|
||||||
},
|
|
||||||
child: Card(
|
|
||||||
shadowColor:
|
|
||||||
selectedCompanyID.value == e.companyid
|
|
||||||
? Constant.bgIconHistory
|
|
||||||
: Colors.white,
|
|
||||||
surfaceTintColor:
|
|
||||||
selectedCompanyID.value == e.companyid
|
|
||||||
? Constant.bgIconHistory
|
|
||||||
: Colors.white,
|
|
||||||
// elevation: selectedCompanyID.value == e.companyid
|
|
||||||
// ? 0
|
|
||||||
// : 1,
|
|
||||||
elevation: 10,
|
|
||||||
color: selectedCompanyID.value == e.companyid
|
|
||||||
? Constant.bgIconHistory
|
|
||||||
: Colors.white,
|
|
||||||
child: Container(
|
|
||||||
padding: EdgeInsets.all(20),
|
|
||||||
width: MediaQuery.of(context).size.width,
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
flex: 1,
|
|
||||||
child: Icon(
|
|
||||||
Icons.corporate_fare,
|
|
||||||
color:
|
|
||||||
selectedCompanyID.value ==
|
|
||||||
e.companyid
|
|
||||||
? Constant.textRed
|
|
||||||
: Colors.black,
|
|
||||||
size: 30,
|
|
||||||
)),
|
|
||||||
SizedBox(
|
|
||||||
width: 10,
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 8,
|
|
||||||
child: Text(e.companyname ?? "",
|
|
||||||
softWrap: true,
|
|
||||||
maxLines: 3,
|
|
||||||
// overflow: ,
|
|
||||||
style: Constant.body1(
|
|
||||||
context: context)
|
|
||||||
.copyWith(
|
|
||||||
color: selectedCompanyID
|
|
||||||
.value ==
|
|
||||||
e.companyid
|
|
||||||
? Constant.textRed
|
|
||||||
: Colors.black,
|
|
||||||
fontSize: 25)),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
))
|
|
||||||
.toList()
|
|
||||||
// [
|
|
||||||
// Card(
|
|
||||||
// shadowColor: Colors.white,
|
|
||||||
// // surfaceTintColor: Colors.white,
|
|
||||||
// elevation: 0,
|
|
||||||
// color: Constant.bgIconHistory,
|
|
||||||
// child: Container(
|
|
||||||
// padding: EdgeInsets.all(10),
|
|
||||||
// width: MediaQuery.of(context).size.width,
|
|
||||||
// child: Row(
|
|
||||||
// children: [
|
|
||||||
// Icon(Icons.corporate_fare),
|
|
||||||
// SizedBox(
|
|
||||||
// width: 10,
|
|
||||||
// ),
|
|
||||||
// Text("Company",
|
|
||||||
// style: Constant.body1(context: context)
|
|
||||||
// .copyWith(color: Constant.textRed)),
|
|
||||||
// ],
|
|
||||||
// )),
|
|
||||||
// )
|
|
||||||
// ],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,69 +0,0 @@
|
|||||||
import 'package:app_petty_cash/model/company_model.dart';
|
|
||||||
import 'package:app_petty_cash/repository/company_repository.dart';
|
|
||||||
|
|
||||||
import '../../model/list_category_model.dart';
|
|
||||||
import '../../repository/transaksi_repository.dart';
|
|
||||||
import 'package:equatable/equatable.dart';
|
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
||||||
|
|
||||||
import '../../provider/dio_provider.dart';
|
|
||||||
import '../../repository/base_repository.dart';
|
|
||||||
|
|
||||||
abstract class ListCompanyState extends Equatable {
|
|
||||||
final DateTime date;
|
|
||||||
const ListCompanyState(this.date);
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [date];
|
|
||||||
}
|
|
||||||
|
|
||||||
class ListCompanyStateInit extends ListCompanyState {
|
|
||||||
ListCompanyStateInit() : super(DateTime.now());
|
|
||||||
}
|
|
||||||
|
|
||||||
class ListCompanyStateLoading extends ListCompanyState {
|
|
||||||
ListCompanyStateLoading() : super(DateTime.now());
|
|
||||||
}
|
|
||||||
|
|
||||||
class ListCompanyStateError extends ListCompanyState {
|
|
||||||
final String message;
|
|
||||||
ListCompanyStateError({
|
|
||||||
required this.message,
|
|
||||||
}) : super(DateTime.now());
|
|
||||||
}
|
|
||||||
|
|
||||||
class ListCompanyStateDone extends ListCompanyState {
|
|
||||||
final List<CompanyModel> model;
|
|
||||||
ListCompanyStateDone({
|
|
||||||
required this.model,
|
|
||||||
}) : super(DateTime.now());
|
|
||||||
}
|
|
||||||
|
|
||||||
//notifier
|
|
||||||
class ListCompanyNotifier extends StateNotifier<ListCompanyState> {
|
|
||||||
final Ref ref;
|
|
||||||
ListCompanyNotifier({
|
|
||||||
required this.ref,
|
|
||||||
}) : super(ListCompanyStateInit());
|
|
||||||
|
|
||||||
void getListCompany({required String userID}) async {
|
|
||||||
try {
|
|
||||||
state = ListCompanyStateLoading();
|
|
||||||
final dio = ref.read(dioProvider);
|
|
||||||
final resp =
|
|
||||||
await CompanyRepository(dio: dio).getListCompany(userID: userID);
|
|
||||||
state = ListCompanyStateDone(model: resp);
|
|
||||||
} catch (e) {
|
|
||||||
if (e is BaseRepositoryException) {
|
|
||||||
state = ListCompanyStateError(message: e.message.toString());
|
|
||||||
} else {
|
|
||||||
state = ListCompanyStateError(message: e.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//provider
|
|
||||||
final ListCompanyProvider =
|
|
||||||
StateNotifierProvider<ListCompanyNotifier, ListCompanyState>(
|
|
||||||
(ref) => ListCompanyNotifier(ref: ref),
|
|
||||||
);
|
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
import 'package:app_petty_cash/model/auth_model.dart';
|
|
||||||
import 'package:app_petty_cash/model/company_model.dart';
|
|
||||||
import 'package:app_petty_cash/repository/auth_repository.dart';
|
|
||||||
import 'package:app_petty_cash/repository/company_repository.dart';
|
|
||||||
|
|
||||||
import '../../model/list_category_model.dart';
|
|
||||||
import '../../repository/transaksi_repository.dart';
|
|
||||||
import 'package:equatable/equatable.dart';
|
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
||||||
|
|
||||||
import '../../provider/dio_provider.dart';
|
|
||||||
import '../../repository/base_repository.dart';
|
|
||||||
|
|
||||||
abstract class ChangePasswordState extends Equatable {
|
|
||||||
final DateTime date;
|
|
||||||
const ChangePasswordState(this.date);
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [date];
|
|
||||||
}
|
|
||||||
|
|
||||||
class ChangePasswordStateInit extends ChangePasswordState {
|
|
||||||
ChangePasswordStateInit() : super(DateTime.now());
|
|
||||||
}
|
|
||||||
|
|
||||||
class ChangePasswordStateLoading extends ChangePasswordState {
|
|
||||||
ChangePasswordStateLoading() : super(DateTime.now());
|
|
||||||
}
|
|
||||||
|
|
||||||
class ChangePasswordStateError extends ChangePasswordState {
|
|
||||||
final String message;
|
|
||||||
ChangePasswordStateError({
|
|
||||||
required this.message,
|
|
||||||
}) : super(DateTime.now());
|
|
||||||
}
|
|
||||||
|
|
||||||
class ChangePasswordStateDone extends ChangePasswordState {
|
|
||||||
final String model;
|
|
||||||
ChangePasswordStateDone({
|
|
||||||
required this.model,
|
|
||||||
}) : super(DateTime.now());
|
|
||||||
}
|
|
||||||
|
|
||||||
//notifier
|
|
||||||
class ChangePasswordNotifier extends StateNotifier<ChangePasswordState> {
|
|
||||||
final Ref ref;
|
|
||||||
ChangePasswordNotifier({
|
|
||||||
required this.ref,
|
|
||||||
}) : super(ChangePasswordStateInit());
|
|
||||||
|
|
||||||
void postChangePassword({
|
|
||||||
required String userID,
|
|
||||||
required String userToken,
|
|
||||||
required String userTokenx,
|
|
||||||
required String oldPassword,
|
|
||||||
required String newPassword,
|
|
||||||
required String confirmPassword,
|
|
||||||
}) async {
|
|
||||||
try {
|
|
||||||
state = ChangePasswordStateLoading();
|
|
||||||
final dio = ref.read(dioProvider);
|
|
||||||
final resp = await AuthRepository(dio: dio).changePassword(
|
|
||||||
userID: userID,
|
|
||||||
tokenx: userTokenx,
|
|
||||||
token: userToken,
|
|
||||||
oldPassword: oldPassword,
|
|
||||||
newPassword: newPassword,
|
|
||||||
confirmPassword: confirmPassword);
|
|
||||||
state = ChangePasswordStateDone(model: resp);
|
|
||||||
} catch (e) {
|
|
||||||
if (e is BaseRepositoryException) {
|
|
||||||
state = ChangePasswordStateError(message: e.message.toString());
|
|
||||||
} else {
|
|
||||||
state = ChangePasswordStateError(message: e.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//provider
|
|
||||||
final ChangePasswordProvider =
|
|
||||||
StateNotifierProvider<ChangePasswordNotifier, ChangePasswordState>(
|
|
||||||
(ref) => ChangePasswordNotifier(ref: ref),
|
|
||||||
);
|
|
||||||
@@ -1,428 +0,0 @@
|
|||||||
import 'package:app_petty_cash/app/constant.dart';
|
|
||||||
import 'package:app_petty_cash/widget/custom_drawer.dart';
|
|
||||||
import 'package:app_petty_cash/widget/sankbar_widget.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
|
||||||
|
|
||||||
import '../../app/route.dart';
|
|
||||||
import '../../provider/current_user_provider.dart';
|
|
||||||
import 'change_password_provider.dart';
|
|
||||||
|
|
||||||
class ChangePasswordScreen extends HookConsumerWidget {
|
|
||||||
const ChangePasswordScreen({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
|
||||||
final selectedUser = ref.read(currentUserProvider);
|
|
||||||
//menampung user token jika ada
|
|
||||||
final userToken = ref.read(currentUserProvider)?.token ?? "";
|
|
||||||
final userID = ref.read(currentUserProvider)?.model.M_UserID ?? "0";
|
|
||||||
final tokenx = ref.read(currentUserProvider)?.token ?? "";
|
|
||||||
|
|
||||||
final isLoading = useState(false);
|
|
||||||
|
|
||||||
final obscureTextOldPassword = useState<bool>(true);
|
|
||||||
final obscureTextNewPassword = useState<bool>(true);
|
|
||||||
final obscureTextConfirmPassword = useState<bool>(true);
|
|
||||||
|
|
||||||
final ctrlOldPassword = useTextEditingController(text: "");
|
|
||||||
final ctrlNewPassword = useTextEditingController(text: "");
|
|
||||||
final ctrlConfirmPassword = useTextEditingController(text: "");
|
|
||||||
final loading = useState(false);
|
|
||||||
|
|
||||||
// inisialisasi agar bisa cek apakah user sudah login sukses apa belum
|
|
||||||
useEffect(() {
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
|
||||||
final userID = ref.read(currentUserProvider)?.model.M_UserID ?? "0";
|
|
||||||
if (userID == "0") {
|
|
||||||
//not login
|
|
||||||
Navigator.of(context)
|
|
||||||
.pushNamedAndRemoveUntil(loginRoute, (route) => true);
|
|
||||||
|
|
||||||
// Navigator.popAndPushNamed(context, loginRoute);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return () {};
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
// fungsi logout
|
|
||||||
Logout() async {
|
|
||||||
final shared = await SharedPreferences.getInstance();
|
|
||||||
final bearerString = shared.get(Constant.bearerName).toString();
|
|
||||||
// print(bearerString);
|
|
||||||
if (bearerString.isNotEmpty) {
|
|
||||||
shared.remove(bearerString);
|
|
||||||
shared.clear();
|
|
||||||
// Navigator.popAndPushNamed(context, loginRoute);
|
|
||||||
ref.read(currentUserProvider.notifier).state = null;
|
|
||||||
Navigator.of(context)
|
|
||||||
.pushNamedAndRemoveUntil(loginRoute, (route) => false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// read provider home
|
|
||||||
ref.listen(
|
|
||||||
ChangePasswordProvider,
|
|
||||||
(previous, next) {
|
|
||||||
if (next is ChangePasswordStateLoading) {
|
|
||||||
loading.value = true;
|
|
||||||
} else if (next is ChangePasswordStateError) {
|
|
||||||
loading.value = false;
|
|
||||||
SanckbarWidget(context, next.message, snackbarType.error);
|
|
||||||
} else if (next is ChangePasswordStateDone) {
|
|
||||||
loading.value = false;
|
|
||||||
SanckbarWidget(
|
|
||||||
context,
|
|
||||||
"Ubah Password Berhasil!\nSilahkan Login dengan password baru",
|
|
||||||
snackbarType.success,
|
|
||||||
);
|
|
||||||
Logout();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
return Padding(
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
top: Constant.getActualYPhone(context: context, y: 30)),
|
|
||||||
child: Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
// centerTitle: true,
|
|
||||||
title: Text(
|
|
||||||
'Change Password',
|
|
||||||
style: TextStyle(color: Constant.textWhite),
|
|
||||||
),
|
|
||||||
backgroundColor: Constant.pcBtnBackgroundColor,
|
|
||||||
iconTheme: IconThemeData(
|
|
||||||
color: Constant.textWhite,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
drawer: CustomDrawer(),
|
|
||||||
body: SingleChildScrollView(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(20),
|
|
||||||
child: Container(
|
|
||||||
width: Constant.getActualXPhone(context: context, x: 390),
|
|
||||||
height: Constant.getActualYPhone(context: context, y: 844),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
//Old password
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
// top: Constant.getActualYPhone(context: context, y: 63),
|
|
||||||
left: Constant.getActualXPhone(context: context, x: 20),
|
|
||||||
right: Constant.getActualXPhone(context: context, x: 20),
|
|
||||||
),
|
|
||||||
child: Align(
|
|
||||||
alignment: Alignment.centerLeft,
|
|
||||||
child: Text(
|
|
||||||
'Old Password',
|
|
||||||
style: Constant.body1_400_dibulan(context: context)
|
|
||||||
.copyWith(
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
color: Constant.textBlack),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: Constant.getActualYPhone(context: context, y: 4),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
top: Constant.getActualYPhone(context: context, y: 5),
|
|
||||||
left: Constant.getActualXPhone(context: context, x: 20),
|
|
||||||
right: Constant.getActualXPhone(context: context, x: 20),
|
|
||||||
),
|
|
||||||
child: TextField(
|
|
||||||
obscureText: obscureTextOldPassword.value,
|
|
||||||
controller: ctrlOldPassword,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
suffixIcon: IconButton(
|
|
||||||
icon: Icon(
|
|
||||||
obscureTextOldPassword.value
|
|
||||||
? Icons.visibility
|
|
||||||
: Icons.visibility_off,
|
|
||||||
color: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
obscureTextOldPassword.value = !obscureTextOldPassword.value;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
hintStyle:
|
|
||||||
Constant.body2_400(context: context).copyWith(
|
|
||||||
color: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
labelStyle:
|
|
||||||
Constant.body2_400(context: context).copyWith(
|
|
||||||
color: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: Colors.orange,
|
|
||||||
width: 1,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
focusedBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: Constant.textGreyv2,
|
|
||||||
width: 1,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
labelText: "OldPassword",
|
|
||||||
hintText: 'Old Password',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: Constant.getActualYPhone(context: context, y: 40),
|
|
||||||
),
|
|
||||||
//New password
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
// top: Constant.getActualYPhone(context: context, y: 63),
|
|
||||||
left: Constant.getActualXPhone(context: context, x: 20),
|
|
||||||
right: Constant.getActualXPhone(context: context, x: 20),
|
|
||||||
),
|
|
||||||
child: Align(
|
|
||||||
alignment: Alignment.centerLeft,
|
|
||||||
child: Text(
|
|
||||||
'New Password',
|
|
||||||
style: Constant.body1_400_dibulan(context: context)
|
|
||||||
.copyWith(
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
color: Constant.textBlack),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: Constant.getActualYPhone(context: context, y: 4),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
top: Constant.getActualYPhone(context: context, y: 5),
|
|
||||||
left: Constant.getActualXPhone(context: context, x: 20),
|
|
||||||
right: Constant.getActualXPhone(context: context, x: 20),
|
|
||||||
),
|
|
||||||
child: TextField(
|
|
||||||
obscureText: obscureTextNewPassword.value,
|
|
||||||
controller: ctrlNewPassword,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
suffixIcon: IconButton(
|
|
||||||
icon: Icon(
|
|
||||||
obscureTextNewPassword.value
|
|
||||||
? Icons.visibility
|
|
||||||
: Icons.visibility_off,
|
|
||||||
color: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
obscureTextNewPassword.value = !obscureTextNewPassword.value;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
hintStyle:
|
|
||||||
Constant.body2_400(context: context).copyWith(
|
|
||||||
color: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
labelStyle:
|
|
||||||
Constant.body2_400(context: context).copyWith(
|
|
||||||
color: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: Colors.orange,
|
|
||||||
width: 1,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
focusedBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: Constant.textGreyv2,
|
|
||||||
width: 1,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
labelText: "New Password",
|
|
||||||
hintText: 'New Password',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
SizedBox(
|
|
||||||
height: Constant.getActualYPhone(context: context, y: 40),
|
|
||||||
),
|
|
||||||
|
|
||||||
// Confirm password
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
// top: Constant.getActualYPhone(context: context, y: 63),
|
|
||||||
left: Constant.getActualXPhone(context: context, x: 20),
|
|
||||||
right: Constant.getActualXPhone(context: context, x: 20),
|
|
||||||
),
|
|
||||||
child: Align(
|
|
||||||
alignment: Alignment.centerLeft,
|
|
||||||
child: Text(
|
|
||||||
'Confirm Password',
|
|
||||||
style: Constant.body1_400_dibulan(context: context)
|
|
||||||
.copyWith(
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
color: Constant.textBlack),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: Constant.getActualYPhone(context: context, y: 4),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
top: Constant.getActualYPhone(context: context, y: 5),
|
|
||||||
left: Constant.getActualXPhone(context: context, x: 20),
|
|
||||||
right: Constant.getActualXPhone(context: context, x: 20),
|
|
||||||
),
|
|
||||||
child: TextField(
|
|
||||||
obscureText: obscureTextConfirmPassword.value,
|
|
||||||
controller: ctrlConfirmPassword,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
suffixIcon: IconButton(
|
|
||||||
icon: Icon(
|
|
||||||
obscureTextConfirmPassword.value
|
|
||||||
? Icons.visibility
|
|
||||||
: Icons.visibility_off,
|
|
||||||
color: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
obscureTextConfirmPassword.value = !obscureTextConfirmPassword.value;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
hintStyle:
|
|
||||||
Constant.body2_400(context: context).copyWith(
|
|
||||||
color: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
labelStyle:
|
|
||||||
Constant.body2_400(context: context).copyWith(
|
|
||||||
color: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: Colors.orange,
|
|
||||||
width: 1,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
focusedBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: Constant.textGreyv2,
|
|
||||||
width: 1,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
labelText: "Confirm Password",
|
|
||||||
hintText: 'Confirm Password',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: Constant.getActualYPhone(context: context, y: 50),
|
|
||||||
),
|
|
||||||
|
|
||||||
//Button Update Password
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
left: Constant.getActualXPhone(context: context, x: 20),
|
|
||||||
right: Constant.getActualXPhone(context: context, x: 20),
|
|
||||||
),
|
|
||||||
child: SizedBox(
|
|
||||||
width: Constant.getActualXPhone(context: context, x: 390),
|
|
||||||
height: Constant.getActualYPhone(context: context, y: 50),
|
|
||||||
child: ElevatedButton(
|
|
||||||
onPressed: (loading.value == true)
|
|
||||||
? null
|
|
||||||
: () {
|
|
||||||
if (ctrlNewPassword.text !=
|
|
||||||
ctrlConfirmPassword.text) {
|
|
||||||
SanckbarWidget(
|
|
||||||
context,
|
|
||||||
'New Password dan dan confirm password tidak sama!',
|
|
||||||
snackbarType.warning);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (ctrlOldPassword.text ==
|
|
||||||
ctrlConfirmPassword.text) {
|
|
||||||
SanckbarWidget(
|
|
||||||
context,
|
|
||||||
'Password lama dan baru tidak boleh sama',
|
|
||||||
snackbarType.warning);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (ctrlOldPassword.text.isEmpty ||
|
|
||||||
ctrlNewPassword.text.isEmpty ||
|
|
||||||
ctrlConfirmPassword.text.isEmpty) {
|
|
||||||
isLoading.value = true;
|
|
||||||
SanckbarWidget(context, 'Inputan harus diisi',
|
|
||||||
snackbarType.warning);
|
|
||||||
} else {
|
|
||||||
ref
|
|
||||||
.read(ChangePasswordProvider.notifier)
|
|
||||||
.postChangePassword(
|
|
||||||
userTokenx: tokenx,
|
|
||||||
userToken: userToken,
|
|
||||||
userID: userID,
|
|
||||||
oldPassword: ctrlOldPassword.text,
|
|
||||||
newPassword: ctrlNewPassword.text,
|
|
||||||
confirmPassword:
|
|
||||||
ctrlConfirmPassword.text,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
style: ButtonStyle(
|
|
||||||
backgroundColor: MaterialStateColor.resolveWith(
|
|
||||||
(st) => (loading.value == true)
|
|
||||||
? Constant.textGrey
|
|
||||||
: Constant.pcBtnBackgroundColor),
|
|
||||||
shape:
|
|
||||||
MaterialStateProperty.all<RoundedRectangleBorder>(
|
|
||||||
RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
side: BorderSide(
|
|
||||||
color: Constant.pcBtnBackgroundColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
shadowColor:
|
|
||||||
MaterialStateProperty.all(Color(0xffff48423d)),
|
|
||||||
elevation: MaterialStateProperty.all(4.0),
|
|
||||||
),
|
|
||||||
child: Stack(
|
|
||||||
children: [
|
|
||||||
(isLoading.value)
|
|
||||||
? SizedBox(
|
|
||||||
width: Constant.getActualXPhone(
|
|
||||||
context: context, x: 24),
|
|
||||||
height: Constant.getActualYPhone(
|
|
||||||
context: context, y: 32),
|
|
||||||
child: Center(
|
|
||||||
child: CircularProgressIndicator(
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: Align(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
child: Text(
|
|
||||||
'Submit',
|
|
||||||
style: Constant.titleH3_700(
|
|
||||||
context: context)
|
|
||||||
.copyWith(
|
|
||||||
color: Constant.textLoginColor),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,56 +1,17 @@
|
|||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
import 'package:app_petty_cash/screen/home/info_account_balance_provider.dart';
|
|
||||||
import 'package:app_petty_cash/screen/home/list_transaksi_home_provider.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:intl/intl.dart';
|
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
|
||||||
|
|
||||||
import '../../app/constant.dart';
|
import '../../app/constant.dart';
|
||||||
import '../../app/route.dart';
|
import '../../app/route.dart';
|
||||||
import '../../model/info_account_balance.dart';
|
|
||||||
import '../../model/list_transaksi_model.dart';
|
|
||||||
import '../../provider/current_info_account_balance_provider.dart';
|
|
||||||
import '../../provider/current_user_provider.dart';
|
import '../../provider/current_user_provider.dart';
|
||||||
import '../../widget/custom_drawer.dart';
|
import '../../widget/custom_drawer.dart';
|
||||||
import '../../widget/history_row_atas_widget.dart';
|
|
||||||
import '../../widget/sankbar_widget.dart';
|
|
||||||
|
|
||||||
class HomeScreen extends HookConsumerWidget {
|
class HomeScreen extends HookConsumerWidget {
|
||||||
const HomeScreen({super.key});
|
const HomeScreen({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final M_CompanyID = useState<String>("0");
|
|
||||||
final searchTransaksiHomeLoading = useState<bool>(false);
|
|
||||||
final infoAccountBalanceHomeLoading = useState<bool>(false);
|
|
||||||
final listTransaksiHome = useState<List<ListTransaksiHomeModel>>(
|
|
||||||
List.empty(growable: true),
|
|
||||||
);
|
|
||||||
final M_CompanyName = useState("-");
|
|
||||||
|
|
||||||
// company name
|
|
||||||
Future<String> getCompanyName() async {
|
|
||||||
final shared = await SharedPreferences.getInstance();
|
|
||||||
String M_CompanyName = "-";
|
|
||||||
|
|
||||||
if (shared != null) {
|
|
||||||
final bearerString = shared.get(Constant.bearerName).toString();
|
|
||||||
final xmodel = jsonDecode(bearerString);
|
|
||||||
if (xmodel != null) {
|
|
||||||
M_CompanyName = xmodel["model"]["M_CompanyName"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (M_CompanyName == "0") {
|
|
||||||
// throw BaseRepositoryException(message: 'Invalid Company ID');
|
|
||||||
}
|
|
||||||
|
|
||||||
return M_CompanyName;
|
|
||||||
}
|
|
||||||
|
|
||||||
useEffect(() {
|
useEffect(() {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
||||||
final userID = ref.read(currentUserProvider)?.model.M_UserID ?? "0";
|
final userID = ref.read(currentUserProvider)?.model.M_UserID ?? "0";
|
||||||
@@ -62,104 +23,10 @@ class HomeScreen extends HookConsumerWidget {
|
|||||||
// Navigator.popAndPushNamed(context, loginRoute);
|
// Navigator.popAndPushNamed(context, loginRoute);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
M_CompanyName.value = await getCompanyName();
|
|
||||||
});
|
});
|
||||||
return () {};
|
return () {};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
Future<String> getCompanyID() async {
|
|
||||||
final shared = await SharedPreferences.getInstance();
|
|
||||||
String M_CompanyID = "0";
|
|
||||||
|
|
||||||
if (shared != null) {
|
|
||||||
final bearerString = shared.get(Constant.bearerName).toString();
|
|
||||||
final xmodel = jsonDecode(bearerString);
|
|
||||||
if (xmodel != null) {
|
|
||||||
M_CompanyID = xmodel["model"]["M_CompanyID"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (M_CompanyID == "0") {
|
|
||||||
// throw BaseRepositoryException(message: 'Invalid Company ID');
|
|
||||||
}
|
|
||||||
|
|
||||||
return M_CompanyID;
|
|
||||||
}
|
|
||||||
|
|
||||||
useEffect(() {
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
|
||||||
M_CompanyID.value = await getCompanyID();
|
|
||||||
// info account balance
|
|
||||||
ref
|
|
||||||
.read(infoAccountBalanceHomeProvider.notifier)
|
|
||||||
.infoAccountBalanceHome(M_CompanyID.value);
|
|
||||||
});
|
|
||||||
return () {};
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
// read provider home
|
|
||||||
ref.listen(
|
|
||||||
listTransaksiHomeProvider,
|
|
||||||
(previous, next) {
|
|
||||||
if (next is ListTransaksiHomeStateLoading) {
|
|
||||||
searchTransaksiHomeLoading.value = true;
|
|
||||||
} else if (next is ListTransaksiHomeStateError) {
|
|
||||||
// print(next.message);
|
|
||||||
searchTransaksiHomeLoading.value = false;
|
|
||||||
SanckbarWidget(context, next.message, snackbarType.error);
|
|
||||||
} else if (next is ListTransaksiHomeStateDone) {
|
|
||||||
// print(jsonEncode(next.model));
|
|
||||||
// print(next.model.length);
|
|
||||||
listTransaksiHome.value = next.model;
|
|
||||||
searchTransaksiHomeLoading.value = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
// read provider info account balance
|
|
||||||
ref.listen(
|
|
||||||
infoAccountBalanceHomeProvider,
|
|
||||||
(previous, next) {
|
|
||||||
if (next is InfoAccountBalanceHomeStateLoading) {
|
|
||||||
infoAccountBalanceHomeLoading.value = true;
|
|
||||||
} else if (next is InfoAccountBalanceHomeStateError) {
|
|
||||||
// print(next.message);
|
|
||||||
infoAccountBalanceHomeLoading.value = false;
|
|
||||||
SanckbarWidget(context, next.message, snackbarType.error);
|
|
||||||
} else if (next is InfoAccountBalanceHomeStateDone) {
|
|
||||||
// print(jsonEncode(next.model));
|
|
||||||
// print(next.model.length);
|
|
||||||
// infoAccountBalanceObject.value = next.model;
|
|
||||||
ref.read(currentInfoAccountBalanceProvider.notifier).state =
|
|
||||||
InfoAccountBalanceModel(
|
|
||||||
kredit: next.model.kredit,
|
|
||||||
debit: next.model.debit,
|
|
||||||
totalAll: next.model.totalAll,
|
|
||||||
);
|
|
||||||
infoAccountBalanceHomeLoading.value = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
String formatDateString(String inputDate) {
|
|
||||||
try {
|
|
||||||
// Parsing tanggal dari string input
|
|
||||||
DateTime date =
|
|
||||||
DateFormat('dd-MM-yyyy HH:mm:ss', 'id').parse(inputDate);
|
|
||||||
|
|
||||||
// Format tanggal ke '30 Des 2023'
|
|
||||||
String formattedDate =
|
|
||||||
DateFormat('dd MMM yyyy HH:mm:ss', 'id').format(date);
|
|
||||||
|
|
||||||
return formattedDate;
|
|
||||||
} catch (e) {
|
|
||||||
// Tangkap kesalahan jika format tanggal tidak sesuai
|
|
||||||
print('Error parsing date: $e');
|
|
||||||
// return 'Format Tanggal Salah';
|
|
||||||
return inputDate;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
top: Constant.getActualYPhone(context: context, y: 30),
|
top: Constant.getActualYPhone(context: context, y: 30),
|
||||||
@@ -167,12 +34,8 @@ class HomeScreen extends HookConsumerWidget {
|
|||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(
|
title: Text(
|
||||||
// 'Home Screen',
|
'Home Screen',
|
||||||
M_CompanyName.value,
|
style: TextStyle(color: Constant.textWhite),
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: TextStyle(
|
|
||||||
color: Constant.textWhite,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
backgroundColor: Constant.pcBtnBackgroundColor,
|
backgroundColor: Constant.pcBtnBackgroundColor,
|
||||||
iconTheme: IconThemeData(
|
iconTheme: IconThemeData(
|
||||||
@@ -181,337 +44,8 @@ class HomeScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
drawer: CustomDrawer(),
|
drawer: CustomDrawer(),
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: Padding(
|
child: Center(
|
||||||
padding: EdgeInsets.only(
|
child: Text('Home Screen Content'),
|
||||||
top: Constant.getActualYPhone(context: context, y: 36),
|
|
||||||
left: Constant.getActualXPhone(context: context, x: 34),
|
|
||||||
right: Constant.getActualXPhone(context: context, x: 34),
|
|
||||||
),
|
|
||||||
child: RefreshIndicator(
|
|
||||||
onRefresh: () async {
|
|
||||||
ref
|
|
||||||
.read(infoAccountBalanceHomeProvider.notifier)
|
|
||||||
.infoAccountBalanceHome(M_CompanyID.value);
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
width: Constant.getActualXPhone(context: context, x: 390),
|
|
||||||
height: Constant.getActualYPhone(context: context, y: 844),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
width: Constant.getActualXPhone(context: context, x: 332),
|
|
||||||
height:
|
|
||||||
Constant.getActualYPhone(context: context, y: 173),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
// color: Colors.black12,
|
|
||||||
borderRadius: BorderRadius.circular(20),
|
|
||||||
image: DecorationImage(
|
|
||||||
image: AssetImage('images/background_card.png'),
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
),
|
|
||||||
boxShadow: [
|
|
||||||
BoxShadow(
|
|
||||||
color: Color.fromRGBO(145, 158, 171, 0.16),
|
|
||||||
offset: Offset(0, 24),
|
|
||||||
blurRadius: 48,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
//Isi Card
|
|
||||||
child: (infoAccountBalanceHomeLoading.value)
|
|
||||||
? Center(
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
)
|
|
||||||
: Container(
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
// Text1 & Text2
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
top: Constant.getActualYPhone(
|
|
||||||
context: context, y: 17),
|
|
||||||
left: Constant.getActualXPhone(
|
|
||||||
context: context, x: 81),
|
|
||||||
right: Constant.getActualXPhone(
|
|
||||||
context: context, x: 81),
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'Account Balance',
|
|
||||||
style: Constant.body1(
|
|
||||||
context: context)
|
|
||||||
.copyWith(
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
color: Constant.textWhite),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
ref
|
|
||||||
.watch(
|
|
||||||
currentInfoAccountBalanceProvider)
|
|
||||||
.totalAll
|
|
||||||
.toString(),
|
|
||||||
style: Constant.H4_700V3(
|
|
||||||
context: context)
|
|
||||||
.copyWith(
|
|
||||||
color: Constant.textWhite,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
SizedBox(
|
|
||||||
height: Constant.getActualYPhone(
|
|
||||||
context: context, y: 27),
|
|
||||||
),
|
|
||||||
|
|
||||||
//Debit dan Kredit
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment:
|
|
||||||
MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
// Spasi di sebelah kiri "Check In"
|
|
||||||
Expanded(
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
left: Constant.getActualXPhone(
|
|
||||||
context: context, x: 20),
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'Debit',
|
|
||||||
style: Constant.body1(
|
|
||||||
context: context)
|
|
||||||
.copyWith(
|
|
||||||
fontWeight:
|
|
||||||
FontWeight.w400,
|
|
||||||
color:
|
|
||||||
Constant.textWhite),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
ref
|
|
||||||
.watch(
|
|
||||||
currentInfoAccountBalanceProvider)
|
|
||||||
.debit
|
|
||||||
.toString(),
|
|
||||||
style: Constant.H4_700V3(
|
|
||||||
context: context)
|
|
||||||
.copyWith(
|
|
||||||
color:
|
|
||||||
Constant.textWhite),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
// SizedBox(
|
|
||||||
// width: Constant.getActualXPhone(
|
|
||||||
// context: context, x: 51),
|
|
||||||
// ),
|
|
||||||
|
|
||||||
Expanded(
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
right: Constant.getActualXPhone(
|
|
||||||
context: context, x: 28),
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'Credit',
|
|
||||||
style: Constant.body1(
|
|
||||||
context: context)
|
|
||||||
.copyWith(
|
|
||||||
fontWeight:
|
|
||||||
FontWeight.w400,
|
|
||||||
color:
|
|
||||||
Constant.textWhite),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
ref
|
|
||||||
.watch(
|
|
||||||
currentInfoAccountBalanceProvider)
|
|
||||||
.kredit
|
|
||||||
.toString(),
|
|
||||||
style: Constant.H4_700V3(
|
|
||||||
context: context)
|
|
||||||
.copyWith(
|
|
||||||
color:
|
|
||||||
Constant.textWhite),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: Constant.getActualYPhone(
|
|
||||||
context: context, y: 17),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
SizedBox(
|
|
||||||
height: Constant.getActualYPhone(context: context, y: 44),
|
|
||||||
),
|
|
||||||
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.centerLeft,
|
|
||||||
child: Text(
|
|
||||||
'Transaksi Terkini',
|
|
||||||
style: Constant.titleH5_600(context: context)
|
|
||||||
.copyWith(color: Constant.textBlack),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
SizedBox(
|
|
||||||
height: Constant.getActualYPhone(context: context, y: 24),
|
|
||||||
),
|
|
||||||
|
|
||||||
// list transaksi
|
|
||||||
(searchTransaksiHomeLoading.value)
|
|
||||||
? Center(
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
)
|
|
||||||
: Container(
|
|
||||||
child: Expanded(
|
|
||||||
child: ListView.builder(
|
|
||||||
itemCount: listTransaksiHome.value.length,
|
|
||||||
itemBuilder: (context, idx) {
|
|
||||||
return Padding(
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
bottom: Constant.getActualYPhone(
|
|
||||||
context: context,
|
|
||||||
y: 10,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Card(
|
|
||||||
elevation: 2.0,
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.all(10),
|
|
||||||
child: Column(
|
|
||||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
// mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
// atas
|
|
||||||
HistoryRowAtasWidget(
|
|
||||||
icon_category_id:
|
|
||||||
listTransaksiHome
|
|
||||||
.value[idx].kategoriid
|
|
||||||
.toString(),
|
|
||||||
icon_category_name:
|
|
||||||
listTransaksiHome
|
|
||||||
.value[idx].kategoriname
|
|
||||||
.toString(),
|
|
||||||
amount: listTransaksiHome
|
|
||||||
.value[idx].amount
|
|
||||||
.toString(),
|
|
||||||
tglTransaksi: listTransaksiHome
|
|
||||||
.value[idx].tanggaltransaksi
|
|
||||||
.toString(),
|
|
||||||
tipe: listTransaksiHome
|
|
||||||
.value[idx].tipe
|
|
||||||
.toString(),
|
|
||||||
),
|
|
||||||
|
|
||||||
SizedBox(
|
|
||||||
height: Constant.getActualYPhone(
|
|
||||||
context: context, y: 10),
|
|
||||||
),
|
|
||||||
|
|
||||||
// catatan
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.centerLeft,
|
|
||||||
child: Text(
|
|
||||||
listTransaksiHome
|
|
||||||
.value[idx].note
|
|
||||||
.toString(),
|
|
||||||
style: Constant.body1(
|
|
||||||
context: context)
|
|
||||||
.copyWith(
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
color: Constant.textBlack,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
SizedBox(
|
|
||||||
height: Constant.getActualYPhone(
|
|
||||||
context: context, y: 10),
|
|
||||||
),
|
|
||||||
|
|
||||||
// Tanggal Created and by align right
|
|
||||||
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment:
|
|
||||||
MainAxisAlignment.end,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'created : ' +
|
|
||||||
formatDateString(
|
|
||||||
listTransaksiHome
|
|
||||||
.value[idx]
|
|
||||||
.tanggalcreated
|
|
||||||
.toString(),
|
|
||||||
),
|
|
||||||
overflow:
|
|
||||||
TextOverflow.ellipsis,
|
|
||||||
style: Constant.body1(
|
|
||||||
context: context)
|
|
||||||
.copyWith(
|
|
||||||
fontWeight:
|
|
||||||
FontWeight.normal,
|
|
||||||
fontStyle: FontStyle.italic,
|
|
||||||
color: Constant.textBlack,
|
|
||||||
fontSize: 14,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: Container(
|
|
||||||
child: Text(
|
|
||||||
' by : ' +
|
|
||||||
listTransaksiHome
|
|
||||||
.value[idx]
|
|
||||||
.usertransaksi
|
|
||||||
.toString(),
|
|
||||||
overflow:
|
|
||||||
TextOverflow.ellipsis,
|
|
||||||
style: Constant.body1(
|
|
||||||
context: context)
|
|
||||||
.copyWith(
|
|
||||||
fontWeight:
|
|
||||||
FontWeight.normal,
|
|
||||||
fontStyle:
|
|
||||||
FontStyle.italic,
|
|
||||||
color: Constant
|
|
||||||
.pcBtnBackgroundColor,
|
|
||||||
fontSize: 14,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,75 +0,0 @@
|
|||||||
import 'package:app_petty_cash/provider/current_info_account_balance_provider.dart';
|
|
||||||
import 'package:app_petty_cash/repository/home_repository.dart';
|
|
||||||
import 'package:equatable/equatable.dart';
|
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
||||||
|
|
||||||
import '../../model/info_account_balance.dart';
|
|
||||||
import '../../provider/dio_provider.dart';
|
|
||||||
import '../../repository/base_repository.dart';
|
|
||||||
import 'list_transaksi_home_provider.dart';
|
|
||||||
|
|
||||||
abstract class InfoAccountBalanceHomeState extends Equatable {
|
|
||||||
final DateTime date;
|
|
||||||
const InfoAccountBalanceHomeState(this.date);
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [date];
|
|
||||||
}
|
|
||||||
|
|
||||||
class InfoAccountBalanceHomeStateInit extends InfoAccountBalanceHomeState {
|
|
||||||
InfoAccountBalanceHomeStateInit() : super(DateTime.now());
|
|
||||||
}
|
|
||||||
|
|
||||||
class InfoAccountBalanceHomeStateLoading extends InfoAccountBalanceHomeState {
|
|
||||||
InfoAccountBalanceHomeStateLoading() : super(DateTime.now());
|
|
||||||
}
|
|
||||||
|
|
||||||
class InfoAccountBalanceHomeStateError extends InfoAccountBalanceHomeState {
|
|
||||||
final String message;
|
|
||||||
InfoAccountBalanceHomeStateError({
|
|
||||||
required this.message,
|
|
||||||
}) : super(DateTime.now());
|
|
||||||
}
|
|
||||||
|
|
||||||
class InfoAccountBalanceHomeStateDone extends InfoAccountBalanceHomeState {
|
|
||||||
final InfoAccountBalanceModel model;
|
|
||||||
// final String resp;
|
|
||||||
InfoAccountBalanceHomeStateDone({
|
|
||||||
required this.model,
|
|
||||||
}) : super(DateTime.now());
|
|
||||||
}
|
|
||||||
|
|
||||||
//notifier
|
|
||||||
class InfoAccountBalanceHomeNotifier
|
|
||||||
extends StateNotifier<InfoAccountBalanceHomeState> {
|
|
||||||
final Ref ref;
|
|
||||||
InfoAccountBalanceHomeNotifier({
|
|
||||||
required this.ref,
|
|
||||||
}) : super(InfoAccountBalanceHomeStateInit());
|
|
||||||
|
|
||||||
void infoAccountBalanceHome(
|
|
||||||
String companyid,
|
|
||||||
) async {
|
|
||||||
try {
|
|
||||||
state = InfoAccountBalanceHomeStateLoading();
|
|
||||||
final dio = ref.read(dioProvider);
|
|
||||||
final resp = await HomeRepository(dio: dio).getInfoAccountBalance(
|
|
||||||
companyid,
|
|
||||||
);
|
|
||||||
state = InfoAccountBalanceHomeStateDone(model: resp);
|
|
||||||
// list transaksi home
|
|
||||||
ref.read(listTransaksiHomeProvider.notifier).listTransaksiHome(companyid);
|
|
||||||
} catch (e) {
|
|
||||||
if (e is BaseRepositoryException) {
|
|
||||||
state = InfoAccountBalanceHomeStateError(message: e.message.toString());
|
|
||||||
} else {
|
|
||||||
state = InfoAccountBalanceHomeStateError(message: e.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//provider
|
|
||||||
final infoAccountBalanceHomeProvider = StateNotifierProvider<
|
|
||||||
InfoAccountBalanceHomeNotifier, InfoAccountBalanceHomeState>(
|
|
||||||
(ref) => InfoAccountBalanceHomeNotifier(ref: ref),
|
|
||||||
);
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
|
|
||||||
import 'package:app_petty_cash/repository/home_repository.dart';
|
|
||||||
import 'package:equatable/equatable.dart';
|
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
||||||
|
|
||||||
import '../../model/list_transaksi_model.dart';
|
|
||||||
import '../../repository/transaksi_repository.dart';
|
|
||||||
import '../../provider/dio_provider.dart';
|
|
||||||
import '../../repository/base_repository.dart';
|
|
||||||
|
|
||||||
abstract class ListTransaksiHomeState extends Equatable {
|
|
||||||
final DateTime date;
|
|
||||||
const ListTransaksiHomeState(this.date);
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [date];
|
|
||||||
}
|
|
||||||
|
|
||||||
class ListTransaksiHomeStateInit extends ListTransaksiHomeState {
|
|
||||||
ListTransaksiHomeStateInit() : super(DateTime.now());
|
|
||||||
}
|
|
||||||
|
|
||||||
class ListTransaksiHomeStateLoading extends ListTransaksiHomeState {
|
|
||||||
ListTransaksiHomeStateLoading() : super(DateTime.now());
|
|
||||||
}
|
|
||||||
|
|
||||||
class ListTransaksiHomeStateError extends ListTransaksiHomeState {
|
|
||||||
final String message;
|
|
||||||
ListTransaksiHomeStateError({
|
|
||||||
required this.message,
|
|
||||||
}) : super(DateTime.now());
|
|
||||||
}
|
|
||||||
|
|
||||||
class ListTransaksiHomeStateDone extends ListTransaksiHomeState {
|
|
||||||
final List<ListTransaksiHomeModel> model;
|
|
||||||
// final String resp;
|
|
||||||
ListTransaksiHomeStateDone({
|
|
||||||
required this.model,
|
|
||||||
}) : super(DateTime.now());
|
|
||||||
}
|
|
||||||
|
|
||||||
//notifier
|
|
||||||
class ListTransaksiHomeNotifier extends StateNotifier<ListTransaksiHomeState> {
|
|
||||||
final Ref ref;
|
|
||||||
ListTransaksiHomeNotifier({
|
|
||||||
required this.ref,
|
|
||||||
}) : super(ListTransaksiHomeStateInit());
|
|
||||||
|
|
||||||
void listTransaksiHome(
|
|
||||||
String companyid,
|
|
||||||
) async {
|
|
||||||
try {
|
|
||||||
state = ListTransaksiHomeStateLoading();
|
|
||||||
final dio = ref.read(dioProvider);
|
|
||||||
final resp = await HomeRepository(dio: dio).getTransaksiListHome(
|
|
||||||
companyid,
|
|
||||||
);
|
|
||||||
state = ListTransaksiHomeStateDone(model: resp);
|
|
||||||
} catch (e) {
|
|
||||||
if (e is BaseRepositoryException) {
|
|
||||||
state = ListTransaksiHomeStateError(message: e.message.toString());
|
|
||||||
} else {
|
|
||||||
state = ListTransaksiHomeStateError(message: e.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//provider
|
|
||||||
final listTransaksiHomeProvider =
|
|
||||||
StateNotifierProvider<ListTransaksiHomeNotifier, ListTransaksiHomeState>(
|
|
||||||
(ref) => ListTransaksiHomeNotifier(ref: ref),
|
|
||||||
);
|
|
||||||
@@ -114,7 +114,7 @@ class LoginFormScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
width: Constant.getActualXPhone(context: context, x: 390),
|
width: Constant.getActualXPhone(context: context, x: 390),
|
||||||
// height: Constant.getActualYPhone(context: context, y: 485),
|
height: Constant.getActualYPhone(context: context, y: 485),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
|||||||
@@ -55,22 +55,22 @@ class LoginScreen extends HookConsumerWidget {
|
|||||||
onTap: () => FocusManager.instance.primaryFocus?.unfocus(),
|
onTap: () => FocusManager.instance.primaryFocus?.unfocus(),
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
resizeToAvoidBottomInset: true,
|
resizeToAvoidBottomInset: true,
|
||||||
// backgroundColor: Colors.transparent,
|
backgroundColor: Constant.backgroundColor,
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Container(
|
child: Container(
|
||||||
width: Constant.getActualXPhone(context: context, x: 390),
|
width: Constant.getActualXPhone(context: context, x: 390),
|
||||||
height: Constant.getActualYPhone(context: context, y: 844),
|
height: Constant.getActualYPhone(context: context, y: 844),
|
||||||
// decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
// gradient: LinearGradient(
|
gradient: LinearGradient(
|
||||||
// colors: [
|
colors: [
|
||||||
// Color(0xffdadae6),
|
Color(0xffdadae6),
|
||||||
// Color(0xfff6f7fb),
|
Color(0xfff6f7fb),
|
||||||
// ],
|
],
|
||||||
// begin: Alignment.centerLeft,
|
begin: Alignment.centerLeft,
|
||||||
// end: Alignment.centerRight,
|
end: Alignment.centerRight,
|
||||||
// ),
|
),
|
||||||
// ),
|
),
|
||||||
// child: BlockBodyV2(),
|
// child: BlockBodyV2(),
|
||||||
child: LoginFormScreen(),
|
child: LoginFormScreen(),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -31,10 +31,6 @@ class ReportScreen extends HookConsumerWidget {
|
|||||||
final tglAkhirTmp = useState<String>("");
|
final tglAkhirTmp = useState<String>("");
|
||||||
String M_CompanyID = "0";
|
String M_CompanyID = "0";
|
||||||
|
|
||||||
String timeStamp = DateFormat('dd-MM-yyyy').format(
|
|
||||||
DateTime.now(),
|
|
||||||
);
|
|
||||||
|
|
||||||
Future<String> getCompanyID() async {
|
Future<String> getCompanyID() async {
|
||||||
final shared = await SharedPreferences.getInstance();
|
final shared = await SharedPreferences.getInstance();
|
||||||
String M_CompanyID = "0";
|
String M_CompanyID = "0";
|
||||||
@@ -280,168 +276,175 @@ class ReportScreen extends HookConsumerWidget {
|
|||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
ElevatedButton(
|
Expanded(
|
||||||
style: ButtonStyle(
|
child: ElevatedButton(
|
||||||
backgroundColor: MaterialStateColor.resolveWith(
|
style: ButtonStyle(
|
||||||
(states) => Colors.white),
|
backgroundColor: MaterialStateColor.resolveWith(
|
||||||
// side: MaterialStateBorderSide.resolveWith(
|
(states) => Colors.white),
|
||||||
// (states) => BorderSide(color: Colors.green),
|
// side: MaterialStateBorderSide.resolveWith(
|
||||||
// ),
|
// (states) => BorderSide(color: Colors.green),
|
||||||
// backgroundColor: MaterialStateColor.resolveWith(
|
// ),
|
||||||
// (st) => Constant.pcBtnBackgroundColor),
|
|
||||||
shape:
|
// backgroundColor: MaterialStateColor.resolveWith(
|
||||||
MaterialStateProperty.all<RoundedRectangleBorder>(
|
// (st) => Constant.pcBtnBackgroundColor),
|
||||||
RoundedRectangleBorder(
|
shape:
|
||||||
borderRadius: BorderRadius.circular(8),
|
MaterialStateProperty.all<RoundedRectangleBorder>(
|
||||||
side: BorderSide(
|
RoundedRectangleBorder(
|
||||||
color: Colors.green,
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
side: BorderSide(
|
||||||
|
color: Colors.green,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
shadowColor:
|
||||||
|
MaterialStateProperty.all(Color(0xffff48423d)),
|
||||||
|
elevation: MaterialStateProperty.all(4.0),
|
||||||
),
|
),
|
||||||
shadowColor:
|
child: Row(
|
||||||
MaterialStateProperty.all(Color(0xffff48423d)),
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
elevation: MaterialStateProperty.all(4.0),
|
children: [
|
||||||
),
|
Container(
|
||||||
child: Row(
|
width: Constant.getActualXPhone(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
context: context, x: 16),
|
||||||
children: [
|
height: Constant.getActualYPhone(
|
||||||
Container(
|
context: context, y: 16),
|
||||||
width: Constant.getActualXPhone(
|
// decoration: BoxDecoration(color: Colors.grey),
|
||||||
context: context, x: 16),
|
child: Image.asset(
|
||||||
height: Constant.getActualYPhone(
|
"images/logo_excel.png",
|
||||||
context: context, y: 16),
|
fit: BoxFit.fill,
|
||||||
// decoration: BoxDecoration(color: Colors.grey),
|
// scale: 1,
|
||||||
child: Image.asset(
|
),
|
||||||
"images/logo_excel.png",
|
|
||||||
fit: BoxFit.fill,
|
|
||||||
// scale: 1,
|
|
||||||
),
|
),
|
||||||
),
|
SizedBox(
|
||||||
SizedBox(
|
width: Constant.getActualXPhone(
|
||||||
width: Constant.getActualXPhone(
|
context: context, x: 6),
|
||||||
context: context, x: 10),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'Excel',
|
|
||||||
style: Constant.body1(context: context).copyWith(
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
color: Colors.green,
|
|
||||||
),
|
),
|
||||||
),
|
Text(
|
||||||
],
|
'Excel',
|
||||||
|
style: Constant.body1(context: context).copyWith(
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Colors.green,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onPressed: () async {
|
||||||
|
M_CompanyID = await getCompanyID();
|
||||||
|
if (M_CompanyID == "0") {
|
||||||
|
SanckbarWidget(
|
||||||
|
context, 'Invalid Company', snackbarType.error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Awal
|
||||||
|
DateTime parsedDateAwal =
|
||||||
|
DateFormat('dd-MM-yyyy').parse(
|
||||||
|
ctrlTglAwal.value.text.toString(),
|
||||||
|
);
|
||||||
|
String formattedDateAwal =
|
||||||
|
DateFormat('yyyy-MM-dd').format(parsedDateAwal);
|
||||||
|
|
||||||
|
// Akhir
|
||||||
|
DateTime parsedDateAkhir =
|
||||||
|
DateFormat('dd-MM-yyyy').parse(
|
||||||
|
ctrlTglAwal.value.text.toString(),
|
||||||
|
);
|
||||||
|
String formattedDateAkhir =
|
||||||
|
DateFormat('yyyy-MM-dd').format(parsedDateAkhir);
|
||||||
|
|
||||||
|
String url =
|
||||||
|
"https://${Constant.baseUrlDevoneReport}/birt/run?__report=report/one/pettycash/rpt_r_pt_001.rptdesign&__format=xls&PStartDate=$formattedDateAwal&PEndDate=$formattedDateAkhir&PCompanyID=$M_CompanyID&username=adminsas%20";
|
||||||
|
if (!await launchUrl(Uri.parse(url))) {
|
||||||
|
// throw Exception('Could not launch $url');
|
||||||
|
SanckbarWidget(context, 'Could not launch $url',
|
||||||
|
snackbarType.error);
|
||||||
|
}
|
||||||
|
// https://devone.aplikasi.web.id/birt/run?__report=report/one/pettycash/rpt_r_pt_001.rptdesign&__format=pdf&PStartDate=2023-11-01&PEndDate=2023-12-30&PCompanyID=0&username=adminsas%20&tm=1701327096267
|
||||||
|
},
|
||||||
),
|
),
|
||||||
onPressed: () async {
|
),
|
||||||
M_CompanyID = await getCompanyID();
|
|
||||||
if (M_CompanyID == "0") {
|
|
||||||
SanckbarWidget(
|
|
||||||
context, 'Invalid Company', snackbarType.error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Awal
|
|
||||||
DateTime parsedDateAwal =
|
|
||||||
DateFormat('dd-MM-yyyy').parse(
|
|
||||||
ctrlTglAwal.value.text.toString(),
|
|
||||||
);
|
|
||||||
String formattedDateAwal =
|
|
||||||
DateFormat('yyyy-MM-dd').format(parsedDateAwal);
|
|
||||||
|
|
||||||
// Akhir
|
SizedBox(
|
||||||
DateTime parsedDateAkhir =
|
width: Constant.getActualXPhone(context: context, x: 10),
|
||||||
DateFormat('dd-MM-yyyy').parse(
|
|
||||||
ctrlTglAkhir.value.text.toString(),
|
|
||||||
);
|
|
||||||
String formattedDateAkhir =
|
|
||||||
DateFormat('yyyy-MM-dd').format(parsedDateAkhir);
|
|
||||||
|
|
||||||
String url =
|
|
||||||
"https://${Constant.baseUrlDevoneReport}/birt/run?__report=report/one/pettycash/rpt_r_pt_001.rptdesign&__format=xls&PStartDate=$formattedDateAwal&PEndDate=$formattedDateAkhir&PCompanyID=$M_CompanyID&username=adminsas%20&tm=$timeStamp";
|
|
||||||
if (!await launchUrl(Uri.parse(url))) {
|
|
||||||
// throw Exception('Could not launch $url');
|
|
||||||
SanckbarWidget(context, 'Could not launch $url',
|
|
||||||
snackbarType.error);
|
|
||||||
}
|
|
||||||
// https://devone.aplikasi.web.id/birt/run?__report=report/one/pettycash/rpt_r_pt_001.rptdesign&__format=pdf&PStartDate=2023-11-01&PEndDate=2023-12-30&PCompanyID=0&username=adminsas%20&tm=1701327096267
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
|
|
||||||
// PDF
|
// PDF
|
||||||
ElevatedButton(
|
Expanded(
|
||||||
style: ButtonStyle(
|
child: ElevatedButton(
|
||||||
backgroundColor: MaterialStateColor.resolveWith(
|
style: ButtonStyle(
|
||||||
(st) => Constant.pcBtnBackgroundColor),
|
backgroundColor: MaterialStateColor.resolveWith(
|
||||||
shape:
|
(st) => Constant.pcBtnBackgroundColor),
|
||||||
MaterialStateProperty.all<RoundedRectangleBorder>(
|
shape:
|
||||||
RoundedRectangleBorder(
|
MaterialStateProperty.all<RoundedRectangleBorder>(
|
||||||
borderRadius: BorderRadius.circular(8),
|
RoundedRectangleBorder(
|
||||||
side: BorderSide(
|
borderRadius: BorderRadius.circular(8),
|
||||||
color: Constant.pcBtnBackgroundColor,
|
side: BorderSide(
|
||||||
|
color: Constant.pcBtnBackgroundColor,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
shadowColor:
|
||||||
|
MaterialStateProperty.all(Color(0xffff48423d)),
|
||||||
|
elevation: MaterialStateProperty.all(4.0),
|
||||||
),
|
),
|
||||||
shadowColor:
|
child: Row(
|
||||||
MaterialStateProperty.all(Color(0xffff48423d)),
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
elevation: MaterialStateProperty.all(4.0),
|
children: [
|
||||||
),
|
Container(
|
||||||
child: Row(
|
width: Constant.getActualXPhone(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
context: context, x: 16),
|
||||||
children: [
|
height: Constant.getActualYPhone(
|
||||||
Container(
|
context: context, y: 16),
|
||||||
width: Constant.getActualXPhone(
|
// decoration: BoxDecoration(color: Colors.grey),
|
||||||
context: context, x: 16),
|
child: Image.asset(
|
||||||
height: Constant.getActualYPhone(
|
"images/logo_pdf.png",
|
||||||
context: context, y: 16),
|
fit: BoxFit.fill,
|
||||||
// decoration: BoxDecoration(color: Colors.grey),
|
// scale: 1,
|
||||||
child: Image.asset(
|
),
|
||||||
"images/logo_pdf.png",
|
|
||||||
fit: BoxFit.fill,
|
|
||||||
// scale: 1,
|
|
||||||
),
|
),
|
||||||
),
|
SizedBox(
|
||||||
SizedBox(
|
width: Constant.getActualXPhone(
|
||||||
width: Constant.getActualXPhone(
|
context: context, x: 6),
|
||||||
context: context, x: 8),
|
),
|
||||||
),
|
Text(
|
||||||
Text(
|
'PDF',
|
||||||
'PDF',
|
style: Constant.body1(context: context).copyWith(
|
||||||
style: Constant.body1(context: context).copyWith(
|
fontWeight: FontWeight.w600,
|
||||||
fontWeight: FontWeight.w600,
|
color: Constant.white),
|
||||||
color: Constant.white),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
|
onPressed: () async {
|
||||||
|
M_CompanyID = await getCompanyID();
|
||||||
|
if (M_CompanyID == "0") {
|
||||||
|
SanckbarWidget(
|
||||||
|
context, 'Invalid Company', snackbarType.error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Awal
|
||||||
|
DateTime parsedDateAwal =
|
||||||
|
DateFormat('dd-MM-yyyy').parse(
|
||||||
|
ctrlTglAwal.value.text.toString(),
|
||||||
|
);
|
||||||
|
String formattedDateAwal =
|
||||||
|
DateFormat('yyyy-MM-dd').format(parsedDateAwal);
|
||||||
|
|
||||||
|
// Akhir
|
||||||
|
DateTime parsedDateAkhir =
|
||||||
|
DateFormat('dd-MM-yyyy').parse(
|
||||||
|
ctrlTglAwal.value.text.toString(),
|
||||||
|
);
|
||||||
|
String formattedDateAkhir =
|
||||||
|
DateFormat('yyyy-MM-dd').format(parsedDateAkhir);
|
||||||
|
|
||||||
|
String url =
|
||||||
|
"https://${Constant.baseUrlDevoneReport}/birt/run?__report=report/one/pettycash/rpt_r_pt_001.rptdesign&__format=pdf&PStartDate=$formattedDateAwal&PEndDate=$formattedDateAkhir&PCompanyID=$M_CompanyID&username=adminsas%20";
|
||||||
|
if (!await launchUrl(Uri.parse(url))) {
|
||||||
|
// throw Exception('Could not launch $url');
|
||||||
|
SanckbarWidget(context, 'Could not launch $url',
|
||||||
|
snackbarType.error);
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
onPressed: () async {
|
|
||||||
M_CompanyID = await getCompanyID();
|
|
||||||
if (M_CompanyID == "0") {
|
|
||||||
SanckbarWidget(
|
|
||||||
context, 'Invalid Company', snackbarType.error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Awal
|
|
||||||
DateTime parsedDateAwal =
|
|
||||||
DateFormat('dd-MM-yyyy').parse(
|
|
||||||
ctrlTglAwal.value.text.toString(),
|
|
||||||
);
|
|
||||||
String formattedDateAwal =
|
|
||||||
DateFormat('yyyy-MM-dd').format(parsedDateAwal);
|
|
||||||
|
|
||||||
// Akhir
|
|
||||||
DateTime parsedDateAkhir =
|
|
||||||
DateFormat('dd-MM-yyyy').parse(
|
|
||||||
ctrlTglAkhir.value.text.toString(),
|
|
||||||
);
|
|
||||||
String formattedDateAkhir =
|
|
||||||
DateFormat('yyyy-MM-dd').format(parsedDateAkhir);
|
|
||||||
|
|
||||||
String url =
|
|
||||||
"https://${Constant.baseUrlDevoneReport}/birt/run?__report=report/one/pettycash/rpt_r_pt_001.rptdesign&__format=pdf&PStartDate=$formattedDateAwal&PEndDate=$formattedDateAkhir&PCompanyID=$M_CompanyID&username=adminsas%20&tm=$timeStamp";
|
|
||||||
|
|
||||||
print(url);
|
|
||||||
if (!await launchUrl(Uri.parse(url))) {
|
|
||||||
// throw Exception('Could not launch $url');
|
|
||||||
SanckbarWidget(context, 'Could not launch $url',
|
|
||||||
snackbarType.error);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,84 +0,0 @@
|
|||||||
import 'package:equatable/equatable.dart';
|
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
||||||
|
|
||||||
import '../../repository/transaksi_repository.dart';
|
|
||||||
import '../../provider/dio_provider.dart';
|
|
||||||
import '../../repository/base_repository.dart';
|
|
||||||
import 'search_history_transaksi_provider.dart';
|
|
||||||
|
|
||||||
abstract class ConfirmTransaksiState extends Equatable {
|
|
||||||
final DateTime date;
|
|
||||||
const ConfirmTransaksiState(this.date);
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [date];
|
|
||||||
}
|
|
||||||
|
|
||||||
class ConfirmTransaksiStateInit extends ConfirmTransaksiState {
|
|
||||||
ConfirmTransaksiStateInit() : super(DateTime.now());
|
|
||||||
}
|
|
||||||
|
|
||||||
class ConfirmTransaksiStateLoading extends ConfirmTransaksiState {
|
|
||||||
ConfirmTransaksiStateLoading() : super(DateTime.now());
|
|
||||||
}
|
|
||||||
|
|
||||||
class ConfirmTransaksiStateError extends ConfirmTransaksiState {
|
|
||||||
final String message;
|
|
||||||
ConfirmTransaksiStateError({
|
|
||||||
required this.message,
|
|
||||||
}) : super(DateTime.now());
|
|
||||||
}
|
|
||||||
|
|
||||||
class ConfirmTransaksiStateDone extends ConfirmTransaksiState {
|
|
||||||
// final List<ListType> model;
|
|
||||||
final String resp;
|
|
||||||
ConfirmTransaksiStateDone({
|
|
||||||
required this.resp,
|
|
||||||
}) : super(DateTime.now());
|
|
||||||
}
|
|
||||||
|
|
||||||
//notifier
|
|
||||||
class ConfirmTransaksiNotifier extends StateNotifier<ConfirmTransaksiState> {
|
|
||||||
final Ref ref;
|
|
||||||
ConfirmTransaksiNotifier({
|
|
||||||
required this.ref,
|
|
||||||
}) : super(ConfirmTransaksiStateInit());
|
|
||||||
|
|
||||||
void confirmTransaksi(
|
|
||||||
String id,
|
|
||||||
String userid,
|
|
||||||
String companyid,
|
|
||||||
String tglAwal,
|
|
||||||
String tglAkhir,
|
|
||||||
String categoryid,
|
|
||||||
) async {
|
|
||||||
try {
|
|
||||||
state = ConfirmTransaksiStateLoading();
|
|
||||||
final dio = ref.read(dioProvider);
|
|
||||||
final resp = await TransaksiRepository(dio: dio).confirmTransaksi(
|
|
||||||
id,
|
|
||||||
userid,
|
|
||||||
);
|
|
||||||
state = ConfirmTransaksiStateDone(resp: resp);
|
|
||||||
|
|
||||||
// search lagi buat get data
|
|
||||||
ref.read(searchHistoryTransaksiProvider.notifier).searchHistoryTransaksi(
|
|
||||||
companyid,
|
|
||||||
tglAwal,
|
|
||||||
tglAkhir,
|
|
||||||
categoryid,
|
|
||||||
);
|
|
||||||
} catch (e) {
|
|
||||||
if (e is BaseRepositoryException) {
|
|
||||||
state = ConfirmTransaksiStateError(message: e.message.toString());
|
|
||||||
} else {
|
|
||||||
state = ConfirmTransaksiStateError(message: e.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//provider
|
|
||||||
final confirmTransaksiProvider =
|
|
||||||
StateNotifierProvider<ConfirmTransaksiNotifier, ConfirmTransaksiState>(
|
|
||||||
(ref) => ConfirmTransaksiNotifier(ref: ref),
|
|
||||||
);
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
import 'package:app_petty_cash/model/history_total_model.dart';
|
|
||||||
import 'package:app_petty_cash/provider/current_info_account_balance_provider.dart';
|
|
||||||
import 'package:app_petty_cash/repository/home_repository.dart';
|
|
||||||
import 'package:app_petty_cash/repository/transaksi_repository.dart';
|
|
||||||
import 'package:equatable/equatable.dart';
|
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
||||||
|
|
||||||
import '../../model/info_account_balance.dart';
|
|
||||||
import '../../provider/dio_provider.dart';
|
|
||||||
import '../../repository/base_repository.dart';
|
|
||||||
|
|
||||||
abstract class HistoryTotalState extends Equatable {
|
|
||||||
final DateTime date;
|
|
||||||
const HistoryTotalState(this.date);
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [date];
|
|
||||||
}
|
|
||||||
|
|
||||||
class HistoryTotalStateInit extends HistoryTotalState {
|
|
||||||
HistoryTotalStateInit() : super(DateTime.now());
|
|
||||||
}
|
|
||||||
|
|
||||||
class HistoryTotalStateLoading extends HistoryTotalState {
|
|
||||||
HistoryTotalStateLoading() : super(DateTime.now());
|
|
||||||
}
|
|
||||||
|
|
||||||
class HistoryTotalStateError extends HistoryTotalState {
|
|
||||||
final String message;
|
|
||||||
HistoryTotalStateError({
|
|
||||||
required this.message,
|
|
||||||
}) : super(DateTime.now());
|
|
||||||
}
|
|
||||||
|
|
||||||
class HistoryTotalStateDone extends HistoryTotalState {
|
|
||||||
final HistoryTotalModel model;
|
|
||||||
// final String resp;
|
|
||||||
HistoryTotalStateDone({
|
|
||||||
required this.model,
|
|
||||||
}) : super(DateTime.now());
|
|
||||||
}
|
|
||||||
|
|
||||||
//notifier
|
|
||||||
class HistoryTotalNotifier extends StateNotifier<HistoryTotalState> {
|
|
||||||
final Ref ref;
|
|
||||||
HistoryTotalNotifier({
|
|
||||||
required this.ref,
|
|
||||||
}) : super(HistoryTotalStateInit());
|
|
||||||
|
|
||||||
void historyTotal(
|
|
||||||
String companyid,
|
|
||||||
String tglAwal,
|
|
||||||
String tglAkhir,
|
|
||||||
String categoryid,
|
|
||||||
) async {
|
|
||||||
try {
|
|
||||||
state = HistoryTotalStateLoading();
|
|
||||||
final dio = ref.read(dioProvider);
|
|
||||||
final resp = await TransaksiRepository(dio: dio).getHistoryTotal(
|
|
||||||
companyid,
|
|
||||||
tglAwal,
|
|
||||||
tglAkhir,
|
|
||||||
categoryid
|
|
||||||
);
|
|
||||||
state = HistoryTotalStateDone(model: resp);
|
|
||||||
} catch (e) {
|
|
||||||
if (e is BaseRepositoryException) {
|
|
||||||
state = HistoryTotalStateError(message: e.message.toString());
|
|
||||||
} else {
|
|
||||||
state = HistoryTotalStateError(message: e.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//provider
|
|
||||||
final historyTotalProvider =
|
|
||||||
StateNotifierProvider<HistoryTotalNotifier, HistoryTotalState>(
|
|
||||||
(ref) => HistoryTotalNotifier(ref: ref),
|
|
||||||
);
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
|
||||||
@@ -43,18 +44,15 @@ class InsertTransaksiNotifier extends StateNotifier<InsertTransaksiState> {
|
|||||||
}) : super(InsertTransaksiStateInit());
|
}) : super(InsertTransaksiStateInit());
|
||||||
|
|
||||||
void insertTransaksi(
|
void insertTransaksi(
|
||||||
{required String tanggal,
|
String tanggal,
|
||||||
required String tipe,
|
String tipe,
|
||||||
required String kategoriid,
|
String kategoriid,
|
||||||
required String jumlah,
|
String jumlah,
|
||||||
required String catatan,
|
String catatan,
|
||||||
required String userid,
|
String userid,
|
||||||
required String sender,
|
String sender,
|
||||||
required String url,
|
String url,
|
||||||
required String base64file,
|
) async {
|
||||||
required String fileName,
|
|
||||||
required String fileSize,
|
|
||||||
required String fileExtension}) async {
|
|
||||||
try {
|
try {
|
||||||
state = InsertTransaksiStateLoading();
|
state = InsertTransaksiStateLoading();
|
||||||
final dio = ref.read(dioProvider);
|
final dio = ref.read(dioProvider);
|
||||||
@@ -66,10 +64,6 @@ class InsertTransaksiNotifier extends StateNotifier<InsertTransaksiState> {
|
|||||||
catatan,
|
catatan,
|
||||||
userid,
|
userid,
|
||||||
sender,
|
sender,
|
||||||
base64file,
|
|
||||||
fileName,
|
|
||||||
fileSize,
|
|
||||||
fileExtension,
|
|
||||||
url,
|
url,
|
||||||
);
|
);
|
||||||
state = InsertTransaksiStateDone(resp: resp);
|
state = InsertTransaksiStateDone(resp: resp);
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import '../../model/history_transaksi_model.dart';
|
|||||||
import '../../repository/transaksi_repository.dart';
|
import '../../repository/transaksi_repository.dart';
|
||||||
import '../../provider/dio_provider.dart';
|
import '../../provider/dio_provider.dart';
|
||||||
import '../../repository/base_repository.dart';
|
import '../../repository/base_repository.dart';
|
||||||
import 'history_total_provider.dart';
|
|
||||||
|
|
||||||
abstract class SearchHistoryTransaksiState extends Equatable {
|
abstract class SearchHistoryTransaksiState extends Equatable {
|
||||||
final DateTime date;
|
final DateTime date;
|
||||||
@@ -48,26 +47,18 @@ class SearchHistoryTransaksiNotifier
|
|||||||
String companyid,
|
String companyid,
|
||||||
String tglAwal,
|
String tglAwal,
|
||||||
String tglAkhir,
|
String tglAkhir,
|
||||||
String categoryid,
|
String categoryid,
|
||||||
) async {
|
) async {
|
||||||
try {
|
try {
|
||||||
state = SearchHistoryTransaksiStateLoading();
|
state = SearchHistoryTransaksiStateLoading();
|
||||||
final dio = ref.read(dioProvider);
|
final dio = ref.read(dioProvider);
|
||||||
final resp = await TransaksiRepository(dio: dio).getListHistoryTransaksi(
|
final resp = await TransaksiRepository(dio: dio).getListHistoryTransaksi(
|
||||||
companyid,
|
companyid,
|
||||||
tglAwal,
|
tglAwal,
|
||||||
tglAkhir,
|
tglAkhir,
|
||||||
categoryid,
|
categoryid,
|
||||||
);
|
);
|
||||||
state = SearchHistoryTransaksiStateDone(model: resp);
|
state = SearchHistoryTransaksiStateDone(model: resp);
|
||||||
|
|
||||||
// panggil provider total transaksi by category for non all
|
|
||||||
ref.read(historyTotalProvider.notifier).historyTotal(
|
|
||||||
companyid,
|
|
||||||
tglAwal,
|
|
||||||
tglAkhir,
|
|
||||||
categoryid,
|
|
||||||
);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e is BaseRepositoryException) {
|
if (e is BaseRepositoryException) {
|
||||||
state = SearchHistoryTransaksiStateError(message: e.message.toString());
|
state = SearchHistoryTransaksiStateError(message: e.message.toString());
|
||||||
|
|||||||
@@ -1,104 +0,0 @@
|
|||||||
import 'package:app_petty_cash/app/constant.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:intl/intl.dart';
|
|
||||||
|
|
||||||
class TransaksiPickDateWidget extends StatelessWidget {
|
|
||||||
const TransaksiPickDateWidget(
|
|
||||||
{super.key,
|
|
||||||
required this.ctrlTglAwal,
|
|
||||||
required this.tglAwal,
|
|
||||||
required this.tglAwalTmp,
|
|
||||||
required this.isLoading});
|
|
||||||
|
|
||||||
final TextEditingController ctrlTglAwal;
|
|
||||||
final ValueNotifier<DateTime> tglAwal;
|
|
||||||
final ValueNotifier<String> tglAwalTmp;
|
|
||||||
final ValueNotifier<bool> isLoading;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: TextField(
|
|
||||||
readOnly: true,
|
|
||||||
controller: ctrlTglAwal,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
hintStyle: Constant.body2_400(context: context).copyWith(
|
|
||||||
color: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
labelStyle: Constant.body2_400(context: context).copyWith(
|
|
||||||
color: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: Colors.orange,
|
|
||||||
width: 1,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
focusedBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: Constant.textGreyv2,
|
|
||||||
width: 1,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
// labelText: "Tanggal Awal",
|
|
||||||
hintText: 'Tanggal Transaksi',
|
|
||||||
// suffixIcon: isLoadingFilterScope.value
|
|
||||||
// ? SizedBox(
|
|
||||||
// width: Constant.getActualXPhone(
|
|
||||||
// context: context,
|
|
||||||
// x: 4,
|
|
||||||
// ),
|
|
||||||
// height: Constant.getActualYPhone(
|
|
||||||
// context: context,
|
|
||||||
// y: 4,
|
|
||||||
// ),
|
|
||||||
// child: CircularProgressIndicator(
|
|
||||||
// color: Constant.textRed,
|
|
||||||
// ),
|
|
||||||
// )
|
|
||||||
// : Icon(
|
|
||||||
// Icons.calendar_month_sharp,
|
|
||||||
// color: Constant.colorIconDate,
|
|
||||||
// ),
|
|
||||||
),
|
|
||||||
onTap: !isLoading.value
|
|
||||||
? () async {
|
|
||||||
final selectedDateAwal = await showDatePicker(
|
|
||||||
keyboardType: TextInputType.none,
|
|
||||||
// locale: const Locale("en-CA"),
|
|
||||||
// locale: ,
|
|
||||||
context: context,
|
|
||||||
initialEntryMode: DatePickerEntryMode.calendarOnly,
|
|
||||||
firstDate: DateTime(2000),
|
|
||||||
lastDate: DateTime(2100),
|
|
||||||
|
|
||||||
initialDate: (ctrlTglAwal.text.isEmpty)
|
|
||||||
? DateTime.now()
|
|
||||||
: tglAwal.value,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (selectedDateAwal != null) {
|
|
||||||
String formattedDate =
|
|
||||||
DateFormat('dd-MM-yyyy').format(selectedDateAwal);
|
|
||||||
// ctrlTglAwal.text =
|
|
||||||
// selectedDateAwal.toString().split(' ')[0];
|
|
||||||
ctrlTglAwal.text = formattedDate;
|
|
||||||
tglAwal.value = selectedDateAwal;
|
|
||||||
tglAwalTmp.value = selectedDateAwal.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selectedDateAwal == null) {
|
|
||||||
print('cancel button');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +1,22 @@
|
|||||||
import 'dart:convert';
|
import 'package:app_petty_cash/app/app_extension.dart';
|
||||||
import 'dart:io' as io;
|
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:app_petty_cash/app/route.dart';
|
import 'package:app_petty_cash/app/route.dart';
|
||||||
import 'package:app_petty_cash/model/list_type_model.dart';
|
import 'package:app_petty_cash/model/list_type_model.dart';
|
||||||
import 'package:app_petty_cash/screen/transaksi/insert_transaksi_provider.dart';
|
import 'package:app_petty_cash/screen/transaksi/insert_transaksi_provider.dart';
|
||||||
import 'package:app_petty_cash/screen/transaksi/list_category_provider.dart';
|
import 'package:app_petty_cash/screen/transaksi/list_category_provider.dart';
|
||||||
import 'package:app_petty_cash/screen/transaksi/list_type_provider.dart';
|
import 'package:app_petty_cash/screen/transaksi/list_type_provider.dart';
|
||||||
import 'package:app_petty_cash/screen/transaksi/transaksi_pick_date_widget.dart';
|
import 'package:dropdown_button2/dropdown_button2.dart';
|
||||||
import 'package:app_petty_cash/screen/transaksi/transaksi_select_kategori_widget.dart';
|
|
||||||
import 'package:app_petty_cash/screen/transaksi/transaksi_upload_area_widget.dart';
|
|
||||||
import 'package:file_picker/file_picker.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:image_picker/image_picker.dart';
|
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
import '../../app/constant.dart';
|
import '../../app/constant.dart';
|
||||||
import '../../model/list_category_model.dart';
|
import '../../model/list_category_model.dart';
|
||||||
import '../../provider/current_menu_provider.dart';
|
|
||||||
import '../../provider/current_user_provider.dart';
|
import '../../provider/current_user_provider.dart';
|
||||||
import '../../widget/custom_drawer.dart';
|
import '../../widget/custom_drawer.dart';
|
||||||
import '../../widget/sankbar_widget.dart';
|
import '../../widget/sankbar_widget.dart';
|
||||||
|
import '../login/custom_text_field.dart';
|
||||||
import 'package:image/image.dart' as img;
|
|
||||||
|
|
||||||
class DummyDropdownTipe {
|
class DummyDropdownTipe {
|
||||||
final String options;
|
final String options;
|
||||||
@@ -53,12 +44,6 @@ class TransaksiScreen extends HookConsumerWidget {
|
|||||||
final ctrlCatatan = useTextEditingController(text: "");
|
final ctrlCatatan = useTextEditingController(text: "");
|
||||||
final ctrlNamaPengirim = useTextEditingController(text: "");
|
final ctrlNamaPengirim = useTextEditingController(text: "");
|
||||||
final ctrlCompanyName = useTextEditingController(text: "");
|
final ctrlCompanyName = useTextEditingController(text: "");
|
||||||
final fileData = useState<XFile?>(null);
|
|
||||||
final fileDataBase64 = useState<String>("");
|
|
||||||
final isImage = useState(false);
|
|
||||||
final fileEkstension = useState("");
|
|
||||||
final fileSize = useState(0);
|
|
||||||
final fileName = useState("");
|
|
||||||
|
|
||||||
String formattedDate = DateFormat('dd-MM-yyyy').format(DateTime.now());
|
String formattedDate = DateFormat('dd-MM-yyyy').format(DateTime.now());
|
||||||
|
|
||||||
@@ -154,8 +139,6 @@ class TransaksiScreen extends HookConsumerWidget {
|
|||||||
'Data Berhasil Disimpan',
|
'Data Berhasil Disimpan',
|
||||||
snackbarType.success,
|
snackbarType.success,
|
||||||
);
|
);
|
||||||
// diupdate ke menu home jika sukses
|
|
||||||
ref.read(currentPageProvider.notifier).update((state) => 0);
|
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
Navigator.of(context).pushNamed(homeRoute);
|
Navigator.of(context).pushNamed(homeRoute);
|
||||||
}
|
}
|
||||||
@@ -199,193 +182,6 @@ class TransaksiScreen extends HookConsumerWidget {
|
|||||||
|
|
||||||
final userIDLogin = ref.read(currentUserProvider)?.model.M_UserID ?? "0";
|
final userIDLogin = ref.read(currentUserProvider)?.model.M_UserID ?? "0";
|
||||||
|
|
||||||
getBase64_v1() async {
|
|
||||||
// List<int> imageBytes = await fileData.value?.readAsBytes();
|
|
||||||
if (fileData.value != null) {
|
|
||||||
final bytes = io.File(fileData.value!.path).readAsBytesSync();
|
|
||||||
String base64Image = base64Encode(await fileData.value!.readAsBytes());
|
|
||||||
fileDataBase64.value = base64Image;
|
|
||||||
final file = File(fileData.value!.path);
|
|
||||||
print(file.lengthSync() / 1000000);
|
|
||||||
print(await fileData.value!.length());
|
|
||||||
fileSize.value = await fileData.value!.length();
|
|
||||||
|
|
||||||
// await getExternalStorageDirectory();
|
|
||||||
// print(await fileData.value!.saveTo(path));
|
|
||||||
print(fileDataBase64.value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getBase64() async {
|
|
||||||
// List<int> imageBytes = await fileData.value?.readAsBytes();
|
|
||||||
if (fileData.value != null) {
|
|
||||||
final bytes = io.File(fileData.value!.path).readAsBytesSync();
|
|
||||||
String base64Image = base64Encode(await fileData.value!.readAsBytes());
|
|
||||||
fileDataBase64.value = base64Image;
|
|
||||||
final file = File(fileData.value!.path);
|
|
||||||
|
|
||||||
print(file.lengthSync() / 1000000);
|
|
||||||
print(await fileData.value!.length());
|
|
||||||
fileSize.value = await fileData.value!.length();
|
|
||||||
|
|
||||||
// await getExternalStorageDirectory();
|
|
||||||
// print(await fileData.value!.saveTo(path));
|
|
||||||
print(fileDataBase64.value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final ImagePicker _picker = ImagePicker();
|
|
||||||
pickImage() async {
|
|
||||||
final XFile? pickedFile = await _picker.pickImage(
|
|
||||||
source: ImageSource.camera,
|
|
||||||
// maxWidth set untuk width image
|
|
||||||
maxWidth: 640,
|
|
||||||
// maxHeight set untuk width image
|
|
||||||
maxHeight: 480);
|
|
||||||
if (pickedFile != null) {
|
|
||||||
final tmpFile = FilePickerResult([
|
|
||||||
PlatformFile(
|
|
||||||
name: pickedFile.name,
|
|
||||||
size: await pickedFile.length(),
|
|
||||||
path: pickedFile.path,
|
|
||||||
)
|
|
||||||
]);
|
|
||||||
if (await pickedFile.length() > 10000000) {
|
|
||||||
SanckbarWidget(context, "File tidak boleh lebih dari 10 MB",
|
|
||||||
snackbarType.warning);
|
|
||||||
} else {
|
|
||||||
fileData.value = pickedFile;
|
|
||||||
isImage.value = true;
|
|
||||||
fileEkstension.value = tmpFile.files.single.extension ?? "";
|
|
||||||
DateTime now = new DateTime.now();
|
|
||||||
fileName.value =
|
|
||||||
"IMG-${now.year}${now.month}${now.day}.${tmpFile.files.single.extension ?? ''}";
|
|
||||||
}
|
|
||||||
|
|
||||||
// final Directory appDocumentsDir =
|
|
||||||
// await getApplicationDocumentsDirectory();
|
|
||||||
// print(appDocumentsDir);
|
|
||||||
// await pickedFile!.saveTo(appDocumentsDir.path);
|
|
||||||
await getBase64();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
browseImage() async {
|
|
||||||
final XFile? pickedFile = await _picker.pickImage(
|
|
||||||
source: ImageSource.gallery,
|
|
||||||
);
|
|
||||||
fileData.value = pickedFile;
|
|
||||||
getBase64();
|
|
||||||
}
|
|
||||||
|
|
||||||
pickFile() async {
|
|
||||||
List<String> imgExt = [
|
|
||||||
'jpg',
|
|
||||||
'png',
|
|
||||||
'jpeg',
|
|
||||||
];
|
|
||||||
FilePickerResult? result = await FilePicker.platform.pickFiles(
|
|
||||||
allowMultiple: false,
|
|
||||||
type: FileType.custom,
|
|
||||||
dialogTitle: "Pick a file",
|
|
||||||
allowedExtensions: [
|
|
||||||
...imgExt,
|
|
||||||
'pdf',
|
|
||||||
'doc',
|
|
||||||
'docx',
|
|
||||||
'xls',
|
|
||||||
'xlsx',
|
|
||||||
'ppt',
|
|
||||||
'pptx',
|
|
||||||
'txt'
|
|
||||||
],
|
|
||||||
);
|
|
||||||
|
|
||||||
if (result != null) {
|
|
||||||
if (result.files.single.size > 10000000) {
|
|
||||||
SanckbarWidget(context, "File tidak boleh lebih dari 10 MB",
|
|
||||||
snackbarType.warning);
|
|
||||||
} else {
|
|
||||||
// File files = File(result.files.single.path!);
|
|
||||||
print(result.files.single.extension);
|
|
||||||
XFile fl = XFile(result.files.single.path!);
|
|
||||||
fileName.value = result.files.single.name;
|
|
||||||
|
|
||||||
isImage.value = imgExt.contains(result.files.single.extension);
|
|
||||||
|
|
||||||
print(result.files.single.name);
|
|
||||||
fileData.value = fl;
|
|
||||||
await getBase64();
|
|
||||||
fileEkstension.value = result.files.single.extension ?? "";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// User canceled the picker
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
insertTransaksi() {
|
|
||||||
if (selectedListTypeData.value.typeid.toString() == "DEBIT") {
|
|
||||||
ctrlNamaPengirim.text = "";
|
|
||||||
// validasi form
|
|
||||||
if (ctrlJumlah.text.isEmpty || ctrlCatatan.text.trim().isEmpty) {
|
|
||||||
SanckbarWidget(
|
|
||||||
context, "Jumlah dan catatan harus diisi", snackbarType.warning);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (selectedListTypeData.value.typeid.toString() == "KREDIT") {
|
|
||||||
selectedListCategory.value.categoryid = "0";
|
|
||||||
// validasi form
|
|
||||||
if (ctrlNamaPengirim.text.trim().isEmpty ||
|
|
||||||
ctrlJumlah.text.isEmpty ||
|
|
||||||
ctrlCatatan.text.trim().isEmpty) {
|
|
||||||
SanckbarWidget(
|
|
||||||
context,
|
|
||||||
"Nama pengirim, jumlah dan catatan harus diisi",
|
|
||||||
snackbarType.warning);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DateTime parsedDate = DateFormat('dd-MM-yyyy').parse(
|
|
||||||
ctrlTglAwal.value.text.toString(),
|
|
||||||
);
|
|
||||||
String formattedDateTransaksi =
|
|
||||||
DateFormat('yyyy-MM-dd').format(parsedDate);
|
|
||||||
var param = {
|
|
||||||
"tgltransaksi": formattedDateTransaksi,
|
|
||||||
"typeid": selectedListTypeData.value.typeid.toString(),
|
|
||||||
"categoryid": selectedListCategory.value.categoryid.toString(),
|
|
||||||
"jumlah": ctrlJumlah.value.text.toString(),
|
|
||||||
"catatan": ctrlCatatan.value.text.toString(),
|
|
||||||
// "userid": "1",
|
|
||||||
"userid": userIDLogin,
|
|
||||||
"namapengirim": ctrlNamaPengirim.value.text.toString(),
|
|
||||||
"url": "",
|
|
||||||
// "base64file": fileDataBase64.value,
|
|
||||||
"fileName": fileName.value,
|
|
||||||
"fileExtension": fileEkstension.value,
|
|
||||||
"fileSize": fileSize.value.toString()
|
|
||||||
};
|
|
||||||
print(param);
|
|
||||||
// return;
|
|
||||||
ref.read(insertTransaksiProvider.notifier).insertTransaksi(
|
|
||||||
tanggal: formattedDateTransaksi,
|
|
||||||
tipe: selectedListTypeData.value.typeid.toString(),
|
|
||||||
kategoriid: selectedListCategory.value.categoryid.toString(),
|
|
||||||
jumlah: ctrlJumlah.value.text.toString(),
|
|
||||||
catatan: ctrlCatatan.value.text.toString(),
|
|
||||||
// "1",
|
|
||||||
userid: userIDLogin,
|
|
||||||
sender: ctrlNamaPengirim.value.text.toString(),
|
|
||||||
url: "",
|
|
||||||
base64file: fileDataBase64.value,
|
|
||||||
fileName: fileData.value?.name ?? "",
|
|
||||||
fileExtension: fileEkstension.value,
|
|
||||||
fileSize: fileSize.value.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
top: Constant.getActualYPhone(context: context, y: 30),
|
top: Constant.getActualYPhone(context: context, y: 30),
|
||||||
@@ -408,7 +204,7 @@ class TransaksiScreen extends HookConsumerWidget {
|
|||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(20),
|
padding: EdgeInsets.all(20),
|
||||||
child: Container(
|
child: Container(
|
||||||
// height: MediaQuery.of(context).size.height - 10,
|
height: MediaQuery.of(context).size.height - 10,
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@@ -463,11 +259,86 @@ class TransaksiScreen extends HookConsumerWidget {
|
|||||||
height: Constant.getActualYPhone(context: context, y: 10),
|
height: Constant.getActualYPhone(context: context, y: 10),
|
||||||
),
|
),
|
||||||
// Tanggal Transaksi
|
// Tanggal Transaksi
|
||||||
TransaksiPickDateWidget(
|
Row(
|
||||||
ctrlTglAwal: ctrlTglAwal,
|
children: [
|
||||||
tglAwal: tglAwal,
|
Expanded(
|
||||||
tglAwalTmp: tglAwalTmp,
|
child: TextField(
|
||||||
isLoading: transaksiIsLoading,
|
controller: ctrlTglAwal,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintStyle:
|
||||||
|
Constant.body2_400(context: context).copyWith(
|
||||||
|
color: Constant.textGreyv2,
|
||||||
|
),
|
||||||
|
labelStyle:
|
||||||
|
Constant.body2_400(context: context).copyWith(
|
||||||
|
color: Constant.textGreyv2,
|
||||||
|
),
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: Colors.orange,
|
||||||
|
width: 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: Constant.textGreyv2,
|
||||||
|
width: 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// labelText: "Tanggal Awal",
|
||||||
|
hintText: 'Tanggal Transaksi',
|
||||||
|
// suffixIcon: isLoadingFilterScope.value
|
||||||
|
// ? SizedBox(
|
||||||
|
// width: Constant.getActualXPhone(
|
||||||
|
// context: context,
|
||||||
|
// x: 4,
|
||||||
|
// ),
|
||||||
|
// height: Constant.getActualYPhone(
|
||||||
|
// context: context,
|
||||||
|
// y: 4,
|
||||||
|
// ),
|
||||||
|
// child: CircularProgressIndicator(
|
||||||
|
// color: Constant.textRed,
|
||||||
|
// ),
|
||||||
|
// )
|
||||||
|
// : Icon(
|
||||||
|
// Icons.calendar_month_sharp,
|
||||||
|
// color: Constant.colorIconDate,
|
||||||
|
// ),
|
||||||
|
),
|
||||||
|
onTap: () async {
|
||||||
|
final selectedDateAwal = await showDatePicker(
|
||||||
|
// locale: const Locale("en-CA"),
|
||||||
|
// locale: ,
|
||||||
|
context: context,
|
||||||
|
initialEntryMode:
|
||||||
|
DatePickerEntryMode.calendarOnly,
|
||||||
|
firstDate: DateTime(2000),
|
||||||
|
lastDate: DateTime(2100),
|
||||||
|
|
||||||
|
initialDate: (ctrlTglAwal.text.isEmpty)
|
||||||
|
? DateTime.now()
|
||||||
|
: tglAwal.value,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (selectedDateAwal != null) {
|
||||||
|
String formattedDate = DateFormat('dd-MM-yyyy')
|
||||||
|
.format(selectedDateAwal);
|
||||||
|
// ctrlTglAwal.text =
|
||||||
|
// selectedDateAwal.toString().split(' ')[0];
|
||||||
|
ctrlTglAwal.text = formattedDate;
|
||||||
|
tglAwal.value = selectedDateAwal;
|
||||||
|
tglAwalTmp.value = selectedDateAwal.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedDateAwal == null) {
|
||||||
|
print('cancel button');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
SizedBox(
|
SizedBox(
|
||||||
@@ -516,16 +387,14 @@ class TransaksiScreen extends HookConsumerWidget {
|
|||||||
value: listTypeData.value[i],
|
value: listTypeData.value[i],
|
||||||
groupValue:
|
groupValue:
|
||||||
selectedListTypeData.value,
|
selectedListTypeData.value,
|
||||||
onChanged: !transaksiIsLoading.value
|
onChanged: (ListType? index) {
|
||||||
? (ListType? index) {
|
if (isMounted()) {
|
||||||
if (isMounted()) {
|
selectedListTypeData.value =
|
||||||
selectedListTypeData
|
index!;
|
||||||
.value = index!;
|
} else {
|
||||||
} else {
|
return;
|
||||||
return;
|
}
|
||||||
}
|
},
|
||||||
}
|
|
||||||
: null,
|
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
listTypeData.value[i].typename ??
|
listTypeData.value[i].typename ??
|
||||||
@@ -572,10 +441,126 @@ class TransaksiScreen extends HookConsumerWidget {
|
|||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: TransaksiSelectKategoriWidget(
|
: SizedBox(
|
||||||
isLoading: transaksiIsLoading,
|
width: Constant.getActualXPhone(
|
||||||
listCategoryData: listCategoryData,
|
context: context, x: 390),
|
||||||
selectedListCategory: selectedListCategory),
|
child: DropdownButtonHideUnderline(
|
||||||
|
child: DropdownButton2<ListCategory>(
|
||||||
|
isExpanded: true,
|
||||||
|
hint: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
'Select Item',
|
||||||
|
style: Constant.body1(
|
||||||
|
context: context)
|
||||||
|
.copyWith(
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Constant.textBlack),
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
items: listCategoryData.value
|
||||||
|
.map((ListCategory option) {
|
||||||
|
return DropdownMenuItem<ListCategory>(
|
||||||
|
value: option,
|
||||||
|
child: Text(
|
||||||
|
option.categoryname ?? "",
|
||||||
|
style: Constant.body1(context: context)
|
||||||
|
.copyWith(
|
||||||
|
color: Constant.textBlack,
|
||||||
|
fontWeight: FontWeight.w600),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
value: selectedListCategory.value,
|
||||||
|
onChanged: (ListCategory? newValue) {
|
||||||
|
// if (newValue) {
|
||||||
|
selectedListCategory.value = newValue!;
|
||||||
|
print(
|
||||||
|
selectedListCategory.value.categoryid);
|
||||||
|
// }
|
||||||
|
},
|
||||||
|
buttonStyleData: ButtonStyleData(
|
||||||
|
height: Constant.getActualY(
|
||||||
|
context: context, y: 56),
|
||||||
|
width: Constant.getActualX(
|
||||||
|
context: context, x: 320),
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
left: Constant.getActualX(
|
||||||
|
context: context, x: 10),
|
||||||
|
right: Constant.getActualX(
|
||||||
|
context: context, x: 10),
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Constant.white,
|
||||||
|
border: Border.all(
|
||||||
|
color: Constant.textBlack, width: 1),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
elevation: 2,
|
||||||
|
),
|
||||||
|
iconStyleData: IconStyleData(
|
||||||
|
icon: Icon(
|
||||||
|
Icons.keyboard_arrow_down_outlined,
|
||||||
|
),
|
||||||
|
iconSize: 24,
|
||||||
|
iconEnabledColor: Constant.textBlack,
|
||||||
|
iconDisabledColor: Colors.grey,
|
||||||
|
),
|
||||||
|
dropdownStyleData: DropdownStyleData(
|
||||||
|
maxHeight: Constant.getActualY(
|
||||||
|
context: context, y: 200),
|
||||||
|
// width: Constant.getActualX(context: context, x: 320),
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
top: Constant.getActualY(
|
||||||
|
context: context, y: 10),
|
||||||
|
left: Constant.getActualX(
|
||||||
|
context: context, x: 10),
|
||||||
|
right: Constant.getActualX(
|
||||||
|
context: context, x: 10),
|
||||||
|
bottom: Constant.getActualY(
|
||||||
|
context: context, y: 10),
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Constant.white,
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.grey,
|
||||||
|
blurRadius: 20.0,
|
||||||
|
spreadRadius: 2.0,
|
||||||
|
offset: Offset(0.0, 0.0),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
elevation: 8,
|
||||||
|
offset: const Offset(0, -10),
|
||||||
|
scrollbarTheme: ScrollbarThemeData(
|
||||||
|
radius: const Radius.circular(40),
|
||||||
|
thickness:
|
||||||
|
MaterialStateProperty.all<double>(6),
|
||||||
|
thumbVisibility:
|
||||||
|
MaterialStateProperty.all<bool>(true),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
menuItemStyleData: MenuItemStyleData(
|
||||||
|
height: Constant.getActualY(
|
||||||
|
context: context, y: 56),
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
top: Constant.getActualY(
|
||||||
|
context: context, y: 10),
|
||||||
|
left: Constant.getActualX(
|
||||||
|
context: context, x: 10),
|
||||||
|
right: Constant.getActualX(
|
||||||
|
context: context, x: 10),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height:
|
height:
|
||||||
@@ -597,7 +582,6 @@ class TransaksiScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
TextField(
|
TextField(
|
||||||
controller: ctrlNamaPengirim,
|
controller: ctrlNamaPengirim,
|
||||||
readOnly: transaksiIsLoading.value,
|
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintStyle:
|
hintStyle:
|
||||||
Constant.body2_400(context: context).copyWith(
|
Constant.body2_400(context: context).copyWith(
|
||||||
@@ -641,7 +625,6 @@ class TransaksiScreen extends HookConsumerWidget {
|
|||||||
TextField(
|
TextField(
|
||||||
controller: ctrlJumlah,
|
controller: ctrlJumlah,
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
readOnly: transaksiIsLoading.value,
|
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintStyle:
|
hintStyle:
|
||||||
Constant.body2_400(context: context).copyWith(
|
Constant.body2_400(context: context).copyWith(
|
||||||
@@ -684,7 +667,6 @@ class TransaksiScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
|
|
||||||
TextField(
|
TextField(
|
||||||
readOnly: transaksiIsLoading.value,
|
|
||||||
controller: ctrlCatatan,
|
controller: ctrlCatatan,
|
||||||
maxLines: 4,
|
maxLines: 4,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
@@ -718,22 +700,32 @@ class TransaksiScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
|
|
||||||
// Upload File
|
// Upload File
|
||||||
TransaksiUploadAreaWidget(
|
Container(
|
||||||
isLoading: transaksiIsLoading,
|
width: Constant.getActualXPhone(context: context, x: 390),
|
||||||
isImage: isImage,
|
height: Constant.getActualYPhone(context: context, y: 83),
|
||||||
fileData: fileData,
|
decoration: BoxDecoration(color: Constant.bgUploadFile),
|
||||||
fileDataBase64: fileDataBase64,
|
child: Column(
|
||||||
pickFile: pickFile,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
pickImage: pickImage),
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
Icons.upload_outlined,
|
||||||
|
color: Constant.pcBtnBackgroundColor,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Upload File',
|
||||||
|
style: Constant.body1(context: context).copyWith(
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Constant.pcBtnBackgroundColor),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
// Spacer(),
|
Spacer(),
|
||||||
|
|
||||||
Container(
|
Container(
|
||||||
margin: EdgeInsets.only(
|
|
||||||
top: Constant.getActualYPhone(
|
|
||||||
context: context, y: 24)),
|
|
||||||
width: Constant.getActualXPhone(context: context, x: 390),
|
width: Constant.getActualXPhone(context: context, x: 390),
|
||||||
height: Constant.getActualY(context: context, y: 64),
|
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
backgroundColor: MaterialStateColor.resolveWith(
|
backgroundColor: MaterialStateColor.resolveWith(
|
||||||
@@ -756,7 +748,7 @@ class TransaksiScreen extends HookConsumerWidget {
|
|||||||
(transaksiIsLoading.value)
|
(transaksiIsLoading.value)
|
||||||
? SizedBox(
|
? SizedBox(
|
||||||
width: Constant.getActualXPhone(
|
width: Constant.getActualXPhone(
|
||||||
context: context, x: 32),
|
context: context, x: 24),
|
||||||
height: Constant.getActualYPhone(
|
height: Constant.getActualYPhone(
|
||||||
context: context, y: 32),
|
context: context, y: 32),
|
||||||
child: CircularProgressIndicator(
|
child: CircularProgressIndicator(
|
||||||
@@ -772,12 +764,53 @@ class TransaksiScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
onPressed: !transaksiIsLoading.value
|
onPressed: () {
|
||||||
? () {
|
if (selectedListTypeData.value.typeid.toString() ==
|
||||||
// transaksiIsLoading.value = true;
|
"DEBIT") {
|
||||||
insertTransaksi();
|
ctrlNamaPengirim.text = "";
|
||||||
}
|
// validasi form
|
||||||
: null,
|
} else {
|
||||||
|
if (selectedListTypeData.value.typeid.toString() ==
|
||||||
|
"KREDIT") {
|
||||||
|
selectedListCategory.value.categoryid = "0";
|
||||||
|
// validasi form
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DateTime parsedDate = DateFormat('dd-MM-yyyy').parse(
|
||||||
|
ctrlTglAwal.value.text.toString(),
|
||||||
|
);
|
||||||
|
String formattedDateTransaksi =
|
||||||
|
DateFormat('yyyy-MM-dd').format(parsedDate);
|
||||||
|
var param = {
|
||||||
|
"tgltransaksi": formattedDateTransaksi,
|
||||||
|
"typeid":
|
||||||
|
selectedListTypeData.value.typeid.toString(),
|
||||||
|
"categoryid":
|
||||||
|
selectedListCategory.value.categoryid.toString(),
|
||||||
|
"jumlah": ctrlJumlah.value.text.toString(),
|
||||||
|
"catatan": ctrlCatatan.value.text.toString(),
|
||||||
|
// "userid": "1",
|
||||||
|
"userid": userIDLogin,
|
||||||
|
"namapengirim":
|
||||||
|
ctrlNamaPengirim.value.text.toString(),
|
||||||
|
"url": "",
|
||||||
|
};
|
||||||
|
print(param);
|
||||||
|
ref
|
||||||
|
.read(insertTransaksiProvider.notifier)
|
||||||
|
.insertTransaksi(
|
||||||
|
formattedDateTransaksi,
|
||||||
|
selectedListTypeData.value.typeid.toString(),
|
||||||
|
selectedListCategory.value.categoryid.toString(),
|
||||||
|
ctrlJumlah.value.text.toString(),
|
||||||
|
ctrlCatatan.value.text.toString(),
|
||||||
|
// "1",
|
||||||
|
userIDLogin,
|
||||||
|
ctrlNamaPengirim.value.text.toString(),
|
||||||
|
"",
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,122 +0,0 @@
|
|||||||
import 'package:app_petty_cash/app/constant.dart';
|
|
||||||
import 'package:app_petty_cash/model/list_category_model.dart';
|
|
||||||
import 'package:dropdown_button2/dropdown_button2.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
class TransaksiSelectKategoriWidget extends StatelessWidget {
|
|
||||||
const TransaksiSelectKategoriWidget({
|
|
||||||
super.key,
|
|
||||||
required this.listCategoryData,
|
|
||||||
required this.selectedListCategory,
|
|
||||||
required this.isLoading,
|
|
||||||
});
|
|
||||||
|
|
||||||
final ValueNotifier<List<ListCategory>> listCategoryData;
|
|
||||||
final ValueNotifier<ListCategory> selectedListCategory;
|
|
||||||
final ValueNotifier<bool> isLoading;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return SizedBox(
|
|
||||||
width: Constant.getActualXPhone(context: context, x: 390),
|
|
||||||
child: DropdownButtonHideUnderline(
|
|
||||||
child: DropdownButton2<ListCategory>(
|
|
||||||
isExpanded: true,
|
|
||||||
hint: Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
'Select Item',
|
|
||||||
style: Constant.body1(context: context).copyWith(
|
|
||||||
fontWeight: FontWeight.w400, color: Constant.textBlack),
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
items: listCategoryData.value.map((ListCategory option) {
|
|
||||||
return DropdownMenuItem<ListCategory>(
|
|
||||||
value: option,
|
|
||||||
child: Text(
|
|
||||||
option.categoryname ?? "",
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: Constant.body1(context: context).copyWith(
|
|
||||||
color: Constant.textBlack, fontWeight: FontWeight.w400),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}).toList(),
|
|
||||||
style: Constant.body1(context: context)
|
|
||||||
.copyWith(color: Constant.textBlack, fontWeight: FontWeight.w400),
|
|
||||||
value: selectedListCategory.value,
|
|
||||||
onChanged: !isLoading.value
|
|
||||||
? (ListCategory? newValue) {
|
|
||||||
// if (newValue) {
|
|
||||||
selectedListCategory.value = newValue!;
|
|
||||||
print(selectedListCategory.value.categoryid);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
buttonStyleData: ButtonStyleData(
|
|
||||||
height: Constant.getActualY(context: context, y: 80),
|
|
||||||
width: Constant.getActualX(context: context, x: 320),
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
left: Constant.getActualX(context: context, x: 20),
|
|
||||||
right: Constant.getActualX(context: context, x: 20),
|
|
||||||
),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Constant.white,
|
|
||||||
border: Border.all(color: Constant.textGrey, width: 1),
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
),
|
|
||||||
// elevation: 2,
|
|
||||||
),
|
|
||||||
iconStyleData: IconStyleData(
|
|
||||||
icon: Icon(
|
|
||||||
Icons.keyboard_arrow_down_outlined,
|
|
||||||
),
|
|
||||||
iconSize: 24,
|
|
||||||
iconEnabledColor: Constant.textBlack,
|
|
||||||
iconDisabledColor: Colors.grey,
|
|
||||||
),
|
|
||||||
dropdownStyleData: DropdownStyleData(
|
|
||||||
maxHeight: Constant.getActualY(context: context, y: 200),
|
|
||||||
// width: Constant.getActualX(context: context, x: 320),
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
top: Constant.getActualY(context: context, y: 10),
|
|
||||||
left: Constant.getActualX(context: context, x: 20),
|
|
||||||
right: Constant.getActualX(context: context, x: 20),
|
|
||||||
bottom: Constant.getActualY(context: context, y: 10),
|
|
||||||
),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Constant.white,
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
boxShadow: [
|
|
||||||
BoxShadow(
|
|
||||||
color: Colors.grey,
|
|
||||||
blurRadius: 20.0,
|
|
||||||
spreadRadius: 2.0,
|
|
||||||
offset: Offset(0.0, 0.0),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
elevation: 8,
|
|
||||||
offset: const Offset(0, -10),
|
|
||||||
scrollbarTheme: ScrollbarThemeData(
|
|
||||||
radius: const Radius.circular(40),
|
|
||||||
thickness: MaterialStateProperty.all<double>(6),
|
|
||||||
thumbVisibility: MaterialStateProperty.all<bool>(true),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
menuItemStyleData: MenuItemStyleData(
|
|
||||||
height: Constant.getActualY(context: context, y: 56),
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
top: Constant.getActualY(context: context, y: 10),
|
|
||||||
left: Constant.getActualX(context: context, x: 20),
|
|
||||||
right: Constant.getActualX(context: context, x: 20),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,167 +0,0 @@
|
|||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:app_petty_cash/app/constant.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:image_picker/image_picker.dart';
|
|
||||||
import 'package:mime/mime.dart';
|
|
||||||
|
|
||||||
class TransaksiUploadAreaWidget extends StatelessWidget {
|
|
||||||
const TransaksiUploadAreaWidget({
|
|
||||||
super.key,
|
|
||||||
required this.isImage,
|
|
||||||
required this.fileData,
|
|
||||||
required this.fileDataBase64,
|
|
||||||
required this.pickFile,
|
|
||||||
required this.pickImage,
|
|
||||||
required this.isLoading,
|
|
||||||
});
|
|
||||||
|
|
||||||
final ValueNotifier<bool> isImage;
|
|
||||||
final ValueNotifier<bool> isLoading;
|
|
||||||
final ValueNotifier<XFile?> fileData;
|
|
||||||
final ValueNotifier<String> fileDataBase64;
|
|
||||||
final Function pickImage;
|
|
||||||
final Function pickFile;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return InkWell(
|
|
||||||
onTap: !isLoading.value
|
|
||||||
? () {
|
|
||||||
showModalBottomSheet(
|
|
||||||
context: context,
|
|
||||||
builder: (context) {
|
|
||||||
return Container(
|
|
||||||
height: Constant.getActualY(context: context, y: 200),
|
|
||||||
padding: EdgeInsets.all(20),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Column(
|
|
||||||
children: [
|
|
||||||
IconButton(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
pickFile();
|
|
||||||
},
|
|
||||||
icon: Icon(
|
|
||||||
Icons.folder_copy_rounded,
|
|
||||||
size: 50,
|
|
||||||
color: Constant.pcBtnBackgroundColor,
|
|
||||||
)),
|
|
||||||
Text("Browse a file",
|
|
||||||
style: Constant.body1(context: context)
|
|
||||||
.copyWith(
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
color: Constant.textBlack))
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Column(
|
|
||||||
children: [
|
|
||||||
IconButton(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
pickImage();
|
|
||||||
},
|
|
||||||
icon: Icon(
|
|
||||||
Icons.add_a_photo_rounded,
|
|
||||||
size: 50,
|
|
||||||
color: Constant.pcBtnBackgroundColor,
|
|
||||||
)),
|
|
||||||
Text("Take a picture",
|
|
||||||
style: Constant.body1(context: context)
|
|
||||||
.copyWith(
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
color: Constant.textBlack))
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
child: Stack(
|
|
||||||
alignment: AlignmentDirectional.topEnd,
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
width: Constant.getActualXPhone(context: context, x: 390),
|
|
||||||
height: Constant.getActualYPhone(
|
|
||||||
context: context, y: isImage.value ? 200 : 83),
|
|
||||||
decoration: BoxDecoration(color: Constant.bgUploadFile),
|
|
||||||
child: Builder(builder: (context) {
|
|
||||||
final String? mime = lookupMimeType(fileData.value?.path ?? "");
|
|
||||||
return Semantics(
|
|
||||||
label: 'image_picker_example_picked_image',
|
|
||||||
child: (mime != null
|
|
||||||
? (mime.startsWith('image/'))
|
|
||||||
? Image.file(
|
|
||||||
// image: AssetImage(photo.value!.path),
|
|
||||||
File(fileData.value!.path),
|
|
||||||
frameBuilder: (context, child, frame,
|
|
||||||
wasSynchronouslyLoaded) {
|
|
||||||
return (wasSynchronouslyLoaded)
|
|
||||||
? Center(
|
|
||||||
child: Text("Loadinga"),
|
|
||||||
)
|
|
||||||
: Container(
|
|
||||||
child: child,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
errorBuilder: (BuildContext context, Object error,
|
|
||||||
StackTrace? stackTrace) {
|
|
||||||
return const Center(
|
|
||||||
child: Text(
|
|
||||||
'This image type is not supported'));
|
|
||||||
},
|
|
||||||
)
|
|
||||||
: Container(
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Icon(
|
|
||||||
Icons.file_present_rounded,
|
|
||||||
size: 40,
|
|
||||||
color: Constant.pcBtnBackgroundColor,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
fileData.value?.name ?? '',
|
|
||||||
style: Constant.body2_400(context: context),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Icon(
|
|
||||||
Icons.upload_outlined,
|
|
||||||
color: Constant.pcBtnBackgroundColor,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'Upload File',
|
|
||||||
style: Constant.body1(context: context).copyWith(
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
color: Constant.pcBtnBackgroundColor),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
)));
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
if (fileData.value != null && !isLoading.value)
|
|
||||||
IconButton(
|
|
||||||
onPressed: () {
|
|
||||||
fileData.value = null;
|
|
||||||
fileDataBase64.value = '';
|
|
||||||
isImage.value = false;
|
|
||||||
},
|
|
||||||
icon: Icon(Icons.cancel_outlined)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -14,6 +14,7 @@ import '../screen/login/logout_provider.dart';
|
|||||||
|
|
||||||
class CustomDrawer extends HookConsumerWidget {
|
class CustomDrawer extends HookConsumerWidget {
|
||||||
// final String userCompany;
|
// final String userCompany;
|
||||||
|
|
||||||
const CustomDrawer({
|
const CustomDrawer({
|
||||||
Key? key,
|
Key? key,
|
||||||
// required this.userCompany,
|
// required this.userCompany,
|
||||||
@@ -80,6 +81,7 @@ class CustomDrawer extends HookConsumerWidget {
|
|||||||
shared.remove(bearerString);
|
shared.remove(bearerString);
|
||||||
shared.clear();
|
shared.clear();
|
||||||
// Navigator.popAndPushNamed(context, loginRoute);
|
// Navigator.popAndPushNamed(context, loginRoute);
|
||||||
|
|
||||||
Navigator.of(context)
|
Navigator.of(context)
|
||||||
.pushNamedAndRemoveUntil(loginRoute, (route) => false);
|
.pushNamedAndRemoveUntil(loginRoute, (route) => false);
|
||||||
}
|
}
|
||||||
@@ -91,247 +93,228 @@ class CustomDrawer extends HookConsumerWidget {
|
|||||||
|
|
||||||
final currentMenu = ref.read(currentPageProvider);
|
final currentMenu = ref.read(currentPageProvider);
|
||||||
|
|
||||||
return Container(
|
return Drawer(
|
||||||
width: Constant.getActualXPhone(context: context, x: 300),
|
elevation: 0,
|
||||||
height: Constant.getActualYPhone(context: context, y: 844),
|
shape: RoundedRectangleBorder(
|
||||||
child: Drawer(
|
borderRadius: BorderRadius.all(Radius.circular(0))
|
||||||
elevation: 0,
|
),
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.all(Radius.circular(0))),
|
child: Container(
|
||||||
child: Column(
|
child: ListView(
|
||||||
|
// padding: EdgeInsets.only(
|
||||||
|
// top: Constant.getActualYPhone(context: context, y: 10),
|
||||||
|
// ),
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Container(
|
||||||
child: ListView(
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
child: Image(
|
|
||||||
image:
|
|
||||||
AssetImage('images/logo_sismedika_landscape.png')),
|
|
||||||
),
|
|
||||||
|
|
||||||
SizedBox(
|
// decoration: BoxDecoration(
|
||||||
height: Constant.getActualYPhone(context: context, y: 8),
|
// border: Border(bottom: BorderSide(color: Colors.transparent)) // <--- use the global theme to change the dividerColor property
|
||||||
),
|
// ),
|
||||||
|
child:
|
||||||
Padding(
|
Image(image: AssetImage('images/logo_sismedika_landscape.png')),
|
||||||
padding: EdgeInsets.only(
|
|
||||||
top: Constant.getActualYPhone(context: context, y: 10),
|
|
||||||
bottom: Constant.getActualYPhone(context: context, y: 10),
|
|
||||||
right: Constant.getActualXPhone(context: context, x: 24),
|
|
||||||
left: Constant.getActualXPhone(context: context, x: 24),
|
|
||||||
),
|
|
||||||
child: Container(
|
|
||||||
width: Constant.getActualXPhone(context: context, x: 300),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
// child: Padding(
|
|
||||||
// padding: EdgeInsets.only(
|
|
||||||
// left: Constant.getActualXPhone(context: context, x: 24),
|
|
||||||
// right: Constant.getActualXPhone(context: context, x: 71),
|
|
||||||
// ),
|
|
||||||
// child: Container(
|
|
||||||
// decoration: BoxDecoration(
|
|
||||||
// borderRadius: BorderRadius.circular(6),
|
|
||||||
// color: Constant.textGrey.withOpacity(0.16),
|
|
||||||
// ),
|
|
||||||
// child: Padding(
|
|
||||||
// padding: EdgeInsets.only(
|
|
||||||
// left: Constant.getActualXPhone(context: context, x: 8),
|
|
||||||
// right: Constant.getActualXPhone(context: context, x: 8),
|
|
||||||
// ),
|
|
||||||
// child: Text(
|
|
||||||
// M_CompanyName.value,
|
|
||||||
// style: Constant.body3(context: context).copyWith(
|
|
||||||
// fontWeight: FontWeight.w700,
|
|
||||||
// color: Constant.textGreyv2,
|
|
||||||
// backgroundColor: Constant.textGrey.withOpacity(0.16),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
Chip(
|
|
||||||
backgroundColor: Constant.textGrey.withOpacity(0.16),
|
|
||||||
label: Text(
|
|
||||||
M_CompanyName.value,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: TextStyle(
|
|
||||||
color: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
ListTile(
|
|
||||||
leading: Icon(
|
|
||||||
Icons.home,
|
|
||||||
color: (currentMenu == 0)
|
|
||||||
? Constant.pcBtnBackgroundColor
|
|
||||||
: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
title: Text(
|
|
||||||
'Home',
|
|
||||||
style: TextStyle(
|
|
||||||
color: (currentMenu == 0)
|
|
||||||
? Constant.pcBtnBackgroundColor
|
|
||||||
: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
// Handle navigation to Home screen
|
|
||||||
Navigator.pop(context);
|
|
||||||
ref.read(currentPageProvider.state).update((state) => 0);
|
|
||||||
Navigator.pushNamed(context, homeRoute);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
leading: Icon(
|
|
||||||
Icons.money,
|
|
||||||
color: (currentMenu == 1)
|
|
||||||
? Constant.pcBtnBackgroundColor
|
|
||||||
: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
title: Text(
|
|
||||||
'Transaksi',
|
|
||||||
style: TextStyle(
|
|
||||||
color: (currentMenu == 1)
|
|
||||||
? Constant.pcBtnBackgroundColor
|
|
||||||
: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
// Handle navigation to Transaksi screen
|
|
||||||
Navigator.pop(context);
|
|
||||||
ref.read(currentPageProvider.state).update((state) => 1);
|
|
||||||
Navigator.pushNamed(context, transaksiRoute);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
leading: Icon(
|
|
||||||
Icons.history,
|
|
||||||
color: (currentMenu == 2)
|
|
||||||
? Constant.pcBtnBackgroundColor
|
|
||||||
: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
title: Text(
|
|
||||||
'History Transaksi',
|
|
||||||
style: TextStyle(
|
|
||||||
color: (currentMenu == 2)
|
|
||||||
? Constant.pcBtnBackgroundColor
|
|
||||||
: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
// Handle navigation to User screen
|
|
||||||
Navigator.pop(context);
|
|
||||||
ref.read(currentPageProvider.state).update((state) => 2);
|
|
||||||
Navigator.pushNamed(context, historyTransaksiRoute);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
leading: Icon(
|
|
||||||
Icons.feed,
|
|
||||||
color: (currentMenu == 3)
|
|
||||||
? Constant.pcBtnBackgroundColor
|
|
||||||
: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
title: Text(
|
|
||||||
'Report',
|
|
||||||
style: TextStyle(
|
|
||||||
color: (currentMenu == 3)
|
|
||||||
? Constant.pcBtnBackgroundColor
|
|
||||||
: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
// Handle navigation to Transaksi screen
|
|
||||||
Navigator.pop(context);
|
|
||||||
ref.read(currentPageProvider.state).update((state) => 3);
|
|
||||||
Navigator.pushNamed(context, reportRoute);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
leading: Icon(
|
|
||||||
Icons.account_balance,
|
|
||||||
color: (currentMenu == 4)
|
|
||||||
? Constant.pcBtnBackgroundColor
|
|
||||||
: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
title: Text(
|
|
||||||
'Change Company',
|
|
||||||
style: TextStyle(
|
|
||||||
color: (currentMenu == 4)
|
|
||||||
? Constant.pcBtnBackgroundColor
|
|
||||||
: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
// Handle navigation to Transaksi screen
|
|
||||||
Navigator.pop(context);
|
|
||||||
ref.read(currentPageProvider.state).update((state) => 4);
|
|
||||||
Navigator.pushNamed(context, changeCompanyRoute);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
leading: Icon(
|
|
||||||
Icons.lock_reset,
|
|
||||||
color: (currentMenu == 5)
|
|
||||||
? Constant.pcBtnBackgroundColor
|
|
||||||
: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
title: Text(
|
|
||||||
'Change Password',
|
|
||||||
style: TextStyle(
|
|
||||||
color: (currentMenu == 5)
|
|
||||||
? Constant.pcBtnBackgroundColor
|
|
||||||
: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
// Handle navigation to Transaksi screen
|
|
||||||
Navigator.pop(context);
|
|
||||||
ref.read(currentPageProvider.state).update((state) => 5);
|
|
||||||
Navigator.pushNamed(context, changePasswordRoute);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
leading: Icon(
|
|
||||||
Icons.logout,
|
|
||||||
color: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
title: Text(
|
|
||||||
'Logout',
|
|
||||||
style: TextStyle(color: Constant.textGreyv2),
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
// di set ke 0 lagi
|
|
||||||
ref.read(currentPageProvider.state).update((state) => 0);
|
|
||||||
ref.read(logoutProvider.notifier).logout(
|
|
||||||
M_UserID: selectedUser?.model.M_UserID ?? "",
|
|
||||||
M_UserUsername:
|
|
||||||
selectedUser?.model.M_UserUsername ?? "",
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
// Versi Aplikasi
|
|
||||||
|
SizedBox(
|
||||||
|
height: Constant.getActualYPhone(context: context, y: 8),
|
||||||
|
),
|
||||||
|
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
right: Constant.getActualXPhone(context: context, x: 20),
|
top: Constant.getActualYPhone(context: context, y: 10),
|
||||||
bottom: Constant.getActualYPhone(context: context, y: 10),
|
bottom: Constant.getActualYPhone(context: context, y: 10),
|
||||||
|
right: Constant.getActualXPhone(context: context, x: 24),
|
||||||
|
left: Constant.getActualXPhone(context: context, x: 24),
|
||||||
),
|
),
|
||||||
child: Align(
|
child: Container(
|
||||||
alignment: Alignment.bottomRight,
|
width: Constant.getActualXPhone(context: context, x: 300),
|
||||||
child: Text(
|
),
|
||||||
'Versi ${Constant.version}',
|
),
|
||||||
style: Constant.titleH4Login(context: context)
|
|
||||||
.copyWith(color: Constant.textGrey),
|
Expanded(
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
left: Constant.getActualXPhone(context: context, x: 24),
|
||||||
|
right: Constant.getActualXPhone(context: context, x: 71),
|
||||||
|
),
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(6),
|
||||||
|
color: Constant.textGrey.withOpacity(0.16),
|
||||||
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
left: Constant.getActualXPhone(context: context, x: 8),
|
||||||
|
right: Constant.getActualXPhone(context: context, x: 8),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
M_CompanyName.value,
|
||||||
|
style: Constant.body3(context: context).copyWith(
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
color: Constant.textGreyv2,
|
||||||
|
backgroundColor: Constant.textGrey.withOpacity(0.16),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
ListTile(
|
||||||
|
leading: Icon(
|
||||||
|
Icons.home,
|
||||||
|
color: (currentMenu == 0)
|
||||||
|
? Constant.pcBtnBackgroundColor
|
||||||
|
: Constant.textGreyv2,
|
||||||
|
),
|
||||||
|
title: Text(
|
||||||
|
'Home',
|
||||||
|
style: TextStyle(
|
||||||
|
color: (currentMenu == 0)
|
||||||
|
? Constant.pcBtnBackgroundColor
|
||||||
|
: Constant.textGreyv2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// tileColor: (currentMenu == 0)
|
||||||
|
// ? Constant.pcBtnBackgroundColor
|
||||||
|
// : Colors.transparent,
|
||||||
|
onTap: () {
|
||||||
|
// Handle navigation to Home screen
|
||||||
|
Navigator.pop(context);
|
||||||
|
ref.read(currentPageProvider.state).update((state) => 0);
|
||||||
|
Navigator.pushNamed(context, homeRoute);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: Icon(
|
||||||
|
Icons.money,
|
||||||
|
color: (currentMenu == 1)
|
||||||
|
? Constant.pcBtnBackgroundColor
|
||||||
|
: Constant.textGreyv2,
|
||||||
|
),
|
||||||
|
title: Text(
|
||||||
|
'Transaksi',
|
||||||
|
style: TextStyle(
|
||||||
|
color: (currentMenu == 1)
|
||||||
|
? Constant.pcBtnBackgroundColor
|
||||||
|
: Constant.textGreyv2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// tileColor: (currentMenu == 1)
|
||||||
|
// ? Constant.pcBtnBackgroundColor
|
||||||
|
// : Colors.transparent,
|
||||||
|
onTap: () {
|
||||||
|
// Handle navigation to Transaksi screen
|
||||||
|
Navigator.pop(context);
|
||||||
|
ref.read(currentPageProvider.state).update((state) => 1);
|
||||||
|
Navigator.pushNamed(context, transaksiRoute);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: Icon(
|
||||||
|
Icons.history,
|
||||||
|
color: (currentMenu == 2)
|
||||||
|
? Constant.pcBtnBackgroundColor
|
||||||
|
: Constant.textGreyv2,
|
||||||
|
),
|
||||||
|
title: Text(
|
||||||
|
'History Transaksi',
|
||||||
|
style: TextStyle(
|
||||||
|
color: (currentMenu == 2)
|
||||||
|
? Constant.pcBtnBackgroundColor
|
||||||
|
: Constant.textGreyv2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// tileColor: (currentMenu == 2)
|
||||||
|
// ? Constant.pcBtnBackgroundColor
|
||||||
|
// : Colors.transparent,
|
||||||
|
onTap: () {
|
||||||
|
// Handle navigation to User screen
|
||||||
|
Navigator.pop(context);
|
||||||
|
ref.read(currentPageProvider.state).update((state) => 2);
|
||||||
|
Navigator.pushNamed(context, historyTransaksiRoute);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: Icon(
|
||||||
|
Icons.feed,
|
||||||
|
color: (currentMenu == 3)
|
||||||
|
? Constant.pcBtnBackgroundColor
|
||||||
|
: Constant.textGreyv2,
|
||||||
|
),
|
||||||
|
title: Text(
|
||||||
|
'Report',
|
||||||
|
style: TextStyle(
|
||||||
|
color: (currentMenu == 3)
|
||||||
|
? Constant.pcBtnBackgroundColor
|
||||||
|
: Constant.textGreyv2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// tileColor: (currentMenu == 3)
|
||||||
|
// ? Constant.pcBtnBackgroundColor
|
||||||
|
// : Colors.transparent,
|
||||||
|
onTap: () {
|
||||||
|
// Handle navigation to Transaksi screen
|
||||||
|
Navigator.pop(context);
|
||||||
|
ref.read(currentPageProvider.state).update((state) => 3);
|
||||||
|
Navigator.pushNamed(context, reportRoute);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
// ListTile(
|
||||||
|
// title: Text(
|
||||||
|
// 'User',
|
||||||
|
// style: TextStyle(
|
||||||
|
// color: (currentMenu == 4)
|
||||||
|
// ? Constant.textWhite
|
||||||
|
// : Constant.textBlack,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// tileColor: (currentMenu == 4)
|
||||||
|
// ? Constant.pcBtnBackgroundColor
|
||||||
|
// : Colors.transparent,
|
||||||
|
// onTap: () {
|
||||||
|
// // Handle navigation to User screen
|
||||||
|
// Navigator.pop(context);
|
||||||
|
// ref.read(currentPageProvider.state).update((state) => 4);
|
||||||
|
// Navigator.pushNamed(context, userRoute);
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// ListTile(
|
||||||
|
// title: Text(
|
||||||
|
// 'Change Company',
|
||||||
|
// style: TextStyle(
|
||||||
|
// color: (currentMenu == 5)
|
||||||
|
// ? Constant.textWhite
|
||||||
|
// : Constant.textBlack,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// tileColor: (currentMenu == 5)
|
||||||
|
// ? Constant.pcBtnBackgroundColor
|
||||||
|
// : Colors.transparent,
|
||||||
|
// onTap: () {
|
||||||
|
// // Handle navigation to User screen
|
||||||
|
// Navigator.pop(context);
|
||||||
|
// ref.read(currentPageProvider.state).update((state) => 5);
|
||||||
|
// Navigator.pushNamed(context, changeCompanyRoute);
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
ListTile(
|
||||||
|
leading: Icon(
|
||||||
|
Icons.logout,
|
||||||
|
color: Constant.textGreyv2,
|
||||||
|
),
|
||||||
|
title: Text(
|
||||||
|
'Logout',
|
||||||
|
style: TextStyle(color: Constant.textGreyv2),
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
// di set ke 0 lagi
|
||||||
|
ref.read(currentPageProvider.state).update((state) => 0);
|
||||||
|
ref.read(logoutProvider.notifier).logout(
|
||||||
|
M_UserID: selectedUser?.model.M_UserID ?? "",
|
||||||
|
M_UserUsername: selectedUser?.model.M_UserUsername ?? "",
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,221 +0,0 @@
|
|||||||
import 'dart:async';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
|
||||||
|
|
||||||
import '../app/constant.dart';
|
|
||||||
import '../app/route.dart';
|
|
||||||
import '../provider/current_menu_provider.dart';
|
|
||||||
import '../provider/current_user_provider.dart';
|
|
||||||
import '../screen/login/logout_provider.dart';
|
|
||||||
|
|
||||||
class CustomDrawerV1 extends HookConsumerWidget {
|
|
||||||
const CustomDrawerV1({
|
|
||||||
super.key,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
|
||||||
final selectedUser = ref.read(currentUserProvider);
|
|
||||||
final isLoading = useState(false);
|
|
||||||
final errorMessage = useState("");
|
|
||||||
final successMessage = useState("");
|
|
||||||
|
|
||||||
useEffect(() {
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
|
||||||
final userID = ref.read(currentUserProvider)?.model.M_UserID ?? "0";
|
|
||||||
if (userID == "0") {
|
|
||||||
//not login
|
|
||||||
Navigator.of(context)
|
|
||||||
.pushNamedAndRemoveUntil(loginRoute, (route) => true);
|
|
||||||
|
|
||||||
// Navigator.popAndPushNamed(context, loginRoute);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return () {};
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
ref.listen(logoutProvider, (prev, next) async {
|
|
||||||
if (next is LogoutStateLoading) {
|
|
||||||
isLoading.value = true;
|
|
||||||
} else if (next is LogoutStateError) {
|
|
||||||
isLoading.value = false;
|
|
||||||
errorMessage.value = next.message;
|
|
||||||
Timer(const Duration(seconds: 3), () {
|
|
||||||
errorMessage.value = "";
|
|
||||||
});
|
|
||||||
} else if (next is LogoutStateDone) {
|
|
||||||
isLoading.value = false;
|
|
||||||
final shared = await SharedPreferences.getInstance();
|
|
||||||
final bearerString = shared.get(Constant.bearerName).toString();
|
|
||||||
// print(bearerString);
|
|
||||||
if (bearerString.isNotEmpty) {
|
|
||||||
shared.remove(bearerString);
|
|
||||||
shared.clear();
|
|
||||||
// Navigator.popAndPushNamed(context, loginRoute);
|
|
||||||
|
|
||||||
Navigator.of(context)
|
|
||||||
.pushNamedAndRemoveUntil(loginRoute, (route) => false);
|
|
||||||
}
|
|
||||||
Timer(const Duration(seconds: 3), () async {
|
|
||||||
successMessage.value = "";
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
final currentMenu = ref.read(currentPageProvider);
|
|
||||||
|
|
||||||
return Drawer(
|
|
||||||
child: ListView(
|
|
||||||
// padding: EdgeInsets.only(
|
|
||||||
// top: Constant.getActualYPhone(context: context, y: 10),
|
|
||||||
// ),
|
|
||||||
children: [
|
|
||||||
DrawerHeader(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.blue,
|
|
||||||
),
|
|
||||||
child: Text(
|
|
||||||
'Drawer Header',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 24,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text(
|
|
||||||
'Home',
|
|
||||||
style: TextStyle(
|
|
||||||
color: (currentMenu == 0)
|
|
||||||
? Constant.textWhite
|
|
||||||
: Constant.textBlack,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
tileColor: (currentMenu == 0)
|
|
||||||
? Constant.pcBtnBackgroundColor
|
|
||||||
: Colors.transparent,
|
|
||||||
onTap: () {
|
|
||||||
// Handle navigation to Home screen
|
|
||||||
Navigator.pop(context);
|
|
||||||
ref.read(currentPageProvider.state).update((state) => 0);
|
|
||||||
Navigator.pushNamed(context, homeRoute);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text(
|
|
||||||
'Transaksi',
|
|
||||||
style: TextStyle(
|
|
||||||
color: (currentMenu == 1)
|
|
||||||
? Constant.textWhite
|
|
||||||
: Constant.textBlack,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
tileColor: (currentMenu == 1)
|
|
||||||
? Constant.pcBtnBackgroundColor
|
|
||||||
: Colors.transparent,
|
|
||||||
onTap: () {
|
|
||||||
// Handle navigation to Transaksi screen
|
|
||||||
Navigator.pop(context);
|
|
||||||
ref.read(currentPageProvider.state).update((state) => 1);
|
|
||||||
Navigator.pushNamed(context, transaksiRoute);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text(
|
|
||||||
'History Transaksi',
|
|
||||||
style: TextStyle(
|
|
||||||
color: (currentMenu == 2)
|
|
||||||
? Constant.textWhite
|
|
||||||
: Constant.textBlack,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
tileColor: (currentMenu == 2)
|
|
||||||
? Constant.pcBtnBackgroundColor
|
|
||||||
: Colors.transparent,
|
|
||||||
onTap: () {
|
|
||||||
// Handle navigation to User screen
|
|
||||||
Navigator.pop(context);
|
|
||||||
ref.read(currentPageProvider.state).update((state) => 2);
|
|
||||||
Navigator.pushNamed(context, historyTransaksiRoute);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text(
|
|
||||||
'Report',
|
|
||||||
style: TextStyle(
|
|
||||||
color: (currentMenu == 3)
|
|
||||||
? Constant.textWhite
|
|
||||||
: Constant.textBlack,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
tileColor: (currentMenu == 3)
|
|
||||||
? Constant.pcBtnBackgroundColor
|
|
||||||
: Colors.transparent,
|
|
||||||
onTap: () {
|
|
||||||
// Handle navigation to Transaksi screen
|
|
||||||
Navigator.pop(context);
|
|
||||||
ref.read(currentPageProvider.state).update((state) => 3);
|
|
||||||
Navigator.pushNamed(context, reportRoute);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
// ListTile(
|
|
||||||
// title: Text(
|
|
||||||
// 'User',
|
|
||||||
// style: TextStyle(
|
|
||||||
// color: (currentMenu == 4)
|
|
||||||
// ? Constant.textWhite
|
|
||||||
// : Constant.textBlack,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// tileColor: (currentMenu == 4)
|
|
||||||
// ? Constant.pcBtnBackgroundColor
|
|
||||||
// : Colors.transparent,
|
|
||||||
// onTap: () {
|
|
||||||
// // Handle navigation to User screen
|
|
||||||
// Navigator.pop(context);
|
|
||||||
// ref.read(currentPageProvider.state).update((state) => 4);
|
|
||||||
// Navigator.pushNamed(context, userRoute);
|
|
||||||
// },
|
|
||||||
// ),
|
|
||||||
// ListTile(
|
|
||||||
// title: Text(
|
|
||||||
// 'Change Company',
|
|
||||||
// style: TextStyle(
|
|
||||||
// color: (currentMenu == 5)
|
|
||||||
// ? Constant.textWhite
|
|
||||||
// : Constant.textBlack,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// tileColor: (currentMenu == 5)
|
|
||||||
// ? Constant.pcBtnBackgroundColor
|
|
||||||
// : Colors.transparent,
|
|
||||||
// onTap: () {
|
|
||||||
// // Handle navigation to User screen
|
|
||||||
// Navigator.pop(context);
|
|
||||||
// ref.read(currentPageProvider.state).update((state) => 5);
|
|
||||||
// Navigator.pushNamed(context, changeCompanyRoute);
|
|
||||||
// },
|
|
||||||
// ),
|
|
||||||
ListTile(
|
|
||||||
title: Text(
|
|
||||||
'Logout',
|
|
||||||
// style: TextStyle(color: Constant.textWhite),
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
// di set ke 0 lagi
|
|
||||||
ref.read(currentPageProvider.state).update((state) => 0);
|
|
||||||
ref.read(logoutProvider.notifier).logout(
|
|
||||||
M_UserID: selectedUser?.model.M_UserID ?? "",
|
|
||||||
M_UserUsername: selectedUser?.model.M_UserUsername ?? "",
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,341 +0,0 @@
|
|||||||
import 'dart:async';
|
|
||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
|
||||||
|
|
||||||
import '../app/constant.dart';
|
|
||||||
import '../app/route.dart';
|
|
||||||
import '../provider/current_menu_provider.dart';
|
|
||||||
import '../provider/current_user_provider.dart';
|
|
||||||
import '../screen/login/logout_provider.dart';
|
|
||||||
|
|
||||||
class CustomDrawerV2 extends HookConsumerWidget {
|
|
||||||
// final String userCompany;
|
|
||||||
const CustomDrawerV2({
|
|
||||||
Key? key,
|
|
||||||
// required this.userCompany,
|
|
||||||
}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
|
||||||
final selectedUser = ref.read(currentUserProvider);
|
|
||||||
final isLoading = useState(false);
|
|
||||||
final errorMessage = useState("");
|
|
||||||
final successMessage = useState("");
|
|
||||||
final M_CompanyName = useState("-");
|
|
||||||
|
|
||||||
Future<String> getCompanyName() async {
|
|
||||||
final shared = await SharedPreferences.getInstance();
|
|
||||||
String M_CompanyName = "-";
|
|
||||||
|
|
||||||
if (shared != null) {
|
|
||||||
final bearerString = shared.get(Constant.bearerName).toString();
|
|
||||||
final xmodel = jsonDecode(bearerString);
|
|
||||||
if (xmodel != null) {
|
|
||||||
M_CompanyName = xmodel["model"]["M_CompanyName"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (M_CompanyName == "0") {
|
|
||||||
// throw BaseRepositoryException(message: 'Invalid Company ID');
|
|
||||||
}
|
|
||||||
|
|
||||||
return M_CompanyName;
|
|
||||||
}
|
|
||||||
|
|
||||||
useEffect(() {
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
|
||||||
final userID = ref.read(currentUserProvider)?.model.M_UserID ?? "0";
|
|
||||||
if (userID == "0") {
|
|
||||||
//not login
|
|
||||||
Navigator.of(context)
|
|
||||||
.pushNamedAndRemoveUntil(loginRoute, (route) => true);
|
|
||||||
|
|
||||||
// Navigator.popAndPushNamed(context, loginRoute);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
M_CompanyName.value = await getCompanyName();
|
|
||||||
});
|
|
||||||
return () {};
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
ref.listen(logoutProvider, (prev, next) async {
|
|
||||||
if (next is LogoutStateLoading) {
|
|
||||||
isLoading.value = true;
|
|
||||||
} else if (next is LogoutStateError) {
|
|
||||||
isLoading.value = false;
|
|
||||||
errorMessage.value = next.message;
|
|
||||||
Timer(const Duration(seconds: 3), () {
|
|
||||||
errorMessage.value = "";
|
|
||||||
});
|
|
||||||
} else if (next is LogoutStateDone) {
|
|
||||||
isLoading.value = false;
|
|
||||||
final shared = await SharedPreferences.getInstance();
|
|
||||||
final bearerString = shared.get(Constant.bearerName).toString();
|
|
||||||
// print(bearerString);
|
|
||||||
if (bearerString.isNotEmpty) {
|
|
||||||
shared.remove(bearerString);
|
|
||||||
shared.clear();
|
|
||||||
// Navigator.popAndPushNamed(context, loginRoute);
|
|
||||||
Navigator.of(context)
|
|
||||||
.pushNamedAndRemoveUntil(loginRoute, (route) => false);
|
|
||||||
}
|
|
||||||
Timer(const Duration(seconds: 3), () async {
|
|
||||||
successMessage.value = "";
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
final currentMenu = ref.read(currentPageProvider);
|
|
||||||
|
|
||||||
return Drawer(
|
|
||||||
elevation: 0,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.all(Radius.circular(0))),
|
|
||||||
child: Container(
|
|
||||||
child: ListView(
|
|
||||||
// padding: EdgeInsets.only(
|
|
||||||
// top: Constant.getActualYPhone(context: context, y: 10),
|
|
||||||
// ),
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
// decoration: BoxDecoration(
|
|
||||||
// border: Border(bottom: BorderSide(color: Colors.transparent)) // <--- use the global theme to change the dividerColor property
|
|
||||||
// ),
|
|
||||||
child: Image(
|
|
||||||
image: AssetImage('images/logo_sismedika_landscape.png')),
|
|
||||||
),
|
|
||||||
|
|
||||||
SizedBox(
|
|
||||||
height: Constant.getActualYPhone(context: context, y: 8),
|
|
||||||
),
|
|
||||||
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
top: Constant.getActualYPhone(context: context, y: 10),
|
|
||||||
bottom: Constant.getActualYPhone(context: context, y: 10),
|
|
||||||
right: Constant.getActualXPhone(context: context, x: 24),
|
|
||||||
left: Constant.getActualXPhone(context: context, x: 24),
|
|
||||||
),
|
|
||||||
child: Container(
|
|
||||||
width: Constant.getActualXPhone(context: context, x: 300),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
// Expanded(
|
|
||||||
// child: Padding(
|
|
||||||
// padding: EdgeInsets.only(
|
|
||||||
// left: Constant.getActualXPhone(context: context, x: 24),
|
|
||||||
// right: Constant.getActualXPhone(context: context, x: 71),
|
|
||||||
// ),
|
|
||||||
// child: Container(
|
|
||||||
// decoration: BoxDecoration(
|
|
||||||
// borderRadius: BorderRadius.circular(6),
|
|
||||||
// color: Constant.textGrey.withOpacity(0.16),
|
|
||||||
// ),
|
|
||||||
// child: Padding(
|
|
||||||
// padding: EdgeInsets.only(
|
|
||||||
// left: Constant.getActualXPhone(context: context, x: 8),
|
|
||||||
// right: Constant.getActualXPhone(context: context, x: 8),
|
|
||||||
// ),
|
|
||||||
// child: Text(
|
|
||||||
// M_CompanyName.value,
|
|
||||||
// style: Constant.body3(context: context).copyWith(
|
|
||||||
// fontWeight: FontWeight.w700,
|
|
||||||
// color: Constant.textGreyv2,
|
|
||||||
// backgroundColor: Constant.textGrey.withOpacity(0.16),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
|
|
||||||
Chip(
|
|
||||||
backgroundColor: Constant.textGrey.withOpacity(0.16),
|
|
||||||
label: Text(
|
|
||||||
M_CompanyName.value,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: TextStyle(
|
|
||||||
color: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
ListTile(
|
|
||||||
leading: Icon(
|
|
||||||
Icons.home,
|
|
||||||
color: (currentMenu == 0)
|
|
||||||
? Constant.pcBtnBackgroundColor
|
|
||||||
: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
title: Text(
|
|
||||||
'Home',
|
|
||||||
style: TextStyle(
|
|
||||||
color: (currentMenu == 0)
|
|
||||||
? Constant.pcBtnBackgroundColor
|
|
||||||
: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// tileColor: (currentMenu == 0)
|
|
||||||
// ? Constant.pcBtnBackgroundColor
|
|
||||||
// : Colors.transparent,
|
|
||||||
onTap: () {
|
|
||||||
// Handle navigation to Home screen
|
|
||||||
Navigator.pop(context);
|
|
||||||
ref.read(currentPageProvider.state).update((state) => 0);
|
|
||||||
Navigator.pushNamed(context, homeRoute);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
leading: Icon(
|
|
||||||
Icons.money,
|
|
||||||
color: (currentMenu == 1)
|
|
||||||
? Constant.pcBtnBackgroundColor
|
|
||||||
: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
title: Text(
|
|
||||||
'Transaksi',
|
|
||||||
style: TextStyle(
|
|
||||||
color: (currentMenu == 1)
|
|
||||||
? Constant.pcBtnBackgroundColor
|
|
||||||
: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// tileColor: (currentMenu == 1)
|
|
||||||
// ? Constant.pcBtnBackgroundColor
|
|
||||||
// : Colors.transparent,
|
|
||||||
onTap: () {
|
|
||||||
// Handle navigation to Transaksi screen
|
|
||||||
Navigator.pop(context);
|
|
||||||
ref.read(currentPageProvider.state).update((state) => 1);
|
|
||||||
Navigator.pushNamed(context, transaksiRoute);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
leading: Icon(
|
|
||||||
Icons.history,
|
|
||||||
color: (currentMenu == 2)
|
|
||||||
? Constant.pcBtnBackgroundColor
|
|
||||||
: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
title: Text(
|
|
||||||
'History Transaksi',
|
|
||||||
style: TextStyle(
|
|
||||||
color: (currentMenu == 2)
|
|
||||||
? Constant.pcBtnBackgroundColor
|
|
||||||
: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// tileColor: (currentMenu == 2)
|
|
||||||
// ? Constant.pcBtnBackgroundColor
|
|
||||||
// : Colors.transparent,
|
|
||||||
onTap: () {
|
|
||||||
// Handle navigation to User screen
|
|
||||||
Navigator.pop(context);
|
|
||||||
ref.read(currentPageProvider.state).update((state) => 2);
|
|
||||||
Navigator.pushNamed(context, historyTransaksiRoute);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
leading: Icon(
|
|
||||||
Icons.feed,
|
|
||||||
color: (currentMenu == 3)
|
|
||||||
? Constant.pcBtnBackgroundColor
|
|
||||||
: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
title: Text(
|
|
||||||
'Report',
|
|
||||||
style: TextStyle(
|
|
||||||
color: (currentMenu == 3)
|
|
||||||
? Constant.pcBtnBackgroundColor
|
|
||||||
: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// tileColor: (currentMenu == 3)
|
|
||||||
// ? Constant.pcBtnBackgroundColor
|
|
||||||
// : Colors.transparent,
|
|
||||||
onTap: () {
|
|
||||||
// Handle navigation to Transaksi screen
|
|
||||||
Navigator.pop(context);
|
|
||||||
ref.read(currentPageProvider.state).update((state) => 3);
|
|
||||||
Navigator.pushNamed(context, reportRoute);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
// ListTile(
|
|
||||||
// title: Text(
|
|
||||||
// 'User',
|
|
||||||
// style: TextStyle(
|
|
||||||
// color: (currentMenu == 4)
|
|
||||||
// ? Constant.textWhite
|
|
||||||
// : Constant.textBlack,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// tileColor: (currentMenu == 4)
|
|
||||||
// ? Constant.pcBtnBackgroundColor
|
|
||||||
// : Colors.transparent,
|
|
||||||
// onTap: () {
|
|
||||||
// // Handle navigation to User screen
|
|
||||||
// Navigator.pop(context);
|
|
||||||
// ref.read(currentPageProvider.state).update((state) => 4);
|
|
||||||
// Navigator.pushNamed(context, userRoute);
|
|
||||||
// },
|
|
||||||
// ),
|
|
||||||
// ListTile(
|
|
||||||
// title: Text(
|
|
||||||
// 'Change Company',
|
|
||||||
// style: TextStyle(
|
|
||||||
// color: (currentMenu == 5)
|
|
||||||
// ? Constant.textWhite
|
|
||||||
// : Constant.textBlack,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// tileColor: (currentMenu == 5)
|
|
||||||
// ? Constant.pcBtnBackgroundColor
|
|
||||||
// : Colors.transparent,
|
|
||||||
// onTap: () {
|
|
||||||
// // Handle navigation to User screen
|
|
||||||
// Navigator.pop(context);
|
|
||||||
// ref.read(currentPageProvider.state).update((state) => 5);
|
|
||||||
// Navigator.pushNamed(context, changeCompanyRoute);
|
|
||||||
// },
|
|
||||||
// ),
|
|
||||||
ListTile(
|
|
||||||
leading: Icon(
|
|
||||||
Icons.logout,
|
|
||||||
color: Constant.textGreyv2,
|
|
||||||
),
|
|
||||||
title: Text(
|
|
||||||
'Logout',
|
|
||||||
style: TextStyle(color: Constant.textGreyv2),
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
// di set ke 0 lagi
|
|
||||||
ref.read(currentPageProvider.state).update((state) => 0);
|
|
||||||
ref.read(logoutProvider.notifier).logout(
|
|
||||||
M_UserID: selectedUser?.model.M_UserID ?? "",
|
|
||||||
M_UserUsername: selectedUser?.model.M_UserUsername ?? "",
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
|
|
||||||
Spacer(),
|
|
||||||
|
|
||||||
// Versi Aplikasi
|
|
||||||
ListTile(
|
|
||||||
title: Text(
|
|
||||||
'Versi ${Constant.version}',
|
|
||||||
style: Constant.titleH4Login(context: context)
|
|
||||||
.copyWith(color: Constant.textGrey),
|
|
||||||
),
|
|
||||||
onTap: () {},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -28,44 +28,7 @@ class HistoryRowAtasWidget extends HookConsumerWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
// check file exist
|
// check file exist
|
||||||
// Future<Widget> checkFileExistence(String fileUrl) async {
|
Future<Widget> checkFileExistence(String fileUrl) async {
|
||||||
// try {
|
|
||||||
// final dio = Dio();
|
|
||||||
// final response = await dio.head(fileUrl);
|
|
||||||
// if (response.statusCode == 200) {
|
|
||||||
// return SvgPicture.network(
|
|
||||||
// fileUrl,
|
|
||||||
// semanticsLabel: 'Icon pizza',
|
|
||||||
// // placeholderBuilder: (BuildContext context) => Container(
|
|
||||||
// // padding: const EdgeInsets.all(30.0),
|
|
||||||
// // child: const CircularProgressIndicator(),
|
|
||||||
// // ),
|
|
||||||
// );
|
|
||||||
// } else {
|
|
||||||
// return SvgPicture.network(
|
|
||||||
// 'https://devone.aplikasi.web.id/pettycash-media/icon/icon_13.svg',
|
|
||||||
// semanticsLabel: 'Icon pizza',
|
|
||||||
// // placeholderBuilder: (BuildContext context) => Container(
|
|
||||||
// // padding: const EdgeInsets.all(30.0),
|
|
||||||
// // child: const CircularProgressIndicator(),
|
|
||||||
// // ),
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// } catch (e) {
|
|
||||||
// // print('Error checking file existence: $e');
|
|
||||||
// return SvgPicture.network(
|
|
||||||
// 'https://devone.aplikasi.web.id/pettycash-media/icon/icon_13.svg',
|
|
||||||
// semanticsLabel: 'Icon pizza',
|
|
||||||
// // placeholderBuilder: (BuildContext context) => Container(
|
|
||||||
// // padding: const EdgeInsets.all(30.0),
|
|
||||||
// // child: const CircularProgressIndicator(),
|
|
||||||
// // ),
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
final iconProvider =
|
|
||||||
FutureProvider.family<Widget, String>((ref, fileUrl) async {
|
|
||||||
try {
|
try {
|
||||||
final dio = Dio();
|
final dio = Dio();
|
||||||
final response = await dio.head(fileUrl);
|
final response = await dio.head(fileUrl);
|
||||||
@@ -73,26 +36,39 @@ class HistoryRowAtasWidget extends HookConsumerWidget {
|
|||||||
return SvgPicture.network(
|
return SvgPicture.network(
|
||||||
fileUrl,
|
fileUrl,
|
||||||
semanticsLabel: 'Icon pizza',
|
semanticsLabel: 'Icon pizza',
|
||||||
|
placeholderBuilder: (BuildContext context) => Container(
|
||||||
|
padding: const EdgeInsets.all(30.0),
|
||||||
|
child: const CircularProgressIndicator(),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return SvgPicture.network(
|
return SvgPicture.network(
|
||||||
'https://devone.aplikasi.web.id/pettycash-media/icon/icon_13.svg',
|
'https://devone.aplikasi.web.id/pettycash-media/icon/icon_13.svg',
|
||||||
semanticsLabel: 'Icon pizza',
|
semanticsLabel: 'Icon pizza',
|
||||||
|
placeholderBuilder: (BuildContext context) => Container(
|
||||||
|
padding: const EdgeInsets.all(30.0),
|
||||||
|
child: const CircularProgressIndicator(),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
// print('Error checking file existence: $e');
|
||||||
return SvgPicture.network(
|
return SvgPicture.network(
|
||||||
'https://devone.aplikasi.web.id/pettycash-media/icon/icon_13.svg',
|
'https://devone.aplikasi.web.id/pettycash-media/icon/icon_13.svg',
|
||||||
semanticsLabel: 'Icon pizza',
|
semanticsLabel: 'Icon pizza',
|
||||||
|
placeholderBuilder: (BuildContext context) => Container(
|
||||||
|
padding: const EdgeInsets.all(30.0),
|
||||||
|
child: const CircularProgressIndicator(),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
// fungsi tanggal
|
// fungsi tanggal
|
||||||
String formatDateString(String inputDate) {
|
String formatDateString(String inputDate) {
|
||||||
try {
|
try {
|
||||||
// Parsing tanggal dari string input
|
// Parsing tanggal dari string input
|
||||||
DateTime date = DateFormat('dd-MM-yyyy', 'id').parse(inputDate);
|
DateTime date = DateFormat('dd-MM-yyyy').parse(inputDate);
|
||||||
|
|
||||||
// Format tanggal ke '30 Des 2023'
|
// Format tanggal ke '30 Des 2023'
|
||||||
String formattedDate = DateFormat('dd MMM yyyy', 'id').format(date);
|
String formattedDate = DateFormat('dd MMM yyyy', 'id').format(date);
|
||||||
@@ -106,99 +82,6 @@ class HistoryRowAtasWidget extends HookConsumerWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget getIconUrl(String categoryid) {
|
|
||||||
List<Map<String, String>> iconDataList = [
|
|
||||||
{
|
|
||||||
'categoryid': '1',
|
|
||||||
'url':
|
|
||||||
'https://devone.aplikasi.web.id/pettycash-media/icon/icon_13.svg'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'categoryid': '2',
|
|
||||||
'url':
|
|
||||||
'https://devone.aplikasi.web.id/pettycash-media/icon/icon_13.svg'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'categoryid': '3',
|
|
||||||
'url':
|
|
||||||
'https://devone.aplikasi.web.id/pettycash-media/icon/icon_3.svg'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'categoryid': '4',
|
|
||||||
'url':
|
|
||||||
'https://devone.aplikasi.web.id/pettycash-media/icon/icon_13.svg'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'categoryid': '5',
|
|
||||||
'url':
|
|
||||||
'https://devone.aplikasi.web.id/pettycash-media/icon/icon_5.svg'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'categoryid': '6',
|
|
||||||
'url':
|
|
||||||
'https://devone.aplikasi.web.id/pettycash-media/icon/icon_6.svg'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'categoryid': '7',
|
|
||||||
'url':
|
|
||||||
'https://devone.aplikasi.web.id/pettycash-media/icon/icon_13.svg'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'categoryid': '8',
|
|
||||||
'url':
|
|
||||||
'https://devone.aplikasi.web.id/pettycash-media/icon/icon_13.svg'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'categoryid': '9',
|
|
||||||
'url':
|
|
||||||
'https://devone.aplikasi.web.id/pettycash-media/icon/icon_13.svg'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'categoryid': '10',
|
|
||||||
'url':
|
|
||||||
'https://devone.aplikasi.web.id/pettycash-media/icon/icon_13.svg'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'categoryid': '11',
|
|
||||||
'url':
|
|
||||||
'https://devone.aplikasi.web.id/pettycash-media/icon/icon_13.svg'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'categoryid': '12',
|
|
||||||
'url':
|
|
||||||
'https://devone.aplikasi.web.id/pettycash-media/icon/icon_12.svg'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'categoryid': '13',
|
|
||||||
'url':
|
|
||||||
'https://devone.aplikasi.web.id/pettycash-media/icon/icon_13.svg'
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
String urlFix = "";
|
|
||||||
|
|
||||||
for (var i = 0; i < iconDataList.length; i++) {
|
|
||||||
if (iconDataList[i]['categoryid'] == categoryid) {
|
|
||||||
// urlFix =
|
|
||||||
// "https://devone.aplikasi.web.id/pettycash-media/icon/icon_$icon_category_id.svg";
|
|
||||||
|
|
||||||
urlFix = iconDataList[i]['url'] ??
|
|
||||||
"https://devone.aplikasi.web.id/pettycash-media/icon/icon_13.svg";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (urlFix == "") {
|
|
||||||
urlFix =
|
|
||||||
"https://devone.aplikasi.web.id/pettycash-media/icon/icon_13.svg";
|
|
||||||
}
|
|
||||||
|
|
||||||
// return urlFix;
|
|
||||||
return SvgPicture.network(
|
|
||||||
urlFix,
|
|
||||||
semanticsLabel: 'Icon category',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
// kiri
|
// kiri
|
||||||
@@ -211,7 +94,23 @@ class HistoryRowAtasWidget extends HookConsumerWidget {
|
|||||||
Radius.circular(8.0),
|
Radius.circular(8.0),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: getIconUrl(icon_category_id),
|
// child: Text('s'),
|
||||||
|
child: FutureBuilder<Widget>(
|
||||||
|
future: checkFileExistence(
|
||||||
|
'https://devone.aplikasi.web.id/pettycash-media/icon/icon_$icon_category_id.svg'),
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||||
|
return CircularProgressIndicator();
|
||||||
|
} else if (snapshot.hasError) {
|
||||||
|
return Icon(
|
||||||
|
Icons.error,
|
||||||
|
color: Colors.red,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return snapshot.data ?? Container();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
// tengah
|
// tengah
|
||||||
@@ -259,23 +158,21 @@ class HistoryRowAtasWidget extends HookConsumerWidget {
|
|||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
width: Constant.getActualXPhone(context: context, x: 80),
|
// width: Constant.getActualXPhone(context: context, x: 32),
|
||||||
height: Constant.getActualYPhone(context: context, y: 24),
|
height: Constant.getActualYPhone(context: context, y: 19),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Constant.bgIconHistory,
|
color: Constant.bgIconHistory,
|
||||||
borderRadius: BorderRadius.all(
|
borderRadius: BorderRadius.all(
|
||||||
Radius.circular(6.0),
|
Radius.circular(6.0),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Align(
|
child: Padding(
|
||||||
alignment: Alignment.center,
|
padding: EdgeInsets.all(2.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
tipe,
|
tipe,
|
||||||
style: Constant.body1_600(context: context).copyWith(
|
style: Constant.body1_600(context: context).copyWith(
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: Constant.pcBtnBackgroundColor,
|
color: Constant.pcBtnBackgroundColor),
|
||||||
fontSize: 14,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -6,13 +6,9 @@
|
|||||||
|
|
||||||
#include "generated_plugin_registrant.h"
|
#include "generated_plugin_registrant.h"
|
||||||
|
|
||||||
#include <file_selector_linux/file_selector_plugin.h>
|
|
||||||
#include <url_launcher_linux/url_launcher_plugin.h>
|
#include <url_launcher_linux/url_launcher_plugin.h>
|
||||||
|
|
||||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||||
g_autoptr(FlPluginRegistrar) file_selector_linux_registrar =
|
|
||||||
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin");
|
|
||||||
file_selector_plugin_register_with_registrar(file_selector_linux_registrar);
|
|
||||||
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
|
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
|
||||||
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
|
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
|
||||||
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
|
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
list(APPEND FLUTTER_PLUGIN_LIST
|
list(APPEND FLUTTER_PLUGIN_LIST
|
||||||
file_selector_linux
|
|
||||||
url_launcher_linux
|
url_launcher_linux
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -5,14 +5,10 @@
|
|||||||
import FlutterMacOS
|
import FlutterMacOS
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
import file_selector_macos
|
|
||||||
import path_provider_foundation
|
|
||||||
import shared_preferences_foundation
|
import shared_preferences_foundation
|
||||||
import url_launcher_macos
|
import url_launcher_macos
|
||||||
|
|
||||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||||
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
|
|
||||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
|
||||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||||
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
|
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,68 +1,68 @@
|
|||||||
{
|
{
|
||||||
"info": {
|
"images" : [
|
||||||
"version": 1,
|
{
|
||||||
"author": "xcode"
|
"size" : "16x16",
|
||||||
|
"idiom" : "mac",
|
||||||
|
"filename" : "app_icon_16.png",
|
||||||
|
"scale" : "1x"
|
||||||
},
|
},
|
||||||
"images": [
|
{
|
||||||
{
|
"size" : "16x16",
|
||||||
"size": "16x16",
|
"idiom" : "mac",
|
||||||
"idiom": "mac",
|
"filename" : "app_icon_32.png",
|
||||||
"filename": "app_icon_16.png",
|
"scale" : "2x"
|
||||||
"scale": "1x"
|
},
|
||||||
},
|
{
|
||||||
{
|
"size" : "32x32",
|
||||||
"size": "16x16",
|
"idiom" : "mac",
|
||||||
"idiom": "mac",
|
"filename" : "app_icon_32.png",
|
||||||
"filename": "app_icon_32.png",
|
"scale" : "1x"
|
||||||
"scale": "2x"
|
},
|
||||||
},
|
{
|
||||||
{
|
"size" : "32x32",
|
||||||
"size": "32x32",
|
"idiom" : "mac",
|
||||||
"idiom": "mac",
|
"filename" : "app_icon_64.png",
|
||||||
"filename": "app_icon_32.png",
|
"scale" : "2x"
|
||||||
"scale": "1x"
|
},
|
||||||
},
|
{
|
||||||
{
|
"size" : "128x128",
|
||||||
"size": "32x32",
|
"idiom" : "mac",
|
||||||
"idiom": "mac",
|
"filename" : "app_icon_128.png",
|
||||||
"filename": "app_icon_64.png",
|
"scale" : "1x"
|
||||||
"scale": "2x"
|
},
|
||||||
},
|
{
|
||||||
{
|
"size" : "128x128",
|
||||||
"size": "128x128",
|
"idiom" : "mac",
|
||||||
"idiom": "mac",
|
"filename" : "app_icon_256.png",
|
||||||
"filename": "app_icon_128.png",
|
"scale" : "2x"
|
||||||
"scale": "1x"
|
},
|
||||||
},
|
{
|
||||||
{
|
"size" : "256x256",
|
||||||
"size": "128x128",
|
"idiom" : "mac",
|
||||||
"idiom": "mac",
|
"filename" : "app_icon_256.png",
|
||||||
"filename": "app_icon_256.png",
|
"scale" : "1x"
|
||||||
"scale": "2x"
|
},
|
||||||
},
|
{
|
||||||
{
|
"size" : "256x256",
|
||||||
"size": "256x256",
|
"idiom" : "mac",
|
||||||
"idiom": "mac",
|
"filename" : "app_icon_512.png",
|
||||||
"filename": "app_icon_256.png",
|
"scale" : "2x"
|
||||||
"scale": "1x"
|
},
|
||||||
},
|
{
|
||||||
{
|
"size" : "512x512",
|
||||||
"size": "256x256",
|
"idiom" : "mac",
|
||||||
"idiom": "mac",
|
"filename" : "app_icon_512.png",
|
||||||
"filename": "app_icon_512.png",
|
"scale" : "1x"
|
||||||
"scale": "2x"
|
},
|
||||||
},
|
{
|
||||||
{
|
"size" : "512x512",
|
||||||
"size": "512x512",
|
"idiom" : "mac",
|
||||||
"idiom": "mac",
|
"filename" : "app_icon_1024.png",
|
||||||
"filename": "app_icon_512.png",
|
"scale" : "2x"
|
||||||
"scale": "1x"
|
}
|
||||||
},
|
],
|
||||||
{
|
"info" : {
|
||||||
"size": "512x512",
|
"version" : 1,
|
||||||
"idiom": "mac",
|
"author" : "xcode"
|
||||||
"filename": "app_icon_1024.png",
|
}
|
||||||
"scale": "2x"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
Before Width: | Height: | Size: 167 KiB After Width: | Height: | Size: 101 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 715 B After Width: | Height: | Size: 520 B |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 2.2 KiB |
@@ -1,14 +1,6 @@
|
|||||||
# Generated by pub
|
# Generated by pub
|
||||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
# See https://dart.dev/tools/pub/glossary#lockfile
|
||||||
packages:
|
packages:
|
||||||
archive:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: archive
|
|
||||||
sha256: "22600aa1e926be775fa5fe7e6894e7fb3df9efda8891c73f70fb3262399a432d"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "3.4.10"
|
|
||||||
args:
|
args:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -57,22 +49,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.0"
|
version: "1.3.0"
|
||||||
checked_yaml:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: checked_yaml
|
|
||||||
sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.0.3"
|
|
||||||
cli_util:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: cli_util
|
|
||||||
sha256: c05b7406fdabc7a49a3929d4af76bcaccbbffcbcdcf185b082e1ae07da323d19
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.4.1"
|
|
||||||
clock:
|
clock:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -85,10 +61,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: collection
|
name: collection
|
||||||
sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c"
|
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.17.1"
|
version: "1.18.0"
|
||||||
convert:
|
convert:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -97,14 +73,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.1"
|
version: "3.1.1"
|
||||||
cross_file:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: cross_file
|
|
||||||
sha256: "2f9d2cbccb76127ba28528cb3ae2c2326a122446a83de5a056aaa3880d3882c5"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.3.3+7"
|
|
||||||
crypto:
|
crypto:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -113,14 +81,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.3"
|
version: "3.0.3"
|
||||||
csslib:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: csslib
|
|
||||||
sha256: "706b5707578e0c1b4b7550f64078f0a0f19dec3f50a178ffae7006b0a9ca58fb"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.0.0"
|
|
||||||
cupertino_icons:
|
cupertino_icons:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -193,38 +153,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.1.1"
|
version: "6.1.1"
|
||||||
file_selector_linux:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: file_selector_linux
|
|
||||||
sha256: "045d372bf19b02aeb69cacf8b4009555fb5f6f0b7ad8016e5f46dd1387ddd492"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.9.2+1"
|
|
||||||
file_selector_macos:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: file_selector_macos
|
|
||||||
sha256: b15c3da8bd4908b9918111fa486903f5808e388b8d1c559949f584725a6594d6
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.9.3+3"
|
|
||||||
file_selector_platform_interface:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: file_selector_platform_interface
|
|
||||||
sha256: a3994c26f10378a039faa11de174d7b78eb8f79e4dd0af2a451410c1a5c3f66b
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.6.2"
|
|
||||||
file_selector_windows:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: file_selector_windows
|
|
||||||
sha256: d3547240c20cabf205c7c7f01a50ecdbc413755814d6677f3cb366f04abcead0
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.9.3+1"
|
|
||||||
flutter:
|
flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -238,14 +166,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.18.6"
|
version: "0.18.6"
|
||||||
flutter_launcher_icons:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: flutter_launcher_icons
|
|
||||||
sha256: "526faf84284b86a4cb36d20a5e45147747b7563d921373d4ee0559c54fcdbcea"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.13.1"
|
|
||||||
flutter_lints:
|
flutter_lints:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
@@ -278,14 +198,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.4"
|
version: "1.0.4"
|
||||||
flutter_share:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: flutter_share
|
|
||||||
sha256: ae12c1cea13b35926a109824ffac601531e40cb94ad53eeae58625eceb3eaaaa
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.0.0"
|
|
||||||
flutter_svg:
|
flutter_svg:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -312,22 +224,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.4"
|
version: "1.0.4"
|
||||||
html:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: html
|
|
||||||
sha256: "3a7812d5bcd2894edf53dfaf8cd640876cf6cef50a8f238745c8b8120ea74d3a"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.15.4"
|
|
||||||
http:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: http
|
|
||||||
sha256: "759d1a329847dd0f39226c688d3e06a6b8679668e350e2891a6474f8b4bb8525"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.1.0"
|
|
||||||
http_parser:
|
http_parser:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -336,78 +232,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.0.2"
|
version: "4.0.2"
|
||||||
image:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: image
|
|
||||||
sha256: "004a2e90ce080f8627b5a04aecb4cdfac87d2c3f3b520aa291260be5a32c033d"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "4.1.4"
|
|
||||||
image_picker:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: image_picker
|
|
||||||
sha256: "26222b01a0c9a2c8fe02fc90b8208bd3325da5ed1f4a2acabf75939031ac0bdd"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.0.7"
|
|
||||||
image_picker_android:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: image_picker_android
|
|
||||||
sha256: "39f2bfe497e495450c81abcd44b62f56c2a36a37a175da7d137b4454977b51b1"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.8.9+3"
|
|
||||||
image_picker_for_web:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: image_picker_for_web
|
|
||||||
sha256: e2423c53a68b579a7c37a1eda967b8ae536c3d98518e5db95ca1fe5719a730a3
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "3.0.2"
|
|
||||||
image_picker_ios:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: image_picker_ios
|
|
||||||
sha256: fadafce49e8569257a0cad56d24438a6fa1f0cbd7ee0af9b631f7492818a4ca3
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.8.9+1"
|
|
||||||
image_picker_linux:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: image_picker_linux
|
|
||||||
sha256: "4ed1d9bb36f7cd60aa6e6cd479779cc56a4cb4e4de8f49d487b1aaad831300fa"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.2.1+1"
|
|
||||||
image_picker_macos:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: image_picker_macos
|
|
||||||
sha256: "3f5ad1e8112a9a6111c46d0b57a7be2286a9a07fc6e1976fdf5be2bd31d4ff62"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.2.1+1"
|
|
||||||
image_picker_platform_interface:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: image_picker_platform_interface
|
|
||||||
sha256: fa4e815e6fcada50e35718727d83ba1c92f1edf95c0b4436554cec301b56233b
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.9.3"
|
|
||||||
image_picker_windows:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: image_picker_windows
|
|
||||||
sha256: "6ad07afc4eb1bc25f3a01084d28520496c4a3bb0cb13685435838167c9dcedeb"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.2.1+1"
|
|
||||||
intl:
|
intl:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -416,22 +240,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.17.0"
|
version: "0.17.0"
|
||||||
js:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: js
|
|
||||||
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.6.7"
|
|
||||||
json_annotation:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: json_annotation
|
|
||||||
sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "4.8.1"
|
|
||||||
lints:
|
lints:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -444,34 +252,26 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: matcher
|
name: matcher
|
||||||
sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb"
|
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.15"
|
version: "0.12.16"
|
||||||
material_color_utilities:
|
material_color_utilities:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: material_color_utilities
|
name: material_color_utilities
|
||||||
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
|
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.2.0"
|
version: "0.5.0"
|
||||||
meta:
|
meta:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: meta
|
name: meta
|
||||||
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
|
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.9.1"
|
version: "1.10.0"
|
||||||
mime:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: mime
|
|
||||||
sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.0.4"
|
|
||||||
open_file:
|
open_file:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -496,30 +296,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.1"
|
version: "1.0.1"
|
||||||
path_provider:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: path_provider
|
|
||||||
sha256: b27217933eeeba8ff24845c34003b003b2b22151de3c908d0e679e8fe1aa078b
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.1.2"
|
|
||||||
path_provider_android:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: path_provider_android
|
|
||||||
sha256: "477184d672607c0a3bf68fbbf601805f92ef79c82b64b4d6eb318cbca4c48668"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.2.2"
|
|
||||||
path_provider_foundation:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: path_provider_foundation
|
|
||||||
sha256: "5a7999be66e000916500be4f15a3633ebceb8302719b47b9cc49ce924125350f"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.3.2"
|
|
||||||
path_provider_linux:
|
path_provider_linux:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -592,14 +368,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.4.0"
|
version: "5.4.0"
|
||||||
photo_view:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: photo_view
|
|
||||||
sha256: "8036802a00bae2a78fc197af8a158e3e2f7b500561ed23b4c458107685e645bb"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.14.0"
|
|
||||||
platform:
|
platform:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -616,14 +384,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.8"
|
version: "2.1.8"
|
||||||
pointycastle:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: pointycastle
|
|
||||||
sha256: "43ac87de6e10afabc85c445745a7b799e04de84cebaa4fd7bf55a5e1e9604d29"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "3.7.4"
|
|
||||||
riverpod:
|
riverpod:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -697,18 +457,18 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: source_span
|
name: source_span
|
||||||
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
|
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.9.1"
|
version: "1.10.0"
|
||||||
stack_trace:
|
stack_trace:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: stack_trace
|
name: stack_trace
|
||||||
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
|
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.11.0"
|
version: "1.11.1"
|
||||||
state_notifier:
|
state_notifier:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -721,10 +481,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: stream_channel
|
name: stream_channel
|
||||||
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
|
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.1"
|
version: "2.1.2"
|
||||||
string_scanner:
|
string_scanner:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -745,10 +505,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_api
|
name: test_api
|
||||||
sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb
|
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.5.1"
|
version: "0.6.1"
|
||||||
top_snackbar_flutter:
|
top_snackbar_flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -861,54 +621,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.4"
|
version: "2.1.4"
|
||||||
video_player:
|
web:
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: video_player
|
|
||||||
sha256: "74b86e63529cf5885130c639d74cd2f9232e7c8a66cbecbddd1dcb9dbd060d1e"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.7.2"
|
|
||||||
video_player_android:
|
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: video_player_android
|
name: web
|
||||||
sha256: "7f8f25d7ad56819a82b2948357f3c3af071f6a678db33833b26ec36bbc221316"
|
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.11"
|
version: "0.3.0"
|
||||||
video_player_avfoundation:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: video_player_avfoundation
|
|
||||||
sha256: bf1a1322bf68bccd349982ba1f5a41314a3880861fb9a93d25d6d0a2345845f0
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.4.11"
|
|
||||||
video_player_platform_interface:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: video_player_platform_interface
|
|
||||||
sha256: "236454725fafcacf98f0f39af0d7c7ab2ce84762e3b63f2cbb3ef9a7e0550bc6"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "6.2.2"
|
|
||||||
video_player_web:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: video_player_web
|
|
||||||
sha256: "9c34a243785feca23148bfcd772dbb803d63c9304488177ec4f3f4463802fcb7"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.0.17"
|
|
||||||
whatsapp_share:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: whatsapp_share
|
|
||||||
sha256: d1884f302a52d9f400bc3d7d4274b77aad83424e08f425351cea8d13b4cb8649
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.0.2"
|
|
||||||
win32:
|
win32:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -933,14 +653,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.3.0"
|
version: "6.3.0"
|
||||||
yaml:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: yaml
|
|
||||||
sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "3.1.2"
|
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.0.6 <4.0.0"
|
dart: ">=3.2.0-194.0.dev <4.0.0"
|
||||||
flutter: ">=3.10.0"
|
flutter: ">=3.10.0"
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
name: app_petty_cash
|
name: app_petty_cash
|
||||||
# name: PettyCash
|
|
||||||
description: A new Flutter project.
|
description: A new Flutter project.
|
||||||
# The following line prevents the package from being accidentally published to
|
# The following line prevents the package from being accidentally published to
|
||||||
# pub.dev using `flutter pub publish`. This is preferred for private packages.
|
# pub.dev using `flutter pub publish`. This is preferred for private packages.
|
||||||
@@ -17,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
# In Windows, build-name is used as the major, minor, and patch parts
|
# In Windows, build-name is used as the major, minor, and patch parts
|
||||||
# of the product and file versions while build-number is used as the build suffix.
|
# of the product and file versions while build-number is used as the build suffix.
|
||||||
version: 1.2.0
|
version: 1.0.0+1
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=3.0.6 <4.0.0'
|
sdk: '>=3.0.6 <4.0.0'
|
||||||
@@ -52,15 +51,6 @@ dependencies:
|
|||||||
top_snackbar_flutter: ^3.1.0
|
top_snackbar_flutter: ^3.1.0
|
||||||
url_launcher: ^6.1.13
|
url_launcher: ^6.1.13
|
||||||
flutter_svg: ^2.0.9
|
flutter_svg: ^2.0.9
|
||||||
flutter_launcher_icons: ^0.13.1
|
|
||||||
image_picker: ^1.0.7
|
|
||||||
video_player: ^2.7.2
|
|
||||||
photo_view: ^0.14.0
|
|
||||||
mime: ^1.0.4
|
|
||||||
path_provider: ^2.1.2
|
|
||||||
flutter_share: ^2.0.0
|
|
||||||
whatsapp_share: ^2.0.2
|
|
||||||
image: ^4.1.4
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
@@ -76,24 +66,6 @@ dev_dependencies:
|
|||||||
# For information on the generic Dart part of this file, see the
|
# For information on the generic Dart part of this file, see the
|
||||||
# following page: https://dart.dev/tools/pub/pubspec
|
# following page: https://dart.dev/tools/pub/pubspec
|
||||||
|
|
||||||
flutter_launcher_icons:
|
|
||||||
android: "launcher_icon"
|
|
||||||
ios: true
|
|
||||||
image_path: "images/logo_apk_v2.png"
|
|
||||||
min_sdk_android: 21 # android min sdk min:16, default 21
|
|
||||||
web:
|
|
||||||
generate: true
|
|
||||||
image_path: "images/logo_apk_v2.png"
|
|
||||||
background_color: "#00FFFFFF"
|
|
||||||
theme_color: "#00FFFFFF"
|
|
||||||
windows:
|
|
||||||
generate: true
|
|
||||||
image_path: "images/logo_apk_v2.png"
|
|
||||||
icon_size: 48 # min:48, max:256, default: 48
|
|
||||||
macos:
|
|
||||||
generate: true
|
|
||||||
image_path: "images/logo_apk_v2.png"
|
|
||||||
|
|
||||||
# The following section is specific to Flutter packages.
|
# The following section is specific to Flutter packages.
|
||||||
flutter:
|
flutter:
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 715 B After Width: | Height: | Size: 917 B |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 8.1 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 20 KiB |
@@ -3,8 +3,8 @@
|
|||||||
"short_name": "app_petty_cash",
|
"short_name": "app_petty_cash",
|
||||||
"start_url": ".",
|
"start_url": ".",
|
||||||
"display": "standalone",
|
"display": "standalone",
|
||||||
"background_color": "#00FFFFFF",
|
"background_color": "#0175C2",
|
||||||
"theme_color": "#00FFFFFF",
|
"theme_color": "#0175C2",
|
||||||
"description": "A new Flutter project.",
|
"description": "A new Flutter project.",
|
||||||
"orientation": "portrait-primary",
|
"orientation": "portrait-primary",
|
||||||
"prefer_related_applications": false,
|
"prefer_related_applications": false,
|
||||||
|
|||||||
@@ -6,13 +6,10 @@
|
|||||||
|
|
||||||
#include "generated_plugin_registrant.h"
|
#include "generated_plugin_registrant.h"
|
||||||
|
|
||||||
#include <file_selector_windows/file_selector_windows.h>
|
|
||||||
#include <permission_handler_windows/permission_handler_windows_plugin.h>
|
#include <permission_handler_windows/permission_handler_windows_plugin.h>
|
||||||
#include <url_launcher_windows/url_launcher_windows.h>
|
#include <url_launcher_windows/url_launcher_windows.h>
|
||||||
|
|
||||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||||
FileSelectorWindowsRegisterWithRegistrar(
|
|
||||||
registry->GetRegistrarForPlugin("FileSelectorWindows"));
|
|
||||||
PermissionHandlerWindowsPluginRegisterWithRegistrar(
|
PermissionHandlerWindowsPluginRegisterWithRegistrar(
|
||||||
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
|
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
|
||||||
UrlLauncherWindowsRegisterWithRegistrar(
|
UrlLauncherWindowsRegisterWithRegistrar(
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
list(APPEND FLUTTER_PLUGIN_LIST
|
list(APPEND FLUTTER_PLUGIN_LIST
|
||||||
file_selector_windows
|
|
||||||
permission_handler_windows
|
permission_handler_windows
|
||||||
url_launcher_windows
|
url_launcher_windows
|
||||||
)
|
)
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 33 KiB |