Added Appoinment Module and Ads Filter
parent
057a202ed9
commit
8a8efa37f2
@ -0,0 +1,138 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mc_common_app/classes/consts.dart';
|
||||||
|
import 'package:mc_common_app/extensions/int_extensions.dart';
|
||||||
|
import 'package:mc_common_app/models/widgets_models.dart';
|
||||||
|
import 'package:mc_common_app/theme/colors.dart';
|
||||||
|
import 'package:mc_common_app/view_models/ad_view_model.dart';
|
||||||
|
import 'package:mc_common_app/widgets/button/show_fill_button.dart';
|
||||||
|
import 'package:mc_common_app/widgets/common_widgets/app_bar.dart';
|
||||||
|
import 'package:mc_common_app/widgets/common_widgets/search_entity_widget.dart';
|
||||||
|
import 'package:mc_common_app/widgets/dropdown/dropdow_field.dart';
|
||||||
|
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:sizer/sizer.dart';
|
||||||
|
|
||||||
|
class AdsFilterView extends StatelessWidget {
|
||||||
|
const AdsFilterView({super.key});
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: CustomAppBar(
|
||||||
|
title: "Ads Filter",
|
||||||
|
profileImageUrl: MyAssets.bnCar,
|
||||||
|
isRemoveBackButton: false,
|
||||||
|
isDrawerEnabled: false,
|
||||||
|
onBackButtonTapped: () {
|
||||||
|
context.read<AdVM>().resetValues();
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
body: Consumer<AdVM>(
|
||||||
|
builder: (BuildContext context, AdVM adVM, Widget? child) {
|
||||||
|
return WillPopScope(
|
||||||
|
onWillPop: () async {
|
||||||
|
context.read<AdVM>().resetValues();
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
ListView(
|
||||||
|
children: [
|
||||||
|
20.height,
|
||||||
|
SearchEntityWidget(
|
||||||
|
title: "Search By Location",
|
||||||
|
actionWidget: Builder(builder: (context) {
|
||||||
|
List<DropValue> vehicleBrandsDrop = [];
|
||||||
|
for (var element in adVM.vehicleCities) {
|
||||||
|
vehicleBrandsDrop.add(DropValue(element.id?.toInt() ?? 0, element.cityName ?? "", ""));
|
||||||
|
}
|
||||||
|
return DropdownField(
|
||||||
|
(DropValue value) => adVM.updateSelectionVehicleCityId(SelectionModel(selectedId: value.id, selectedOption: value.value), isForSearch: true),
|
||||||
|
list: vehicleBrandsDrop,
|
||||||
|
dropdownValue: adVM.vehicleCityId.selectedId != -1 ? DropValue(adVM.vehicleCityId.selectedId, adVM.vehicleCityId.selectedOption, "") : null,
|
||||||
|
hint: "Select Location",
|
||||||
|
errorValue: adVM.vehicleCityId.errorValue,
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
historyContent: adVM.vehicleLocationAdSearchHistory,
|
||||||
|
onHistoryItemDeleted: (index) {
|
||||||
|
adVM.removeVehicleLocationAdSearchHistory(index: index);
|
||||||
|
},
|
||||||
|
onHistoryItemTapped: (DropValue value) => adVM.updateSelectionVehicleCityId(SelectionModel(selectedId: value.id, selectedOption: value.value), isForSearch: true),
|
||||||
|
),
|
||||||
|
const Divider(thickness: 1.2).paddingOnly(top: 7, bottom: 7),
|
||||||
|
SearchEntityWidget(
|
||||||
|
title: "Search By Brand Name",
|
||||||
|
actionWidget: Builder(builder: (context) {
|
||||||
|
List<DropValue> vehicleBrandsDrop = [];
|
||||||
|
for (var element in adVM.vehicleBrands) {
|
||||||
|
vehicleBrandsDrop.add(DropValue(element.id?.toInt() ?? 0, element.vehicleBrandDescription ?? "", ""));
|
||||||
|
}
|
||||||
|
return DropdownField(
|
||||||
|
(DropValue value) => adVM.updateSelectionVehicleBrandId(SelectionModel(selectedId: value.id, selectedOption: value.value), isForSearch: true),
|
||||||
|
list: vehicleBrandsDrop,
|
||||||
|
dropdownValue: adVM.vehicleBrandId.selectedId != -1 ? DropValue(adVM.vehicleBrandId.selectedId, adVM.vehicleBrandId.selectedOption, "") : null,
|
||||||
|
hint: "Select Vehicle Brand",
|
||||||
|
errorValue: adVM.vehicleBrandId.errorValue,
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
historyContent: adVM.vehicleBrandsAdSearchHistory,
|
||||||
|
onHistoryItemDeleted: (index) => adVM.removeVehicleBrandsAdSearchHistory(index: index),
|
||||||
|
onHistoryItemTapped: (DropValue value) => adVM.updateSelectionVehicleBrandId(SelectionModel(selectedId: value.id, selectedOption: value.value), isForSearch: true),
|
||||||
|
),
|
||||||
|
const Divider(thickness: 1.2).paddingOnly(top: 7, bottom: 7),
|
||||||
|
SearchEntityWidget(
|
||||||
|
title: "Search By Year",
|
||||||
|
actionWidget: Builder(builder: (context) {
|
||||||
|
List<DropValue> vehicleBrandsDrop = [];
|
||||||
|
for (var element in adVM.vehicleModelYears) {
|
||||||
|
vehicleBrandsDrop.add(DropValue(element.id?.toInt() ?? 0, element.modelYear ?? "", ""));
|
||||||
|
}
|
||||||
|
return DropdownField(
|
||||||
|
(DropValue value) => adVM.updateSelectionVehicleModelYearId(SelectionModel(selectedId: value.id, selectedOption: value.value), isForSearch: true),
|
||||||
|
list: vehicleBrandsDrop,
|
||||||
|
dropdownValue: adVM.vehicleModelYearId.selectedId != -1 ? DropValue(adVM.vehicleModelYearId.selectedId, adVM.vehicleModelYearId.selectedOption, "") : null,
|
||||||
|
hint: "Select Year",
|
||||||
|
errorValue: adVM.vehicleModelYearId.errorValue,
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
historyContent: adVM.vehicleYearAdSearchHistory,
|
||||||
|
onHistoryItemDeleted: (index) => adVM.removeVehicleYearAdSearchHistory(index: index),
|
||||||
|
onHistoryItemTapped: (DropValue value) => adVM.updateSelectionVehicleModelYearId(SelectionModel(selectedId: value.id, selectedOption: value.value), isForSearch: true),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
).expand(),
|
||||||
|
Container(
|
||||||
|
color: MyColors.white,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
5.height,
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: ShowFillButton(
|
||||||
|
maxHeight: 55,
|
||||||
|
title: "Search",
|
||||||
|
onPressed: () {},
|
||||||
|
backgroundColor: MyColors.darkPrimaryColor,
|
||||||
|
txtColor: MyColors.white,
|
||||||
|
fontSize: 18,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
10.height,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).horPaddingMain(),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,19 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:mc_common_app/classes/consts.dart';
|
|
||||||
import 'package:mc_common_app/widgets/common_widgets/app_bar.dart';
|
|
||||||
|
|
||||||
class AdsSearchFilterView extends StatelessWidget {
|
|
||||||
const AdsSearchFilterView({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: CustomAppBar(
|
|
||||||
title: "Filter Ads",
|
|
||||||
profileImageUrl: MyAssets.bnCar,
|
|
||||||
isRemoveBackButton: false,
|
|
||||||
isDrawerEnabled: false,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,50 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mc_common_app/extensions/int_extensions.dart';
|
||||||
|
import 'package:mc_common_app/extensions/string_extensions.dart';
|
||||||
|
import 'package:mc_common_app/theme/colors.dart';
|
||||||
|
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
|
||||||
|
|
||||||
|
class CustomRectangleChip extends StatelessWidget {
|
||||||
|
final String text;
|
||||||
|
final double? height;
|
||||||
|
final double? width;
|
||||||
|
final Color bgColor;
|
||||||
|
final Color textColor;
|
||||||
|
final Function() onHistoryItemDeleted;
|
||||||
|
final Function() onHistoryItemTapped;
|
||||||
|
|
||||||
|
const CustomRectangleChip({
|
||||||
|
super.key,
|
||||||
|
this.bgColor = MyColors.chipColor,
|
||||||
|
required this.text,
|
||||||
|
this.textColor = MyColors.darkTextColor,
|
||||||
|
this.width,
|
||||||
|
this.height = 28,
|
||||||
|
required this.onHistoryItemDeleted,
|
||||||
|
required this.onHistoryItemTapped,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 10),
|
||||||
|
color: bgColor,
|
||||||
|
height: height,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
text.toText(fontSize: 15, color: MyColors.darkTextColor),
|
||||||
|
8.width,
|
||||||
|
Container(
|
||||||
|
height: 15,
|
||||||
|
width: 15,
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
color: MyColors.roundedCrossBgColor,
|
||||||
|
),
|
||||||
|
child: const Icon(Icons.close, color: MyColors.white, size: 10),
|
||||||
|
).onPress(onHistoryItemDeleted),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
).onPress(onHistoryItemTapped);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,56 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mc_common_app/extensions/int_extensions.dart';
|
||||||
|
import 'package:mc_common_app/extensions/string_extensions.dart';
|
||||||
|
import 'package:mc_common_app/widgets/common_widgets/custom_rectangle_chip.dart';
|
||||||
|
import 'package:mc_common_app/widgets/dropdown/dropdow_field.dart';
|
||||||
|
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
|
||||||
|
|
||||||
|
class SearchEntityWidget extends StatelessWidget {
|
||||||
|
final String title;
|
||||||
|
final Widget actionWidget;
|
||||||
|
final List<DropValue> historyContent;
|
||||||
|
final Function(int) onHistoryItemDeleted;
|
||||||
|
final Function(DropValue) onHistoryItemTapped;
|
||||||
|
|
||||||
|
const SearchEntityWidget({
|
||||||
|
super.key,
|
||||||
|
required this.title,
|
||||||
|
required this.actionWidget,
|
||||||
|
required this.historyContent,
|
||||||
|
required this.onHistoryItemDeleted,
|
||||||
|
required this.onHistoryItemTapped,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
title.toText(fontSize: 16, isBold: true),
|
||||||
|
8.height,
|
||||||
|
actionWidget,
|
||||||
|
10.height,
|
||||||
|
historyContent.isNotEmpty
|
||||||
|
? SizedBox(
|
||||||
|
height: 33,
|
||||||
|
child: ListView.builder(
|
||||||
|
shrinkWrap: true,
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
itemCount: historyContent.length,
|
||||||
|
itemBuilder: (BuildContext context, int index) {
|
||||||
|
return CustomRectangleChip(
|
||||||
|
text: historyContent[index].value,
|
||||||
|
onHistoryItemDeleted: () {
|
||||||
|
onHistoryItemDeleted(index);
|
||||||
|
},
|
||||||
|
onHistoryItemTapped: () {
|
||||||
|
onHistoryItemTapped(historyContent[index]);
|
||||||
|
},
|
||||||
|
).paddingOnly(right: 10);
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
: const SizedBox.shrink(),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue