Initial commit
This commit is contained in:
@@ -0,0 +1,155 @@
|
||||
import 'package:cargocalculaterapp/core/extension/build_context_extension.dart';
|
||||
import 'package:cargocalculaterapp/core/functions/base_finctions.dart';
|
||||
import 'package:cargocalculaterapp/core/utils/app_utils.dart';
|
||||
import 'package:cargocalculaterapp/core/widgets/loading/progress_hud.dart';
|
||||
import 'package:cargocalculaterapp/features/calculator/presentation/pages/calculator_info/widget/calculator_info_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
||||
import '../../../../../constants/constants.dart';
|
||||
import '../../../../../generated/l10n.dart';
|
||||
import '../../arguments/calculator_info_argument.dart';
|
||||
import '../../bloc/calculator_info/calculator_info_bloc.dart';
|
||||
|
||||
class CalculatorInfoPage extends StatelessWidget {
|
||||
const CalculatorInfoPage({super.key, required this.argument});
|
||||
|
||||
final CalculatorInfoArgument? argument;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<CalculatorInfoBloc, CalculatorInfoState>(
|
||||
builder: (context, state) {
|
||||
return Scaffold(
|
||||
backgroundColor: context.color.grayBackground,
|
||||
appBar: AppBar(title: Text(AppLocalization.current.calculator)),
|
||||
body: ModalProgressHUD(
|
||||
inAsyncCall: state.isLoading,
|
||||
child: ListView(
|
||||
padding: AppUtils.kPaddingAll16,
|
||||
children: [
|
||||
Container(
|
||||
margin: const EdgeInsets.only(bottom: 32),
|
||||
padding: AppUtils.kPaddingAll16,
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: AppUtils.kBorderRadius16,
|
||||
color: context.color.statusBackground,
|
||||
border: Border.all(color: context.color.lightBorder),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CalculatorInfoWidget(
|
||||
title: AppLocalization.current.product_name,
|
||||
name: argument?.productName ?? "-",
|
||||
),
|
||||
CalculatorInfoWidget(
|
||||
title: AppLocalization.current.warehouse,
|
||||
name: Functions.getTranslatedItem(
|
||||
AppConst.warehouseOptions[argument?.weraHouse],
|
||||
context,
|
||||
),
|
||||
),
|
||||
CalculatorInfoWidget(
|
||||
title: AppLocalization.current.weight,
|
||||
name: "${argument?.weight} kg",
|
||||
),
|
||||
CalculatorInfoWidget(
|
||||
title: AppLocalization.current.size,
|
||||
name: "${argument?.size} m³",
|
||||
),
|
||||
CalculatorInfoWidget(
|
||||
title: AppLocalization.current.average_weight,
|
||||
name: "${argument?.averageWeight}",
|
||||
),
|
||||
CalculatorInfoWidget(
|
||||
title: AppLocalization.current.delivery_price,
|
||||
name: "${argument?.deliveryPrice}",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
if (argument != null) {
|
||||
context.read<CalculatorInfoBloc>().add(
|
||||
CreateLeadEvent(
|
||||
isCall: true,
|
||||
argument: argument!,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
borderRadius: AppUtils.kBorderRadius24,
|
||||
child: Ink(
|
||||
decoration: BoxDecoration(
|
||||
color: context.color.scaffoldBackgroundColor,
|
||||
borderRadius: AppUtils.kBorderRadius24,
|
||||
border: Border.all(
|
||||
color: context.color.primaryColor,
|
||||
),
|
||||
),
|
||||
height: 56,
|
||||
padding: AppUtils.kPaddingHor16,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
"assets/svg/ic_phone.svg",
|
||||
colorFilter: ColorFilter.mode(
|
||||
context.color.textColor,
|
||||
BlendMode.srcIn,
|
||||
),
|
||||
),
|
||||
AppUtils.kBoxWidth4,
|
||||
Text(
|
||||
AppLocalization.current.phone_call,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: context.color.textColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
AppUtils.kBoxWidth16,
|
||||
Expanded(
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
if (argument != null) {
|
||||
context.read<CalculatorInfoBloc>().add(
|
||||
CreateLeadEvent(
|
||||
isCall: false,
|
||||
argument: argument!,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SvgPicture.asset("assets/svg/ic_list_1.svg"),
|
||||
AppUtils.kBoxWidth4,
|
||||
Text(AppLocalization.current.send),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import 'package:cargocalculaterapp/core/extension/build_context_extension.dart';
|
||||
import 'package:cargocalculaterapp/core/utils/app_utils.dart';
|
||||
import 'package:cargocalculaterapp/generated/l10n.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
||||
class OrderDialog extends StatelessWidget {
|
||||
const OrderDialog({super.key, required this.isCall});
|
||||
|
||||
final bool isCall;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Dialog(
|
||||
backgroundColor: context.color.scaffoldBackgroundColor,
|
||||
insetPadding: AppUtils.kPaddingAll16,
|
||||
child: Padding(
|
||||
padding: AppUtils.kPaddingVer24Hor16,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SvgPicture.asset("assets/svg/ic_done.svg"),
|
||||
AppUtils.kBoxHeight20,
|
||||
Text(
|
||||
isCall
|
||||
? AppLocalization.current.done_phone
|
||||
: AppLocalization.current.done_order,
|
||||
style: context.text.authDesc.copyWith(
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
AppUtils.kBoxHeight20,
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context, true);
|
||||
},
|
||||
child: Text(AppLocalization.current.done_ready),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import 'package:cargocalculaterapp/core/extension/build_context_extension.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../../../core/utils/app_utils.dart';
|
||||
|
||||
class CalculatorInfoWidget extends StatelessWidget {
|
||||
const CalculatorInfoWidget({super.key, required this.title, required this.name});
|
||||
|
||||
final String title;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 16),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(child: Text(title, style: context.text.orderListTitle)),
|
||||
AppUtils.kBoxWidth8,
|
||||
Expanded(
|
||||
child: Text(
|
||||
name,
|
||||
style: context.text.profileCategory,
|
||||
textAlign: TextAlign.end,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
146
lib/features/calculator/presentation/pages/calculator_page.dart
Normal file
146
lib/features/calculator/presentation/pages/calculator_page.dart
Normal file
@@ -0,0 +1,146 @@
|
||||
import 'package:cargocalculaterapp/core/extension/build_context_extension.dart';
|
||||
import 'package:cargocalculaterapp/core/utils/app_utils.dart';
|
||||
import 'package:cargocalculaterapp/core/widgets/loading/progress_hud.dart';
|
||||
import 'package:cargocalculaterapp/generated/l10n.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
||||
import '../../../../core/widgets/drop_down/custom_drop_down.dart';
|
||||
import '../../../../core/widgets/text_filds/custom_text_field_name.dart';
|
||||
import '../bloc/calculator_bloc.dart';
|
||||
import '../mixin/calculator_mixin.dart';
|
||||
|
||||
class CalculatorPage extends StatefulWidget {
|
||||
const CalculatorPage({super.key});
|
||||
|
||||
@override
|
||||
State<CalculatorPage> createState() => _CalculatorPageState();
|
||||
}
|
||||
|
||||
class _CalculatorPageState extends State<CalculatorPage> with CalculatorMixin {
|
||||
@override
|
||||
void initState() {
|
||||
initControllers();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocConsumer<CalculatorBloc, CalculatorState>(
|
||||
listener: (context, state) {
|
||||
if ((state.weight ?? 0) > 0 && (state.size ?? 0) > 0) {
|
||||
averageWeightController.text =
|
||||
"${(state.weight ?? 0) / (state.size ?? 1)}";
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
return Scaffold(
|
||||
backgroundColor: context.color.grayBackground,
|
||||
appBar: AppBar(title: Text(AppLocalization.current.calculator)),
|
||||
body: ModalProgressHUD(
|
||||
inAsyncCall: state.isLoading,
|
||||
child: ListView(
|
||||
padding: AppUtils.kPaddingAll16,
|
||||
children: [
|
||||
CustomTextFieldName(
|
||||
hint: AppLocalization.current.weight,
|
||||
name: AppLocalization.current.weight_in_kg,
|
||||
isRequired: true,
|
||||
format: [
|
||||
FilteringTextInputFormatter.allow(
|
||||
RegExp(r'^\d*[.,]?\d{0,}$'), // accepts both "." and ","
|
||||
),
|
||||
],
|
||||
controller: weightController,
|
||||
inputType: const TextInputType.numberWithOptions(
|
||||
decimal: true,
|
||||
),
|
||||
onchange: (value) {
|
||||
context.read<CalculatorBloc>().add(
|
||||
WeightSizeEnterEvent(
|
||||
weight: value,
|
||||
size: sizeController.text,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
AppUtils.kBoxHeight16,
|
||||
CustomTextFieldName(
|
||||
hint: AppLocalization.current.size,
|
||||
name: AppLocalization.current.size_in_m3,
|
||||
isRequired: true,
|
||||
controller: sizeController,
|
||||
format: [
|
||||
FilteringTextInputFormatter.allow(
|
||||
RegExp(r'^\d*[.,]?\d{0,}$'), // accepts both "." and ","
|
||||
),
|
||||
],
|
||||
inputType: const TextInputType.numberWithOptions(
|
||||
decimal: true,
|
||||
),
|
||||
onchange: (value) {
|
||||
context.read<CalculatorBloc>().add(
|
||||
WeightSizeEnterEvent(
|
||||
weight: weightController.text,
|
||||
size: value,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
AppUtils.kBoxHeight16,
|
||||
CustomTextFieldName(
|
||||
hint: AppLocalization.current.average_weight,
|
||||
name: AppLocalization.current.average_weight_in,
|
||||
controller: averageWeightController,
|
||||
readOnly: true,
|
||||
),
|
||||
AppUtils.kBoxHeight16,
|
||||
CustomTextFieldName(
|
||||
hint: AppLocalization.current.product_name,
|
||||
isRequired: true,
|
||||
name: AppLocalization.current.product_name,
|
||||
controller: productNameController,
|
||||
inputType: TextInputType.name,
|
||||
),
|
||||
AppUtils.kBoxHeight16,
|
||||
CustomDropDown(
|
||||
isRequired: false,
|
||||
value: state.selectedWarehouse,
|
||||
|
||||
onChange: (value) {
|
||||
context.read<CalculatorBloc>().add(
|
||||
WareHouseSelectEvent(wareHouse: value ?? ""),
|
||||
);
|
||||
},
|
||||
name: AppLocalization.current.select_warehouse,
|
||||
),
|
||||
AppUtils.kBoxHeight16,
|
||||
ElevatedButton(
|
||||
onPressed: ((state.weight ?? 0) > 0 && (state.size ?? 0) > 0)
|
||||
? () {
|
||||
context.read<CalculatorBloc>().add(
|
||||
CalculateEvent(
|
||||
productName: productNameController.text,
|
||||
),
|
||||
);
|
||||
}
|
||||
: null,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SvgPicture.asset("assets/svg/ic_calculator_1.svg"),
|
||||
AppUtils.kBoxWith8,
|
||||
Text(AppLocalization.current.calculate),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import 'package:cargocalculaterapp/core/extension/build_context_extension.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../../core/utils/app_utils.dart';
|
||||
|
||||
class OrderDataWidget extends StatelessWidget {
|
||||
const OrderDataWidget({super.key, required this.title, required this.name});
|
||||
|
||||
final String title;
|
||||
final String name;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(child: Text(title, style: context.text.profileCategory)),
|
||||
AppUtils.kBoxWidth8,
|
||||
Expanded(
|
||||
child: Text(
|
||||
name,
|
||||
style: context.text.profileCategory,
|
||||
textAlign: TextAlign.end,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
const Padding(padding: AppUtils.kPaddingVer8, child: AppUtils.kDivider),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user