first commit
This commit is contained in:
@ -0,0 +1,117 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import '../../../../app/themes/app_colors.dart';
|
||||
import '../../../../app/themes/app_text.dart';
|
||||
import '../../../widgets/top_container.dart';
|
||||
import './admin_first_page_view_model.dart';
|
||||
|
||||
class AdminFirstPageView extends StatelessWidget {
|
||||
const AdminFirstPageView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<AdminFirstPageViewModel>.reactive(
|
||||
viewModelBuilder: () => AdminFirstPageViewModel(),
|
||||
onViewModelReady: (AdminFirstPageViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
AdminFirstPageViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Scaffold(
|
||||
body: WillPopScope(
|
||||
onWillPop: () async {
|
||||
// model.log.i('backPressed: ${model.globalVar.backPressed}');
|
||||
if (model.globalVar.backPressed == 'exitApp') {
|
||||
// model.back();
|
||||
model.quitApp(context);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
child: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const TopContainer(
|
||||
title: 'Jumlah Area',
|
||||
value: '10 Area',
|
||||
icon: Icons.place_outlined,
|
||||
background: warningColor,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
const TopContainer(
|
||||
title: 'Jumlah Caleg',
|
||||
value: '10 Caleg',
|
||||
icon: Icons.co_present_outlined,
|
||||
background: greenColor,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
const TopContainer(
|
||||
title: 'Jumlah Pemilih',
|
||||
value: '10 Pemilih',
|
||||
icon: Icons.people_alt_outlined,
|
||||
background: blueColor,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
text: 'Selamat Datang, ',
|
||||
style: regularTextStyle,
|
||||
children: [
|
||||
const TextSpan(
|
||||
text: 'Admin\n',
|
||||
style: boldTextStyle,
|
||||
),
|
||||
const TextSpan(
|
||||
text: 'Silahkan tambahkan data ',
|
||||
style: regularTextStyle,
|
||||
),
|
||||
TextSpan(
|
||||
text: 'Area ',
|
||||
style: boldTextStyle.copyWith(
|
||||
color: greenColor,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
const TextSpan(
|
||||
text: 'terlebih dahulu sebelum menambahkan data ',
|
||||
style: regularTextStyle,
|
||||
),
|
||||
TextSpan(
|
||||
text: 'Caleg',
|
||||
style: boldTextStyle.copyWith(
|
||||
color: greenColor,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
const TextSpan(
|
||||
text:
|
||||
'.\n\nData Pemilih akan diambil dari data yang dimasukkan oleh tim survei\n\n',
|
||||
style: regularTextStyle,
|
||||
),
|
||||
const TextSpan(
|
||||
text:
|
||||
'Jika terjadi kesalahan pada data, silahkan hubungi ',
|
||||
style: regularTextStyle,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
import '../../../../app/core/custom_base_view_model.dart';
|
||||
|
||||
class AdminFirstPageViewModel extends CustomBaseViewModel {
|
||||
Future<void> init() async {
|
||||
globalVar.backPressed = 'exitApp';
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
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 './admin_index_tracking_view_model.dart';
|
||||
|
||||
class AdminIndexTrackingView extends StatelessWidget {
|
||||
const AdminIndexTrackingView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<AdminIndexTrackingViewModel>.reactive(
|
||||
viewModelBuilder: () => AdminIndexTrackingViewModel(),
|
||||
onViewModelReady: (AdminIndexTrackingViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
AdminIndexTrackingViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Scaffold(
|
||||
extendBody: false,
|
||||
body: ExtendedNavigator(
|
||||
router: AdminIndexTrackingViewRouter(),
|
||||
navigatorKey: StackedService.nestedNavigationKey(2),
|
||||
),
|
||||
bottomNavigationBar: StylishBottomBar(
|
||||
items: [
|
||||
for (var item in model.bottomNavBarList)
|
||||
BottomBarItem(
|
||||
icon: Icon(item['icon'],
|
||||
color: model.currentIndex ==
|
||||
model.bottomNavBarList.indexOf(item)
|
||||
? warningColor
|
||||
: fontColor),
|
||||
title: Text(
|
||||
item['name'],
|
||||
style: regularTextStyle.copyWith(
|
||||
color: model.currentIndex ==
|
||||
model.bottomNavBarList.indexOf(item)
|
||||
? warningColor
|
||||
: fontColor,
|
||||
),
|
||||
// textAlign: TextAlign.l,
|
||||
),
|
||||
backgroundColor:
|
||||
model.currentIndex == model.bottomNavBarList.indexOf(item)
|
||||
? fontColor
|
||||
: fontColor,
|
||||
),
|
||||
],
|
||||
currentIndex: model.currentIndex,
|
||||
option: BubbleBarOptions(),
|
||||
hasNotch: true,
|
||||
backgroundColor: warningColor,
|
||||
onTap: (value) {
|
||||
model.handleNavigation(value);
|
||||
},
|
||||
// fabLocation: StylishBarFabLocation.center,
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
|
||||
import '../../../app/app.locator.dart';
|
||||
import '../../../app/app.logger.dart';
|
||||
import '../../../app/app.router.dart';
|
||||
import '../../../services/global_var.dart';
|
||||
|
||||
class AdminIndexTrackingViewModel extends IndexTrackingViewModel {
|
||||
final log = getLogger('AdminIndexTrackingViewModel');
|
||||
final globalVar = locator<GlobalVar>();
|
||||
final navigationService = locator<NavigationService>();
|
||||
|
||||
final _bottomNavBarList = [
|
||||
{
|
||||
'name': 'Area',
|
||||
'icon': Icons.place_outlined,
|
||||
'header': 'Halaman Area',
|
||||
},
|
||||
{
|
||||
'name': 'Caleg',
|
||||
'icon': Icons.co_present_outlined,
|
||||
'header': 'Halaman Caleg',
|
||||
},
|
||||
{
|
||||
'name': 'Tim\nSurvei',
|
||||
'icon': Icons.people_outlined,
|
||||
'header': 'Tim Survei',
|
||||
},
|
||||
{
|
||||
'name': 'Pengaturan',
|
||||
'icon': Icons.settings_outlined,
|
||||
'header': 'Halaman Pengaturan',
|
||||
},
|
||||
];
|
||||
|
||||
String header = 'Halaman Utama';
|
||||
|
||||
List<Map<String, dynamic>> get bottomNavBarList => _bottomNavBarList;
|
||||
|
||||
final List<String> _views = [
|
||||
AdminIndexTrackingViewRoutes.halamanAreaView,
|
||||
AdminIndexTrackingViewRoutes.halamanCalegView,
|
||||
AdminIndexTrackingViewRoutes.timSurveiView,
|
||||
AdminIndexTrackingViewRoutes.halamanPengaturanView,
|
||||
];
|
||||
|
||||
Future<void> init() async {
|
||||
globalVar.backPressed = 'exitApp';
|
||||
setIndex(3);
|
||||
// await super.init();
|
||||
}
|
||||
|
||||
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: 2,
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,139 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:validatorless/validatorless.dart';
|
||||
|
||||
import '../../../../app/themes/app_colors.dart';
|
||||
import '../../../widgets/my_button.dart';
|
||||
import '../../../widgets/my_textformfield.dart';
|
||||
import './halaman_area_view_model.dart';
|
||||
|
||||
class HalamanAreaView extends StatelessWidget {
|
||||
const HalamanAreaView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<HalamanAreaViewModel>.reactive(
|
||||
viewModelBuilder: () => HalamanAreaViewModel(),
|
||||
onViewModelReady: (HalamanAreaViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
HalamanAreaViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Scaffold(
|
||||
body: WillPopScope(
|
||||
onWillPop: () async {
|
||||
// model.log.i('backPressed: ${model.globalVar.backPressed}');
|
||||
if (model.globalVar.backPressed == 'exitApp') {
|
||||
// model.back();
|
||||
model.quitApp(context);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
child: SafeArea(
|
||||
child: Container(
|
||||
height: MediaQuery.of(context).size.height,
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Form(
|
||||
key: model.formKey,
|
||||
child: Column(
|
||||
children: [
|
||||
MyTextFormField(
|
||||
hintText: 'Nama Area',
|
||||
labelText: 'Nama Area',
|
||||
controller: model.namaAreaController,
|
||||
validator: Validatorless.required(
|
||||
'Nama Area tidak boleh kosong'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
SizedBox(
|
||||
width: 250,
|
||||
child: MyButton(
|
||||
text: 'Tambah Area',
|
||||
onPressed: () async {
|
||||
if (model.formKey.currentState!.validate()) {
|
||||
// close keyboard
|
||||
FocusScope.of(context).unfocus();
|
||||
bool res = await model.addArea();
|
||||
model.log.i('res: $res');
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Container(
|
||||
height: double.infinity,
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.grey),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: warningColor,
|
||||
),
|
||||
child: Column(
|
||||
// mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Jumlah Area: ${model.jumlahArea} area',
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
if (model.isBusy)
|
||||
const Center(
|
||||
child: CircularProgressIndicator()),
|
||||
if (!model.isBusy)
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
if (model.jumlahArea == 0)
|
||||
const Center(
|
||||
child: Text(
|
||||
'Belum ada area diinput')),
|
||||
if (model.jumlahArea > 0)
|
||||
for (var i = 0;
|
||||
i < model.jumlahArea;
|
||||
i++)
|
||||
Card(
|
||||
child: ListTile(
|
||||
leading: Text('${i + 1}'),
|
||||
title: Text(
|
||||
'${model.listAreaModel[i].namaArea}'),
|
||||
trailing: IconButton(
|
||||
// trash bin icon
|
||||
icon: const Icon(
|
||||
Icons.delete,
|
||||
color: Colors.red,
|
||||
),
|
||||
onPressed: () {
|
||||
model.deleteArea(model
|
||||
.listAreaModel[i]
|
||||
.idArea!);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../app/app.logger.dart';
|
||||
import '../../../../app/core/custom_base_view_model.dart';
|
||||
import '../../../../app/themes/app_colors.dart';
|
||||
import '../../../../model/area_model.dart';
|
||||
import '../../../../model/my_response.model.dart';
|
||||
|
||||
class HalamanAreaViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('HalamanAreaViewModel');
|
||||
|
||||
// variabel
|
||||
List<AreaModel> listAreaModel = [];
|
||||
int jumlahArea = 0;
|
||||
|
||||
// add area form
|
||||
final formKey = GlobalKey<FormState>();
|
||||
TextEditingController namaAreaController = TextEditingController();
|
||||
|
||||
Future<void> init() async {
|
||||
globalVar.backPressed = 'exitApp';
|
||||
await getData();
|
||||
}
|
||||
|
||||
getData() async {
|
||||
log.i('getData');
|
||||
setBusy(true);
|
||||
globalVar.backPressed = 'cantBack';
|
||||
try {
|
||||
var response = await httpService.get('area');
|
||||
log.i(response.data);
|
||||
MyResponseModel myResponseModel = MyResponseModel.fromJson(response.data);
|
||||
AreaListModel areaListModel =
|
||||
AreaListModel.fromJson(myResponseModel.data);
|
||||
listAreaModel = areaListModel.area!;
|
||||
jumlahArea = areaListModel.jumlah!;
|
||||
|
||||
log.i('listAreaModel: $listAreaModel');
|
||||
log.i('jumlahArea: $jumlahArea');
|
||||
} catch (e) {
|
||||
log.e(e);
|
||||
} finally {
|
||||
globalVar.backPressed = 'exitApp';
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> addArea() async {
|
||||
log.i('addArea');
|
||||
setBusy(true);
|
||||
globalVar.backPressed = 'cantBack';
|
||||
easyLoading.customLoading('Tambah Area..');
|
||||
|
||||
var formData = FormData.fromMap({
|
||||
'area': namaAreaController.text,
|
||||
});
|
||||
|
||||
try {
|
||||
var response = await httpService.postWithFormData('area', formData);
|
||||
log.i(response.data);
|
||||
await getData();
|
||||
return true;
|
||||
} catch (e) {
|
||||
log.e(e);
|
||||
return false;
|
||||
} finally {
|
||||
easyLoading.dismissLoading();
|
||||
globalVar.backPressed = 'exitApp';
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
deleteArea(int idArea) {
|
||||
dialogService
|
||||
.showDialog(
|
||||
title: 'Hapus Area',
|
||||
description: 'Apakah Anda yakin ingin menghapus area ini?',
|
||||
buttonTitle: 'Hapus',
|
||||
cancelTitle: 'Batal',
|
||||
buttonTitleColor: dangerColor,
|
||||
cancelTitleColor: mainColor,
|
||||
)
|
||||
.then((value) async {
|
||||
if (value!.confirmed) {
|
||||
log.i('deleteArea id_area: $idArea');
|
||||
setBusy(true);
|
||||
globalVar.backPressed = 'cantBack';
|
||||
easyLoading.customLoading('Hapus Area..');
|
||||
|
||||
try {
|
||||
var response = await httpService.delete('area/$idArea');
|
||||
log.i(response.data);
|
||||
await getData();
|
||||
} catch (e) {
|
||||
log.e(e);
|
||||
} finally {
|
||||
easyLoading.dismissLoading();
|
||||
globalVar.backPressed = 'exitApp';
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,131 @@
|
||||
import 'package:cek_suara/app/themes/app_text.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import '../../../../app/themes/app_colors.dart';
|
||||
import '../../../widgets/top_container.dart';
|
||||
import './halaman_caleg_view_model.dart';
|
||||
|
||||
class HalamanCalegView extends StatelessWidget {
|
||||
const HalamanCalegView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<HalamanCalegViewModel>.reactive(
|
||||
viewModelBuilder: () => HalamanCalegViewModel(),
|
||||
onViewModelReady: (HalamanCalegViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
HalamanCalegViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Scaffold(
|
||||
body: WillPopScope(
|
||||
onWillPop: () async {
|
||||
// model.log.i('backPressed: ${model.globalVar.backPressed}');
|
||||
if (model.globalVar.backPressed == 'exitApp') {
|
||||
// model.back();
|
||||
model.quitApp(context);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
child: SafeArea(
|
||||
child: Container(
|
||||
height: MediaQuery.of(context).size.height,
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
children: [
|
||||
TopContainer(
|
||||
title: 'Jumlah Caleg',
|
||||
value: '${model.jumlahCaleg} Caleg',
|
||||
icon: Icons.co_present_outlined,
|
||||
background: greenColor,
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Expanded(
|
||||
// flex: 3,
|
||||
child: Container(
|
||||
height: double.infinity,
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.grey),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: warningColor,
|
||||
),
|
||||
child: Column(
|
||||
// mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: model.isBusy
|
||||
? MainAxisAlignment.center
|
||||
: (model.listCalegModel.isNotEmpty
|
||||
? MainAxisAlignment.start
|
||||
: MainAxisAlignment.center),
|
||||
children: [
|
||||
if (model.isBusy)
|
||||
const LinearProgressIndicator(
|
||||
minHeight: 5,
|
||||
color: mainColor,
|
||||
),
|
||||
if (!model.isBusy &&
|
||||
model.listCalegModel.isNotEmpty)
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
for (var i = 0;
|
||||
i < model.jumlahCaleg;
|
||||
i++)
|
||||
Card(
|
||||
child: ListTile(
|
||||
leading: Text('${i + 1}'),
|
||||
title: Text(
|
||||
model
|
||||
.listCalegModel[i].namaCaleg!,
|
||||
style: boldTextStyle,
|
||||
),
|
||||
subtitle: Text(
|
||||
'No. Urut: ${model.listCalegModel[i].nomorUrutCaleg!}',
|
||||
style: italicTextStyle,
|
||||
),
|
||||
trailing: IconButton(
|
||||
icon: const Icon(Icons.edit,
|
||||
color: mainColor),
|
||||
onPressed: () {},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
if (!model.isBusy && model.listCalegModel.isEmpty)
|
||||
const Center(
|
||||
child: Text(
|
||||
'Tidak ada data caleg diinput sebelumnya',
|
||||
style: italicTextStyle,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () {
|
||||
model.addCaleg();
|
||||
},
|
||||
child: const Icon(Icons.add),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
import '../../../../app/app.dialogs.dart';
|
||||
import '../../../../app/app.logger.dart';
|
||||
import '../../../../app/core/custom_base_view_model.dart';
|
||||
import '../../../../model/caleg_model.dart';
|
||||
import '../../../../model/my_response.model.dart';
|
||||
|
||||
class HalamanCalegViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('HalamanCalegViewModel');
|
||||
|
||||
// variabel
|
||||
List<CalegModel> listCalegModel = [];
|
||||
int jumlahCaleg = 0;
|
||||
|
||||
Future<void> init() async {
|
||||
globalVar.backPressed = 'exitApp';
|
||||
await getData();
|
||||
}
|
||||
|
||||
getData() async {
|
||||
log.i('getData');
|
||||
setBusy(true);
|
||||
globalVar.backPressed = 'cantBack';
|
||||
try {
|
||||
var response = await httpService.get('caleg');
|
||||
log.i(response.data);
|
||||
MyResponseModel myResponseModel = MyResponseModel.fromJson(response.data);
|
||||
CalegListModel calegListModel =
|
||||
CalegListModel.fromJson(myResponseModel.data);
|
||||
listCalegModel = calegListModel.caleg!;
|
||||
jumlahCaleg = calegListModel.jumlah!;
|
||||
|
||||
log.i('listCalegModel: $listCalegModel');
|
||||
log.i('jumlahCaleg: $jumlahCaleg');
|
||||
} catch (e) {
|
||||
log.e(e);
|
||||
} finally {
|
||||
globalVar.backPressed = 'exitApp';
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
addCaleg() async {
|
||||
// log.i('addCaleg');
|
||||
var res = await dialogService.showCustomDialog(
|
||||
variant: DialogType.tambahEditCalegView,
|
||||
data: {
|
||||
'title': 'Tambah Caleg',
|
||||
},
|
||||
);
|
||||
|
||||
log.i(res?.confirmed);
|
||||
}
|
||||
}
|
@ -0,0 +1,216 @@
|
||||
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 '../../../../../app/themes/app_text.dart';
|
||||
import '../../../../widgets/my_button.dart';
|
||||
import '../../../../widgets/my_textformfield.dart';
|
||||
import './tambah_edit_caleg_view_model.dart';
|
||||
|
||||
class TambahEditCalegView extends StatelessWidget {
|
||||
final DialogRequest? request;
|
||||
final Function(DialogResponse)? completer;
|
||||
|
||||
const TambahEditCalegView({
|
||||
Key? key,
|
||||
this.request,
|
||||
this.completer,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<TambahEditCalegViewModel>.reactive(
|
||||
viewModelBuilder: () => TambahEditCalegViewModel(),
|
||||
onViewModelReady: (TambahEditCalegViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
TambahEditCalegViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Dialog(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(15),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: backgroundColor,
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Form(
|
||||
key: model.formKey,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
request?.data['title'] ?? '',
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Stack(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: 50,
|
||||
backgroundColor: fontParagraphColor,
|
||||
child: model.imageBytes == null
|
||||
? const Icon(
|
||||
Icons.person,
|
||||
size: 50,
|
||||
color: Colors.white,
|
||||
)
|
||||
: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(50),
|
||||
child: Image.memory(
|
||||
model.imageBytes!,
|
||||
width: 100,
|
||||
height: 100,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
right: 0,
|
||||
child: CircleAvatar(
|
||||
radius: 15,
|
||||
backgroundColor: warningColor,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
model.addImage();
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.add,
|
||||
color: fontColor,
|
||||
size: 15,
|
||||
)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MyTextFormField(
|
||||
hintText: 'Masukan Nama Caleg',
|
||||
labelText: 'Nama Caleg',
|
||||
controller: model.namaController,
|
||||
validator: Validatorless.required(
|
||||
'Nama Caleg tidak boleh kosong'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MyTextFormField(
|
||||
hintText: 'Area',
|
||||
labelText: 'Pencarian Area',
|
||||
controller: model.cariAreaController,
|
||||
suffixIcon: GestureDetector(
|
||||
onTap: () {
|
||||
// remove keyboard focus
|
||||
FocusScope.of(context).unfocus();
|
||||
model.cariArea();
|
||||
},
|
||||
child: const Icon(Icons.search),
|
||||
),
|
||||
|
||||
// controller: model.partaiController,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height * 0.3,
|
||||
width: double.infinity,
|
||||
|
||||
// create 10 random checkbox
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (model.isBusy)
|
||||
const Center(child: CircularProgressIndicator()),
|
||||
if (!model.isBusy && model.listAreaModel.isNotEmpty)
|
||||
// FutureBuilder(future: , builder: builder)
|
||||
Wrap(
|
||||
spacing: 10,
|
||||
children: List.generate(
|
||||
model.listAreaModel.length,
|
||||
(index) => Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Checkbox(
|
||||
value: model.listAreaId.contains(
|
||||
model.listAreaModel[index].idArea!),
|
||||
onChanged: (value) {
|
||||
model.tambahHapusArea(
|
||||
model.listAreaModel[index].idArea!,
|
||||
);
|
||||
},
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
model.listAreaModel[index].namaArea!,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
if (!model.isBusy && model.listAreaModel.isEmpty)
|
||||
Center(
|
||||
child: RichText(
|
||||
textAlign: TextAlign.center,
|
||||
text: TextSpan(
|
||||
text: 'Tidak ada pencarian area\n',
|
||||
style: regularTextStyle,
|
||||
children: [
|
||||
TextSpan(
|
||||
text:
|
||||
' ${model.cariAreaController.text}',
|
||||
style: boldTextStyle.copyWith(
|
||||
color: dangerColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
SizedBox(
|
||||
width: 250,
|
||||
child: MyButton(
|
||||
text: 'Tambah Caleg',
|
||||
onPressed: () async {
|
||||
if (model.listAreaId.isEmpty) {
|
||||
model.snackbarService.showSnackbar(
|
||||
message:
|
||||
'Pilih Area Calon Legislatif terlebih dahulu',
|
||||
duration: const Duration(seconds: 2),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (model.imageBytes == null) {
|
||||
model.snackbarService.showSnackbar(
|
||||
message:
|
||||
'Pilih Foto Calon Legislatif terlebih dahulu',
|
||||
duration: const Duration(seconds: 2),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (model.formKey.currentState!.validate()) {
|
||||
model.addCaleg();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,165 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http_parser/http_parser.dart';
|
||||
|
||||
import '../../../../../app/app.logger.dart';
|
||||
import '../../../../../app/core/custom_base_view_model.dart';
|
||||
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
import '../../../../../model/area_model.dart';
|
||||
import '../../../../../model/my_response.model.dart';
|
||||
|
||||
class TambahEditCalegViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('TambahEditCalegViewModel');
|
||||
|
||||
// variabel list area
|
||||
List<AreaModel> listAreaModel = [];
|
||||
List<AreaModel> allListAreaModel = [];
|
||||
|
||||
// form variable
|
||||
final formKey = GlobalKey<FormState>();
|
||||
TextEditingController namaController = TextEditingController();
|
||||
TextEditingController cariAreaController = TextEditingController();
|
||||
List<int> listAreaId = [];
|
||||
|
||||
// image picker
|
||||
String? _imagePath;
|
||||
final ImagePicker _picker = ImagePicker();
|
||||
XFile? imageFile;
|
||||
Uint8List? imageBytes;
|
||||
|
||||
Future<void> init() async {
|
||||
globalVar.backPressed = 'exitApp';
|
||||
await getData();
|
||||
}
|
||||
|
||||
getData() async {
|
||||
log.i('getData');
|
||||
setBusy(true);
|
||||
globalVar.backPressed = 'cantBack';
|
||||
try {
|
||||
var response = await httpService.get('area');
|
||||
log.i(response.data);
|
||||
MyResponseModel myResponseModel = MyResponseModel.fromJson(response.data);
|
||||
AreaListModel areaListModel =
|
||||
AreaListModel.fromJson(myResponseModel.data);
|
||||
listAreaModel = areaListModel.area!;
|
||||
allListAreaModel = areaListModel.area!;
|
||||
// jumlahArea = areaListModel.jumlah!;
|
||||
|
||||
log.i('listAreaModel: $listAreaModel');
|
||||
// log.i('jumlahArea: $jumlahArea');
|
||||
} catch (e) {
|
||||
log.e(e);
|
||||
} finally {
|
||||
globalVar.backPressed = 'exitApp';
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
void addImage() async {
|
||||
try {
|
||||
final XFile? image = await _picker.pickImage(source: ImageSource.gallery);
|
||||
if (image != null) {
|
||||
imageFile = image;
|
||||
_imagePath = image.path;
|
||||
imageBytes = await image.readAsBytes();
|
||||
|
||||
log.i('image path: $_imagePath');
|
||||
notifyListeners();
|
||||
}
|
||||
} catch (e) {
|
||||
log.e(e);
|
||||
}
|
||||
}
|
||||
|
||||
tambahHapusArea(int idArea) {
|
||||
log.i('tambahHapusArea');
|
||||
if (listAreaId.contains(idArea)) {
|
||||
listAreaId.remove(idArea);
|
||||
} else {
|
||||
listAreaId.add(idArea);
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
cariArea() {
|
||||
log.i('cariArea ${cariAreaController.text}');
|
||||
|
||||
if (cariAreaController.text.isEmpty) {
|
||||
listAreaModel = allListAreaModel;
|
||||
return;
|
||||
}
|
||||
|
||||
listAreaModel = allListAreaModel
|
||||
.where((element) => element.namaArea!
|
||||
.toLowerCase()
|
||||
.contains(cariAreaController.text.toLowerCase()))
|
||||
.toList();
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
addCaleg() async {
|
||||
dialogService
|
||||
.showDialog(
|
||||
title: 'Tambah Caleg',
|
||||
description:
|
||||
'Apakah anda yakin ingin menambahkan Caleg ${namaController.text}?',
|
||||
buttonTitle: 'Ya',
|
||||
cancelTitle: 'Tidak',
|
||||
)
|
||||
.then((value) async {
|
||||
if (value!.confirmed) {
|
||||
log.i('addCaleg');
|
||||
setBusy(true);
|
||||
globalVar.backPressed = 'cantBack';
|
||||
easyLoading.customLoading('Tambah Caleg..');
|
||||
|
||||
var formData = FormData.fromMap({
|
||||
'nama': namaController.text,
|
||||
'area': const JsonEncoder().convert(listAreaId),
|
||||
'foto': await MultipartFile.fromFile(
|
||||
imageFile!.path,
|
||||
filename: imageFile!.name,
|
||||
contentType: MediaType('image', 'jpeg'),
|
||||
)
|
||||
});
|
||||
|
||||
try {
|
||||
var response = await httpService.postWithFormData('caleg', formData);
|
||||
log.i(response.data);
|
||||
await getData();
|
||||
|
||||
navigationService.back();
|
||||
// navigationService.back();
|
||||
snackbarService.showSnackbar(
|
||||
message: 'Berhasil menambahkan Caleg',
|
||||
duration: const Duration(seconds: 2),
|
||||
);
|
||||
// navigationService.popRepeated(2);
|
||||
} catch (e) {
|
||||
log.e(e);
|
||||
|
||||
// navigationService.back();
|
||||
snackbarService.showSnackbar(
|
||||
message: 'Gagal menambahkan Caleg, ${e.toString()}',
|
||||
duration: const Duration(seconds: 2),
|
||||
);
|
||||
} finally {
|
||||
easyLoading.dismissLoading();
|
||||
globalVar.backPressed = 'exitApp';
|
||||
setBusy(false);
|
||||
// navigationService.back();
|
||||
// Navigator.of(context!).pop();
|
||||
// remove all dialog
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import './halaman_pengaturan_view_model.dart';
|
||||
|
||||
class HalamanPengaturanView extends StatelessWidget {
|
||||
const HalamanPengaturanView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<HalamanPengaturanViewModel>.reactive(
|
||||
viewModelBuilder: () => HalamanPengaturanViewModel(),
|
||||
onViewModelReady: (HalamanPengaturanViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
HalamanPengaturanViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Scaffold(
|
||||
body: WillPopScope(
|
||||
onWillPop: () async {
|
||||
// model.log.i('backPressed: ${model.globalVar.backPressed}');
|
||||
if (model.globalVar.backPressed == 'exitApp') {
|
||||
// model.back();
|
||||
model.quitApp(context);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
child: const Center(
|
||||
child: Text(
|
||||
'HalamanPengaturanView',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
import '../../../../app/core/custom_base_view_model.dart';
|
||||
|
||||
class HalamanPengaturanViewModel extends CustomBaseViewModel {
|
||||
Future<void> init() async {
|
||||
globalVar.backPressed = 'exitApp';
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import './tim_survei_view_model.dart';
|
||||
|
||||
class TimSurveiView extends StatelessWidget {
|
||||
const TimSurveiView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<TimSurveiViewModel>.reactive(
|
||||
viewModelBuilder: () => TimSurveiViewModel(),
|
||||
onViewModelReady: (TimSurveiViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
TimSurveiViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Scaffold(
|
||||
body: WillPopScope(
|
||||
onWillPop: () async {
|
||||
// model.log.i('backPressed: ${model.globalVar.backPressed}');
|
||||
if (model.globalVar.backPressed == 'exitApp') {
|
||||
// model.back();
|
||||
model.quitApp(context);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
child: const Center(
|
||||
child: Text(
|
||||
'TimSurveiView',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
import '../../../../app/core/custom_base_view_model.dart';
|
||||
|
||||
class TimSurveiViewModel extends CustomBaseViewModel {
|
||||
Future<void> init() async {
|
||||
globalVar.backPressed = 'exitApp';
|
||||
}
|
||||
}
|
102
lib/ui/views/login_screen/login_screen_view.dart
Normal file
102
lib/ui/views/login_screen/login_screen_view.dart
Normal file
@ -0,0 +1,102 @@
|
||||
import 'package:cek_suara/app/themes/app_colors.dart';
|
||||
import 'package:cek_suara/ui/widgets/my_button.dart';
|
||||
import 'package:cek_suara/ui/widgets/my_textformfield.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.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(
|
||||
backgroundColor: warningColor,
|
||||
body: WillPopScope(
|
||||
onWillPop: () async {
|
||||
model.log.i('backPressed: ${model.globalVar.backPressed}');
|
||||
if (model.globalVar.backPressed == 'backNormal') {
|
||||
// model.back();
|
||||
model.quitApp(context);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
child: SafeArea(
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 50,
|
||||
),
|
||||
Center(
|
||||
child: Image.asset(
|
||||
'assets/logo.png',
|
||||
width: 200,
|
||||
height: 200,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
const Text(
|
||||
'Halaman Login',
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
const MyTextFormField(
|
||||
// controller: model.usernameController,
|
||||
hintText: 'Username',
|
||||
// prefixIcon: Icons.person,
|
||||
obscureText: false,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
const MyTextFormField(
|
||||
// controller: model.passwordController,
|
||||
hintText: 'Password',
|
||||
suffixIcon: Icon(Icons.lock),
|
||||
obscureText: true,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
SizedBox(
|
||||
width: 250,
|
||||
child: MyButton(
|
||||
// theBackgroundColor: lightColor,
|
||||
textColor: fontColor,
|
||||
text: 'Login',
|
||||
onPressed: () {
|
||||
model.login();
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
21
lib/ui/views/login_screen/login_screen_view_model.dart
Normal file
21
lib/ui/views/login_screen/login_screen_view_model.dart
Normal file
@ -0,0 +1,21 @@
|
||||
import '../../../app/app.router.dart';
|
||||
|
||||
import '../../../app/app.logger.dart';
|
||||
import '../../../app/core/custom_base_view_model.dart';
|
||||
|
||||
class LoginScreenViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('LoginScreenViewModel');
|
||||
Future<void> init() async {
|
||||
globalVar.backPressed = 'backNormal';
|
||||
}
|
||||
|
||||
login() async {
|
||||
easyLoading.customLoading('Login..');
|
||||
globalVar.backPressed = 'cantBack';
|
||||
await Future.delayed(const Duration(seconds: 2));
|
||||
easyLoading.dismissLoading();
|
||||
globalVar.backPressed = 'backNormal';
|
||||
// navigationService.pushNamedAndRemoveUntil('/home-screen');
|
||||
await navigationService.navigateToAdminIndexTrackingView();
|
||||
}
|
||||
}
|
90
lib/ui/views/splash_screen/splash_screen_view.dart
Normal file
90
lib/ui/views/splash_screen/splash_screen_view.dart
Normal file
@ -0,0 +1,90 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import '../../../app/themes/app_colors.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>.reactive(
|
||||
viewModelBuilder: () => SplashScreenViewModel(),
|
||||
onViewModelReady: (SplashScreenViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
SplashScreenViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Scaffold(
|
||||
backgroundColor: warningColor,
|
||||
body: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
const Expanded(
|
||||
flex: 1,
|
||||
child: SizedBox(
|
||||
height: 100,
|
||||
),
|
||||
),
|
||||
Image.asset(
|
||||
'assets/logo.png',
|
||||
width: 200,
|
||||
height: 200,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Text(
|
||||
'SISTEM CEK SUARA',
|
||||
style: boldTextStyle.copyWith(
|
||||
// color: backgroundColor,
|
||||
fontSize: 20,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
Text(
|
||||
'(Admin App)',
|
||||
style: boldTextStyle.copyWith(
|
||||
// color: backgroundColor,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const Expanded(child: SizedBox()),
|
||||
Text(
|
||||
'Created By',
|
||||
style: regularTextStyle.copyWith(
|
||||
fontSize: 12,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
Text(
|
||||
'Kicap Karan',
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 13,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
Text(
|
||||
'www.kicap-karan.com',
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 13,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
12
lib/ui/views/splash_screen/splash_screen_view_model.dart
Normal file
12
lib/ui/views/splash_screen/splash_screen_view_model.dart
Normal file
@ -0,0 +1,12 @@
|
||||
import '../../../app/app.logger.dart';
|
||||
import '../../../app/app.router.dart';
|
||||
import '../../../app/core/custom_base_view_model.dart';
|
||||
|
||||
class SplashScreenViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('SplashScreenViewModel');
|
||||
Future<void> init() async {
|
||||
// await 3 seconds then go to login
|
||||
await Future.delayed(const Duration(seconds: 3));
|
||||
await navigationService.navigateTo(Routes.loginScreenView);
|
||||
}
|
||||
}
|
38
lib/ui/widgets/my_button.dart
Normal file
38
lib/ui/widgets/my_button.dart
Normal file
@ -0,0 +1,38 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../app/themes/app_colors.dart';
|
||||
|
||||
class MyButton extends StatelessWidget {
|
||||
const MyButton({
|
||||
Key? key,
|
||||
required this.text,
|
||||
this.theBackgroundColor = mainColor,
|
||||
this.textColor = backgroundColor,
|
||||
this.onPressed,
|
||||
}) : super(key: key);
|
||||
|
||||
final String text;
|
||||
final VoidCallback? onPressed;
|
||||
final Color theBackgroundColor;
|
||||
final Color textColor;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: theBackgroundColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
),
|
||||
),
|
||||
onPressed: onPressed,
|
||||
child: Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
color: textColor,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
73
lib/ui/widgets/my_textformfield.dart
Normal file
73
lib/ui/widgets/my_textformfield.dart
Normal file
@ -0,0 +1,73 @@
|
||||
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,
|
||||
}) : 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;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TextFormField(
|
||||
onEditingComplete: onEditingComplete,
|
||||
maxLines: maxLines,
|
||||
controller: controller,
|
||||
focusNode: focusNode,
|
||||
obscureText: obscureText ?? false,
|
||||
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,
|
||||
);
|
||||
}
|
||||
}
|
73
lib/ui/widgets/top_container.dart
Normal file
73
lib/ui/widgets/top_container.dart
Normal file
@ -0,0 +1,73 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../app/themes/app_colors.dart';
|
||||
|
||||
class TopContainer extends StatelessWidget {
|
||||
const TopContainer({
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.value,
|
||||
required this.icon,
|
||||
required this.background,
|
||||
});
|
||||
|
||||
final String title;
|
||||
final String value;
|
||||
final IconData icon;
|
||||
final Color background;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: background,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
color: fontGrey,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
textAlign: TextAlign.justify,
|
||||
),
|
||||
),
|
||||
const Expanded(
|
||||
flex: 1,
|
||||
child: Text(
|
||||
':',
|
||||
style: TextStyle(
|
||||
color: fontGrey,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: Text(
|
||||
value,
|
||||
style: const TextStyle(
|
||||
color: fontGrey,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
Icon(
|
||||
icon,
|
||||
color: fontGrey,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user