Compare commits
5 Commits
7986d68560
...
81733ec865
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
81733ec865 | ||
|
|
9d9db9eeb4 | ||
|
|
acc42c2d8f | ||
|
|
f03266674a | ||
|
|
60919d6d12 |
@@ -13,7 +13,7 @@ class Constant {
|
||||
// static String version = "1.00";
|
||||
|
||||
// NOTE VERSI HARUS SAMA DENGAN PUBSPEC.YAML
|
||||
static String version = "1.0.0";
|
||||
static String version = "1.1.0";
|
||||
|
||||
// static String baseUrl = "https://devregonline.pramita.co.id/one-api/xdoc/";
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'package:app_petty_cash/screen/change_pasword/change_password_screen.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';
|
||||
@@ -20,6 +22,7 @@ const transaksiRoute = "/transaksiRoute";
|
||||
const userRoute = "/userRoute";
|
||||
const reportRoute = "/reportRoute";
|
||||
const changeCompanyRoute = "/changeCompanyRoute";
|
||||
const changePasswordRoute = "/changePasswordRoute";
|
||||
const historyTransaksiRoute = "/historyTransaksiRoute";
|
||||
const cameraExampleRoute = "/cameraExampleRoute";
|
||||
const cobaCameraRoute = "/cobaCameraRoute";
|
||||
@@ -119,6 +122,18 @@ class AppRoute {
|
||||
);
|
||||
});
|
||||
}
|
||||
// transaksi screen
|
||||
if (settings.name == changePasswordRoute) {
|
||||
return MaterialPageRoute(builder: (context) {
|
||||
return MediaQuery(
|
||||
data: MediaQuery.of(context).copyWith(
|
||||
textScaleFactor: 1.0,
|
||||
padding: EdgeInsets.all(0),
|
||||
),
|
||||
child: ChangePasswordScreen(),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// test file picker screen
|
||||
if (settings.name == testFilePickerRoute) {
|
||||
|
||||
@@ -12,6 +12,7 @@ class HistoryTransaksiModel {
|
||||
String? tanggalconfirm;
|
||||
String? usertransaksi;
|
||||
String? userconfirm;
|
||||
String? tanggalcreated;
|
||||
|
||||
HistoryTransaksiModel(
|
||||
{this.id,
|
||||
@@ -26,7 +27,9 @@ class HistoryTransaksiModel {
|
||||
this.isconfirm,
|
||||
this.tanggalconfirm,
|
||||
this.usertransaksi,
|
||||
this.userconfirm});
|
||||
this.userconfirm,
|
||||
this.tanggalcreated
|
||||
});
|
||||
|
||||
HistoryTransaksiModel.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
@@ -42,6 +45,7 @@ class HistoryTransaksiModel {
|
||||
tanggalconfirm = json['tanggalconfirm'];
|
||||
usertransaksi = json['usertransaksi'];
|
||||
userconfirm = json['userconfirm'];
|
||||
tanggalcreated = json['tanggalcreated'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
@@ -59,6 +63,7 @@ class HistoryTransaksiModel {
|
||||
data['tanggalconfirm'] = this.tanggalconfirm;
|
||||
data['usertransaksi'] = this.usertransaksi;
|
||||
data['userconfirm'] = this.userconfirm;
|
||||
data['tanggalcreated'] = this.tanggalcreated;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -12,21 +12,24 @@ class ListTransaksiHomeModel {
|
||||
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});
|
||||
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'];
|
||||
@@ -42,6 +45,7 @@ class ListTransaksiHomeModel {
|
||||
tanggalconfirm = json['tanggalconfirm'];
|
||||
usertransaksi = json['usertransaksi'];
|
||||
userconfirm = json['userconfirm'];
|
||||
tanggalcreated = json['tanggalcreated'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
@@ -59,6 +63,7 @@ class ListTransaksiHomeModel {
|
||||
data['tanggalconfirm'] = this.tanggalconfirm;
|
||||
data['usertransaksi'] = this.usertransaksi;
|
||||
data['userconfirm'] = this.userconfirm;
|
||||
data['tanggalcreated'] = this.tanggalcreated;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,35 +59,24 @@ class AuthRepository extends BaseRepository {
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> change_password({
|
||||
Future<String> changePassword({
|
||||
required String userID,
|
||||
required String token,
|
||||
required String M_UserID,
|
||||
required String username,
|
||||
required String doctor_id,
|
||||
required String new_password,
|
||||
required String confirm_password,
|
||||
required String oldPassword,
|
||||
required String newPassword,
|
||||
required String confirmPassword,
|
||||
}) async {
|
||||
final param = {
|
||||
"token": token,
|
||||
"M_UserID": M_UserID,
|
||||
"username": username,
|
||||
"doctor_id": doctor_id,
|
||||
"new_password": new_password,
|
||||
"confirm_password": confirm_password
|
||||
"M_UserID": userID,
|
||||
"old_password": oldPassword,
|
||||
"new_password": newPassword,
|
||||
"confirm_password": confirmPassword
|
||||
|
||||
// "username": "alhadad",
|
||||
// "doctor_id": "3101210841",
|
||||
// "password": "riau123"
|
||||
};
|
||||
|
||||
final service = "${Constant.baseUrlDevone}auth/change_password";
|
||||
final resp = await post(param: param, service: service);
|
||||
|
||||
// final result = AuthModel(
|
||||
// token: resp["data"]["token"],
|
||||
// model: AuthDoctorModel.fromJson(resp["data"]["user"]),
|
||||
// );
|
||||
// return result;
|
||||
final resp = await post(param: param, service: service, token: token);
|
||||
|
||||
if (resp["status"] == "OK") {
|
||||
return resp['message'];
|
||||
|
||||
@@ -139,7 +139,7 @@ class TransaksiRepository extends BaseRepository {
|
||||
String categoryid,
|
||||
) async {
|
||||
final service =
|
||||
"${Constant.baseUrlDevone}/homescreen/list_transaction/?companyid=$companyid&startdate=$tglAwal&enddate=$tglAkhir&kategoriid=$categoryid";
|
||||
"${Constant.baseUrlDevone}/history/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
|
||||
final resp = await get(
|
||||
// param: {
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
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 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,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),
|
||||
);
|
||||
@@ -0,0 +1,424 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:app_petty_cash/app/constant.dart';
|
||||
import 'package:app_petty_cash/provider/current_menu_provider.dart';
|
||||
import 'package:app_petty_cash/screen/change_pasword/change_password_provider.dart';
|
||||
import 'package:app_petty_cash/screen/login/logout_provider.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';
|
||||
|
||||
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 isLoading = useState(false);
|
||||
final obscureText = 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 () {};
|
||||
}, []);
|
||||
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: obscureText.value,
|
||||
controller: ctrlOldPassword,
|
||||
decoration: InputDecoration(
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(
|
||||
obscureText.value
|
||||
? Icons.visibility
|
||||
: Icons.visibility_off,
|
||||
color: Constant.textGreyv2,
|
||||
),
|
||||
onPressed: () {
|
||||
obscureText.value = !obscureText.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: obscureText.value,
|
||||
controller: ctrlNewPassword,
|
||||
decoration: InputDecoration(
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(
|
||||
obscureText.value
|
||||
? Icons.visibility
|
||||
: Icons.visibility_off,
|
||||
color: Constant.textGreyv2,
|
||||
),
|
||||
onPressed: () {
|
||||
obscureText.value = !obscureText.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: obscureText.value,
|
||||
controller: ctrlConfirmPassword,
|
||||
decoration: InputDecoration(
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(
|
||||
obscureText.value
|
||||
? Icons.visibility
|
||||
: Icons.visibility_off,
|
||||
color: Constant.textGreyv2,
|
||||
),
|
||||
onPressed: () {
|
||||
obscureText.value = !obscureText.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(
|
||||
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),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import 'package:app_petty_cash/screen/home/list_transaksi_home_provider.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../app/constant.dart';
|
||||
@@ -140,6 +141,25 @@ class HomeScreen extends HookConsumerWidget {
|
||||
},
|
||||
);
|
||||
|
||||
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(
|
||||
padding: EdgeInsets.only(
|
||||
top: Constant.getActualYPhone(context: context, y: 30),
|
||||
@@ -400,6 +420,60 @@ class HomeScreen extends HookConsumerWidget {
|
||||
.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 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,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -31,6 +31,10 @@ class ReportScreen extends HookConsumerWidget {
|
||||
final tglAkhirTmp = useState<String>("");
|
||||
String M_CompanyID = "0";
|
||||
|
||||
String timeStamp = DateFormat('dd-MM-yyyy').format(
|
||||
DateTime.now(),
|
||||
);
|
||||
|
||||
Future<String> getCompanyID() async {
|
||||
final shared = await SharedPreferences.getInstance();
|
||||
String M_CompanyID = "0";
|
||||
@@ -328,8 +332,9 @@ class ReportScreen extends HookConsumerWidget {
|
||||
),
|
||||
onPressed: () async {
|
||||
M_CompanyID = await getCompanyID();
|
||||
if(M_CompanyID == "0"){
|
||||
SanckbarWidget(context, 'Invalid Company', snackbarType.error);
|
||||
if (M_CompanyID == "0") {
|
||||
SanckbarWidget(
|
||||
context, 'Invalid Company', snackbarType.error);
|
||||
return;
|
||||
}
|
||||
// Awal
|
||||
@@ -343,13 +348,13 @@ class ReportScreen extends HookConsumerWidget {
|
||||
// Akhir
|
||||
DateTime parsedDateAkhir =
|
||||
DateFormat('dd-MM-yyyy').parse(
|
||||
ctrlTglAwal.value.text.toString(),
|
||||
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";
|
||||
"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',
|
||||
@@ -406,8 +411,9 @@ class ReportScreen extends HookConsumerWidget {
|
||||
),
|
||||
onPressed: () async {
|
||||
M_CompanyID = await getCompanyID();
|
||||
if(M_CompanyID == "0"){
|
||||
SanckbarWidget(context, 'Invalid Company', snackbarType.error);
|
||||
if (M_CompanyID == "0") {
|
||||
SanckbarWidget(
|
||||
context, 'Invalid Company', snackbarType.error);
|
||||
return;
|
||||
}
|
||||
// Awal
|
||||
@@ -421,13 +427,15 @@ class ReportScreen extends HookConsumerWidget {
|
||||
// Akhir
|
||||
DateTime parsedDateAkhir =
|
||||
DateFormat('dd-MM-yyyy').parse(
|
||||
ctrlTglAwal.value.text.toString(),
|
||||
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";
|
||||
"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',
|
||||
|
||||
@@ -464,6 +464,25 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
|
||||
final FocusNode focusNodetglAkhir = useFocusNode();
|
||||
final tglAkhirHasFocus = useState(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 GestureDetector(
|
||||
onTap: () => FocusManager.instance.primaryFocus?.unfocus(),
|
||||
child: Padding(
|
||||
@@ -736,6 +755,7 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
|
||||
value: option,
|
||||
child: Text(
|
||||
option.categoryname ?? "",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Constant.body1(context: context)
|
||||
.copyWith(
|
||||
color: Constant.textBlack,
|
||||
@@ -875,13 +895,27 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
|
||||
],
|
||||
),
|
||||
onPressed: () async {
|
||||
DateTime parsedDate =
|
||||
DateFormat('dd-MM-yyyy').parse(
|
||||
ctrlTglAwal.value.text.toString(),
|
||||
);
|
||||
String formattedDateAwal =
|
||||
DateFormat('yyyy-MM-dd').format(parsedDate);
|
||||
|
||||
DateTime parsedDateAkhir =
|
||||
DateFormat('dd-MM-yyyy').parse(
|
||||
ctrlTglAkhir.value.text.toString(),
|
||||
);
|
||||
String formattedDateAkhir = DateFormat('yyyy-MM-dd')
|
||||
.format(parsedDateAkhir);
|
||||
|
||||
M_CompanyID.value = await getCompanyID();
|
||||
ref
|
||||
.read(searchHistoryTransaksiProvider.notifier)
|
||||
.searchHistoryTransaksi(
|
||||
M_CompanyID.value,
|
||||
ctrlTglAwal.text,
|
||||
ctrlTglAkhir.text,
|
||||
formattedDateAwal,
|
||||
formattedDateAkhir,
|
||||
selectedListCategory.value.categoryid ?? "0",
|
||||
);
|
||||
},
|
||||
@@ -1080,7 +1114,27 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
|
||||
// ),
|
||||
SizedBox(
|
||||
height: Constant.getActualYPhone(
|
||||
context: context, y: 6),
|
||||
context: context, y: 10),
|
||||
),
|
||||
|
||||
// catatan
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
listSearchHistory.value[idx].note
|
||||
.toString(),
|
||||
style: Constant.body1(
|
||||
context: context)
|
||||
.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Constant.textBlack,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(
|
||||
height: Constant.getActualYPhone(
|
||||
context: context, y: 10),
|
||||
),
|
||||
|
||||
if (listSearchHistory
|
||||
@@ -1308,70 +1362,32 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
// Row(
|
||||
// children: [
|
||||
// Container(
|
||||
// width: Constant.getActualXPhone(
|
||||
// context: context, x: 40),
|
||||
// height: Constant.getActualYPhone(
|
||||
// context: context,
|
||||
// y: 40,
|
||||
// ),
|
||||
// child: Image.asset(
|
||||
// "images/icon_delete.png",
|
||||
// // scale: 1,
|
||||
// ),
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: Constant.getActualYPhone(
|
||||
// context: context, y: 12),
|
||||
// ),
|
||||
// Expanded(
|
||||
// child: ElevatedButton(
|
||||
// style: ButtonStyle(
|
||||
// backgroundColor: MaterialStateColor
|
||||
// .resolveWith((st) => 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: [
|
||||
// Text(
|
||||
// 'Confirmed',
|
||||
// style: Constant.body1(
|
||||
// context: context)
|
||||
// .copyWith(
|
||||
// fontWeight:
|
||||
// FontWeight
|
||||
// .w600,
|
||||
// color: Constant
|
||||
// .white),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// onPressed: () {},
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// Tanggal Created align right
|
||||
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
'created : ' +
|
||||
formatDateString(
|
||||
listSearchHistory
|
||||
.value[idx]
|
||||
.tanggalcreated
|
||||
.toString(),
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Constant.body1(
|
||||
context: context)
|
||||
.copyWith(
|
||||
fontWeight: FontWeight.normal,
|
||||
fontStyle: FontStyle.italic,
|
||||
color: Constant.textBlack,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -39,6 +39,7 @@ class TransaksiSelectKategoriWidget extends StatelessWidget {
|
||||
value: option,
|
||||
child: Text(
|
||||
option.categoryname ?? "",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Constant.body1(context: context).copyWith(
|
||||
color: Constant.textBlack, fontWeight: FontWeight.w400),
|
||||
),
|
||||
|
||||
@@ -272,6 +272,28 @@ class CustomDrawer extends HookConsumerWidget {
|
||||
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(
|
||||
|
||||
@@ -211,71 +211,6 @@ class HistoryRowAtasWidget extends HookConsumerWidget {
|
||||
Radius.circular(8.0),
|
||||
),
|
||||
),
|
||||
// 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();
|
||||
// // return Text('');
|
||||
// // } else if (snapshot.hasError) {
|
||||
// // return Icon(
|
||||
// // Icons.error,
|
||||
// // color: Colors.red,
|
||||
// // );
|
||||
// // } else {
|
||||
// // return snapshot.data ?? Container();
|
||||
// // }
|
||||
|
||||
// if (snapshot.connectionState == ConnectionState.done) {
|
||||
// return snapshot.data ?? Container();
|
||||
// } else if (snapshot.hasError) {
|
||||
// return Icon(
|
||||
// Icons.error,
|
||||
// color: Colors.red,
|
||||
// );
|
||||
// } else {
|
||||
// return Text('');
|
||||
// }
|
||||
// },
|
||||
// ),
|
||||
// child: Consumer(
|
||||
// builder: (context, watch, child) {
|
||||
// String iconUrl =
|
||||
// 'https://devone.aplikasi.web.id/pettycash-media/icon/icon_$icon_category_id.svg';
|
||||
// final iconAsyncValue = ref.read(
|
||||
// iconProvider(
|
||||
// iconUrl,
|
||||
// ),
|
||||
// );
|
||||
|
||||
// return iconAsyncValue.when(
|
||||
// loading: () {
|
||||
// print('loading iconurl : $iconUrl');
|
||||
// return CircularProgressIndicator();
|
||||
// },
|
||||
// error: (error, stackTrace) {
|
||||
// print('error iconurl : $iconUrl');
|
||||
// return Icon(
|
||||
// Icons.error,
|
||||
// color: Colors.red,
|
||||
// );
|
||||
// },
|
||||
// data: (iconWidget) {
|
||||
// print('data iconurl : $iconUrl');
|
||||
// return iconWidget ?? Container();
|
||||
// }
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
|
||||
// child: SvgPicture.network(
|
||||
// 'https://devone.aplikasi.web.id/pettycash-media/icon/icon_$icon_category_id.svg',
|
||||
// semanticsLabel: 'Icon pizza',
|
||||
// ),
|
||||
|
||||
child: getIconUrl(icon_category_id),
|
||||
),
|
||||
|
||||
|
||||
@@ -17,7 +17,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
|
||||
# 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.
|
||||
version: 1.0.0+1
|
||||
version: 1.1.0
|
||||
|
||||
environment:
|
||||
sdk: '>=3.0.6 <4.0.0'
|
||||
|
||||
Reference in New Issue
Block a user