Skip to content

Commit 013710a

Browse files
Merge pull request flutter#35 from Otobucks01/Saim
Filter and car Details pages
2 parents 99ad27a + 2495bb5 commit 013710a

30 files changed

+903
-797
lines changed

lib/View/AddCar/addCar_toSell.dart

Lines changed: 86 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import 'dart:io';
44
import 'package:flutter/material.dart';
55
import 'package:get/get.dart';
66
import 'package:image_picker/image_picker.dart';
7-
import 'package:otobucks/View/CatBuyCar/controllers/buy_car_controller.dart';
87

98
import '../../global/app_colors.dart';
109
import '../../global/app_dimens.dart';
@@ -21,6 +20,7 @@ import '../../widgets/image_view.dart';
2120
import '../../widgets/media_button.dart';
2221
import '../CatBuyCar/models/CarBrandsModel.dart';
2322
import '../Profile/Controller/profile_screen_controller.dart';
23+
import '../Profile/Model/car_list_model.dart';
2424
import 'controller/add_car_controler.dart';
2525

2626
enum TransmitionType { manaual, autommatic }
@@ -33,17 +33,25 @@ class AddCarToSell extends StatefulWidget {
3333
}
3434

3535
class _AddCarToSellState extends State<AddCarToSell> {
36-
var profileController = Get.put(ProfileScreenController());
36+
var profileController = Get.put(ProfileScreenController());
3737
var addcarController = Get.put(AddCarController());
3838

3939
@override
4040
void initState() {
4141
super.initState();
42-
// profileController.getCarList().then((value) {
43-
// // getcardata();
44-
// });
42+
profileController.getCarList().then((value) {
43+
addcarController.getcardata();
44+
});
4545
addcarController.getBrandsList();
4646
}
47+
// getcardata() {
48+
// if (profileController.carList.isNotEmpty) {
49+
// for (int i = 0; i < profileController.carList.length; i++) {
50+
// print("getcardata");
51+
// print(profileController.carList[i].toJson());
52+
// }
53+
// }
54+
// }
4755

4856
double height = AppDimens.dimens_36;
4957
@override
@@ -63,69 +71,83 @@ class _AddCarToSellState extends State<AddCarToSell> {
6371
),
6472
ListView(
6573
children: [
66-
addVerticleSpace(AppDimens.dimens_16),
67-
Container(
68-
margin: const EdgeInsets.only(
69-
top: AppDimens.dimens_8,
74+
addVerticleSpace(AppDimens.dimens_16),
75+
Row(
76+
children: [
77+
Text("Select From Your Cars"),
78+
DropdownButton<GetCarModelResult>(
79+
value: null,
80+
icon: const Icon(Icons.keyboard_arrow_down_outlined),
81+
elevation: 16,
82+
style: AppStyle.textViewStyleNormalBodyText2(context: context, color: AppColors.colorBlack),
83+
underline: Container(
84+
height: 0,
85+
),
86+
onChanged: (GetCarModelResult? newValue) {
87+
value.setMyCarDropDown(newValue);
88+
89+
},
90+
items: addcarController.myCars.map<DropdownMenuItem<GetCarModelResult>>((GetCarModelResult value) {
91+
return DropdownMenuItem<GetCarModelResult>(
92+
value: value,
93+
enabled: true,
94+
child: Text(
95+
"${value.brand} ${value.modelYear}",
96+
style: AppStyle.textViewStyleNormalBodyText2(context: context, color: AppColors.colorBlack),
97+
),
98+
);
99+
}).toList(),
70100
),
71-
child: value.listOfCarBrand.isNotEmpty
72-
? DropdownButtonFormField2(
73-
buttonHeight: 45,
74-
decoration: InputDecoration(
75-
//Add isDense true and zero Padding.
76-
//Add Horizontal padding using buttonPadding and Vertical padding by increasing buttonHeight instead of add Padding here so that The whole TextField Button become clickable, and also the dropdown menu open under The whole TextField Button.
77-
isDense: true,
78-
hintStyle: AppStyle.textViewStyleNormalBodyText2(
79-
color: AppColors.colorTextFieldHint, fontSizeDelta: -5, fontWeightDelta: -1, context: Get.context!),
80-
fillColor: Colors.white,
81-
focusedBorder: AppViews.textFieldRoundBorder(),
82-
border: AppViews.textFieldRoundBorder(),
83-
disabledBorder: AppViews.textFieldRoundBorder(),
84-
focusedErrorBorder: AppViews.textFieldRoundBorder(),
85-
contentPadding: EdgeInsets.zero,
86-
filled: true,
87-
//Add more decoration as you want here
88-
//Add label If you want but add hint outside the decoration to be aligned in the button perfectly.
89-
),
90-
isExpanded: true,
91-
hint: Text(
92-
Constants.STR_CAR_BRAND.tr,
93-
),
94-
icon: const Icon(Icons.arrow_drop_down, color: Colors.black),
95-
iconSize: 30,
96-
buttonPadding: const EdgeInsets.only(left: 20, right: 10),
97-
dropdownDecoration: BoxDecoration(
98-
color: Colors.white,
99-
borderRadius: BorderRadius.circular(10),
100-
),
101-
items: value.listOfCarBrand!
102-
.map((item) => DropdownMenuItem<CarBrandDetails>(
103-
value: item,
104-
child: Text(
105-
item.name,
106-
style: AppStyle.textViewStyleSmall(context: Get.context!, color: Colors.black),
107-
),
108-
))
109-
.toList(),
110-
// validator: (value) {
111-
// if (value == null) {
112-
// return 'Field can not empty';
113-
// }
114-
// },
101+
],
102+
),
103+
addVerticleSpace(AppDimens.dimens_16),
104+
Row(children: [
105+
Expanded(
106+
child: TextField(
107+
textInputAction: TextInputAction.next,
115108

116-
onChanged: (CarBrandDetails? newvalue) {
117-
log(newvalue!.name.toString());
118-
value.controllerCarBrand.text = newvalue!.name.toString();
109+
controller: value.controllerCarBrand,
110+
keyboardType: TextInputType.text,decoration: InputDecoration(
111+
contentPadding: const EdgeInsets.only(top: AppDimens.dimens_7, left: AppDimens.dimens_15, right: AppDimens.dimens_15),
112+
focusedBorder: AppViews.textFieldRoundBorder(),
113+
enabledBorder: AppViews.textFieldRoundBorder(),
114+
border: AppViews.textFieldRoundBorder(),
115+
disabledBorder: AppViews.textFieldRoundBorder(),
116+
focusedErrorBorder: AppViews.textFieldRoundBorder(),
117+
suffixIcon: DropdownButton<CarBrandDetails>(
118+
value: value.carBrand ?? null,
119+
icon: Icon(Icons.keyboard_arrow_down_outlined),
120+
elevation: 16,
121+
style: AppStyle.textViewStyleNormalBodyText2(context: context, color: AppColors.colorBlack),
122+
underline: Container(
123+
height: 0,
124+
),
125+
onChanged: (CarBrandDetails? newValue) {
126+
value.setMyCarBrandDetails(newValue);
119127

120-
// selectedValue = value.toString();
121-
setState(() {});
122-
},
123-
onSaved: (newvalue) {
124-
// selectedValue = value.toString();
125-
setState(() {});
126128
},
127-
)
128-
: const SizedBox()),
129+
items: value.listOfCarBrand.map<DropdownMenuItem<CarBrandDetails>>((CarBrandDetails value) {
130+
return DropdownMenuItem<CarBrandDetails>(
131+
value: value,
132+
enabled: true,
133+
child: Text(
134+
"${value.name} ",
135+
style: AppStyle.textViewStyleNormalBodyText2(context: context, color: AppColors.colorBlack),
136+
),
137+
);
138+
}).toList(),
139+
),
140+
filled: true,
141+
142+
fillColor: AppColors.colorWhite,
143+
hintStyle:
144+
AppStyle.textViewStyleNormalBodyText2(color: AppColors.colorTextFieldHint, fontSizeDelta: 0, fontWeightDelta: 0, context: context),
145+
),
146+
),
147+
),
148+
149+
],),
150+
129151

130152
// CustomTextFieldWithIcon(
131153
// height: 42,

lib/View/AddCar/controller/add_car_controler.dart

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import '../../../global/global.dart';
1515
import '../../../global/url_collection.dart';
1616
import '../../../services/repository/buy_car_repo.dart';
1717
import '../../CatBuyCar/models/CarBrandsModel.dart';
18+
import '../../Profile/Controller/profile_screen_controller.dart';
19+
import '../../Profile/Model/car_list_model.dart';
1820
import '../addCar_toSell.dart';
1921

2022
class AddCarController extends GetxController {
@@ -39,6 +41,7 @@ class AddCarController extends GetxController {
3941
List<String> keyfeatureList = [];
4042
List<String> badgesList = [];
4143

44+
4245
String pickedImage = "";
4346
String pickedVideo = "";
4447
bool isNew = false;
@@ -49,6 +52,45 @@ class AddCarController extends GetxController {
4952
bool isShowLoader = false;
5053

5154
List<CarBrandDetails> listOfCarBrand = [];
55+
CarBrandDetails? carBrand;
56+
List<GetCarModelResult> myCars=[];
57+
var profileController=Get.find<ProfileScreenController>();
58+
GetCarModelResult? dropdownValue ;
59+
60+
getcardata() {
61+
if (profileController.carList.isNotEmpty) {
62+
// myCars=profileController.carList;
63+
// update();
64+
myCars.clear();
65+
for (int i = 0; i < profileController.carList.length; i++) {
66+
myCars.add(profileController.carList[i]);
67+
} update();
68+
69+
}
70+
}
71+
72+
setMyCarBrandDetails(CarBrandDetails? value){
73+
controllerCarBrand=TextEditingController(text: value?.name);
74+
update();
75+
76+
}
77+
setMyCarDropDown(GetCarModelResult? value){
78+
dropdownValue=value;
79+
controllerCarModelYear=TextEditingController(text: value?.modelYear);
80+
controllerCarModel=TextEditingController(text: value?.modelYear);
81+
controllerColour=TextEditingController(text: value?.color);
82+
update();
83+
for (var element in listOfCarBrand) {
84+
if(element.name.toLowerCase().toString()==
85+
dropdownValue?.brand?.trim().toLowerCase().toString()){
86+
controllerCarBrand=TextEditingController(text: element.name);
87+
}
88+
}
89+
// print("getcardata");
90+
91+
}
92+
93+
5294
Future<void> showLoader() async {
5395
isShowLoader = true;
5496
update();
@@ -260,10 +302,7 @@ class AddCarController extends GetxController {
260302
}, (mResult) {
261303
var carBrandsModel = mResult.responseData as CarBrandsModel;
262304

263-
if (carBrandsModel != null) {
264-
listOfCarBrand = carBrandsModel.data;
265-
}
266-
log(listOfCarBrand.length.toString());
305+
listOfCarBrand = carBrandsModel.data;
267306
update();
268307
});
269308
isShowLoader = false;

lib/View/Analytics/Controllers/analytics_controller.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class AnalyticsController extends GetxController {
1717
totalWithdraw: '0',
1818
earning: '0',
1919
balance: "0",
20-
currency: 'USD',
20+
currency: 'AED',
2121
id: '',
2222
stripeWallet: '',
2323
user: '',

lib/View/CatAssesories/Controllers/accessories_sub_cat_controller.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,19 @@ class AccessoriesSubCatController extends GetxController {
1616
update();
1717
HashMap<String, Object> requestParams = HashMap();
1818
var categories = await AccessoriesRepo().getStores(requestParams);
19+
20+
1921
categories.fold((failure) {
22+
print("stores.length B");
23+
2024
Global.showToastAlert(context: Get.overlayContext!, strTitle: "", strMsg: failure.MESSAGE, toastType: TOAST_TYPE.toastError);
2125
mShowData = ShowData.showNoDataFound;
2226
update();
2327
}, (mResult) {
24-
stores = mResult.responseData as List<AccessoriesStoreModel>;
28+
stores = mResult.responseData
29+
as List<AccessoriesStoreModel>;
30+
print("stores.length C");
31+
print(stores.length);
2532
if (stores.isNotEmpty) {
2633
mShowData = ShowData.showData;
2734
} else {

0 commit comments

Comments
 (0)