Compare commits
2 Commits
7986d68560
...
add_drawer
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d23236d6a3 | ||
|
|
bfe30a7c17 |
@@ -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,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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -186,33 +186,4 @@ class TransaksiRepository extends BaseRepository {
|
|||||||
|
|
||||||
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'];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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),
|
|
||||||
);
|
|
||||||
@@ -82,207 +82,226 @@ class ReportScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
drawer: CustomDrawer(),
|
drawer: CustomDrawer(),
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: Padding(
|
child: SingleChildScrollView(
|
||||||
padding: EdgeInsets.all(20),
|
child: Padding(
|
||||||
child: Column(
|
padding: EdgeInsets.all(20),
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
child: Column(
|
||||||
children: [
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
Text(
|
children: [
|
||||||
'Tanggal Awal',
|
Text(
|
||||||
style: Constant.body1(context: context).copyWith(
|
'Tanggal Awal',
|
||||||
fontWeight: FontWeight.w600, color: Constant.textBlack),
|
style: Constant.body1(context: context).copyWith(
|
||||||
),
|
fontWeight: FontWeight.w600, color: Constant.textBlack),
|
||||||
SizedBox(
|
),
|
||||||
height: Constant.getActualYPhone(context: context, y: 10),
|
SizedBox(
|
||||||
),
|
height: Constant.getActualYPhone(context: context, y: 10),
|
||||||
// Tanggal Awal
|
),
|
||||||
Row(
|
// Tanggal Awal
|
||||||
children: [
|
Row(
|
||||||
Expanded(
|
children: [
|
||||||
child: TextField(
|
Expanded(
|
||||||
controller: ctrlTglAwal,
|
child: TextField(
|
||||||
decoration: InputDecoration(
|
controller: ctrlTglAwal,
|
||||||
hintStyle:
|
decoration: InputDecoration(
|
||||||
Constant.body2_400(context: context).copyWith(
|
hintStyle:
|
||||||
color: Colors.orange,
|
Constant.body2_400(context: context).copyWith(
|
||||||
),
|
|
||||||
labelStyle:
|
|
||||||
Constant.body2_400(context: context).copyWith(
|
|
||||||
color: Colors.orange,
|
|
||||||
),
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: Colors.orange,
|
color: Colors.orange,
|
||||||
width: 1,
|
|
||||||
),
|
),
|
||||||
),
|
labelStyle:
|
||||||
focusedBorder: OutlineInputBorder(
|
Constant.body2_400(context: context).copyWith(
|
||||||
borderSide: BorderSide(
|
|
||||||
color: Colors.orange,
|
color: Colors.orange,
|
||||||
width: 1,
|
|
||||||
),
|
),
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: Colors.orange,
|
||||||
|
width: 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: Colors.orange,
|
||||||
|
width: 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// labelText: "Tanggal Awal",
|
||||||
|
hintText: 'Tanggal Awal',
|
||||||
|
// 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,
|
||||||
|
// ),
|
||||||
),
|
),
|
||||||
// labelText: "Tanggal Awal",
|
onTap: () async {
|
||||||
hintText: 'Tanggal Awal',
|
final selectedDateAwal = await showDatePicker(
|
||||||
// suffixIcon: isLoadingFilterScope.value
|
// locale: const Locale("en-CA"),
|
||||||
// ? SizedBox(
|
// locale: ,
|
||||||
// width: Constant.getActualXPhone(
|
context: context,
|
||||||
// context: context,
|
initialEntryMode:
|
||||||
// x: 4,
|
DatePickerEntryMode.calendarOnly,
|
||||||
// ),
|
firstDate: DateTime(2000),
|
||||||
// height: Constant.getActualYPhone(
|
lastDate: DateTime(2100),
|
||||||
// context: context,
|
|
||||||
// y: 4,
|
initialDate: (ctrlTglAwal.text.isEmpty)
|
||||||
// ),
|
? DateTime.now()
|
||||||
// child: CircularProgressIndicator(
|
: tglAwal.value,
|
||||||
// color: Constant.textRed,
|
);
|
||||||
// ),
|
|
||||||
// )
|
if (selectedDateAwal != null) {
|
||||||
// : Icon(
|
String formattedDate = DateFormat('dd-MM-yyyy')
|
||||||
// Icons.calendar_month_sharp,
|
.format(selectedDateAwal);
|
||||||
// color: Constant.colorIconDate,
|
// ctrlTglAwal.text =
|
||||||
// ),
|
// selectedDateAwal.toString().split(' ')[0];
|
||||||
|
ctrlTglAwal.text = formattedDate;
|
||||||
|
tglAwal.value = selectedDateAwal;
|
||||||
|
tglAwalTmp.value = selectedDateAwal.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedDateAwal == null) {
|
||||||
|
print('cancel button');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
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(
|
||||||
height: Constant.getActualYPhone(context: context, y: 20),
|
height: Constant.getActualYPhone(context: context, y: 20),
|
||||||
),
|
),
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
'Tanggal Akhir',
|
'Tanggal Akhir',
|
||||||
style: Constant.body1(context: context).copyWith(
|
style: Constant.body1(context: context).copyWith(
|
||||||
fontWeight: FontWeight.w600, color: Constant.textBlack),
|
fontWeight: FontWeight.w600, color: Constant.textBlack),
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: Constant.getActualYPhone(context: context, y: 10),
|
height: Constant.getActualYPhone(context: context, y: 10),
|
||||||
),
|
),
|
||||||
// Tanggal Akhir
|
// Tanggal Akhir
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: TextField(
|
||||||
controller: ctrlTglAkhir,
|
controller: ctrlTglAkhir,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintStyle:
|
hintStyle:
|
||||||
Constant.body2_400(context: context).copyWith(
|
Constant.body2_400(context: context).copyWith(
|
||||||
color: Colors.orange,
|
|
||||||
),
|
|
||||||
labelStyle:
|
|
||||||
Constant.body2_400(context: context).copyWith(
|
|
||||||
color: Colors.orange,
|
|
||||||
),
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: Colors.orange,
|
color: Colors.orange,
|
||||||
width: 1,
|
|
||||||
),
|
),
|
||||||
),
|
labelStyle:
|
||||||
focusedBorder: OutlineInputBorder(
|
Constant.body2_400(context: context).copyWith(
|
||||||
borderSide: BorderSide(
|
|
||||||
color: Colors.orange,
|
color: Colors.orange,
|
||||||
width: 1,
|
|
||||||
),
|
),
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: Colors.orange,
|
||||||
|
width: 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: Colors.orange,
|
||||||
|
width: 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// labelText: "Tanggal Awal",
|
||||||
|
hintText: 'Tanggal Akhir',
|
||||||
|
// 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,
|
||||||
|
// ),
|
||||||
),
|
),
|
||||||
// labelText: "Tanggal Awal",
|
onTap: () async {
|
||||||
hintText: 'Tanggal Akhir',
|
final selectedDateAkhir = await showDatePicker(
|
||||||
// suffixIcon: isLoadingFilterScope.value
|
// locale: const Locale("en-CA"),
|
||||||
// ? SizedBox(
|
// locale: ,
|
||||||
// width: Constant.getActualXPhone(
|
context: context,
|
||||||
// context: context,
|
initialEntryMode:
|
||||||
// x: 4,
|
DatePickerEntryMode.calendarOnly,
|
||||||
// ),
|
firstDate: DateTime(2000),
|
||||||
// height: Constant.getActualYPhone(
|
lastDate: DateTime(2100),
|
||||||
// context: context,
|
|
||||||
// y: 4,
|
initialDate: (ctrlTglAkhir.text.isEmpty)
|
||||||
// ),
|
? DateTime.now()
|
||||||
// child: CircularProgressIndicator(
|
: tglAkhir.value,
|
||||||
// color: Constant.textRed,
|
);
|
||||||
// ),
|
|
||||||
// )
|
if (selectedDateAkhir != null) {
|
||||||
// : Icon(
|
String formattedDate = DateFormat('dd-MM-yyyy')
|
||||||
// Icons.calendar_month_sharp,
|
.format(selectedDateAkhir);
|
||||||
// color: Constant.colorIconDate,
|
// ctrlTglAkhir.text =
|
||||||
// ),
|
// selectedDateAkhir.toString().split(' ')[0];
|
||||||
|
ctrlTglAkhir.text = formattedDate;
|
||||||
|
tglAkhir.value = selectedDateAkhir;
|
||||||
|
tglAkhirTmp.value = selectedDateAkhir.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedDateAkhir == null) {
|
||||||
|
print('cancel button');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
onTap: () async {
|
|
||||||
final selectedDateAkhir = await showDatePicker(
|
|
||||||
// locale: const Locale("en-CA"),
|
|
||||||
// locale: ,
|
|
||||||
context: context,
|
|
||||||
initialEntryMode: DatePickerEntryMode.calendarOnly,
|
|
||||||
firstDate: DateTime(2000),
|
|
||||||
lastDate: DateTime(2100),
|
|
||||||
|
|
||||||
initialDate: (ctrlTglAkhir.text.isEmpty)
|
|
||||||
? DateTime.now()
|
|
||||||
: tglAkhir.value,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (selectedDateAkhir != null) {
|
|
||||||
String formattedDate = DateFormat('dd-MM-yyyy')
|
|
||||||
.format(selectedDateAkhir);
|
|
||||||
// ctrlTglAkhir.text =
|
|
||||||
// selectedDateAkhir.toString().split(' ')[0];
|
|
||||||
ctrlTglAkhir.text = formattedDate;
|
|
||||||
tglAkhir.value = selectedDateAkhir;
|
|
||||||
tglAkhirTmp.value = selectedDateAkhir.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selectedDateAkhir == null) {
|
|
||||||
print('cancel button');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
|
),
|
||||||
Spacer(),
|
),
|
||||||
|
),
|
||||||
Row(
|
),
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
bottomNavigationBar: BottomAppBar(
|
||||||
children: [
|
height: 150,
|
||||||
ElevatedButton(
|
child: Container(
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
// right: Constant.getActualXPhone(context: context, x: 27),
|
||||||
|
// left: Constant.getActualXPhone(context: context, x: 27),
|
||||||
|
// bottom: Constant.getActualYPhone(context: context, y: 32),
|
||||||
|
// top: Constant.getActualYPhone(context: context, y: 24),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
// Excel
|
||||||
|
Container(
|
||||||
|
width: Constant.getActualXPhone(context: context, x: 336),
|
||||||
|
height: Constant.getActualYPhone(context: context, y: 42),
|
||||||
|
child: ElevatedButton(
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
backgroundColor: MaterialStateColor.resolveWith(
|
backgroundColor: MaterialStateColor.resolveWith(
|
||||||
(states) => Colors.white),
|
(states) => Colors.white),
|
||||||
// side: MaterialStateBorderSide.resolveWith(
|
// side: MaterialStateBorderSide.resolveWith(
|
||||||
// (states) => BorderSide(color: Colors.green),
|
// (states) => BorderSide(color: Colors.green),
|
||||||
// ),
|
// ),
|
||||||
|
|
||||||
// backgroundColor: MaterialStateColor.resolveWith(
|
// backgroundColor: MaterialStateColor.resolveWith(
|
||||||
// (st) => Constant.pcBtnBackgroundColor),
|
// (st) => Constant.pcBtnBackgroundColor),
|
||||||
shape:
|
shape:
|
||||||
@@ -314,11 +333,11 @@ class ReportScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: Constant.getActualXPhone(
|
height: Constant.getActualXPhone(
|
||||||
context: context, x: 10),
|
context: context, x: 8),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'Excel',
|
'Download Report (xls) ',
|
||||||
style: Constant.body1(context: context).copyWith(
|
style: Constant.body1(context: context).copyWith(
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: Colors.green,
|
color: Colors.green,
|
||||||
@@ -326,41 +345,19 @@ class ReportScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
onPressed: () async {
|
onPressed: () {},
|
||||||
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
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
|
||||||
// PDF
|
SizedBox(
|
||||||
ElevatedButton(
|
height: Constant.getActualYPhone(context: context, y: 20),
|
||||||
|
),
|
||||||
|
|
||||||
|
// PDF
|
||||||
|
Container(
|
||||||
|
width: Constant.getActualXPhone(context: context, x: 336),
|
||||||
|
height: Constant.getActualYPhone(context: context, y: 42),
|
||||||
|
child: ElevatedButton(
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
backgroundColor: MaterialStateColor.resolveWith(
|
backgroundColor: MaterialStateColor.resolveWith(
|
||||||
(st) => Constant.pcBtnBackgroundColor),
|
(st) => Constant.pcBtnBackgroundColor),
|
||||||
@@ -393,11 +390,11 @@ class ReportScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: Constant.getActualXPhone(
|
height: Constant.getActualXPhone(
|
||||||
context: context, x: 8),
|
context: context, x: 8),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'PDF',
|
'Download Report (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),
|
||||||
@@ -405,29 +402,7 @@ class ReportScreen extends HookConsumerWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
M_CompanyID = await getCompanyID();
|
String url = "https://pub.dev/packages?q=url+launcher";
|
||||||
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))) {
|
if (!await launchUrl(Uri.parse(url))) {
|
||||||
// throw Exception('Could not launch $url');
|
// throw Exception('Could not launch $url');
|
||||||
SanckbarWidget(context, 'Could not launch $url',
|
SanckbarWidget(context, 'Could not launch $url',
|
||||||
@@ -435,9 +410,9 @@ class ReportScreen extends HookConsumerWidget {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -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),
|
|
||||||
);
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -152,6 +152,7 @@ class CustomDrawer extends HookConsumerWidget {
|
|||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
|
|
||||||
Chip(
|
Chip(
|
||||||
backgroundColor: Constant.textGrey.withOpacity(0.16),
|
backgroundColor: Constant.textGrey.withOpacity(0.16),
|
||||||
label: Text(
|
label: Text(
|
||||||
@@ -250,28 +251,6 @@ class CustomDrawer extends HookConsumerWidget {
|
|||||||
ref.read(currentPageProvider.state).update((state) => 3);
|
ref.read(currentPageProvider.state).update((state) => 3);
|
||||||
Navigator.pushNamed(context, reportRoute);
|
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(
|
ListTile(
|
||||||
leading: Icon(
|
leading: Icon(
|
||||||
|
|||||||
@@ -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: () {},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -85,10 +85,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: collection
|
name: collection
|
||||||
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
|
sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.18.0"
|
version: "1.17.1"
|
||||||
convert:
|
convert:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -436,26 +436,26 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: matcher
|
name: matcher
|
||||||
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
|
sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.16"
|
version: "0.12.15"
|
||||||
material_color_utilities:
|
material_color_utilities:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: material_color_utilities
|
name: material_color_utilities
|
||||||
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
|
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.5.0"
|
version: "0.2.0"
|
||||||
meta:
|
meta:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: meta
|
name: meta
|
||||||
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
|
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.10.0"
|
version: "1.9.1"
|
||||||
mime:
|
mime:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -689,18 +689,18 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: source_span
|
name: source_span
|
||||||
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
|
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.10.0"
|
version: "1.9.1"
|
||||||
stack_trace:
|
stack_trace:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: stack_trace
|
name: stack_trace
|
||||||
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
|
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.11.1"
|
version: "1.11.0"
|
||||||
state_notifier:
|
state_notifier:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -713,10 +713,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: stream_channel
|
name: stream_channel
|
||||||
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
|
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.2"
|
version: "2.1.1"
|
||||||
string_scanner:
|
string_scanner:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -737,10 +737,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_api
|
name: test_api
|
||||||
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
|
sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.6.1"
|
version: "0.5.1"
|
||||||
top_snackbar_flutter:
|
top_snackbar_flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -893,14 +893,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.17"
|
version: "2.0.17"
|
||||||
web:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: web
|
|
||||||
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.3.0"
|
|
||||||
win32:
|
win32:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -934,5 +926,5 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.2"
|
version: "3.1.2"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.2.0-194.0.dev <4.0.0"
|
dart: ">=3.0.6 <4.0.0"
|
||||||
flutter: ">=3.10.0"
|
flutter: ">=3.10.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user