Skip to content

Commit

Permalink
fix: filtering by date range in the "My Orders" page
Browse files Browse the repository at this point in the history
  • Loading branch information
fleetimee committed Apr 2, 2023
1 parent 092af12 commit 7e3f844
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 87 deletions.
3 changes: 3 additions & 0 deletions lib/app/modules/home/controllers/home_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ class HomeController extends GetxController {
// Controller for formKey
final formKey = GlobalKey<FormBuilderState>();

// Index for tabbar
var selectedIndex = 0.obs;

// Bunch of controllers for textfield
var uid = TextEditingController();
var setPassword = TextEditingController();
Expand Down
65 changes: 43 additions & 22 deletions lib/app/modules/home/widget/home_history_and_submission.dart
Original file line number Diff line number Diff line change
@@ -1,30 +1,39 @@
// 🐦 Flutter imports:
import 'package:akm/app/common/style.dart';
import 'package:akm/app/modules/home/controllers/home_controller.dart';
import 'package:akm/app/modules/home/widget/components/home_history_and_submission.dart/empty_history_and_submission.dart';
import 'package:akm/app/modules/home/widget/components/home_history_and_submission.dart/list_riwayat_input.dart';
import 'package:akm/app/modules/home/widget/components/home_history_and_submission.dart/list_riwayat_pengajuan.dart';
import 'package:akm/app/routes/app_pages.dart';
import 'package:avatar_glow/avatar_glow.dart';
import 'package:bootstrap_alert/bootstrap_alert.dart';
import 'package:flutter/material.dart';

// 📦 Package imports:
import 'package:get/get.dart';
import 'package:scaffold_gradient_background/scaffold_gradient_background.dart';

class HomeHistoryAndSubmission extends StatelessWidget {
class HomeHistoryAndSubmission extends StatefulWidget {
final HomeController controller;

const HomeHistoryAndSubmission({
super.key,
required this.controller,
});

@override
State<HomeHistoryAndSubmission> createState() =>
_HomeHistoryAndSubmissionState();
}

class _HomeHistoryAndSubmissionState extends State<HomeHistoryAndSubmission> {
final bool _showAlert = true;
final int selectedIndex = 0;

int selectedIndex = 0;

@override
Widget build(BuildContext context) {
return DefaultTabController(
initialIndex: selectedIndex,
length: 2,
child: ScaffoldGradientBackground(
gradient: LinearGradient(
Expand All @@ -37,10 +46,15 @@ class HomeHistoryAndSubmission extends StatelessWidget {
),
body: Column(
children: [
const TabBar(
physics: NeverScrollableScrollPhysics(),
TabBar(
onTap: (index) {
setState(() {
selectedIndex = index;
});
},
physics: const NeverScrollableScrollPhysics(),
indicatorColor: Colors.white,
tabs: [
tabs: const [
Tab(
text: 'Riwayat Penginputan',
icon: Icon(Icons.history),
Expand All @@ -56,12 +70,12 @@ class HomeHistoryAndSubmission extends StatelessWidget {
physics: const NeverScrollableScrollPhysics(),
children: [
Obx(() {
if (controller.isMyInputProcessing.value) {
if (widget.controller.isMyInputProcessing.value) {
return const Center(
child: CircularProgressIndicator(),
);
} else {
if (controller.listMyInput.isNotEmpty) {
if (widget.controller.listMyInput.isNotEmpty) {
return Column(
children: [
BootstrapAlert(
Expand Down Expand Up @@ -105,29 +119,29 @@ class HomeHistoryAndSubmission extends StatelessWidget {
),
Expanded(
child: ListRiwayatInput(
controller: controller,
controller: widget.controller,
),
),
],
);
} else {
return EmptyHistoryAndSubmission(
controller: controller,
controller: widget.controller,
text: 'Belum ada riwayat penginputan',
onPressed: () {
controller.refreshInputtan();
widget.controller.refreshInputtan();
},
);
}
}
}),
Obx(() {
if (controller.isMySubmissionProcessing.value) {
if (widget.controller.isMySubmissionProcessing.value) {
return const Center(
child: CircularProgressIndicator(),
);
} else {
if (controller.listMySubmission.isNotEmpty) {
if (widget.controller.listMySubmission.isNotEmpty) {
return Column(
children: [
BootstrapAlert(
Expand All @@ -145,17 +159,17 @@ class HomeHistoryAndSubmission extends StatelessWidget {
),
Expanded(
child: ListRiwayatPengajuan(
controller: controller,
controller: widget.controller,
),
),
],
);
} else {
return EmptyHistoryAndSubmission(
controller: controller,
controller: widget.controller,
text: 'Belum ada riwayat pengajuan',
onPressed: () {
controller.refreshPengajuan();
widget.controller.refreshPengajuan();
},
);
}
Expand All @@ -167,13 +181,20 @@ class HomeHistoryAndSubmission extends StatelessWidget {
],
),
floatingActionButton: selectedIndex == 0
? FloatingActionButton(
onPressed: () {
Get.toNamed('/home/input');
},
child: const Icon(Icons.add),
? AvatarGlow(
endRadius: 50,
child: FloatingActionButton(
backgroundColor: primaryColor,
elevation: 10,
onPressed: () {
Get.toNamed(Routes.LIST_DEBITUR);
},
child: const Icon(
Icons.search_outlined,
),
),
)
: null,
: const SizedBox.shrink(),
),
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import 'package:flutter/material.dart';

class FilterLabel extends StatelessWidget {
final String text;

const FilterLabel({super.key, required this.text});

@override
Widget build(BuildContext context) {
return Align(
alignment: Alignment.topLeft,
child: Padding(
padding: const EdgeInsets.only(left: 48),
child: Text(
text,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
),
);
}
}
103 changes: 38 additions & 65 deletions lib/app/modules/list_debitur/widget/list_debitur_filter_fab.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// 🐦 Flutter imports:
import 'package:akm/app/modules/list_debitur/widget/components/list_debitur_filter_fab/label_text.dart';
import 'package:flutter/material.dart';

// 📦 Package imports:
Expand Down Expand Up @@ -37,8 +38,13 @@ class ListDebiturFilterFab extends StatelessWidget {
showMaterialModalBottomSheet(
context: context,
builder: (context) {
return SafeArea(
child: Container(
return Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar(
title: const Text('Filter'),
leading: const SizedBox.shrink(),
),
body: Container(
padding: const EdgeInsets.all(16),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
Expand All @@ -50,17 +56,8 @@ class ListDebiturFilterFab extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Align(
alignment: Alignment.topLeft,
child: Text(
'Umur',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
),
const SizedBox(height: 10),
const FilterLabel(text: 'Filter berdasarkan Umur'),
const SizedBox(height: 16),
Obx(
() => Row(
children: [
Expand Down Expand Up @@ -98,14 +95,22 @@ class ListDebiturFilterFab extends StatelessWidget {
]),
keyboardType: TextInputType.number,
controller: controller.filterUmurInput,
decoration: const InputDecoration(
prefixIcon:
Icon(FontAwesomeIcons.odnoklassniki),
hintText: 'Filter berdasarkan Umur',
border: OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10),
),
decoration: InputDecoration(
hintText: 'Masukkan umur',
filled: true,
suffixText: 'Tahun',
suffixStyle: const TextStyle(
fontSize: 16,
),
fillColor: Colors.grey.shade400,
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color:
Theme.of(context).primaryColor),
),
enabledBorder: const OutlineInputBorder(
borderSide:
BorderSide(color: Colors.grey),
),
),
enabled:
Expand All @@ -127,17 +132,9 @@ class ListDebiturFilterFab extends StatelessWidget {
],
),
),
const SizedBox(height: 10),
const Align(
alignment: Alignment.topLeft,
child: Text(
'Domisili',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
),
const SizedBox(height: 16),
const FilterLabel(
text: 'Filter berdasarkan Domisili'),
const SizedBox(height: 10),
Obx(
() => Row(
Expand Down Expand Up @@ -204,17 +201,10 @@ class ListDebiturFilterFab extends StatelessWidget {
],
),
),
const SizedBox(height: 10),
const Align(
alignment: Alignment.topLeft,
child: Text(
'Tanggal',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
),
const SizedBox(height: 16),
const FilterLabel(
text:
'Filter berdasarkan Jarak Tanggal Penginputan'),
const SizedBox(height: 10),
Obx(
() => Row(
Expand Down Expand Up @@ -280,17 +270,9 @@ class ListDebiturFilterFab extends StatelessWidget {
],
),
),
const SizedBox(height: 10),
const Align(
alignment: Alignment.topLeft,
child: Text(
'Jenis Usaha',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
),
const SizedBox(height: 16),
const FilterLabel(
text: 'Filter berdasarkan Jenis Usaha'),
const SizedBox(height: 10),
Obx(
() => Row(
Expand Down Expand Up @@ -358,17 +340,8 @@ class ListDebiturFilterFab extends StatelessWidget {
],
),
),
const SizedBox(height: 10),
const Align(
alignment: Alignment.topLeft,
child: Text(
'Plafond',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
),
const SizedBox(height: 16),
const FilterLabel(text: 'Filter berdasarkan Plafond'),
const SizedBox(height: 10),
Obx(
() => Column(
Expand Down
4 changes: 4 additions & 0 deletions lib/app/widget/form/text_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class FleetimeTextField extends StatelessWidget {
final bool? alignLabelWithHint;
final bool? readOnly;
final String? suffixText;
final bool? enabled;
final void Function(String)? onSaved;

const FleetimeTextField({
Key? key,
Expand All @@ -31,6 +33,8 @@ class FleetimeTextField extends StatelessWidget {
this.alignLabelWithHint,
this.readOnly,
this.suffixText,
this.enabled,
this.onSaved,
}) : super(key: key);

@override
Expand Down

0 comments on commit 7e3f844

Please sign in to comment.