@@ -4,7 +4,6 @@ import 'dart:io';
4
4
import 'package:flutter/material.dart' ;
5
5
import 'package:get/get.dart' ;
6
6
import 'package:image_picker/image_picker.dart' ;
7
- import 'package:otobucks/View/CatBuyCar/controllers/buy_car_controller.dart' ;
8
7
9
8
import '../../global/app_colors.dart' ;
10
9
import '../../global/app_dimens.dart' ;
@@ -21,6 +20,7 @@ import '../../widgets/image_view.dart';
21
20
import '../../widgets/media_button.dart' ;
22
21
import '../CatBuyCar/models/CarBrandsModel.dart' ;
23
22
import '../Profile/Controller/profile_screen_controller.dart' ;
23
+ import '../Profile/Model/car_list_model.dart' ;
24
24
import 'controller/add_car_controler.dart' ;
25
25
26
26
enum TransmitionType { manaual, autommatic }
@@ -33,17 +33,25 @@ class AddCarToSell extends StatefulWidget {
33
33
}
34
34
35
35
class _AddCarToSellState extends State <AddCarToSell > {
36
- var profileController = Get .put (ProfileScreenController ());
36
+ var profileController = Get .put (ProfileScreenController ());
37
37
var addcarController = Get .put (AddCarController ());
38
38
39
39
@override
40
40
void initState () {
41
41
super .initState ();
42
- // profileController.getCarList().then((value) {
43
- // // getcardata();
44
- // });
42
+ profileController.getCarList ().then ((value) {
43
+ addcarController. getcardata ();
44
+ });
45
45
addcarController.getBrandsList ();
46
46
}
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
+ // }
47
55
48
56
double height = AppDimens .dimens_36;
49
57
@override
@@ -63,69 +71,83 @@ class _AddCarToSellState extends State<AddCarToSell> {
63
71
),
64
72
ListView (
65
73
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 (),
70
100
),
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,
115
108
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);
119
127
120
- // selectedValue = value.toString();
121
- setState (() {});
122
- },
123
- onSaved: (newvalue) {
124
- // selectedValue = value.toString();
125
- setState (() {});
126
128
},
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
+
129
151
130
152
// CustomTextFieldWithIcon(
131
153
// height: 42,
0 commit comments