Initial commit
This commit is contained in:
25
lib/app/app.bottomsheets.dart
Normal file
25
lib/app/app.bottomsheets.dart
Normal file
@ -0,0 +1,25 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
// **************************************************************************
|
||||
// StackedBottomsheetGenerator
|
||||
// **************************************************************************
|
||||
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
|
||||
import 'app.locator.dart';
|
||||
import '../ui/views/retributor_index/log_history_sewaan/detail_log_history/detail_log_history_view.dart';
|
||||
|
||||
enum BottomSheetType {
|
||||
detailLogHistoryView,
|
||||
}
|
||||
|
||||
void setupBottomSheetUi() {
|
||||
final bottomsheetService = locator<BottomSheetService>();
|
||||
|
||||
final Map<BottomSheetType, SheetBuilder> builders = {
|
||||
BottomSheetType.detailLogHistoryView: (context, request, completer) =>
|
||||
DetailLogHistoryView(request: request, completer: completer),
|
||||
};
|
||||
|
||||
bottomsheetService.setCustomSheetBuilders(builders);
|
||||
}
|
||||
67
lib/app/app.dart
Normal file
67
lib/app/app.dart
Normal file
@ -0,0 +1,67 @@
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
import 'package:stacked/stacked_annotations.dart';
|
||||
|
||||
import '../services/http_services.dart';
|
||||
import '../services/my_easyloading.dart';
|
||||
import '../services/my_socket_io_client.dart';
|
||||
import '../services/other_function.dart';
|
||||
import '../services/shared_prefs.dart';
|
||||
import '../ui/views/login_screen/login_screen_view.dart';
|
||||
import '../ui/views/penyewa_index/penyewa_index_view.dart';
|
||||
import '../ui/views/penyewa_index/penyewa_log/penyewa_log_view.dart';
|
||||
import '../ui/views/penyewa_index/pulsa_detail/pulsa_detail_view.dart';
|
||||
import '../ui/views/penyewa_index/tempat_sewaan/tempat_sewaan_view.dart';
|
||||
import '../ui/views/retributor_index/log_history_sewaan/detail_log_history/detail_log_history_view.dart';
|
||||
import '../ui/views/retributor_index/log_history_sewaan/log_history_sewaan_view.dart';
|
||||
import '../ui/views/retributor_index/penyewa_list/edit_penyewa_dialog/edit_penyewa_dialog_view.dart';
|
||||
import '../ui/views/retributor_index/penyewa_list/penyewa_list_view.dart';
|
||||
import '../ui/views/retributor_index/penyewa_list/top_up_saldo/top_up_saldo_view.dart';
|
||||
import '../ui/views/retributor_index/retributor_index_view.dart';
|
||||
import '../ui/views/retributor_index/scan_rfid_dialog/scan_rfid_dialog_view.dart';
|
||||
import '../ui/views/retributor_index/tempat_sewa_list/edit_tempat_sewa_dialog/edit_tempat_sewa_dialog_view.dart';
|
||||
import '../ui/views/retributor_index/tempat_sewa_list/tempat_sewa_list_view.dart';
|
||||
import '../ui/views/splash_screen/splash_screen_view.dart';
|
||||
|
||||
@StackedApp(
|
||||
routes: [
|
||||
MaterialRoute(page: SplashScreenView, initial: true),
|
||||
MaterialRoute(page: LoginScreenView),
|
||||
MaterialRoute(
|
||||
page: RetributorIndexView,
|
||||
children: [
|
||||
MaterialRoute(page: TempatSewaListView),
|
||||
MaterialRoute(page: LogHistorySewaanView),
|
||||
MaterialRoute(page: PenyewaListView),
|
||||
],
|
||||
),
|
||||
MaterialRoute(page: PenyewaIndexView, children: [
|
||||
MaterialRoute(page: PenyewaLogView),
|
||||
MaterialRoute(page: TempatSewaanView),
|
||||
MaterialRoute(page: PulsaDetailView),
|
||||
])
|
||||
],
|
||||
dialogs: [
|
||||
StackedDialog(classType: ScanRfidDialogView),
|
||||
StackedDialog(classType: TopUpSaldoView),
|
||||
StackedDialog(classType: EditTempatSewaDialogView),
|
||||
StackedDialog(classType: EditPenyewaDialogView)
|
||||
],
|
||||
bottomsheets: [
|
||||
StackedBottomsheet(classType: DetailLogHistoryView),
|
||||
],
|
||||
dependencies: [
|
||||
LazySingleton(classType: NavigationService),
|
||||
LazySingleton(classType: DialogService),
|
||||
LazySingleton(classType: SnackbarService),
|
||||
LazySingleton(classType: BottomSheetService),
|
||||
//
|
||||
|
||||
LazySingleton(classType: MyEasyLoading),
|
||||
LazySingleton(classType: MyHttpServices),
|
||||
LazySingleton(classType: OtherFunction),
|
||||
LazySingleton(classType: MySocketIoClient),
|
||||
LazySingleton(classType: MySharedPrefs)
|
||||
],
|
||||
logger: StackedLogger(),
|
||||
)
|
||||
class App {}
|
||||
37
lib/app/app.dialogs.dart
Normal file
37
lib/app/app.dialogs.dart
Normal file
@ -0,0 +1,37 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
// **************************************************************************
|
||||
// StackedDialogGenerator
|
||||
// **************************************************************************
|
||||
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
|
||||
import 'app.locator.dart';
|
||||
import '../ui/views/retributor_index/penyewa_list/edit_penyewa_dialog/edit_penyewa_dialog_view.dart';
|
||||
import '../ui/views/retributor_index/penyewa_list/top_up_saldo/top_up_saldo_view.dart';
|
||||
import '../ui/views/retributor_index/scan_rfid_dialog/scan_rfid_dialog_view.dart';
|
||||
import '../ui/views/retributor_index/tempat_sewa_list/edit_tempat_sewa_dialog/edit_tempat_sewa_dialog_view.dart';
|
||||
|
||||
enum DialogType {
|
||||
scanRfidDialogView,
|
||||
topUpSaldoView,
|
||||
editTempatSewaDialogView,
|
||||
editPenyewaDialogView,
|
||||
}
|
||||
|
||||
void setupDialogUi() {
|
||||
final dialogService = locator<DialogService>();
|
||||
|
||||
final Map<DialogType, DialogBuilder> builders = {
|
||||
DialogType.scanRfidDialogView: (context, request, completer) =>
|
||||
ScanRfidDialogView(request: request, completer: completer),
|
||||
DialogType.topUpSaldoView: (context, request, completer) =>
|
||||
TopUpSaldoView(request: request, completer: completer),
|
||||
DialogType.editTempatSewaDialogView: (context, request, completer) =>
|
||||
EditTempatSewaDialogView(request: request, completer: completer),
|
||||
DialogType.editPenyewaDialogView: (context, request, completer) =>
|
||||
EditPenyewaDialogView(request: request, completer: completer),
|
||||
};
|
||||
|
||||
dialogService.registerCustomDialogBuilders(builders);
|
||||
}
|
||||
41
lib/app/app.locator.dart
Normal file
41
lib/app/app.locator.dart
Normal file
@ -0,0 +1,41 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
// **************************************************************************
|
||||
// StackedLocatorGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// ignore_for_file: public_member_api_docs, implementation_imports, depend_on_referenced_packages
|
||||
|
||||
import 'package:stacked_services/src/bottom_sheet/bottom_sheet_service.dart';
|
||||
import 'package:stacked_services/src/dialog/dialog_service.dart';
|
||||
import 'package:stacked_services/src/navigation/navigation_service.dart';
|
||||
import 'package:stacked_services/src/snackbar/snackbar_service.dart';
|
||||
import 'package:stacked_shared/stacked_shared.dart';
|
||||
|
||||
import '../services/http_services.dart';
|
||||
import '../services/my_easyloading.dart';
|
||||
import '../services/my_socket_io_client.dart';
|
||||
import '../services/other_function.dart';
|
||||
import '../services/shared_prefs.dart';
|
||||
|
||||
final locator = StackedLocator.instance;
|
||||
|
||||
Future<void> setupLocator({
|
||||
String? environment,
|
||||
EnvironmentFilter? environmentFilter,
|
||||
}) async {
|
||||
// Register environments
|
||||
locator.registerEnvironment(
|
||||
environment: environment, environmentFilter: environmentFilter);
|
||||
|
||||
// Register dependencies
|
||||
locator.registerLazySingleton(() => NavigationService());
|
||||
locator.registerLazySingleton(() => DialogService());
|
||||
locator.registerLazySingleton(() => SnackbarService());
|
||||
locator.registerLazySingleton(() => BottomSheetService());
|
||||
locator.registerLazySingleton(() => MyEasyLoading());
|
||||
locator.registerLazySingleton(() => MyHttpServices());
|
||||
locator.registerLazySingleton(() => OtherFunction());
|
||||
locator.registerLazySingleton(() => MySocketIoClient());
|
||||
locator.registerLazySingleton(() => MySharedPrefs());
|
||||
}
|
||||
159
lib/app/app.logger.dart
Normal file
159
lib/app/app.logger.dart
Normal file
@ -0,0 +1,159 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
// **************************************************************************
|
||||
// StackedLoggerGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// ignore_for_file: avoid_print, depend_on_referenced_packages
|
||||
|
||||
/// Maybe this should be generated for the user as well?
|
||||
///
|
||||
/// import 'package:customer_app/services/stackdriver/stackdriver_service.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:logger/logger.dart';
|
||||
|
||||
class SimpleLogPrinter extends LogPrinter {
|
||||
final String className;
|
||||
final bool printCallingFunctionName;
|
||||
final bool printCallStack;
|
||||
final List<String> exludeLogsFromClasses;
|
||||
final String? showOnlyClass;
|
||||
|
||||
SimpleLogPrinter(
|
||||
this.className, {
|
||||
this.printCallingFunctionName = true,
|
||||
this.printCallStack = false,
|
||||
this.exludeLogsFromClasses = const [],
|
||||
this.showOnlyClass,
|
||||
});
|
||||
|
||||
@override
|
||||
List<String> log(LogEvent event) {
|
||||
var color = PrettyPrinter.levelColors[event.level];
|
||||
var emoji = PrettyPrinter.levelEmojis[event.level];
|
||||
var methodName = _getMethodName();
|
||||
|
||||
var methodNameSection =
|
||||
printCallingFunctionName && methodName != null ? ' | $methodName' : '';
|
||||
var stackLog = event.stackTrace.toString();
|
||||
var output =
|
||||
'$emoji $className$methodNameSection - ${event.message}${event.error != null ? '\nERROR: ${event.error}\n' : ''}${printCallStack ? '\nSTACKTRACE:\n$stackLog' : ''}';
|
||||
|
||||
if (exludeLogsFromClasses
|
||||
.any((excludeClass) => className == excludeClass) ||
|
||||
(showOnlyClass != null && className != showOnlyClass)) return [];
|
||||
|
||||
final pattern = RegExp('.{1,800}'); // 800 is the size of each chunk
|
||||
List<String> result = [];
|
||||
|
||||
for (var line in output.split('\n')) {
|
||||
result.addAll(pattern.allMatches(line).map((match) {
|
||||
if (kReleaseMode) {
|
||||
return match.group(0)!;
|
||||
} else {
|
||||
return color!(match.group(0)!);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
String? _getMethodName() {
|
||||
try {
|
||||
final currentStack = StackTrace.current;
|
||||
final formattedStacktrace = _formatStackTrace(currentStack, 3);
|
||||
if (kIsWeb) {
|
||||
final classNameParts = _splitClassNameWords(className);
|
||||
return _findMostMatchedTrace(formattedStacktrace!, classNameParts)
|
||||
.split(' ')
|
||||
.last;
|
||||
} else {
|
||||
final realFirstLine = formattedStacktrace
|
||||
?.firstWhere((line) => line.contains(className), orElse: () => "");
|
||||
|
||||
final methodName = realFirstLine?.replaceAll('$className.', '');
|
||||
return methodName;
|
||||
}
|
||||
} catch (e) {
|
||||
// There's no deliberate function call from our code so we return null;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
List<String> _splitClassNameWords(String className) {
|
||||
return className
|
||||
.split(RegExp(r'(?=[A-Z])'))
|
||||
.map((e) => e.toLowerCase())
|
||||
.toList();
|
||||
}
|
||||
|
||||
/// When the faulty word exists in the begging this method will not be very usefull
|
||||
String _findMostMatchedTrace(
|
||||
List<String> stackTraces, List<String> keyWords) {
|
||||
String match = stackTraces.firstWhere(
|
||||
(trace) => _doesTraceContainsAllKeywords(trace, keyWords),
|
||||
orElse: () => '');
|
||||
if (match.isEmpty) {
|
||||
match = _findMostMatchedTrace(
|
||||
stackTraces, keyWords.sublist(0, keyWords.length - 1));
|
||||
}
|
||||
return match;
|
||||
}
|
||||
|
||||
bool _doesTraceContainsAllKeywords(String stackTrace, List<String> keywords) {
|
||||
final formattedKeywordsAsRegex = RegExp(keywords.join('.*'));
|
||||
return stackTrace.contains(formattedKeywordsAsRegex);
|
||||
}
|
||||
}
|
||||
|
||||
final stackTraceRegex = RegExp(r'#[0-9]+[\s]+(.+) \(([^\s]+)\)');
|
||||
|
||||
List<String>? _formatStackTrace(StackTrace stackTrace, int methodCount) {
|
||||
var lines = stackTrace.toString().split('\n');
|
||||
|
||||
var formatted = <String>[];
|
||||
var count = 0;
|
||||
for (var line in lines) {
|
||||
var match = stackTraceRegex.matchAsPrefix(line);
|
||||
if (match != null) {
|
||||
if (match.group(2)!.startsWith('package:logger')) {
|
||||
continue;
|
||||
}
|
||||
var newLine = ("${match.group(1)}");
|
||||
formatted.add(newLine.replaceAll('<anonymous closure>', '()'));
|
||||
if (++count == methodCount) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
formatted.add(line);
|
||||
}
|
||||
}
|
||||
|
||||
if (formatted.isEmpty) {
|
||||
return null;
|
||||
} else {
|
||||
return formatted;
|
||||
}
|
||||
}
|
||||
|
||||
Logger getLogger(
|
||||
String className, {
|
||||
bool printCallingFunctionName = true,
|
||||
bool printCallstack = false,
|
||||
List<String> exludeLogsFromClasses = const [],
|
||||
String? showOnlyClass,
|
||||
}) {
|
||||
return Logger(
|
||||
printer: SimpleLogPrinter(
|
||||
className,
|
||||
printCallingFunctionName: printCallingFunctionName,
|
||||
printCallStack: printCallstack,
|
||||
showOnlyClass: showOnlyClass,
|
||||
exludeLogsFromClasses: exludeLogsFromClasses,
|
||||
),
|
||||
output: MultiOutput([
|
||||
if (!kReleaseMode) ConsoleOutput(),
|
||||
]),
|
||||
);
|
||||
}
|
||||
537
lib/app/app.router.dart
Normal file
537
lib/app/app.router.dart
Normal file
@ -0,0 +1,537 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
// **************************************************************************
|
||||
// StackedNavigatorGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'package:flutter/material.dart' as _i6;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rfid_app/model/penyewa_model.dart' as _i7;
|
||||
import 'package:rfid_app/ui/views/login_screen/login_screen_view.dart' as _i3;
|
||||
import 'package:rfid_app/ui/views/penyewa_index/penyewa_index_view.dart' as _i5;
|
||||
import 'package:rfid_app/ui/views/penyewa_index/penyewa_log/penyewa_log_view.dart'
|
||||
as _i11;
|
||||
import 'package:rfid_app/ui/views/penyewa_index/pulsa_detail/pulsa_detail_view.dart'
|
||||
as _i13;
|
||||
import 'package:rfid_app/ui/views/penyewa_index/tempat_sewaan/tempat_sewaan_view.dart'
|
||||
as _i12;
|
||||
import 'package:rfid_app/ui/views/retributor_index/log_history_sewaan/log_history_sewaan_view.dart'
|
||||
as _i9;
|
||||
import 'package:rfid_app/ui/views/retributor_index/penyewa_list/penyewa_list_view.dart'
|
||||
as _i10;
|
||||
import 'package:rfid_app/ui/views/retributor_index/retributor_index_view.dart'
|
||||
as _i4;
|
||||
import 'package:rfid_app/ui/views/retributor_index/tempat_sewa_list/tempat_sewa_list_view.dart'
|
||||
as _i8;
|
||||
import 'package:rfid_app/ui/views/splash_screen/splash_screen_view.dart' as _i2;
|
||||
import 'package:stacked/stacked.dart' as _i1;
|
||||
import 'package:stacked_services/stacked_services.dart' as _i14;
|
||||
|
||||
class Routes {
|
||||
static const splashScreenView = '/';
|
||||
|
||||
static const loginScreenView = '/login-screen-view';
|
||||
|
||||
static const retributorIndexView = '/retributor-index-view';
|
||||
|
||||
static const penyewaIndexView = '/penyewa-index-view';
|
||||
|
||||
static const all = <String>{
|
||||
splashScreenView,
|
||||
loginScreenView,
|
||||
retributorIndexView,
|
||||
penyewaIndexView,
|
||||
};
|
||||
}
|
||||
|
||||
class StackedRouter extends _i1.RouterBase {
|
||||
final _routes = <_i1.RouteDef>[
|
||||
_i1.RouteDef(
|
||||
Routes.splashScreenView,
|
||||
page: _i2.SplashScreenView,
|
||||
),
|
||||
_i1.RouteDef(
|
||||
Routes.loginScreenView,
|
||||
page: _i3.LoginScreenView,
|
||||
),
|
||||
_i1.RouteDef(
|
||||
Routes.retributorIndexView,
|
||||
page: _i4.RetributorIndexView,
|
||||
),
|
||||
_i1.RouteDef(
|
||||
Routes.penyewaIndexView,
|
||||
page: _i5.PenyewaIndexView,
|
||||
),
|
||||
];
|
||||
|
||||
final _pagesMap = <Type, _i1.StackedRouteFactory>{
|
||||
_i2.SplashScreenView: (data) {
|
||||
return _i6.MaterialPageRoute<dynamic>(
|
||||
builder: (context) => const _i2.SplashScreenView(),
|
||||
settings: data,
|
||||
);
|
||||
},
|
||||
_i3.LoginScreenView: (data) {
|
||||
return _i6.MaterialPageRoute<dynamic>(
|
||||
builder: (context) => const _i3.LoginScreenView(),
|
||||
settings: data,
|
||||
);
|
||||
},
|
||||
_i4.RetributorIndexView: (data) {
|
||||
return _i6.MaterialPageRoute<dynamic>(
|
||||
builder: (context) => const _i4.RetributorIndexView(),
|
||||
settings: data,
|
||||
);
|
||||
},
|
||||
_i5.PenyewaIndexView: (data) {
|
||||
final args = data.getArgs<PenyewaIndexViewArguments>(nullOk: false);
|
||||
return _i6.MaterialPageRoute<dynamic>(
|
||||
builder: (context) =>
|
||||
_i5.PenyewaIndexView(key: args.key, penyewa: args.penyewa),
|
||||
settings: data,
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
@override
|
||||
List<_i1.RouteDef> get routes => _routes;
|
||||
|
||||
@override
|
||||
Map<Type, _i1.StackedRouteFactory> get pagesMap => _pagesMap;
|
||||
}
|
||||
|
||||
class PenyewaIndexViewArguments {
|
||||
const PenyewaIndexViewArguments({
|
||||
this.key,
|
||||
required this.penyewa,
|
||||
});
|
||||
|
||||
final _i6.Key? key;
|
||||
|
||||
final _i7.DetailPenyewaModel penyewa;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return '{"key": "$key", "penyewa": "$penyewa"}';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(covariant PenyewaIndexViewArguments other) {
|
||||
if (identical(this, other)) return true;
|
||||
return other.key == key && other.penyewa == penyewa;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return key.hashCode ^ penyewa.hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
class RetributorIndexViewRoutes {
|
||||
static const tempatSewaListView = 'tempat-sewa-list-view';
|
||||
|
||||
static const logHistorySewaanView = 'log-history-sewaan-view';
|
||||
|
||||
static const penyewaListView = 'penyewa-list-view';
|
||||
|
||||
static const all = <String>{
|
||||
tempatSewaListView,
|
||||
logHistorySewaanView,
|
||||
penyewaListView,
|
||||
};
|
||||
}
|
||||
|
||||
class RetributorIndexViewRouter extends _i1.RouterBase {
|
||||
final _routes = <_i1.RouteDef>[
|
||||
_i1.RouteDef(
|
||||
RetributorIndexViewRoutes.tempatSewaListView,
|
||||
page: _i8.TempatSewaListView,
|
||||
),
|
||||
_i1.RouteDef(
|
||||
RetributorIndexViewRoutes.logHistorySewaanView,
|
||||
page: _i9.LogHistorySewaanView,
|
||||
),
|
||||
_i1.RouteDef(
|
||||
RetributorIndexViewRoutes.penyewaListView,
|
||||
page: _i10.PenyewaListView,
|
||||
),
|
||||
];
|
||||
|
||||
final _pagesMap = <Type, _i1.StackedRouteFactory>{
|
||||
_i8.TempatSewaListView: (data) {
|
||||
return _i6.MaterialPageRoute<dynamic>(
|
||||
builder: (context) => const _i8.TempatSewaListView(),
|
||||
settings: data,
|
||||
);
|
||||
},
|
||||
_i9.LogHistorySewaanView: (data) {
|
||||
return _i6.MaterialPageRoute<dynamic>(
|
||||
builder: (context) => const _i9.LogHistorySewaanView(),
|
||||
settings: data,
|
||||
);
|
||||
},
|
||||
_i10.PenyewaListView: (data) {
|
||||
return _i6.MaterialPageRoute<dynamic>(
|
||||
builder: (context) => const _i10.PenyewaListView(),
|
||||
settings: data,
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
@override
|
||||
List<_i1.RouteDef> get routes => _routes;
|
||||
|
||||
@override
|
||||
Map<Type, _i1.StackedRouteFactory> get pagesMap => _pagesMap;
|
||||
}
|
||||
|
||||
class PenyewaIndexViewRoutes {
|
||||
static const penyewaLogView = 'penyewa-log-view';
|
||||
|
||||
static const tempatSewaanView = 'tempat-sewaan-view';
|
||||
|
||||
static const pulsaDetailView = 'pulsa-detail-view';
|
||||
|
||||
static const all = <String>{
|
||||
penyewaLogView,
|
||||
tempatSewaanView,
|
||||
pulsaDetailView,
|
||||
};
|
||||
}
|
||||
|
||||
class PenyewaIndexViewRouter extends _i1.RouterBase {
|
||||
final _routes = <_i1.RouteDef>[
|
||||
_i1.RouteDef(
|
||||
PenyewaIndexViewRoutes.penyewaLogView,
|
||||
page: _i11.PenyewaLogView,
|
||||
),
|
||||
_i1.RouteDef(
|
||||
PenyewaIndexViewRoutes.tempatSewaanView,
|
||||
page: _i12.TempatSewaanView,
|
||||
),
|
||||
_i1.RouteDef(
|
||||
PenyewaIndexViewRoutes.pulsaDetailView,
|
||||
page: _i13.PulsaDetailView,
|
||||
),
|
||||
];
|
||||
|
||||
final _pagesMap = <Type, _i1.StackedRouteFactory>{
|
||||
_i11.PenyewaLogView: (data) {
|
||||
return _i6.MaterialPageRoute<dynamic>(
|
||||
builder: (context) => const _i11.PenyewaLogView(),
|
||||
settings: data,
|
||||
);
|
||||
},
|
||||
_i12.TempatSewaanView: (data) {
|
||||
return _i6.MaterialPageRoute<dynamic>(
|
||||
builder: (context) => const _i12.TempatSewaanView(),
|
||||
settings: data,
|
||||
);
|
||||
},
|
||||
_i13.PulsaDetailView: (data) {
|
||||
return _i6.MaterialPageRoute<dynamic>(
|
||||
builder: (context) => const _i13.PulsaDetailView(),
|
||||
settings: data,
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
@override
|
||||
List<_i1.RouteDef> get routes => _routes;
|
||||
|
||||
@override
|
||||
Map<Type, _i1.StackedRouteFactory> get pagesMap => _pagesMap;
|
||||
}
|
||||
|
||||
extension NavigatorStateExtension on _i14.NavigationService {
|
||||
Future<dynamic> navigateToSplashScreenView([
|
||||
int? routerId,
|
||||
bool preventDuplicates = true,
|
||||
Map<String, String>? parameters,
|
||||
Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
|
||||
transition,
|
||||
]) async {
|
||||
return navigateTo<dynamic>(Routes.splashScreenView,
|
||||
id: routerId,
|
||||
preventDuplicates: preventDuplicates,
|
||||
parameters: parameters,
|
||||
transition: transition);
|
||||
}
|
||||
|
||||
Future<dynamic> navigateToLoginScreenView([
|
||||
int? routerId,
|
||||
bool preventDuplicates = true,
|
||||
Map<String, String>? parameters,
|
||||
Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
|
||||
transition,
|
||||
]) async {
|
||||
return navigateTo<dynamic>(Routes.loginScreenView,
|
||||
id: routerId,
|
||||
preventDuplicates: preventDuplicates,
|
||||
parameters: parameters,
|
||||
transition: transition);
|
||||
}
|
||||
|
||||
Future<dynamic> navigateToRetributorIndexView([
|
||||
int? routerId,
|
||||
bool preventDuplicates = true,
|
||||
Map<String, String>? parameters,
|
||||
Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
|
||||
transition,
|
||||
]) async {
|
||||
return navigateTo<dynamic>(Routes.retributorIndexView,
|
||||
id: routerId,
|
||||
preventDuplicates: preventDuplicates,
|
||||
parameters: parameters,
|
||||
transition: transition);
|
||||
}
|
||||
|
||||
Future<dynamic> navigateToPenyewaIndexView({
|
||||
_i6.Key? key,
|
||||
required _i7.DetailPenyewaModel penyewa,
|
||||
int? routerId,
|
||||
bool preventDuplicates = true,
|
||||
Map<String, String>? parameters,
|
||||
Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
|
||||
transition,
|
||||
}) async {
|
||||
return navigateTo<dynamic>(Routes.penyewaIndexView,
|
||||
arguments: PenyewaIndexViewArguments(key: key, penyewa: penyewa),
|
||||
id: routerId,
|
||||
preventDuplicates: preventDuplicates,
|
||||
parameters: parameters,
|
||||
transition: transition);
|
||||
}
|
||||
|
||||
Future<dynamic>
|
||||
navigateToNestedTempatSewaListViewInRetributorIndexViewRouter([
|
||||
int? routerId,
|
||||
bool preventDuplicates = true,
|
||||
Map<String, String>? parameters,
|
||||
Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
|
||||
transition,
|
||||
]) async {
|
||||
return navigateTo<dynamic>(RetributorIndexViewRoutes.tempatSewaListView,
|
||||
id: routerId,
|
||||
preventDuplicates: preventDuplicates,
|
||||
parameters: parameters,
|
||||
transition: transition);
|
||||
}
|
||||
|
||||
Future<dynamic>
|
||||
navigateToNestedLogHistorySewaanViewInRetributorIndexViewRouter([
|
||||
int? routerId,
|
||||
bool preventDuplicates = true,
|
||||
Map<String, String>? parameters,
|
||||
Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
|
||||
transition,
|
||||
]) async {
|
||||
return navigateTo<dynamic>(RetributorIndexViewRoutes.logHistorySewaanView,
|
||||
id: routerId,
|
||||
preventDuplicates: preventDuplicates,
|
||||
parameters: parameters,
|
||||
transition: transition);
|
||||
}
|
||||
|
||||
Future<dynamic> navigateToNestedPenyewaListViewInRetributorIndexViewRouter([
|
||||
int? routerId,
|
||||
bool preventDuplicates = true,
|
||||
Map<String, String>? parameters,
|
||||
Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
|
||||
transition,
|
||||
]) async {
|
||||
return navigateTo<dynamic>(RetributorIndexViewRoutes.penyewaListView,
|
||||
id: routerId,
|
||||
preventDuplicates: preventDuplicates,
|
||||
parameters: parameters,
|
||||
transition: transition);
|
||||
}
|
||||
|
||||
Future<dynamic> navigateToNestedPenyewaLogViewInPenyewaIndexViewRouter([
|
||||
int? routerId,
|
||||
bool preventDuplicates = true,
|
||||
Map<String, String>? parameters,
|
||||
Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
|
||||
transition,
|
||||
]) async {
|
||||
return navigateTo<dynamic>(PenyewaIndexViewRoutes.penyewaLogView,
|
||||
id: routerId,
|
||||
preventDuplicates: preventDuplicates,
|
||||
parameters: parameters,
|
||||
transition: transition);
|
||||
}
|
||||
|
||||
Future<dynamic> navigateToNestedTempatSewaanViewInPenyewaIndexViewRouter([
|
||||
int? routerId,
|
||||
bool preventDuplicates = true,
|
||||
Map<String, String>? parameters,
|
||||
Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
|
||||
transition,
|
||||
]) async {
|
||||
return navigateTo<dynamic>(PenyewaIndexViewRoutes.tempatSewaanView,
|
||||
id: routerId,
|
||||
preventDuplicates: preventDuplicates,
|
||||
parameters: parameters,
|
||||
transition: transition);
|
||||
}
|
||||
|
||||
Future<dynamic> navigateToNestedPulsaDetailViewInPenyewaIndexViewRouter([
|
||||
int? routerId,
|
||||
bool preventDuplicates = true,
|
||||
Map<String, String>? parameters,
|
||||
Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
|
||||
transition,
|
||||
]) async {
|
||||
return navigateTo<dynamic>(PenyewaIndexViewRoutes.pulsaDetailView,
|
||||
id: routerId,
|
||||
preventDuplicates: preventDuplicates,
|
||||
parameters: parameters,
|
||||
transition: transition);
|
||||
}
|
||||
|
||||
Future<dynamic> replaceWithSplashScreenView([
|
||||
int? routerId,
|
||||
bool preventDuplicates = true,
|
||||
Map<String, String>? parameters,
|
||||
Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
|
||||
transition,
|
||||
]) async {
|
||||
return replaceWith<dynamic>(Routes.splashScreenView,
|
||||
id: routerId,
|
||||
preventDuplicates: preventDuplicates,
|
||||
parameters: parameters,
|
||||
transition: transition);
|
||||
}
|
||||
|
||||
Future<dynamic> replaceWithLoginScreenView([
|
||||
int? routerId,
|
||||
bool preventDuplicates = true,
|
||||
Map<String, String>? parameters,
|
||||
Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
|
||||
transition,
|
||||
]) async {
|
||||
return replaceWith<dynamic>(Routes.loginScreenView,
|
||||
id: routerId,
|
||||
preventDuplicates: preventDuplicates,
|
||||
parameters: parameters,
|
||||
transition: transition);
|
||||
}
|
||||
|
||||
Future<dynamic> replaceWithRetributorIndexView([
|
||||
int? routerId,
|
||||
bool preventDuplicates = true,
|
||||
Map<String, String>? parameters,
|
||||
Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
|
||||
transition,
|
||||
]) async {
|
||||
return replaceWith<dynamic>(Routes.retributorIndexView,
|
||||
id: routerId,
|
||||
preventDuplicates: preventDuplicates,
|
||||
parameters: parameters,
|
||||
transition: transition);
|
||||
}
|
||||
|
||||
Future<dynamic> replaceWithPenyewaIndexView({
|
||||
_i6.Key? key,
|
||||
required _i7.DetailPenyewaModel penyewa,
|
||||
int? routerId,
|
||||
bool preventDuplicates = true,
|
||||
Map<String, String>? parameters,
|
||||
Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
|
||||
transition,
|
||||
}) async {
|
||||
return replaceWith<dynamic>(Routes.penyewaIndexView,
|
||||
arguments: PenyewaIndexViewArguments(key: key, penyewa: penyewa),
|
||||
id: routerId,
|
||||
preventDuplicates: preventDuplicates,
|
||||
parameters: parameters,
|
||||
transition: transition);
|
||||
}
|
||||
|
||||
Future<dynamic>
|
||||
replaceWithNestedTempatSewaListViewInRetributorIndexViewRouter([
|
||||
int? routerId,
|
||||
bool preventDuplicates = true,
|
||||
Map<String, String>? parameters,
|
||||
Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
|
||||
transition,
|
||||
]) async {
|
||||
return replaceWith<dynamic>(RetributorIndexViewRoutes.tempatSewaListView,
|
||||
id: routerId,
|
||||
preventDuplicates: preventDuplicates,
|
||||
parameters: parameters,
|
||||
transition: transition);
|
||||
}
|
||||
|
||||
Future<dynamic>
|
||||
replaceWithNestedLogHistorySewaanViewInRetributorIndexViewRouter([
|
||||
int? routerId,
|
||||
bool preventDuplicates = true,
|
||||
Map<String, String>? parameters,
|
||||
Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
|
||||
transition,
|
||||
]) async {
|
||||
return replaceWith<dynamic>(RetributorIndexViewRoutes.logHistorySewaanView,
|
||||
id: routerId,
|
||||
preventDuplicates: preventDuplicates,
|
||||
parameters: parameters,
|
||||
transition: transition);
|
||||
}
|
||||
|
||||
Future<dynamic> replaceWithNestedPenyewaListViewInRetributorIndexViewRouter([
|
||||
int? routerId,
|
||||
bool preventDuplicates = true,
|
||||
Map<String, String>? parameters,
|
||||
Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
|
||||
transition,
|
||||
]) async {
|
||||
return replaceWith<dynamic>(RetributorIndexViewRoutes.penyewaListView,
|
||||
id: routerId,
|
||||
preventDuplicates: preventDuplicates,
|
||||
parameters: parameters,
|
||||
transition: transition);
|
||||
}
|
||||
|
||||
Future<dynamic> replaceWithNestedPenyewaLogViewInPenyewaIndexViewRouter([
|
||||
int? routerId,
|
||||
bool preventDuplicates = true,
|
||||
Map<String, String>? parameters,
|
||||
Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
|
||||
transition,
|
||||
]) async {
|
||||
return replaceWith<dynamic>(PenyewaIndexViewRoutes.penyewaLogView,
|
||||
id: routerId,
|
||||
preventDuplicates: preventDuplicates,
|
||||
parameters: parameters,
|
||||
transition: transition);
|
||||
}
|
||||
|
||||
Future<dynamic> replaceWithNestedTempatSewaanViewInPenyewaIndexViewRouter([
|
||||
int? routerId,
|
||||
bool preventDuplicates = true,
|
||||
Map<String, String>? parameters,
|
||||
Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
|
||||
transition,
|
||||
]) async {
|
||||
return replaceWith<dynamic>(PenyewaIndexViewRoutes.tempatSewaanView,
|
||||
id: routerId,
|
||||
preventDuplicates: preventDuplicates,
|
||||
parameters: parameters,
|
||||
transition: transition);
|
||||
}
|
||||
|
||||
Future<dynamic> replaceWithNestedPulsaDetailViewInPenyewaIndexViewRouter([
|
||||
int? routerId,
|
||||
bool preventDuplicates = true,
|
||||
Map<String, String>? parameters,
|
||||
Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
|
||||
transition,
|
||||
]) async {
|
||||
return replaceWith<dynamic>(PenyewaIndexViewRoutes.pulsaDetailView,
|
||||
id: routerId,
|
||||
preventDuplicates: preventDuplicates,
|
||||
parameters: parameters,
|
||||
transition: transition);
|
||||
}
|
||||
}
|
||||
26
lib/app/core/custom_base_view_model.dart
Executable file
26
lib/app/core/custom_base_view_model.dart
Executable file
@ -0,0 +1,26 @@
|
||||
// import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
|
||||
import '../../services/http_services.dart';
|
||||
import '../../services/my_easyloading.dart';
|
||||
import '../../services/my_socket_io_client.dart';
|
||||
import '../../services/other_function.dart';
|
||||
import '../../services/shared_prefs.dart';
|
||||
import '../app.locator.dart';
|
||||
|
||||
class CustomBaseViewModel extends BaseViewModel {
|
||||
final dialogService = locator<DialogService>();
|
||||
final navigationService = locator<NavigationService>();
|
||||
final bottomSheetService = locator<BottomSheetService>();
|
||||
final snackbarService = locator<SnackbarService>();
|
||||
final mySharedPrefs = locator<MySharedPrefs>();
|
||||
final otherFunction = locator<OtherFunction>();
|
||||
final socketIoClient = locator<MySocketIoClient>();
|
||||
final httpService = locator<MyHttpServices>();
|
||||
final easyLoading = locator<MyEasyLoading>();
|
||||
|
||||
void back() {
|
||||
navigationService.back();
|
||||
}
|
||||
}
|
||||
30
lib/app/themes/app_colors.dart
Executable file
30
lib/app/themes/app_colors.dart
Executable file
@ -0,0 +1,30 @@
|
||||
import 'dart:ui';
|
||||
|
||||
const Color mainColor = Color.fromARGB(255, 6, 238, 48);
|
||||
const Color secondaryColor = Color(0xFFB72025);
|
||||
const Color dangerColor = Color(0xFFFF4B68);
|
||||
const Color warningColor = Color(0xFFFBFFA3);
|
||||
const Color lightColor = Color(0xFFF4FAFE);
|
||||
const Color lightGreyColor = Color(0xFFFCFCFC);
|
||||
const Color stockColor = Color(0xFFEEF3F6);
|
||||
|
||||
const Color backgroundColor = Color(0xFFE5E5E5);
|
||||
const Color backgroundColor3 = Color(0xFFF6F7F8);
|
||||
|
||||
const Color orangeColor = Color.fromARGB(255, 250, 145, 84);
|
||||
const Color blueColor = Color(0xFF026AA2);
|
||||
const Color greenColor = Color(0xFF2ABB52);
|
||||
const Color redColor = Color(0xFFED1717);
|
||||
const Color greyBlueColor = Color(0xFF363F72);
|
||||
|
||||
const Color fontColor = Color(0xFF101828);
|
||||
const Color fontSecondaryColor = Color(0xFF667085);
|
||||
const Color fontParagraphColor = Color(0xFFB2B2B2);
|
||||
const Color fontGrey = Color(0xFF1C1C1C);
|
||||
|
||||
const Color mainGrey = Color(0xFF8991A4);
|
||||
const Color secondaryGrey = Color(0xFFD0D5DD);
|
||||
const Color thirdGrey = Color(0xFFF2F4F7);
|
||||
const Color fourthGrey = Color(0xFF5C5C5C);
|
||||
const Color fifthGrey = Color(0xFFEBEBEB);
|
||||
const Color sixthGrey = Color(0xFF151515);
|
||||
44
lib/app/themes/app_text.dart
Normal file
44
lib/app/themes/app_text.dart
Normal file
@ -0,0 +1,44 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'app_colors.dart';
|
||||
|
||||
const regularTextStyle = TextStyle(
|
||||
fontFamily: 'Arial',
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: fontColor);
|
||||
|
||||
const italicTextStyle = TextStyle(
|
||||
fontFamily: 'Arial',
|
||||
fontSize: 14,
|
||||
color: fontColor,
|
||||
fontStyle: FontStyle.italic,
|
||||
);
|
||||
|
||||
const mediumTextStyle = TextStyle(
|
||||
fontFamily: 'Arial',
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: fontColor,
|
||||
);
|
||||
|
||||
const semiBoldTextStyle = TextStyle(
|
||||
fontFamily: 'Arial',
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: fontColor,
|
||||
);
|
||||
|
||||
const boldTextStyle = TextStyle(
|
||||
fontFamily: 'Arial',
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: fontColor,
|
||||
);
|
||||
|
||||
const extraBoldTextStyle = TextStyle(
|
||||
fontFamily: 'Arial',
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: fontColor,
|
||||
);
|
||||
124
lib/app/themes/app_theme.dart
Executable file
124
lib/app/themes/app_theme.dart
Executable file
@ -0,0 +1,124 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'app_colors.dart';
|
||||
import 'app_text.dart';
|
||||
|
||||
ThemeData appTheme = ThemeData(
|
||||
useMaterial3: true,
|
||||
primaryColor: mainColor,
|
||||
scaffoldBackgroundColor: Colors.white,
|
||||
canvasColor: Colors.white,
|
||||
fontFamily: 'Poppins',
|
||||
appBarTheme: AppBarTheme(
|
||||
elevation: 0,
|
||||
titleTextStyle: boldTextStyle.copyWith(fontSize: 16, color: fontGrey),
|
||||
centerTitle: true,
|
||||
),
|
||||
textTheme: TextTheme(
|
||||
displayLarge: regularTextStyle.copyWith(fontSize: 32),
|
||||
displayMedium: regularTextStyle.copyWith(fontSize: 20),
|
||||
displaySmall: regularTextStyle.copyWith(fontSize: 18),
|
||||
),
|
||||
elevatedButtonTheme: ElevatedButtonThemeData(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: mainColor,
|
||||
foregroundColor: Colors.white,
|
||||
disabledBackgroundColor: mainColor.withOpacity(.3),
|
||||
minimumSize: const Size(double.maxFinite, 58),
|
||||
textStyle: boldTextStyle,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
shadowColor: Colors.transparent,
|
||||
elevation: 0,
|
||||
),
|
||||
),
|
||||
outlinedButtonTheme: OutlinedButtonThemeData(
|
||||
style: OutlinedButton.styleFrom(
|
||||
textStyle: boldTextStyle,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
side: const BorderSide(
|
||||
color: mainColor,
|
||||
width: 1,
|
||||
),
|
||||
foregroundColor: mainColor,
|
||||
// disabledForegroundColor: mainColor.withOpacity(.3),
|
||||
minimumSize: const Size(double.maxFinite, 58),
|
||||
),
|
||||
),
|
||||
textButtonTheme: TextButtonThemeData(
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: mainColor,
|
||||
disabledForegroundColor: mainColor.withOpacity(.3),
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
textStyle: semiBoldTextStyle,
|
||||
shadowColor: Colors.transparent,
|
||||
),
|
||||
),
|
||||
iconTheme: const IconThemeData(
|
||||
color: mainColor,
|
||||
),
|
||||
listTileTheme: ListTileThemeData(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
checkboxTheme: CheckboxThemeData(
|
||||
fillColor: MaterialStateProperty.all(mainColor),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
side: const BorderSide(
|
||||
color: secondaryGrey,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
radioTheme: RadioThemeData(
|
||||
fillColor: MaterialStateProperty.all(mainColor),
|
||||
),
|
||||
tabBarTheme: TabBarTheme(
|
||||
labelColor: mainColor,
|
||||
unselectedLabelColor: secondaryGrey,
|
||||
labelStyle: boldTextStyle.copyWith(fontSize: 16),
|
||||
unselectedLabelStyle: mediumTextStyle.copyWith(fontSize: 16),
|
||||
),
|
||||
chipTheme: ChipThemeData(
|
||||
backgroundColor: Colors.white,
|
||||
disabledColor: Colors.white,
|
||||
selectedColor: Colors.white,
|
||||
secondarySelectedColor: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||
side: const BorderSide(color: fifthGrey),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
labelStyle: regularTextStyle.copyWith(fontSize: 12, color: fontGrey),
|
||||
secondaryLabelStyle:
|
||||
regularTextStyle.copyWith(fontSize: 12, color: secondaryColor),
|
||||
deleteIconColor: fontGrey,
|
||||
showCheckmark: false,
|
||||
),
|
||||
popupMenuTheme: PopupMenuThemeData(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
side: const BorderSide(
|
||||
color: fifthGrey,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
colorScheme: const ColorScheme.light(
|
||||
primary: mainColor,
|
||||
secondary: secondaryColor,
|
||||
onPrimary: Colors.white,
|
||||
onSecondary: Colors.white,
|
||||
error: dangerColor,
|
||||
onError: dangerColor,
|
||||
background: backgroundColor,
|
||||
).copyWith(background: Colors.white),
|
||||
);
|
||||
53
lib/main.dart
Normal file
53
lib/main.dart
Normal file
@ -0,0 +1,53 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:intl/date_symbol_data_local.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
|
||||
import 'app/app.bottomsheets.dart';
|
||||
import 'app/app.dialogs.dart';
|
||||
import 'app/app.locator.dart';
|
||||
import 'app/app.router.dart';
|
||||
import 'app/themes/app_theme.dart';
|
||||
|
||||
Future main() async {
|
||||
await initializeDateFormatting('id_ID');
|
||||
await dotenv.load(fileName: ".env");
|
||||
await setupAllLocator();
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
|
||||
// This widget is the root of your application.
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: 'Sistem Retribusi Pasar Enerekang',
|
||||
theme: appTheme,
|
||||
debugShowCheckedModeBanner: false,
|
||||
navigatorKey: StackedService.navigatorKey,
|
||||
onGenerateRoute: StackedRouter().onGenerateRoute,
|
||||
builder: EasyLoading.init(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> setupAllLocator() async {
|
||||
await setupLocator();
|
||||
setupDialogUi();
|
||||
setupBottomSheetUi();
|
||||
// setupSnackbarUi();
|
||||
}
|
||||
|
||||
class MyHttpOverrides extends HttpOverrides {
|
||||
@override
|
||||
HttpClient createHttpClient(SecurityContext? context) {
|
||||
return super.createHttpClient(context)
|
||||
..badCertificateCallback =
|
||||
(X509Certificate cert, String host, int port) => true;
|
||||
}
|
||||
}
|
||||
21
lib/model/my_response_model.dart
Normal file
21
lib/model/my_response_model.dart
Normal file
@ -0,0 +1,21 @@
|
||||
class MyResponseModel {
|
||||
String? message;
|
||||
dynamic data;
|
||||
bool? status;
|
||||
|
||||
MyResponseModel({this.message, this.data, this.status});
|
||||
|
||||
MyResponseModel.fromJson(Map<String, dynamic> json) {
|
||||
message = json['message'];
|
||||
data = json['data'];
|
||||
status = json['status'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['message'] = message;
|
||||
data['data'] = this.data;
|
||||
data['status'] = status;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
77
lib/model/penyewa_model.dart
Normal file
77
lib/model/penyewa_model.dart
Normal file
@ -0,0 +1,77 @@
|
||||
class PenyewaModel {
|
||||
String? nik;
|
||||
String? nama;
|
||||
String? rfid;
|
||||
int? saldo;
|
||||
int? idTempatSerwa;
|
||||
String? namaTempatSewa;
|
||||
int? hargaSewa;
|
||||
String? date;
|
||||
String? jenis;
|
||||
String? ket;
|
||||
|
||||
PenyewaModel(
|
||||
{this.nik,
|
||||
this.nama,
|
||||
this.rfid,
|
||||
this.saldo,
|
||||
this.idTempatSerwa,
|
||||
this.namaTempatSewa,
|
||||
this.hargaSewa,
|
||||
this.date,
|
||||
this.jenis,
|
||||
this.ket});
|
||||
|
||||
PenyewaModel.fromJson(Map<String, dynamic> json) {
|
||||
nik = json['nik'];
|
||||
nama = json['nama'];
|
||||
rfid = json['rfid'];
|
||||
saldo = json['saldo'];
|
||||
idTempatSerwa = json['id_tempat_serwa'];
|
||||
namaTempatSewa = json['nama_tempat_sewa'];
|
||||
hargaSewa = json['harga_sewa'];
|
||||
date = json['date'];
|
||||
jenis = json['jenis'];
|
||||
ket = json['ket'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['nik'] = nik;
|
||||
data['nama'] = nama;
|
||||
data['rfid'] = rfid;
|
||||
data['saldo'] = saldo;
|
||||
data['id_tempat_serwa'] = idTempatSerwa;
|
||||
data['nama_tempat_sewa'] = namaTempatSewa;
|
||||
data['harga_sewa'] = hargaSewa;
|
||||
data['date'] = date;
|
||||
data['jenis'] = jenis;
|
||||
data['ket'] = ket;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class DetailPenyewaModel {
|
||||
String? nik;
|
||||
String? nama;
|
||||
String? rfid;
|
||||
int? saldo;
|
||||
|
||||
DetailPenyewaModel({this.nik, this.nama, this.rfid, this.saldo});
|
||||
|
||||
DetailPenyewaModel.fromJson(Map<String, dynamic> json) {
|
||||
nik = json['nik'];
|
||||
nama = json['nama'];
|
||||
rfid = json['rfid'];
|
||||
saldo = json['saldo'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['nik'] = nik;
|
||||
data['nama'] = nama;
|
||||
data['rfid'] = rfid;
|
||||
data['saldo'] = saldo;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
95
lib/services/http_services.dart
Normal file
95
lib/services/http_services.dart
Normal file
@ -0,0 +1,95 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:rfid_app/app/app.locator.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
|
||||
import '../app/app.logger.dart';
|
||||
|
||||
class MyHttpServices {
|
||||
final _log = getLogger('MyHttpServices');
|
||||
final _snackbarService = locator<SnackbarService>();
|
||||
final _options = BaseOptions(
|
||||
baseUrl: dotenv.env['api_url']!,
|
||||
connectTimeout: const Duration(seconds: 120),
|
||||
receiveTimeout: const Duration(seconds: 120),
|
||||
);
|
||||
|
||||
late Dio _dio;
|
||||
|
||||
MyHttpServices() {
|
||||
_dio = Dio(_options);
|
||||
}
|
||||
|
||||
Future<Response> get(String path) async {
|
||||
try {
|
||||
return await _dio.get(path);
|
||||
} on DioException catch (e) {
|
||||
String response = e.response != null
|
||||
? e.response!.data['message'].toString()
|
||||
: e.toString();
|
||||
_log.e('ini errornya: $response');
|
||||
_snackbarService.showSnackbar(
|
||||
message: response,
|
||||
title: 'Error',
|
||||
duration: const Duration(milliseconds: 1000),
|
||||
);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future<Response> postWithFormData(String path, FormData formData) async {
|
||||
try {
|
||||
return await _dio.post(path, data: formData);
|
||||
} on DioException catch (e) {
|
||||
String response = e.response != null
|
||||
? e.response!.data['message'].toString()
|
||||
: e.toString();
|
||||
_log.e('ini errornya: $response');
|
||||
_snackbarService.showSnackbar(
|
||||
message: response,
|
||||
title: 'Error',
|
||||
duration: const Duration(milliseconds: 1000),
|
||||
);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
// putWithFormData
|
||||
Future<Response> putWithFormData(String path, FormData formData) async {
|
||||
try {
|
||||
return await _dio.put(path, data: formData);
|
||||
} on DioException catch (e) {
|
||||
String response = e.response != null
|
||||
? e.response!.data['message'].toString()
|
||||
: e.toString();
|
||||
_log.e('ini errornya: $response');
|
||||
_snackbarService.showSnackbar(
|
||||
message: response,
|
||||
title: 'Error',
|
||||
duration: const Duration(milliseconds: 1000),
|
||||
);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
// // delete
|
||||
// Future<Response> delete(String path, FormData data) async {
|
||||
// try {
|
||||
// // log.i('path: $path');
|
||||
// return await _dio.delete(
|
||||
// path,
|
||||
// data: data,
|
||||
// // encoding: Encoding.getByName('utf-8'),
|
||||
// options: Options(
|
||||
// headers: {
|
||||
// 'Content-Type': 'application/x-www-form-urlencoded',
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
// } on DioError catch (e) {
|
||||
// log.e(e.message);
|
||||
// log.e(e.response);
|
||||
// rethrow;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
39
lib/services/my_easyloading.dart
Normal file
39
lib/services/my_easyloading.dart
Normal file
@ -0,0 +1,39 @@
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
|
||||
class MyEasyLoading {
|
||||
showLoading() {
|
||||
EasyLoading.show(
|
||||
status: 'loading...',
|
||||
maskType: EasyLoadingMaskType.black,
|
||||
dismissOnTap: false,
|
||||
);
|
||||
}
|
||||
|
||||
dismiss() {
|
||||
EasyLoading.dismiss();
|
||||
}
|
||||
|
||||
customLoading(String message) {
|
||||
EasyLoading.show(
|
||||
status: message,
|
||||
maskType: EasyLoadingMaskType.black,
|
||||
dismissOnTap: false,
|
||||
);
|
||||
}
|
||||
|
||||
showSuccess(String message) {
|
||||
EasyLoading.showSuccess(message);
|
||||
}
|
||||
|
||||
showError(String message) {
|
||||
EasyLoading.showError(message);
|
||||
}
|
||||
|
||||
showInfo(String message) {
|
||||
EasyLoading.showInfo(message);
|
||||
}
|
||||
|
||||
showProgress(double progress, String status) {
|
||||
EasyLoading.showProgress(progress, status: status);
|
||||
}
|
||||
}
|
||||
48
lib/services/my_socket_io_client.dart
Normal file
48
lib/services/my_socket_io_client.dart
Normal file
@ -0,0 +1,48 @@
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:socket_io_client/socket_io_client.dart';
|
||||
|
||||
import '../app/app.logger.dart';
|
||||
|
||||
class MySocketIoClient {
|
||||
final log = getLogger('MySocketIoClient');
|
||||
final String _url = dotenv.env['url']!;
|
||||
static final MySocketIoClient _instance = MySocketIoClient._internal();
|
||||
factory MySocketIoClient() => _instance;
|
||||
MySocketIoClient._internal();
|
||||
|
||||
late Socket _socket;
|
||||
Socket get socket => _socket;
|
||||
|
||||
Future<void> init() async {
|
||||
try {
|
||||
_socket = io(_url, <String, dynamic>{
|
||||
'transports': ['websocket'],
|
||||
'autoConnect': false,
|
||||
});
|
||||
_socket.connect();
|
||||
log.i('socket connected');
|
||||
} catch (e) {
|
||||
log.e('error : $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> emit(String event, dynamic data) async {
|
||||
_socket.emit(event, data);
|
||||
}
|
||||
|
||||
Future<void> on(String event, Function(dynamic) callback) async {
|
||||
_socket.on(event, callback);
|
||||
}
|
||||
|
||||
Future<void> off(String event) async {
|
||||
_socket.off(event);
|
||||
}
|
||||
|
||||
Future<void> disconnect() async {
|
||||
_socket.disconnect();
|
||||
}
|
||||
|
||||
Future<void> connect() async {
|
||||
_socket.connect();
|
||||
}
|
||||
}
|
||||
137
lib/services/other_function.dart
Normal file
137
lib/services/other_function.dart
Normal file
@ -0,0 +1,137 @@
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class OtherFunction {
|
||||
int umur(String tanggalLahir) {
|
||||
// change tanggalLahir to DateTime
|
||||
DateTime date = DateTime.parse(tanggalLahir);
|
||||
// get current date
|
||||
DateTime now = DateTime.now();
|
||||
// get difference in year
|
||||
int year = now.year - date.year;
|
||||
return year;
|
||||
}
|
||||
|
||||
String commaFormat(int number) {
|
||||
final formatter = NumberFormat('#,###');
|
||||
return formatter.format(number);
|
||||
}
|
||||
|
||||
String changeMonth(String month) {
|
||||
switch (month) {
|
||||
case 'Januari':
|
||||
return '01';
|
||||
case 'Februari':
|
||||
return '02';
|
||||
case 'Maret':
|
||||
return '03';
|
||||
case 'April':
|
||||
return '04';
|
||||
case 'Mei':
|
||||
return '05';
|
||||
case 'Juni':
|
||||
return '06';
|
||||
case 'Juli':
|
||||
return '07';
|
||||
case 'Agustus':
|
||||
return '08';
|
||||
case 'September':
|
||||
return '09';
|
||||
case 'Oktober':
|
||||
return '10';
|
||||
case 'November':
|
||||
return '11';
|
||||
case 'Desember':
|
||||
return '12';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
String changeMonthYear(String s) {
|
||||
// get the last 2 digits
|
||||
String month = s.substring(s.length - 2);
|
||||
// get the first 4 digits
|
||||
String year = s.substring(0, 4);
|
||||
// return the month and year
|
||||
switch (month) {
|
||||
case '01':
|
||||
return 'Januari $year';
|
||||
case '02':
|
||||
return 'Februari $year';
|
||||
case '03':
|
||||
return 'Maret $year';
|
||||
case '04':
|
||||
return 'April $year';
|
||||
case '05':
|
||||
return 'Mei $year';
|
||||
case '06':
|
||||
return 'Juni $year';
|
||||
case '07':
|
||||
return 'Juli $year';
|
||||
case '08':
|
||||
return 'Agustus $year';
|
||||
case '09':
|
||||
return 'September $year';
|
||||
case '10':
|
||||
return 'Oktober $year';
|
||||
case '11':
|
||||
return 'November $year';
|
||||
case '12':
|
||||
return 'Desember $year';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
String getDayOfWeek(String date) {
|
||||
DateTime dateTime = DateTime.parse(date);
|
||||
List<String> daysOfWeek = [
|
||||
'Senin',
|
||||
'Selasa',
|
||||
'Rabu',
|
||||
'Kamis',
|
||||
'Jumat',
|
||||
'Sabtu',
|
||||
'Minggu'
|
||||
];
|
||||
return daysOfWeek[dateTime.weekday - 1];
|
||||
}
|
||||
|
||||
String formatDateString(String dateString) {
|
||||
// Remove the "T" and replace it with " | "
|
||||
String formattedString = dateString.replaceAll('T', '\n');
|
||||
|
||||
// Remove the ".000Z"
|
||||
formattedString = formattedString.replaceAll('.000Z', '');
|
||||
|
||||
// Parse the input string to DateTime object
|
||||
DateTime dateTime = DateTime.parse(dateString);
|
||||
|
||||
// Get the day of the week in Indonesian
|
||||
String dayOfWeek = DateFormat.EEEE('id_ID').format(dateTime);
|
||||
|
||||
// Add the day of the week to the formatted string
|
||||
formattedString = '$formattedString\n$dayOfWeek';
|
||||
|
||||
return formattedString;
|
||||
}
|
||||
|
||||
String formatDateString2(String dateString) {
|
||||
// Remove the "T" and replace it with " | "
|
||||
String formattedString = dateString.replaceAll('T', ' | ');
|
||||
|
||||
// Remove the ".000Z"
|
||||
formattedString = formattedString.replaceAll('.000Z', ' | ');
|
||||
|
||||
// Parse the input string to DateTime object
|
||||
DateTime dateTime = DateTime.parse(dateString);
|
||||
|
||||
// Get the day of the week in Indonesian
|
||||
String dayOfWeek = DateFormat.EEEE('id_ID').format(dateTime);
|
||||
|
||||
// Add the day of the week to the formatted string
|
||||
formattedString = '$formattedString | $dayOfWeek';
|
||||
|
||||
return formattedString;
|
||||
}
|
||||
}
|
||||
25
lib/services/shared_prefs.dart
Normal file
25
lib/services/shared_prefs.dart
Normal file
@ -0,0 +1,25 @@
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class MySharedPrefs {
|
||||
final Future<SharedPreferences> prefs = SharedPreferences.getInstance();
|
||||
|
||||
Future<String?> getString(String key) async {
|
||||
final SharedPreferences prefs = await this.prefs;
|
||||
return prefs.getString(key);
|
||||
}
|
||||
|
||||
Future<bool> setString(String key, String value) async {
|
||||
final SharedPreferences prefs = await this.prefs;
|
||||
return prefs.setString(key, value);
|
||||
}
|
||||
|
||||
Future<bool> removeString(String key) async {
|
||||
final SharedPreferences prefs = await this.prefs;
|
||||
return prefs.remove(key);
|
||||
}
|
||||
|
||||
Future<bool> clear() async {
|
||||
final SharedPreferences prefs = await this.prefs;
|
||||
return prefs.clear();
|
||||
}
|
||||
}
|
||||
111
lib/ui/views/login_screen/login_screen_view.dart
Normal file
111
lib/ui/views/login_screen/login_screen_view.dart
Normal file
@ -0,0 +1,111 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:validatorless/validatorless.dart';
|
||||
|
||||
import '../../../app/themes/app_text.dart';
|
||||
import '../../widgets/my_button.dart';
|
||||
import '../../widgets/my_textformfield.dart';
|
||||
import './login_screen_view_model.dart';
|
||||
|
||||
class LoginScreenView extends StatelessWidget {
|
||||
const LoginScreenView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<LoginScreenViewModel>.reactive(
|
||||
viewModelBuilder: () => LoginScreenViewModel(),
|
||||
onViewModelReady: (LoginScreenViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
LoginScreenViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Scaffold(
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 20),
|
||||
child: SingleChildScrollView(
|
||||
child: Form(
|
||||
key: model.formKey,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height * 0.2,
|
||||
),
|
||||
// show the logo.png
|
||||
const Center(
|
||||
child: Image(
|
||||
image: AssetImage("assets/logo.png"),
|
||||
width: 150,
|
||||
height: 150,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
"SILAHKAN LOGIN",
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
MyTextFormField(
|
||||
hintText: "Username",
|
||||
prefixIcon: const Icon(Icons.person),
|
||||
controller: model.usernameController,
|
||||
validator:
|
||||
Validatorless.required("Username tidak boleh kosong"),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
MyTextFormField(
|
||||
hintText: "Password",
|
||||
prefixIcon: const Icon(Icons.lock),
|
||||
controller: model.passwordController,
|
||||
obscureText: true,
|
||||
validator:
|
||||
Validatorless.required("Password tidak boleh kosong"),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
SizedBox(
|
||||
width: MediaQuery.of(context).size.width * 0.5,
|
||||
child: MyButton(
|
||||
text: "LOGIN",
|
||||
onPressed: () {
|
||||
if (model.formKey.currentState!.validate()) {
|
||||
model.login();
|
||||
// model.log.i("Login Success");
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
// TextButton(
|
||||
// onPressed: () {
|
||||
// model.navigationService
|
||||
// .navigateTo(Routes.retributorIndexView);
|
||||
// },
|
||||
// child: const Text(
|
||||
// "Kembali ke beranda",
|
||||
// style: TextStyle(
|
||||
// color: mainColor,
|
||||
// ),
|
||||
// ),
|
||||
// )
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
61
lib/ui/views/login_screen/login_screen_view_model.dart
Normal file
61
lib/ui/views/login_screen/login_screen_view_model.dart
Normal file
@ -0,0 +1,61 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../app/app.logger.dart';
|
||||
import '../../../app/app.router.dart';
|
||||
import '../../../app/core/custom_base_view_model.dart';
|
||||
import '../../../model/my_response_model.dart';
|
||||
import '../../../model/penyewa_model.dart';
|
||||
|
||||
class LoginScreenViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('LoginScreenViewModel');
|
||||
|
||||
TextEditingController usernameController = TextEditingController();
|
||||
TextEditingController passwordController = TextEditingController();
|
||||
|
||||
final formKey = GlobalKey<FormState>();
|
||||
|
||||
Future<void> init() async {}
|
||||
|
||||
login() async {
|
||||
String username = usernameController.text;
|
||||
String password = passwordController.text;
|
||||
|
||||
if (username == 'retributor' && password == 'retributor') {
|
||||
await mySharedPrefs.clear();
|
||||
await mySharedPrefs.setString('level', 'retributor');
|
||||
snackbarService.showSnackbar(
|
||||
message: 'Login Berhasil\nSelamat Datang Retributor');
|
||||
navigationService.navigateTo(Routes.retributorIndexView);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
var formData =
|
||||
FormData.fromMap({'username': username, 'password': password});
|
||||
var response = await httpService.postWithFormData('login', formData);
|
||||
MyResponseModel myResponseModel = MyResponseModel.fromJson(response.data);
|
||||
// log.i(myResponseModel.status);
|
||||
if (myResponseModel.status == true) {
|
||||
// mySharedPrefs.clear();
|
||||
// log.i('pindah');
|
||||
DetailPenyewaModel detailPenyewa =
|
||||
DetailPenyewaModel.fromJson(myResponseModel.data);
|
||||
// log.i(detailPenyewa.nik);
|
||||
await mySharedPrefs.setString('level', 'penyewa');
|
||||
mySharedPrefs.setString('nik', detailPenyewa.nik!);
|
||||
// String ininikcoba = await mySharedPrefs.getString('nik') ?? 'tidak ada';
|
||||
// log.i("ini nik coba $ininikcoba");
|
||||
snackbarService.showSnackbar(
|
||||
message: 'Login Berhasil\nSelamat Datang ${detailPenyewa.nama}');
|
||||
navigationService.navigateTo(
|
||||
Routes.penyewaIndexView,
|
||||
arguments: PenyewaIndexViewArguments(penyewa: detailPenyewa),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
log.e(e);
|
||||
// snackbarService.showSnackbar(message: 'Error: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
103
lib/ui/views/penyewa_index/penyewa_index_view.dart
Normal file
103
lib/ui/views/penyewa_index/penyewa_index_view.dart
Normal file
@ -0,0 +1,103 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
import 'package:stylish_bottom_bar/model/bar_items.dart';
|
||||
import 'package:stylish_bottom_bar/stylish_bottom_bar.dart';
|
||||
|
||||
import '../../../app/app.router.dart';
|
||||
import '../../../app/themes/app_colors.dart';
|
||||
import '../../../app/themes/app_text.dart';
|
||||
import '../../../model/penyewa_model.dart';
|
||||
import './penyewa_index_view_model.dart';
|
||||
|
||||
class PenyewaIndexView extends StatelessWidget {
|
||||
final DetailPenyewaModel penyewa;
|
||||
|
||||
const PenyewaIndexView({super.key, required this.penyewa});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<PenyewaIndexViewModel>.reactive(
|
||||
viewModelBuilder: () => PenyewaIndexViewModel(),
|
||||
onViewModelReady: (PenyewaIndexViewModel model) async {
|
||||
await model.init(penyewa);
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
PenyewaIndexViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
return false;
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
model.header,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 20,
|
||||
),
|
||||
),
|
||||
backgroundColor: mainColor,
|
||||
elevation: 0,
|
||||
automaticallyImplyLeading: false,
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
model.logout();
|
||||
},
|
||||
icon: const Icon(Icons.logout, color: Colors.white),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 15),
|
||||
child: ExtendedNavigator(
|
||||
navigatorKey: StackedService.nestedNavigationKey(4),
|
||||
router: PenyewaIndexViewRouter(),
|
||||
initialRoute: PenyewaIndexViewRoutes.penyewaLogView,
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: StylishBottomBar(
|
||||
items: [
|
||||
for (var item in model.bottomNavBarList)
|
||||
BottomBarItem(
|
||||
icon: Icon(item['icon'],
|
||||
color: model.currentIndex ==
|
||||
model.bottomNavBarList.indexOf(item)
|
||||
? sixthGrey
|
||||
: backgroundColor),
|
||||
title: Text(
|
||||
item['name'],
|
||||
style: regularTextStyle.copyWith(
|
||||
color: model.currentIndex ==
|
||||
model.bottomNavBarList.indexOf(item)
|
||||
? sixthGrey
|
||||
: mainGrey,
|
||||
),
|
||||
),
|
||||
backgroundColor: model.currentIndex ==
|
||||
model.bottomNavBarList.indexOf(item)
|
||||
? fontColor
|
||||
: mainGrey,
|
||||
),
|
||||
],
|
||||
currentIndex: model.currentIndex,
|
||||
hasNotch: true,
|
||||
backgroundColor: mainColor,
|
||||
onTap: (value) {
|
||||
model.handleNavigation(value);
|
||||
},
|
||||
option: BubbleBarOptions(
|
||||
barStyle: BubbleBarStyle.horizotnal,
|
||||
bubbleFillStyle: BubbleFillStyle.fill,
|
||||
opacity: 0.3),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
93
lib/ui/views/penyewa_index/penyewa_index_view_model.dart
Normal file
93
lib/ui/views/penyewa_index/penyewa_index_view_model.dart
Normal file
@ -0,0 +1,93 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rfid_app/app/app.locator.dart';
|
||||
import 'package:rfid_app/model/penyewa_model.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
|
||||
import '../../../app/app.logger.dart';
|
||||
import '../../../app/app.router.dart';
|
||||
import '../../../services/shared_prefs.dart';
|
||||
|
||||
class PenyewaIndexViewModel extends IndexTrackingViewModel {
|
||||
final log = getLogger('PenyewaIndexViewModel');
|
||||
final mySharedPrefs = locator<MySharedPrefs>();
|
||||
final _navigationService = locator<NavigationService>();
|
||||
final dialogService = locator<DialogService>();
|
||||
final snackbarService = locator<SnackbarService>();
|
||||
// final socketIoClient = locator<MySocketIoClient>();
|
||||
|
||||
final _bottomNavBarList = [
|
||||
{
|
||||
'name': 'Tempat Sewa',
|
||||
'icon': Icons.home_outlined,
|
||||
'header': 'List Tempat Sewa',
|
||||
},
|
||||
{
|
||||
'name': 'Log History',
|
||||
'icon': Icons.work_history_outlined,
|
||||
'header': 'Log History',
|
||||
},
|
||||
{
|
||||
'name': 'Detail User',
|
||||
'icon': Icons.mobile_friendly_outlined,
|
||||
'header': 'Detail User',
|
||||
},
|
||||
];
|
||||
|
||||
List<Map<String, dynamic>> get bottomNavBarList => _bottomNavBarList;
|
||||
|
||||
final List<String> _views = [
|
||||
PenyewaIndexViewRoutes.tempatSewaanView,
|
||||
PenyewaIndexViewRoutes.penyewaLogView,
|
||||
PenyewaIndexViewRoutes.pulsaDetailView,
|
||||
];
|
||||
|
||||
String header = 'Log History';
|
||||
String? level;
|
||||
|
||||
Future<void> init(DetailPenyewaModel penyewa) async {
|
||||
level = await mySharedPrefs.getString('level');
|
||||
if (level != 'penyewa') {
|
||||
snackbarService.showSnackbar(
|
||||
message: 'Hanya Penyewa yang dapat mengakses halaman ini',
|
||||
);
|
||||
_navigationService.navigateTo(Routes.loginScreenView);
|
||||
return;
|
||||
}
|
||||
|
||||
setIndex(1);
|
||||
// String nikAtprefs = await mySharedPrefs.getString('nik') ?? 'tidak ada';
|
||||
// log.i("ini nikAtprefs $nikAtprefs");
|
||||
// log.i(penyewa.nik);
|
||||
}
|
||||
|
||||
void handleNavigation(int index) {
|
||||
log.d("handleNavigation: $index");
|
||||
log.d("currentIndex: $currentIndex");
|
||||
|
||||
if (currentIndex == index) return;
|
||||
|
||||
setIndex(index);
|
||||
header = _bottomNavBarList[index]['header'] as String;
|
||||
_navigationService.navigateTo(
|
||||
_views[index],
|
||||
id: 4,
|
||||
);
|
||||
}
|
||||
|
||||
logout() async {
|
||||
dialogService
|
||||
.showConfirmationDialog(
|
||||
title: 'Konfirmasi',
|
||||
description: 'Apakah anda yakin ingin keluar?',
|
||||
cancelTitle: 'Batal',
|
||||
confirmationTitle: 'Keluar',
|
||||
)
|
||||
.then((value) async {
|
||||
if (value!.confirmed) {
|
||||
await mySharedPrefs.clear();
|
||||
_navigationService.clearStackAndShow(Routes.loginScreenView);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
103
lib/ui/views/penyewa_index/penyewa_log/penyewa_log_view.dart
Normal file
103
lib/ui/views/penyewa_index/penyewa_log/penyewa_log_view.dart
Normal file
@ -0,0 +1,103 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import '../../../../app/themes/app_colors.dart';
|
||||
import '../../../../app/themes/app_text.dart';
|
||||
import './penyewa_log_view_model.dart';
|
||||
|
||||
class PenyewaLogView extends StatelessWidget {
|
||||
const PenyewaLogView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<PenyewaLogViewModel>.reactive(
|
||||
viewModelBuilder: () => PenyewaLogViewModel(),
|
||||
onViewModelReady: (PenyewaLogViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
fireOnViewModelReadyOnce: true,
|
||||
builder: (
|
||||
BuildContext context,
|
||||
PenyewaLogViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async => false,
|
||||
child: Scaffold(
|
||||
body: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: mainGrey.withOpacity(0.5),
|
||||
spreadRadius: 5,
|
||||
blurRadius: 7,
|
||||
offset:
|
||||
const Offset(0, 3), // changes position of shadow
|
||||
),
|
||||
],
|
||||
),
|
||||
child: model.logHistorySewaanList == null
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 15, vertical: 10),
|
||||
itemCount: model.logHistorySewaanList!.length,
|
||||
itemBuilder: (context, index) {
|
||||
// model.log
|
||||
// .i(model.logHistorySewaanList![index].date);
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
// model.log.i('clicked on index $index');
|
||||
model.checkKet(
|
||||
model.logHistorySewaanList![index],
|
||||
);
|
||||
},
|
||||
child: Card(
|
||||
child: ListTile(
|
||||
title: Text(
|
||||
model.logHistorySewaanList![index].jenis!,
|
||||
style:
|
||||
boldTextStyle.copyWith(fontSize: 15),
|
||||
),
|
||||
subtitle: const Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Text(
|
||||
// 'Tempat : ${model.logHistorySewaanList![index].}',
|
||||
// style: regularTextStyle,
|
||||
// ),
|
||||
// Text(
|
||||
// model.logHistorySewaanList![index]
|
||||
// .jenis!,
|
||||
// style: italicTextStyle,
|
||||
// ),
|
||||
],
|
||||
),
|
||||
// dummy date and time
|
||||
trailing: Text(
|
||||
model.otherFunction.formatDateString(model
|
||||
.logHistorySewaanList![index].date!),
|
||||
style: regularTextStyle,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
import '../../../../app/app.bottomsheets.dart';
|
||||
import '../../../../app/app.logger.dart';
|
||||
import '../../../../app/core/custom_base_view_model.dart';
|
||||
import '../../../../model/my_response_model.dart';
|
||||
import '../../../../model/penyewa_model.dart';
|
||||
|
||||
class PenyewaLogViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('PenyewaLogViewModel');
|
||||
List<PenyewaModel>? logHistorySewaanList;
|
||||
String? nik;
|
||||
Future<void> init() async {
|
||||
nik = await mySharedPrefs.getString('nik');
|
||||
await getData(nik);
|
||||
}
|
||||
|
||||
getData(String? nik) async {
|
||||
try {
|
||||
var response = await httpService.get('user/log_user/$nik');
|
||||
MyResponseModel myResponseModel = MyResponseModel.fromJson(response.data);
|
||||
log.i(myResponseModel.data);
|
||||
logHistorySewaanList = [];
|
||||
myResponseModel.data.forEach((item) {
|
||||
PenyewaModel penyewa = PenyewaModel.fromJson(item);
|
||||
logHistorySewaanList!.add(penyewa);
|
||||
log.d(penyewa);
|
||||
});
|
||||
notifyListeners();
|
||||
} catch (e) {
|
||||
log.e(e);
|
||||
}
|
||||
}
|
||||
|
||||
checkKet(PenyewaModel penyewaModel) async {
|
||||
await bottomSheetService.showCustomSheet(
|
||||
variant: BottomSheetType.detailLogHistoryView,
|
||||
data: penyewaModel,
|
||||
);
|
||||
}
|
||||
}
|
||||
105
lib/ui/views/penyewa_index/pulsa_detail/pulsa_detail_view.dart
Normal file
105
lib/ui/views/penyewa_index/pulsa_detail/pulsa_detail_view.dart
Normal file
@ -0,0 +1,105 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rfid_app/app/themes/app_text.dart';
|
||||
import 'package:rfid_app/ui/widgets/my_button.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import '../../../../app/themes/app_colors.dart';
|
||||
import './pulsa_detail_view_model.dart';
|
||||
|
||||
class PulsaDetailView extends StatelessWidget {
|
||||
const PulsaDetailView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<PulsaDetailViewModel>.reactive(
|
||||
viewModelBuilder: () => PulsaDetailViewModel(),
|
||||
onViewModelReady: (PulsaDetailViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
PulsaDetailViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Scaffold(
|
||||
body: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: mainColor,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
_RowChildren(
|
||||
title: 'NIK',
|
||||
value: model.detailPenyewaModel!.nik ?? '...',
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
_RowChildren(
|
||||
title: 'Nama',
|
||||
value: model.detailPenyewaModel!.nama ?? '...',
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
_RowChildren(
|
||||
title: 'Pulsa',
|
||||
value:
|
||||
'Rp. ${model.otherFunction.commaFormat(model.detailPenyewaModel!.saldo ?? 0)}',
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
_RowChildren(
|
||||
title: 'Card ID',
|
||||
value: model.detailPenyewaModel!.rfid ?? '...',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
MyButton(text: 'Ganti Password')
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _RowChildren extends StatelessWidget {
|
||||
const _RowChildren({
|
||||
required this.title,
|
||||
required this.value,
|
||||
});
|
||||
|
||||
final String title;
|
||||
final String value;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Text(
|
||||
title,
|
||||
style: regularTextStyle,
|
||||
),
|
||||
),
|
||||
const Expanded(flex: 1, child: Text(':')),
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: Text(
|
||||
value,
|
||||
style: boldTextStyle,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
import '../../../../app/app.logger.dart';
|
||||
import '../../../../app/core/custom_base_view_model.dart';
|
||||
import '../../../../model/my_response_model.dart';
|
||||
import '../../../../model/penyewa_model.dart';
|
||||
|
||||
class PulsaDetailViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('PulsaDetailViewModel');
|
||||
String? nik;
|
||||
DetailPenyewaModel? detailPenyewaModel;
|
||||
Future<void> init() async {
|
||||
nik = await mySharedPrefs.getString('nik');
|
||||
await getData(nik);
|
||||
}
|
||||
|
||||
getData(String? nik) async {
|
||||
try {
|
||||
var response = await httpService.get('user/user/$nik');
|
||||
MyResponseModel myResponseModel = MyResponseModel.fromJson(response.data);
|
||||
detailPenyewaModel = DetailPenyewaModel.fromJson(myResponseModel.data);
|
||||
notifyListeners();
|
||||
} catch (e) {
|
||||
log.e(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
168
lib/ui/views/penyewa_index/tempat_sewaan/tempat_sewaan_view.dart
Normal file
168
lib/ui/views/penyewa_index/tempat_sewaan/tempat_sewaan_view.dart
Normal file
@ -0,0 +1,168 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import '../../../../app/themes/app_colors.dart';
|
||||
import '../../../../app/themes/app_text.dart';
|
||||
import './tempat_sewaan_view_model.dart';
|
||||
|
||||
class TempatSewaanView extends StatelessWidget {
|
||||
const TempatSewaanView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<TempatSewaanViewModel>.reactive(
|
||||
viewModelBuilder: () => TempatSewaanViewModel(),
|
||||
onViewModelReady: (TempatSewaanViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
fireOnViewModelReadyOnce: true,
|
||||
builder: (
|
||||
BuildContext context,
|
||||
TempatSewaanViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async => false,
|
||||
child: Scaffold(
|
||||
body: Column(
|
||||
children: [
|
||||
Container(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: mainColor,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: mainGrey.withOpacity(0.5),
|
||||
spreadRadius: 5,
|
||||
blurRadius: 7,
|
||||
offset:
|
||||
const Offset(0, 3), // changes position of shadow
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Total Tempat Retribusi',
|
||||
style: regularTextStyle.copyWith(
|
||||
color: Colors.white,
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
model.tempatSewaanList?.length.toString() ?? '...',
|
||||
style: regularTextStyle.copyWith(
|
||||
color: Colors.white,
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: mainGrey.withOpacity(0.5),
|
||||
spreadRadius: 5,
|
||||
blurRadius: 7,
|
||||
offset:
|
||||
const Offset(0, 3), // changes position of shadow
|
||||
),
|
||||
],
|
||||
),
|
||||
child: model.tempatSewaanList == null
|
||||
? const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 15, vertical: 10),
|
||||
itemCount: model.tempatSewaanList!.length,
|
||||
itemBuilder: (context, index) {
|
||||
model.log.i(model.tempatSewaanList![index]);
|
||||
return Card(
|
||||
child: ListTile(
|
||||
title: Text(
|
||||
model.tempatSewaanList![index]
|
||||
.namaTempatSewa ??
|
||||
'',
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
subtitle: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Text(
|
||||
// 'Penyewa : ${model.tempatSewaanList![index].nama}',
|
||||
// ),
|
||||
Text(
|
||||
'Sewa / Bulan : Rp. ${model.otherFunction.commaFormat(model.tempatSewaanList![index].hargaSewa!)}',
|
||||
),
|
||||
],
|
||||
),
|
||||
// circle avatar
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () => model.snackbarService
|
||||
.showSnackbar(
|
||||
message:
|
||||
'Fitur sedang dalam tahap pengembangan'),
|
||||
child: Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: mainColor,
|
||||
borderRadius:
|
||||
BorderRadius.circular(40),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.list_alt_outlined,
|
||||
color: Colors.white,
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
),
|
||||
// const SizedBox(width: 5),
|
||||
// Container(
|
||||
// width: 50,
|
||||
// height: 50,
|
||||
// decoration: BoxDecoration(
|
||||
// color: mainColor,
|
||||
// borderRadius:
|
||||
// BorderRadius.circular(50),
|
||||
// ),
|
||||
// child: const Icon(
|
||||
// Icons.edit_square,
|
||||
// color: Colors.white,
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
import '../../../../app/app.logger.dart';
|
||||
import '../../../../app/core/custom_base_view_model.dart';
|
||||
import '../../../../model/my_response_model.dart';
|
||||
import '../../../../model/penyewa_model.dart';
|
||||
|
||||
class TempatSewaanViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('TempatSewaanViewModel');
|
||||
List<PenyewaModel>? tempatSewaanList;
|
||||
String? nik;
|
||||
Future<void> init() async {
|
||||
nik = await mySharedPrefs.getString('nik');
|
||||
await getData(nik);
|
||||
}
|
||||
|
||||
getData(String? nik) async {
|
||||
try {
|
||||
var response = await httpService.get('user/tempat_sewa/$nik');
|
||||
MyResponseModel myResponseModel = MyResponseModel.fromJson(response.data);
|
||||
log.i(myResponseModel.data);
|
||||
tempatSewaanList = [];
|
||||
myResponseModel.data.forEach((item) {
|
||||
PenyewaModel penyewa = PenyewaModel.fromJson(item);
|
||||
tempatSewaanList!.add(penyewa);
|
||||
log.d(penyewa);
|
||||
});
|
||||
notifyListeners();
|
||||
} catch (e) {
|
||||
log.e(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,111 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rfid_app/app/themes/app_colors.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
|
||||
import '../../../../../app/themes/app_text.dart';
|
||||
import '../../../../../model/penyewa_model.dart';
|
||||
import './detail_log_history_view_model.dart';
|
||||
|
||||
class DetailLogHistoryView extends StatelessWidget {
|
||||
final SheetRequest<PenyewaModel> request;
|
||||
final Function(SheetResponse) completer;
|
||||
|
||||
const DetailLogHistoryView({
|
||||
super.key,
|
||||
required SheetRequest request,
|
||||
required this.completer,
|
||||
}) : request = request as SheetRequest<PenyewaModel>;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<DetailLogHistoryViewModel>.reactive(
|
||||
viewModelBuilder: () => DetailLogHistoryViewModel(),
|
||||
onViewModelReady: (DetailLogHistoryViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
DetailLogHistoryViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return SafeArea(
|
||||
child: Container(
|
||||
// alignment: Alignment.topCenter,
|
||||
width: double.infinity,
|
||||
height: MediaQuery.of(context).size.height,
|
||||
margin: const EdgeInsets.all(5),
|
||||
padding: const EdgeInsets.all(25),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Center(child: Text(request.data!.jenis!, style: boldTextStyle)),
|
||||
const Divider(
|
||||
color: mainGrey,
|
||||
thickness: 1,
|
||||
),
|
||||
_RowDetail(
|
||||
title: 'Nama',
|
||||
value: request.data!.nama!,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_RowDetail(
|
||||
title: 'Waktu',
|
||||
value: model.otherFunction
|
||||
.formatDateString2(request.data!.date!),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_RowDetail(
|
||||
title: 'Keterangan',
|
||||
value: request.data!.ket!,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _RowDetail extends StatelessWidget {
|
||||
const _RowDetail({
|
||||
required this.title,
|
||||
required this.value,
|
||||
});
|
||||
|
||||
final String title;
|
||||
final String value;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Text(
|
||||
title,
|
||||
style: boldTextStyle,
|
||||
),
|
||||
),
|
||||
const Expanded(
|
||||
flex: 1,
|
||||
child: Text(':'),
|
||||
),
|
||||
Expanded(
|
||||
flex: 7,
|
||||
child: Text(
|
||||
value,
|
||||
style: italicTextStyle,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
import 'package:rfid_app/app/core/custom_base_view_model.dart';
|
||||
|
||||
class DetailLogHistoryViewModel extends CustomBaseViewModel {
|
||||
Future<void> init() async {}
|
||||
}
|
||||
@ -0,0 +1,102 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import '../../../../app/themes/app_colors.dart';
|
||||
import '../../../../app/themes/app_text.dart';
|
||||
import './log_history_sewaan_view_model.dart';
|
||||
|
||||
class LogHistorySewaanView extends StatelessWidget {
|
||||
const LogHistorySewaanView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<LogHistorySewaanViewModel>.reactive(
|
||||
viewModelBuilder: () => LogHistorySewaanViewModel(),
|
||||
onViewModelReady: (LogHistorySewaanViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
LogHistorySewaanViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async => false,
|
||||
child: Scaffold(
|
||||
body: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: mainGrey.withOpacity(0.5),
|
||||
spreadRadius: 5,
|
||||
blurRadius: 7,
|
||||
offset:
|
||||
const Offset(0, 3), // changes position of shadow
|
||||
),
|
||||
],
|
||||
),
|
||||
child: model.logHistorySewaanList == null
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 15, vertical: 10),
|
||||
itemCount: model.logHistorySewaanList!.length,
|
||||
itemBuilder: (context, index) {
|
||||
// model.log
|
||||
// .i(model.logHistorySewaanList![index].date);
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
// model.log.i('clicked on index $index');
|
||||
model.checkKet(
|
||||
model.logHistorySewaanList![index],
|
||||
);
|
||||
},
|
||||
child: Card(
|
||||
child: ListTile(
|
||||
title: Text(
|
||||
model.logHistorySewaanList![index].jenis!,
|
||||
style:
|
||||
boldTextStyle.copyWith(fontSize: 15),
|
||||
),
|
||||
subtitle: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Penyewa : ${model.logHistorySewaanList![index].nama}',
|
||||
style: regularTextStyle,
|
||||
),
|
||||
// Text(
|
||||
// model.logHistorySewaanList![index]
|
||||
// .jenis!,
|
||||
// style: italicTextStyle,
|
||||
// ),
|
||||
],
|
||||
),
|
||||
// dummy date and time
|
||||
trailing: Text(
|
||||
model.otherFunction.formatDateString(model
|
||||
.logHistorySewaanList![index].date!),
|
||||
style: boldTextStyle,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
import '../../../../app/app.bottomsheets.dart';
|
||||
import '../../../../app/app.logger.dart';
|
||||
import '../../../../app/core/custom_base_view_model.dart';
|
||||
import '../../../../model/my_response_model.dart';
|
||||
import '../../../../model/penyewa_model.dart';
|
||||
|
||||
class LogHistorySewaanViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('LogHistorySewaanViewModel');
|
||||
List<PenyewaModel>? logHistorySewaanList;
|
||||
|
||||
Future<void> init() async {
|
||||
log.d('init log history sewaan');
|
||||
await getData();
|
||||
}
|
||||
|
||||
getData() async {
|
||||
try {
|
||||
var response = await httpService.get('scan/log');
|
||||
MyResponseModel myResponseModel = MyResponseModel.fromJson(response.data);
|
||||
logHistorySewaanList = [];
|
||||
myResponseModel.data.forEach((item) {
|
||||
PenyewaModel penyewa = PenyewaModel.fromJson(item);
|
||||
logHistorySewaanList!.add(penyewa);
|
||||
log.d(penyewa);
|
||||
});
|
||||
notifyListeners();
|
||||
} catch (e) {
|
||||
log.e(e);
|
||||
// snackbarService.showSnackbar(message: 'Error: $e');
|
||||
}
|
||||
}
|
||||
|
||||
checkKet(PenyewaModel penyewaModel) async {
|
||||
await bottomSheetService.showCustomSheet(
|
||||
variant: BottomSheetType.detailLogHistoryView,
|
||||
data: penyewaModel,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,104 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
import 'package:validatorless/validatorless.dart';
|
||||
|
||||
import '../../../../../app/themes/app_colors.dart';
|
||||
import '../../../../../model/penyewa_model.dart';
|
||||
import '../../../../widgets/my_button.dart';
|
||||
import '../../../../widgets/my_textformfield.dart';
|
||||
import './edit_penyewa_dialog_view_model.dart';
|
||||
|
||||
class EditPenyewaDialogView extends StatelessWidget {
|
||||
final DialogRequest<DetailPenyewaModel> request;
|
||||
final Function(DialogResponse) completer;
|
||||
const EditPenyewaDialogView({
|
||||
super.key,
|
||||
required DialogRequest request,
|
||||
required this.completer,
|
||||
}) : request = request as DialogRequest<DetailPenyewaModel>;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<EditPenyewaDialogViewModel>.reactive(
|
||||
viewModelBuilder: () => EditPenyewaDialogViewModel(),
|
||||
onViewModelReady: (EditPenyewaDialogViewModel model) async {
|
||||
await model.init(request.data);
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
EditPenyewaDialogViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Dialog(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(15),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: backgroundColor,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
const Text("NIK"),
|
||||
MyTextFormField(
|
||||
controller: model.nikController,
|
||||
hintText: 'Masukkan NIK Penyewa',
|
||||
keyboardType: TextInputType.number,
|
||||
maxLength: 16,
|
||||
validator: Validatorless.multiple(
|
||||
[
|
||||
Validatorless.required('NIK harus diisi'),
|
||||
Validatorless.min(16, 'NIK harus 16 digit'),
|
||||
Validatorless.max(16, 'NIK harus 16 digit'),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const Text("Nama"),
|
||||
MyTextFormField(
|
||||
controller: model.nameController,
|
||||
hintText: 'Masukkan Nama Penyewa',
|
||||
validator: Validatorless.required('Nama harus diisi'),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
MyButton(
|
||||
text: 'Update Data',
|
||||
onPressed: () {
|
||||
if (request.data!.nik == model.nikController.text &&
|
||||
request.data!.nama == model.nameController.text) {
|
||||
model.snackbarService.showSnackbar(
|
||||
message: 'Tidak ada perubahan',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
model.dialogService
|
||||
.showDialog(
|
||||
title: 'Konfirmasi',
|
||||
description: 'Apakah anda yakin ingin mengupdate data?',
|
||||
cancelTitle: 'Batal',
|
||||
buttonTitle: 'Update',
|
||||
// confirmationTitle: 'Update',
|
||||
)
|
||||
.then((value) async {
|
||||
if (value!.confirmed) {
|
||||
bool res = await model.updateData(request.data!.nik);
|
||||
// model.log.i("ini res: $res");
|
||||
if (res) {
|
||||
completer(DialogResponse(confirmed: true));
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../../app/app.logger.dart';
|
||||
import '../../../../../app/core/custom_base_view_model.dart';
|
||||
import '../../../../../model/penyewa_model.dart';
|
||||
|
||||
class EditPenyewaDialogViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('EditPenyewaDialogViewModel');
|
||||
|
||||
TextEditingController nikController = TextEditingController();
|
||||
TextEditingController nameController = TextEditingController();
|
||||
final formKey = GlobalKey<FormState>();
|
||||
|
||||
Future<void> init(DetailPenyewaModel? data) async {
|
||||
log.d('init edit penyewa dialog');
|
||||
nikController.text = data!.nik!;
|
||||
nameController.text = data.nama!;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<bool> updateData(String? nik) async {
|
||||
try {
|
||||
easyLoading.customLoading('Updating Data...');
|
||||
// delay 2 seconds
|
||||
// await Future.delayed(const Duration(seconds: 2));
|
||||
var formData = FormData.fromMap({
|
||||
'nik_baru': nikController.text,
|
||||
'nama': nameController.text,
|
||||
});
|
||||
await httpService.putWithFormData('scan/penyewa/$nik', formData);
|
||||
return true;
|
||||
} catch (e) {
|
||||
log.d(e);
|
||||
return false;
|
||||
} finally {
|
||||
easyLoading.dismiss();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,189 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import '../../../../app/themes/app_colors.dart';
|
||||
import '../../../../app/themes/app_text.dart';
|
||||
import './penyewa_list_view_model.dart';
|
||||
|
||||
class PenyewaListView extends StatelessWidget {
|
||||
const PenyewaListView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<PenyewaListViewModel>.reactive(
|
||||
viewModelBuilder: () => PenyewaListViewModel(),
|
||||
onViewModelReady: (PenyewaListViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
PenyewaListViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async => false,
|
||||
child: Scaffold(
|
||||
body: Column(
|
||||
children: [
|
||||
Container(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: mainColor,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: mainGrey.withOpacity(0.5),
|
||||
spreadRadius: 5,
|
||||
blurRadius: 7,
|
||||
offset:
|
||||
const Offset(0, 3), // changes position of shadow
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Total',
|
||||
style: regularTextStyle.copyWith(
|
||||
color: Colors.white,
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'2 orang',
|
||||
style: regularTextStyle.copyWith(
|
||||
color: Colors.white,
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: mainGrey.withOpacity(0.5),
|
||||
spreadRadius: 5,
|
||||
blurRadius: 7,
|
||||
offset:
|
||||
const Offset(0, 3), // changes position of shadow
|
||||
),
|
||||
],
|
||||
),
|
||||
child: model.penyewaList == null
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 15, vertical: 10),
|
||||
itemCount: model.penyewaList!.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Card(
|
||||
child: ListTile(
|
||||
title: Text(model.penyewaList![index].nama!,
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 13)),
|
||||
subtitle: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.start,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Card ID: ${model.penyewaList![index].rfid!}',
|
||||
style: regularTextStyle.copyWith(
|
||||
fontSize: 12)),
|
||||
Text(
|
||||
'Saldo: Rp. ${model.otherFunction.commaFormat(model.penyewaList![index].saldo!)}',
|
||||
style: regularTextStyle.copyWith(
|
||||
fontSize: 12)),
|
||||
],
|
||||
),
|
||||
// circle avatar
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
await model.topUp(
|
||||
model.penyewaList![index]);
|
||||
},
|
||||
child: Container(
|
||||
width: 30,
|
||||
height: 30,
|
||||
decoration: BoxDecoration(
|
||||
color: mainColor,
|
||||
borderRadius:
|
||||
BorderRadius.circular(30),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.add_card_outlined,
|
||||
color: Colors.white,
|
||||
size: 15,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
GestureDetector(
|
||||
onTap: () => model.snackbarService
|
||||
.showSnackbar(
|
||||
message:
|
||||
'Fitur sedang dalam tahap pengembangan'),
|
||||
child: Container(
|
||||
width: 30,
|
||||
height: 30,
|
||||
decoration: BoxDecoration(
|
||||
color: mainColor,
|
||||
borderRadius:
|
||||
BorderRadius.circular(30),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.list_alt,
|
||||
color: Colors.white,
|
||||
size: 15,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
GestureDetector(
|
||||
onTap: () async =>
|
||||
model.editPenyewaDialog(
|
||||
model.penyewaList![index]),
|
||||
child: Container(
|
||||
width: 30,
|
||||
height: 30,
|
||||
decoration: BoxDecoration(
|
||||
color: mainColor,
|
||||
borderRadius:
|
||||
BorderRadius.circular(30),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.edit_document,
|
||||
color: Colors.white,
|
||||
size: 15,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
)),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
import '../../../../app/app.dialogs.dart';
|
||||
import '../../../../app/app.logger.dart';
|
||||
import '../../../../app/core/custom_base_view_model.dart';
|
||||
import '../../../../model/my_response_model.dart';
|
||||
import '../../../../model/penyewa_model.dart';
|
||||
|
||||
class PenyewaListViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('PenyewaListViewModel');
|
||||
List<DetailPenyewaModel>? penyewaList;
|
||||
Future<void> init() async {
|
||||
log.d('init');
|
||||
await getData();
|
||||
}
|
||||
|
||||
getData() async {
|
||||
try {
|
||||
var response = await httpService.get('scan/penyewa');
|
||||
MyResponseModel myResponseModel = MyResponseModel.fromJson(response.data);
|
||||
penyewaList = [];
|
||||
myResponseModel.data.forEach((item) {
|
||||
DetailPenyewaModel detailPenyewa = DetailPenyewaModel.fromJson(item);
|
||||
penyewaList!.add(detailPenyewa);
|
||||
log.d(detailPenyewa);
|
||||
});
|
||||
|
||||
notifyListeners();
|
||||
} catch (e) {
|
||||
log.d(e);
|
||||
// snackbarService.showSnackbar(message: 'Error: $e');
|
||||
}
|
||||
}
|
||||
|
||||
topUp(DetailPenyewaModel detailPenyewaModel) async {
|
||||
var res = await dialogService.showCustomDialog(
|
||||
variant: DialogType.topUpSaldoView,
|
||||
data: detailPenyewaModel,
|
||||
title: 'Top Up Kartu Retributor',
|
||||
);
|
||||
|
||||
if (res != null && res.confirmed) {
|
||||
snackbarService.showSnackbar(message: res.data);
|
||||
await getData();
|
||||
}
|
||||
}
|
||||
|
||||
editPenyewaDialog(DetailPenyewaModel detailPenyewaModel) async {
|
||||
var res = await dialogService.showCustomDialog(
|
||||
variant: DialogType.editPenyewaDialogView,
|
||||
data: detailPenyewaModel,
|
||||
// title: 'Edit Penyewa',
|
||||
);
|
||||
|
||||
if (res!.confirmed) {
|
||||
snackbarService.showSnackbar(message: 'Berhasil mengupdate data');
|
||||
await getData();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,129 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
|
||||
import '../../../../../app/themes/app_colors.dart';
|
||||
import '../../../../../app/themes/app_text.dart';
|
||||
import '../../../../../model/penyewa_model.dart';
|
||||
import '../../scan_rfid_dialog/scan_rfid_dialog_view.dart';
|
||||
import './top_up_saldo_view_model.dart';
|
||||
|
||||
class TopUpSaldoView extends StatelessWidget {
|
||||
final DialogRequest<DetailPenyewaModel> request;
|
||||
final Function(DialogResponse) completer;
|
||||
const TopUpSaldoView({
|
||||
super.key,
|
||||
required DialogRequest request,
|
||||
required this.completer,
|
||||
}) : request = request as DialogRequest<DetailPenyewaModel>;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<TopUpSaldoViewModel>.reactive(
|
||||
viewModelBuilder: () => TopUpSaldoViewModel(),
|
||||
onViewModelReady: (TopUpSaldoViewModel model) async {
|
||||
await model.init(request.data);
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
TopUpSaldoViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Dialog(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(15),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: backgroundColor,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
request.title!,
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
const Divider(
|
||||
color: greyBlueColor,
|
||||
thickness: 1,
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
DetailRow(
|
||||
title: 'Nama',
|
||||
value: request.data!.nama ?? '...',
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
DetailRow(
|
||||
title: 'Card ID',
|
||||
value: request.data!.rfid ?? '...',
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
DetailRow(
|
||||
title: 'Saldo',
|
||||
value:
|
||||
'Rp. ${model.otherFunction.commaFormat(request.data!.saldo ?? 0)}',
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
height: 60,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(25),
|
||||
border: Border.all(
|
||||
color: mainColor,
|
||||
),
|
||||
),
|
||||
child: DropdownButtonHideUnderline(
|
||||
child: DropdownButton<int>(
|
||||
value: model.topUpValue,
|
||||
onChanged: (int? newValue) {
|
||||
// model.log.d('newValue: $newValue');
|
||||
model.topUpValue = newValue!;
|
||||
model.notifyListeners();
|
||||
},
|
||||
items: model.topUpList.map((Map<String, dynamic> value) {
|
||||
// model.log.d('value: $value');
|
||||
return DropdownMenuItem<int>(
|
||||
value: value['value'],
|
||||
child: Text(
|
||||
value['title'].toString(),
|
||||
style: regularTextStyle.copyWith(
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Center(
|
||||
child: SizedBox(
|
||||
width: 200,
|
||||
child: ElevatedButton(
|
||||
onPressed: () async {
|
||||
String? message = await model.topUpSaldo();
|
||||
|
||||
if (message != null) {
|
||||
completer(DialogResponse(
|
||||
confirmed: true,
|
||||
data: message,
|
||||
));
|
||||
}
|
||||
},
|
||||
child: const Text('TopUp Saldo'),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:rfid_app/model/my_response_model.dart';
|
||||
|
||||
import '../../../../../app/app.logger.dart';
|
||||
import '../../../../../app/core/custom_base_view_model.dart';
|
||||
import '../../../../../model/penyewa_model.dart';
|
||||
|
||||
class TopUpSaldoViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('TopUpSaldoViewModel');
|
||||
|
||||
DetailPenyewaModel? detailPenyewaModel;
|
||||
|
||||
List<Map<String, dynamic>> topUpList = [
|
||||
{'title': 'Rp. 50.000', 'value': 50000},
|
||||
{'title': 'Rp. 75.000', 'value': 75000},
|
||||
{'title': 'Rp. 100.000', 'value': 100000},
|
||||
{'title': 'Rp. 200.000', 'value': 200000},
|
||||
];
|
||||
|
||||
int topUpValue = 50000;
|
||||
|
||||
Future<void> init(DetailPenyewaModel? data) async {
|
||||
log.d(data);
|
||||
|
||||
detailPenyewaModel = data;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<String?> topUpSaldo() async {
|
||||
log.i('ini topUpValue: $topUpValue');
|
||||
try {
|
||||
var formData = FormData.fromMap({
|
||||
'topup': topUpValue,
|
||||
});
|
||||
|
||||
var response = await httpService.postWithFormData(
|
||||
'scan/penyewa/${detailPenyewaModel!.nik}', formData);
|
||||
|
||||
MyResponseModel myResponseModel = MyResponseModel.fromJson(response.data);
|
||||
|
||||
return myResponseModel.message;
|
||||
} catch (e) {
|
||||
log.e(e);
|
||||
// snackbarService.showSnackbar(message: 'Error: $e');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
100
lib/ui/views/retributor_index/retributor_index_view.dart
Normal file
100
lib/ui/views/retributor_index/retributor_index_view.dart
Normal file
@ -0,0 +1,100 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
import 'package:stylish_bottom_bar/model/bar_items.dart';
|
||||
import 'package:stylish_bottom_bar/stylish_bottom_bar.dart';
|
||||
|
||||
import '../../../app/app.router.dart';
|
||||
import '../../../app/themes/app_colors.dart';
|
||||
import '../../../app/themes/app_text.dart';
|
||||
import './retributor_index_view_model.dart';
|
||||
|
||||
class RetributorIndexView extends StatelessWidget {
|
||||
const RetributorIndexView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<RetributorIndexViewModel>.reactive(
|
||||
viewModelBuilder: () => RetributorIndexViewModel(),
|
||||
onViewModelReady: (RetributorIndexViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
RetributorIndexViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
return false;
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
model.header,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 20,
|
||||
),
|
||||
),
|
||||
backgroundColor: mainColor,
|
||||
elevation: 0,
|
||||
automaticallyImplyLeading: false,
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
model.logout();
|
||||
},
|
||||
icon: const Icon(Icons.logout, color: Colors.white),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 15),
|
||||
child: ExtendedNavigator(
|
||||
navigatorKey: StackedService.nestedNavigationKey(3),
|
||||
router: RetributorIndexViewRouter(),
|
||||
initialRoute: RetributorIndexViewRoutes.tempatSewaListView,
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: StylishBottomBar(
|
||||
items: [
|
||||
for (var item in model.bottomNavBarList)
|
||||
BottomBarItem(
|
||||
icon: Icon(item['icon'],
|
||||
color: model.currentIndex ==
|
||||
model.bottomNavBarList.indexOf(item)
|
||||
? sixthGrey
|
||||
: backgroundColor),
|
||||
title: Text(
|
||||
item['name'],
|
||||
style: regularTextStyle.copyWith(
|
||||
color: model.currentIndex ==
|
||||
model.bottomNavBarList.indexOf(item)
|
||||
? sixthGrey
|
||||
: mainGrey,
|
||||
),
|
||||
),
|
||||
backgroundColor: model.currentIndex ==
|
||||
model.bottomNavBarList.indexOf(item)
|
||||
? fontColor
|
||||
: mainGrey,
|
||||
),
|
||||
],
|
||||
currentIndex: model.currentIndex,
|
||||
hasNotch: true,
|
||||
backgroundColor: mainColor,
|
||||
onTap: (value) {
|
||||
model.handleNavigation(value);
|
||||
},
|
||||
option: BubbleBarOptions(
|
||||
barStyle: BubbleBarStyle.horizotnal,
|
||||
bubbleFillStyle: BubbleFillStyle.fill,
|
||||
opacity: 0.3),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
105
lib/ui/views/retributor_index/retributor_index_view_model.dart
Normal file
105
lib/ui/views/retributor_index/retributor_index_view_model.dart
Normal file
@ -0,0 +1,105 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
|
||||
import '../../../app/app.dialogs.dart';
|
||||
import '../../../app/app.locator.dart';
|
||||
import '../../../app/app.logger.dart';
|
||||
import '../../../app/app.router.dart';
|
||||
import '../../../services/my_socket_io_client.dart';
|
||||
import '../../../services/shared_prefs.dart';
|
||||
|
||||
class RetributorIndexViewModel extends IndexTrackingViewModel {
|
||||
final log = getLogger('RetributorIndexViewModel');
|
||||
final _navigationService = locator<NavigationService>();
|
||||
final socketIoClient = locator<MySocketIoClient>();
|
||||
final dialogService = locator<DialogService>();
|
||||
final snackbarService = locator<SnackbarService>();
|
||||
final mySharedPrefs = locator<MySharedPrefs>();
|
||||
|
||||
final _bottomNavBarList = [
|
||||
{
|
||||
'name': 'Tempat Sewa',
|
||||
'icon': Icons.home_outlined,
|
||||
'header': 'List Tempat Sewa',
|
||||
},
|
||||
{
|
||||
'name': 'History Sewaan',
|
||||
'icon': Icons.work_history_outlined,
|
||||
'header': 'Log History Sewaan',
|
||||
},
|
||||
{
|
||||
'name': 'List Penyewa',
|
||||
'icon': Icons.people_outlined,
|
||||
'header': 'List Penyewa',
|
||||
},
|
||||
];
|
||||
|
||||
List<Map<String, dynamic>> get bottomNavBarList => _bottomNavBarList;
|
||||
|
||||
final List<String> _views = [
|
||||
RetributorIndexViewRoutes.tempatSewaListView,
|
||||
RetributorIndexViewRoutes.logHistorySewaanView,
|
||||
RetributorIndexViewRoutes.penyewaListView,
|
||||
];
|
||||
|
||||
String header = 'List Tempat Sewa';
|
||||
|
||||
String? level;
|
||||
|
||||
Future<void> init() async {
|
||||
// socketIoClient.on('connect', (data) => log.i('connected'));
|
||||
level = await mySharedPrefs.getString('level');
|
||||
if (level != 'retributor') {
|
||||
snackbarService.showSnackbar(
|
||||
message: 'Hanya Retributor yang dapat mengakses halaman ini',
|
||||
);
|
||||
_navigationService.navigateTo(Routes.loginScreenView);
|
||||
return;
|
||||
}
|
||||
|
||||
socketIoClient.on('scan', (data) async {
|
||||
var res = await dialogService.showCustomDialog(
|
||||
variant: DialogType.scanRfidDialogView,
|
||||
title: 'Pembayaran Retribusi',
|
||||
data: data,
|
||||
);
|
||||
|
||||
if (res!.confirmed) {
|
||||
snackbarService.showSnackbar(
|
||||
message: res.data,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void handleNavigation(int index) {
|
||||
log.d("handleNavigation: $index");
|
||||
log.d("currentIndex: $currentIndex");
|
||||
|
||||
if (currentIndex == index) return;
|
||||
|
||||
setIndex(index);
|
||||
header = _bottomNavBarList[index]['header'] as String;
|
||||
_navigationService.navigateTo(
|
||||
_views[index],
|
||||
id: 3,
|
||||
);
|
||||
}
|
||||
|
||||
logout() async {
|
||||
dialogService
|
||||
.showConfirmationDialog(
|
||||
title: 'Konfirmasi',
|
||||
description: 'Apakah anda yakin ingin keluar?',
|
||||
cancelTitle: 'Batal',
|
||||
confirmationTitle: 'Keluar',
|
||||
)
|
||||
.then((value) async {
|
||||
if (value!.confirmed) {
|
||||
await mySharedPrefs.clear();
|
||||
_navigationService.clearStackAndShow(Routes.loginScreenView);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,184 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rfid_app/model/penyewa_model.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
|
||||
import '../../../../app/themes/app_colors.dart';
|
||||
import '../../../../app/themes/app_text.dart';
|
||||
import './scan_rfid_dialog_view_model.dart';
|
||||
|
||||
class ScanRfidDialogView extends StatelessWidget {
|
||||
final DialogRequest request;
|
||||
final Function(DialogResponse) completer;
|
||||
|
||||
const ScanRfidDialogView({
|
||||
super.key,
|
||||
required this.request,
|
||||
required this.completer,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<ScanRfidDialogViewModel>.reactive(
|
||||
viewModelBuilder: () => ScanRfidDialogViewModel(),
|
||||
onViewModelReady: (ScanRfidDialogViewModel model) async {
|
||||
await model.init(request.data);
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
ScanRfidDialogViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Dialog(
|
||||
child: Container(
|
||||
// alignment: Alignment.center,
|
||||
padding: const EdgeInsets.all(15),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: backgroundColor,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Center(
|
||||
child: Text(
|
||||
request.title!,
|
||||
style: regularTextStyle.copyWith(
|
||||
fontSize: 20,
|
||||
// color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
// const SizedBox(height: 10),
|
||||
// create line
|
||||
const Divider(
|
||||
color: greyBlueColor,
|
||||
thickness: 1,
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
DetailRow(title: 'nama', value: model.nama ?? '...'),
|
||||
const SizedBox(height: 5),
|
||||
DetailRow(title: 'Card id', value: model.cardId ?? '...'),
|
||||
const SizedBox(height: 5),
|
||||
DetailRow(title: 'Saldo', value: model.saldo ?? '...'),
|
||||
const SizedBox(height: 10),
|
||||
const Text(' Pilih tempat retribusi', style: regularTextStyle),
|
||||
model.penyewaList.isEmpty
|
||||
? Container()
|
||||
: Container(
|
||||
width: double.infinity,
|
||||
height: 60,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(25),
|
||||
border: Border.all(
|
||||
color: mainColor,
|
||||
),
|
||||
),
|
||||
child: DropdownButtonHideUnderline(
|
||||
child: DropdownButton<String>(
|
||||
value: model.idTempatSerwa.toString(),
|
||||
onChanged: (String? newValue) {
|
||||
model.log.d('newValue: $newValue');
|
||||
model.idTempatSerwa = int.parse(newValue!);
|
||||
model.notifyListeners();
|
||||
},
|
||||
items: model.penyewaList.map((PenyewaModel value) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: value.idTempatSerwa.toString(),
|
||||
child: Text(
|
||||
value.namaTempatSewa.toString(),
|
||||
style: regularTextStyle.copyWith(
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Center(
|
||||
child: SizedBox(
|
||||
width: 200,
|
||||
child: ElevatedButton(
|
||||
onPressed: () async {
|
||||
// String? message = await model.bayar();
|
||||
|
||||
// if (message != null) {
|
||||
// completer(DialogResponse(
|
||||
// confirmed: true,
|
||||
// data: message,
|
||||
// ));
|
||||
// }
|
||||
PenyewaModel penyewa = model.penyewaList.firstWhere(
|
||||
(element) =>
|
||||
element.idTempatSerwa == model.idTempatSerwa);
|
||||
|
||||
model.dialogService
|
||||
.showDialog(
|
||||
title: 'Bayar?',
|
||||
description:
|
||||
'${model.nama} dengan Card ID ${model.cardId} akan membayar retribusi ${penyewa.namaTempatSewa} sebanyak Rp. ${model.otherFunction.commaFormat(penyewa.hargaSewa!)} per bulan sekarang?',
|
||||
cancelTitle: 'Batal',
|
||||
)
|
||||
.then((res) async {
|
||||
if (res!.confirmed) {
|
||||
String? message = await model.bayar(penyewa);
|
||||
if (message != null) {
|
||||
completer(DialogResponse(
|
||||
confirmed: true,
|
||||
data: message,
|
||||
));
|
||||
}
|
||||
// completer(DialogResponse(
|
||||
// confirmed: true,
|
||||
// ));
|
||||
}
|
||||
});
|
||||
},
|
||||
child: const Text('Bayar'),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class DetailRow extends StatelessWidget {
|
||||
const DetailRow({
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.value,
|
||||
});
|
||||
|
||||
final String title;
|
||||
final String value;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Text(title),
|
||||
),
|
||||
const Expanded(
|
||||
flex: 1,
|
||||
child: Text(':'),
|
||||
),
|
||||
Expanded(
|
||||
flex: 8,
|
||||
child: Text(value),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:rfid_app/app/core/custom_base_view_model.dart';
|
||||
import 'package:rfid_app/model/my_response_model.dart';
|
||||
import 'package:rfid_app/model/penyewa_model.dart';
|
||||
|
||||
import '../../../../app/app.logger.dart';
|
||||
|
||||
class ScanRfidDialogViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('ScanRfidDialogViewModel');
|
||||
String? nama;
|
||||
String? cardId;
|
||||
String? saldo;
|
||||
List<PenyewaModel> penyewaList = [];
|
||||
|
||||
int? idTempatSerwa;
|
||||
|
||||
Future<void> init(data) async {
|
||||
log.d('init');
|
||||
|
||||
getData(data);
|
||||
}
|
||||
|
||||
getData(String data) async {
|
||||
try {
|
||||
var respose = await httpService.get('scan/id/$data');
|
||||
// log.d(respose.data);
|
||||
MyResponseModel response = MyResponseModel.fromJson(respose.data);
|
||||
|
||||
response.data.forEach((item) {
|
||||
PenyewaModel penyewa = PenyewaModel.fromJson(item);
|
||||
// log.d(penyewa);
|
||||
penyewaList.add(penyewa);
|
||||
});
|
||||
log.d(penyewaList);
|
||||
nama = penyewaList[0].nama;
|
||||
cardId = penyewaList[0].rfid;
|
||||
saldo = 'Rp. ${otherFunction.commaFormat(penyewaList[0].saldo ?? 0)}';
|
||||
idTempatSerwa = penyewaList[0].idTempatSerwa;
|
||||
|
||||
notifyListeners();
|
||||
} catch (e) {
|
||||
log.e(e);
|
||||
// snackbarService.showSnackbar(message: 'Error: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<String?> bayar(PenyewaModel penyewa) async {
|
||||
try {
|
||||
var formData = FormData.fromMap({
|
||||
'nik': penyewa.nik,
|
||||
'rfid': cardId,
|
||||
'id_tempat_sewa': idTempatSerwa,
|
||||
});
|
||||
var respose = await httpService.postWithFormData('scan/bayar', formData);
|
||||
MyResponseModel response = MyResponseModel.fromJson(respose.data);
|
||||
return response.message;
|
||||
} catch (e) {
|
||||
log.e(e);
|
||||
return null;
|
||||
} finally {
|
||||
easyLoading.dismiss();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,104 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
import 'package:validatorless/validatorless.dart';
|
||||
|
||||
import '../../../../../app/themes/app_colors.dart';
|
||||
import '../../../../../model/penyewa_model.dart';
|
||||
import '../../../../widgets/my_button.dart';
|
||||
import '../../../../widgets/my_textformfield.dart';
|
||||
import './edit_tempat_sewa_dialog_view_model.dart';
|
||||
|
||||
class EditTempatSewaDialogView extends StatelessWidget {
|
||||
final DialogRequest<PenyewaModel> request;
|
||||
final Function(DialogResponse) completer;
|
||||
|
||||
const EditTempatSewaDialogView(
|
||||
{super.key, required DialogRequest request, required this.completer})
|
||||
: request = request as DialogRequest<PenyewaModel>;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<EditTempatSewaDialogViewModel>.reactive(
|
||||
viewModelBuilder: () => EditTempatSewaDialogViewModel(),
|
||||
onViewModelReady: (EditTempatSewaDialogViewModel model) async {
|
||||
await model.init(request.data);
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
EditTempatSewaDialogViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Dialog(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(15),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: backgroundColor,
|
||||
),
|
||||
child: Form(
|
||||
key: model.formKey,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
const Text("Tempat Sewa"),
|
||||
MyTextFormField(
|
||||
controller: model.tempatSewaController,
|
||||
hintText: 'Masukkan Tempat Sewa',
|
||||
validator:
|
||||
Validatorless.required('Tempat Sewa harus diisi'),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const Text("Sewa / Bulan (Rp.)"),
|
||||
MyTextFormField(
|
||||
controller: model.sewaBulanController,
|
||||
hintText: 'Masukkan Jumlah Sewa / Bulan',
|
||||
keyboardType: TextInputType.number,
|
||||
maxLength: 5,
|
||||
validator: Validatorless.required(
|
||||
'Jumlah Sewa / Bulan harus diisi',
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
MyButton(
|
||||
text: 'Update Detail',
|
||||
onPressed: () async {
|
||||
if (model.tempatSewaController.text ==
|
||||
request.data!.namaTempatSewa &&
|
||||
model.sewaBulanController.text ==
|
||||
request.data!.hargaSewa.toString()) {
|
||||
model.snackbarService.showSnackbar(
|
||||
message: 'Tidak ada perubahan yang dilakukan',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
model.dialogService
|
||||
.showDialog(
|
||||
title: 'Edit Tempat Sewa',
|
||||
description:
|
||||
'Apakah anda yakin ingin mengedit detail tempat sewa?',
|
||||
buttonTitle: 'Edit',
|
||||
cancelTitle: 'Batal',
|
||||
)
|
||||
.then((value) async {
|
||||
bool result = await model
|
||||
.updateTempatSewa(request.data!.idTempatSerwa);
|
||||
// model.log.i("ini result: $result");
|
||||
if (result) {
|
||||
completer(DialogResponse(confirmed: true));
|
||||
}
|
||||
});
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rfid_app/model/penyewa_model.dart';
|
||||
|
||||
import '../../../../../app/app.logger.dart';
|
||||
import '../../../../../app/core/custom_base_view_model.dart';
|
||||
|
||||
class EditTempatSewaDialogViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('EditTempatSewaDialogViewModel');
|
||||
TextEditingController tempatSewaController = TextEditingController();
|
||||
TextEditingController sewaBulanController = TextEditingController();
|
||||
final formKey = GlobalKey<FormState>();
|
||||
|
||||
Future<void> init(PenyewaModel? data) async {
|
||||
log.d('init edit tempat sewa dialog');
|
||||
tempatSewaController.text = data!.namaTempatSewa!;
|
||||
sewaBulanController.text = data.hargaSewa!.toString();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<bool> updateTempatSewa(int? idTempatSerwa) async {
|
||||
String tempatSewa = tempatSewaController.text;
|
||||
String sewaBulan = sewaBulanController.text;
|
||||
|
||||
try {
|
||||
var formData = FormData.fromMap({
|
||||
'nama_tempat_sewa': tempatSewa,
|
||||
'harga_sewa': int.parse(sewaBulan),
|
||||
});
|
||||
easyLoading.customLoading('Updating...');
|
||||
await httpService.putWithFormData(
|
||||
'scan/tempat_sewa/$idTempatSerwa', formData);
|
||||
return true;
|
||||
} catch (e) {
|
||||
log.e(e);
|
||||
return false;
|
||||
} finally {
|
||||
easyLoading.dismiss();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,170 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import '../../../../app/themes/app_colors.dart';
|
||||
import '../../../../app/themes/app_text.dart';
|
||||
import './tempat_sewa_list_view_model.dart';
|
||||
|
||||
class TempatSewaListView extends StatelessWidget {
|
||||
const TempatSewaListView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<TempatSewaListViewModel>.reactive(
|
||||
viewModelBuilder: () => TempatSewaListViewModel(),
|
||||
onViewModelReady: (TempatSewaListViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
TempatSewaListViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async => false,
|
||||
child: Scaffold(
|
||||
body: Column(
|
||||
children: [
|
||||
Container(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: mainColor,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: mainGrey.withOpacity(0.5),
|
||||
spreadRadius: 5,
|
||||
blurRadius: 7,
|
||||
offset:
|
||||
const Offset(0, 3), // changes position of shadow
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Total Tempat Retribusi',
|
||||
style: regularTextStyle.copyWith(
|
||||
color: Colors.white,
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
model.tempatSewaList?.length.toString() ?? '...',
|
||||
style: regularTextStyle.copyWith(
|
||||
color: Colors.white,
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: mainGrey.withOpacity(0.5),
|
||||
spreadRadius: 5,
|
||||
blurRadius: 7,
|
||||
offset:
|
||||
const Offset(0, 3), // changes position of shadow
|
||||
),
|
||||
],
|
||||
),
|
||||
child: model.tempatSewaList == null
|
||||
? const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 15, vertical: 10),
|
||||
itemCount: model.tempatSewaList!.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Card(
|
||||
child: ListTile(
|
||||
title: Text(
|
||||
model
|
||||
.tempatSewaList![index].namaTempatSewa!,
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
subtitle: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Penyewa : ${model.tempatSewaList![index].nama}',
|
||||
),
|
||||
Text(
|
||||
'Harga : Rp. ${model.otherFunction.commaFormat(model.tempatSewaList![index].hargaSewa!)}',
|
||||
),
|
||||
],
|
||||
),
|
||||
// circle avatar
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () => model.snackbarService
|
||||
.showSnackbar(
|
||||
message:
|
||||
'Fitur sedang dalam tahap pengembangan'),
|
||||
child: Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
color: mainColor,
|
||||
borderRadius:
|
||||
BorderRadius.circular(50),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.list_alt_outlined,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
GestureDetector(
|
||||
onTap: () async =>
|
||||
await model.editTempatSewa(
|
||||
model.tempatSewaList![index],
|
||||
),
|
||||
child: Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
color: mainColor,
|
||||
borderRadius:
|
||||
BorderRadius.circular(50),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.edit_square,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
import '../../../../app/app.dialogs.dart';
|
||||
import '../../../../app/app.logger.dart';
|
||||
import '../../../../app/core/custom_base_view_model.dart';
|
||||
import '../../../../model/my_response_model.dart';
|
||||
import '../../../../model/penyewa_model.dart';
|
||||
|
||||
class TempatSewaListViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('TempatSewaListViewModel');
|
||||
List<PenyewaModel>? tempatSewaList;
|
||||
|
||||
Future<void> init() async {
|
||||
log.d('init tempat sewa list');
|
||||
await getData();
|
||||
}
|
||||
|
||||
getData() async {
|
||||
try {
|
||||
var response = await httpService.get('scan/tempat_sewa');
|
||||
MyResponseModel myResponseModel = MyResponseModel.fromJson(response.data);
|
||||
tempatSewaList = [];
|
||||
myResponseModel.data.forEach((item) {
|
||||
PenyewaModel penyewa = PenyewaModel.fromJson(item);
|
||||
tempatSewaList!.add(penyewa);
|
||||
log.d(penyewa);
|
||||
});
|
||||
notifyListeners();
|
||||
} catch (e) {
|
||||
log.e(e);
|
||||
// snackbarService.showSnackbar(message: 'Error: $e');
|
||||
}
|
||||
}
|
||||
|
||||
editTempatSewa(PenyewaModel penyewaModel) async {
|
||||
var res = await dialogService.showCustomDialog(
|
||||
variant: DialogType.editTempatSewaDialogView,
|
||||
data: penyewaModel,
|
||||
);
|
||||
log.i("ini res: ${res!.confirmed}");
|
||||
if (res.confirmed) {
|
||||
snackbarService.showSnackbar(message: 'Berhasil Update Data');
|
||||
getData();
|
||||
}
|
||||
}
|
||||
}
|
||||
61
lib/ui/views/splash_screen/splash_screen_view.dart
Normal file
61
lib/ui/views/splash_screen/splash_screen_view.dart
Normal file
@ -0,0 +1,61 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import '../../../app/themes/app_text.dart';
|
||||
import './splash_screen_view_model.dart';
|
||||
|
||||
class SplashScreenView extends StatelessWidget {
|
||||
const SplashScreenView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<SplashScreenViewModel>.nonReactive(
|
||||
viewModelBuilder: () => SplashScreenViewModel(),
|
||||
onViewModelReady: (SplashScreenViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
SplashScreenViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Scaffold(
|
||||
// backgroundColor: mainColor,
|
||||
body: Column(
|
||||
children: [
|
||||
const SizedBox(),
|
||||
Expanded(
|
||||
child: Center(
|
||||
// show the logo.png
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Image(
|
||||
image: AssetImage("assets/logo.png"),
|
||||
width: 200,
|
||||
height: 200,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
"Sistem Retribusi Pasar Enrekang",
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 20,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const Text(
|
||||
"Jln Panti Asuhan No. 3 Ujung Lare, Kec. Soreang, Kota Parepare, Sulawesi Selatan 91133",
|
||||
textAlign: TextAlign.center,
|
||||
style: regularTextStyle,
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
18
lib/ui/views/splash_screen/splash_screen_view_model.dart
Normal file
18
lib/ui/views/splash_screen/splash_screen_view_model.dart
Normal file
@ -0,0 +1,18 @@
|
||||
import 'package:rfid_app/app/core/custom_base_view_model.dart';
|
||||
|
||||
import '../../../app/app.logger.dart';
|
||||
import '../../../app/app.router.dart';
|
||||
|
||||
class SplashScreenViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('SplashScreenViewModel');
|
||||
Future<void> init() async {
|
||||
await Future.delayed(const Duration(seconds: 2));
|
||||
// navigate to login page
|
||||
// ignore: use_build_context_synchronously
|
||||
socketIoClient.init();
|
||||
socketIoClient.on('coba', (data) {
|
||||
log.i('data : $data');
|
||||
});
|
||||
navigationService.replaceWith(Routes.loginScreenView);
|
||||
}
|
||||
}
|
||||
34
lib/ui/widgets/my_button.dart
Normal file
34
lib/ui/widgets/my_button.dart
Normal file
@ -0,0 +1,34 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../app/themes/app_colors.dart';
|
||||
|
||||
class MyButton extends StatelessWidget {
|
||||
const MyButton({
|
||||
Key? key,
|
||||
required this.text,
|
||||
this.onPressed,
|
||||
}) : super(key: key);
|
||||
|
||||
final String text;
|
||||
final VoidCallback? onPressed;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: mainColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
),
|
||||
),
|
||||
onPressed: onPressed,
|
||||
child: Text(
|
||||
text,
|
||||
style: const TextStyle(
|
||||
color: backgroundColor,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
91
lib/ui/widgets/my_textformfield.dart
Normal file
91
lib/ui/widgets/my_textformfield.dart
Normal file
@ -0,0 +1,91 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../app/themes/app_colors.dart';
|
||||
|
||||
class MyTextFormField extends StatelessWidget {
|
||||
const MyTextFormField({
|
||||
Key? key,
|
||||
this.labelText,
|
||||
this.hintText,
|
||||
this.obscureText,
|
||||
this.validator,
|
||||
this.suffixIcon,
|
||||
this.prefixIcon,
|
||||
this.focusNode,
|
||||
this.controller,
|
||||
this.maxLines = 1,
|
||||
this.onEditingComplete,
|
||||
this.readOnly = false,
|
||||
this.onTap,
|
||||
this.keyboardType = TextInputType.text,
|
||||
this.initialValue,
|
||||
this.enabled = true,
|
||||
this.maxLength,
|
||||
}) : super(key: key);
|
||||
|
||||
final String? labelText;
|
||||
final String? hintText;
|
||||
final bool? obscureText;
|
||||
final FormFieldValidator<String>? validator;
|
||||
final Widget? suffixIcon;
|
||||
final Widget? prefixIcon;
|
||||
final FocusNode? focusNode;
|
||||
final TextEditingController? controller;
|
||||
final int maxLines;
|
||||
final VoidCallback? onEditingComplete;
|
||||
final bool readOnly;
|
||||
final VoidCallback? onTap;
|
||||
final TextInputType keyboardType;
|
||||
final String? initialValue;
|
||||
final bool enabled;
|
||||
final int? maxLength;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TextFormField(
|
||||
maxLength: maxLength,
|
||||
enabled: enabled,
|
||||
initialValue: initialValue,
|
||||
onEditingComplete: onEditingComplete,
|
||||
maxLines: maxLines,
|
||||
controller: controller,
|
||||
focusNode: focusNode,
|
||||
obscureText: obscureText ?? false,
|
||||
readOnly: readOnly,
|
||||
onTap: onTap,
|
||||
keyboardType: keyboardType,
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: prefixIcon,
|
||||
suffixIcon: suffixIcon,
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(25)),
|
||||
borderSide: BorderSide(
|
||||
color: mainColor,
|
||||
),
|
||||
),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(25)),
|
||||
borderSide: BorderSide(
|
||||
color: mainColor,
|
||||
),
|
||||
),
|
||||
focusedErrorBorder: const OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(25)),
|
||||
borderSide: BorderSide(
|
||||
color: dangerColor,
|
||||
),
|
||||
),
|
||||
errorBorder: const OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(25)),
|
||||
borderSide: BorderSide(
|
||||
color: dangerColor,
|
||||
),
|
||||
),
|
||||
labelText: labelText,
|
||||
hintText: hintText,
|
||||
labelStyle: const TextStyle(color: fontColor),
|
||||
),
|
||||
validator: validator,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user