You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
car_common_app/lib/views/advertisement/ad_creation_steps_container...

467 lines
14 KiB
Dart

import 'package:flutter/cupertino.dart';
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/extensions/string_extensions.dart';
import 'package:mc_common_app/theme/colors.dart';
import 'package:mc_common_app/utils/enums.dart';
import 'package:mc_common_app/view_models/ad_view_model.dart';
import 'package:mc_common_app/widgets/dropdown/dropdow_field.dart';
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
import 'package:mc_common_app/widgets/txt_field.dart';
import 'package:provider/provider.dart';
import 'package:mc_common_app/widgets/common_widgets/dotted_rect.dart';
class AttachImageContainer extends StatelessWidget {
final Function() onTap;
const AttachImageContainer({Key? key, required this.onTap}) : super(key: key);
@override
Widget build(BuildContext context) {
return InkWell(
onTap: onTap,
child: Container(
height: 46,
width: double.infinity,
color: MyColors.white,
child: DashedRect(
color: MyColors.lightIconColor,
strokeWidth: 2.0,
gap: 4.0,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
MyAssets.attachmentIcon.buildSvg(),
"Attach Image".toText(
fontSize: 15,
isBold: true,
color: MyColors.darkPrimaryColor,
),
],
),
),
),
);
}
}
class BuildAdStepContainer extends StatelessWidget {
final WidgetBuilder onVehicleDetails;
final WidgetBuilder onDamageParts;
final WidgetBuilder onAdDuration;
final WidgetBuilder onReviewAd;
final AdCreationStepsEnum adCreationStepsEnum;
const BuildAdStepContainer({
Key? key,
required this.onVehicleDetails,
required this.onDamageParts,
required this.onAdDuration,
required this.onReviewAd,
required this.adCreationStepsEnum,
}) : super(key: key);
@override
Widget build(BuildContext context) {
switch (adCreationStepsEnum) {
case AdCreationStepsEnum.vehicleDetails:
return onVehicleDetails(context);
case AdCreationStepsEnum.damageParts:
return onDamageParts(context);
case AdCreationStepsEnum.adDuration:
return onAdDuration(context);
case AdCreationStepsEnum.reviewAd:
return onReviewAd(context);
}
}
}
class VehicleDetails extends StatelessWidget {
const VehicleDetails({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
List<DropValue> dropList = [
DropValue(0, "Maintenance", ""),
DropValue(1, "Car Wash", ""),
DropValue(2, "Monthly Checkup", ""),
DropValue(3, "Friendly Visit", ""),
DropValue(4, "Muftaa", ""),
];
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
"Vehicle Detail".toText(fontSize: 18, isBold: true),
8.height,
DropdownField(
(DropValue value) {},
list: dropList,
hint: "Vehicle Type",
),
8.height,
DropdownField(
(DropValue value) {},
list: dropList,
hint: "Vehicle Model",
),
8.height,
DropdownField(
(DropValue value) {},
list: dropList,
hint: "Vehicle Model Year",
),
8.height,
DropdownField(
(DropValue value) {},
list: dropList,
hint: "Vehicle Color",
),
8.height,
DropdownField(
(DropValue value) {},
list: dropList,
hint: "Vehicle Condition",
),
8.height,
DropdownField(
(DropValue value) {},
list: dropList,
hint: "Vehicle Category",
),
8.height,
TxtField(
hint: "Vehicle Mileage",
// onChanged: (v) => email = v,
),
8.height,
DropdownField(
(DropValue value) {},
list: dropList,
hint: "Vehicle Transmission",
),
8.height,
DropdownField(
(DropValue value) {},
list: dropList,
hint: "Vehicle Seller Type",
),
8.height,
DropdownField(
(DropValue value) {},
list: dropList,
hint: "Vehicle Country",
),
8.height,
DropdownField(
(DropValue value) {},
list: dropList,
hint: "Vehicle City",
),
8.height,
TxtField(
hint: "Demand Amount",
// onChanged: (v) => email = v,
),
8.height,
TxtField(
hint: "Vehicle VIN",
// onChanged: (v) => email = v,
),
8.height,
TxtField(
hint: "Vehicle Title",
// onChanged: (v) => email = v,
),
8.height,
TxtField(
hint: "Warranty Available (No. of Years)",
// onChanged: (v) => email = v,
),
8.height,
TxtField(
hint: "Vehicle Description",
maxLines: 5,
// onChanged: (v) => email = v,
),
22.height,
"Finance Available".toText(fontSize: 16),
8.height,
Consumer(builder: (BuildContext context, AdVM adVm, Widget? child) {
return Container(
width: 65,
height: 37,
decoration: BoxDecoration(
color: adVm.financeAvailableStatus ? MyColors.darkPrimaryColor : MyColors.white,
borderRadius: BorderRadius.circular(25.0),
border: Border.all(color: MyColors.black, width: 1.5),
),
child: CupertinoSwitch(
activeColor: MyColors.darkPrimaryColor,
trackColor: MyColors.white,
thumbColor: MyColors.grey98Color,
value: adVm.financeAvailableStatus,
onChanged: (value) {
adVm.updateFinanceAvailableStatus(value);
},
),
);
}),
28.height,
"Vehicle Pictures".toText(fontSize: 18, isBold: true),
8.height,
AttachImageContainer(onTap: () {
context.read<AdVM>().pickImageFromPhone(1);
}),
20.height,
],
).toWhiteContainer(width: double.infinity, allPading: 12, margin: EdgeInsets.symmetric(horizontal: 21, vertical: 10));
}
}
class DamageParts extends StatelessWidget {
const DamageParts({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
List<DropValue> dropList = [
DropValue(0, "Door Handles", ""),
DropValue(1, "Wind Screen", ""),
DropValue(2, "Rear Light", ""),
DropValue(3, "Bumper", ""),
DropValue(4, "Headlight", ""),
];
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
"Vehicle Damage Pictures".toText(fontSize: 18, isBold: true),
8.height,
DropdownField(
(DropValue value) {},
list: dropList,
hint: "Vehicle Part",
),
8.height,
AttachImageContainer(onTap: () {
context.read<AdVM>().pickImageFromPhone(1);
}),
20.height,
],
).toWhiteContainer(width: double.infinity, allPading: 12, margin: EdgeInsets.symmetric(horizontal: 21, vertical: 10));
}
}
class AdDuration extends StatelessWidget {
const AdDuration({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
List<DropValue> dropList = [
DropValue(0, "One Week", ""),
DropValue(1, "Two Weeks", ""),
DropValue(2, "Three Weeks", ""),
DropValue(3, "One Month", ""),
];
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
"Ad Duration".toText(fontSize: 18, isBold: true),
8.height,
DropdownField(
(DropValue value) {},
list: dropList,
hint: "Select Duration",
),
8.height,
DropdownField(
(DropValue value) {},
list: dropList,
hint: "Start Date",
),
28.height,
"Select Special Services".toText(fontSize: 18, isBold: true),
8.height,
DropdownField(
(DropValue value) {},
list: dropList,
hint: "Ad Management",
),
20.height,
],
).toWhiteContainer(width: double.infinity, allPading: 12, margin: EdgeInsets.symmetric(horizontal: 21, vertical: 10));
}
}
class SingleDetailWidget extends StatelessWidget {
final String title;
final String subTitle;
const SingleDetailWidget({Key? key, required this.title, required this.subTitle}) : super(key: key);
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
"$subTitle:".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true),
title.toText(fontSize: 14, color: MyColors.black, isBold: true),
],
);
}
}
class ReviewAd extends StatelessWidget {
const ReviewAd({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
VehicleDetailsReview(),
DamagePartsReview(),
AdDurationReview(),
],
);
}
}
class VehicleDetailsReview extends StatelessWidget {
const VehicleDetailsReview({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
"Vehicle Details".toText(fontSize: 18, isBold: true),
8.height,
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Expanded(
flex: 5,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SingleDetailWidget(title: "Vehicle Type", subTitle: "Car"),
16.height,
SingleDetailWidget(title: "Vehicle Type", subTitle: "Car"),
16.height,
SingleDetailWidget(title: "Vehicle Type", subTitle: "Car"),
16.height,
SingleDetailWidget(title: "Vehicle Type", subTitle: "Car"),
16.height,
SingleDetailWidget(title: "Vehicle Type", subTitle: "Car"),
16.height,
SingleDetailWidget(title: "Vehicle Type", subTitle: "Car"),
16.height,
SingleDetailWidget(title: "Vehicle Type", subTitle: "Car"),
16.height,
SingleDetailWidget(title: "Vehicle Type", subTitle: "Car"),
16.height,
],
),
),
Expanded(
flex: 5,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SingleDetailWidget(title: "Vehicle Type", subTitle: "Car"),
16.height,
SingleDetailWidget(title: "Vehicle Type", subTitle: "Car"),
16.height,
SingleDetailWidget(title: "Vehicle Type", subTitle: "Car"),
16.height,
SingleDetailWidget(title: "Vehicle Type", subTitle: "Car"),
16.height,
SingleDetailWidget(title: "Vehicle Type", subTitle: "Car"),
16.height,
SingleDetailWidget(title: "Vehicle Type", subTitle: "Car"),
16.height,
SingleDetailWidget(title: "Vehicle Type", subTitle: "Car"),
16.height,
SingleDetailWidget(title: "Vehicle Type", subTitle: "Car"),
16.height,
],
),
),
],
),
SingleDetailWidget(title: "Warranty Available", subTitle: "0 Years"),
8.height,
SingleDetailWidget(subTitle: "Description", title: "Some Two lines Description about the car and its unique features"),
8.height,
SingleDetailWidget(subTitle: "Finance Available", title: "No"),
8.height,
"Vehicle Pictures:".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true),
],
).toWhiteContainer(width: double.infinity, allPading: 12, margin: EdgeInsets.symmetric(horizontal: 21, vertical: 10));
}
}
class DamagePartsReview extends StatelessWidget {
const DamagePartsReview({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
"Vehicle Damage Part".toText(fontSize: 18, isBold: true),
8.height,
Row(
children: [
SingleDetailWidget(subTitle: "Vehicle Part", title: "Bumper"),
],
),
8.height,
"Damage Part Pictures:".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true),
],
).toWhiteContainer(width: double.infinity, allPading: 12, margin: EdgeInsets.symmetric(horizontal: 21, vertical: 10));
}
}
class AdDurationReview extends StatelessWidget {
const AdDurationReview({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
"Vehicle Damage Part".toText(fontSize: 18, isBold: true),
8.height,
Row(
children: [
Expanded(
flex: 5,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SingleDetailWidget(subTitle: "Duration", title: "One Week"),
8.height,
SingleDetailWidget(subTitle: "Special Services", title: "Ad Management"),
],
),
),
Expanded(
flex: 5,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SingleDetailWidget(subTitle: "Start Date", title: "5 February, 2023"),
],
),
),
],
),
],
).toWhiteContainer(width: double.infinity, allPading: 12, margin: EdgeInsets.symmetric(horizontal: 21, vertical: 10));
}
}