From 1699acc27cb481ef04d64f52f220bf4f71f4977e Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Mon, 11 May 2026 12:56:26 +0300 Subject: [PATCH] improvements --- lib/modules/cm_module/create_cm_request.dart | 15 +- .../device_transfer/search_device_page.dart | 146 +++---- .../common_widgets/app_dashed_button.dart | 6 +- .../common_widgets/app_text_form_field.dart | 16 +- .../requests/create_service_request_page.dart | 407 ------------------ lib/views/widgets/equipment/asset_picker.dart | 52 +-- lib/views/widgets/horizontal_list_widget.dart | 16 +- .../widgets/sound/TextSpeechRecordWidget.dart | 25 +- lib/views/widgets/sound/sound_player.dart | 18 +- 9 files changed, 130 insertions(+), 571 deletions(-) delete mode 100644 lib/views/pages/user/requests/create_service_request_page.dart diff --git a/lib/modules/cm_module/create_cm_request.dart b/lib/modules/cm_module/create_cm_request.dart index 95c74d29..e9d38414 100644 --- a/lib/modules/cm_module/create_cm_request.dart +++ b/lib/modules/cm_module/create_cm_request.dart @@ -158,13 +158,12 @@ class _CreateCMRequestState extends State with TickerProviderSt AttachmentPicker( label: context.translation.attachImage, attachment: _deviceImages, - buttonColor: AppColor.black10, onlyImages: false, - buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120), + buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.primary10), ), ], ).paddingAll(0).toShadowContainer(context), - 16.height, + 12.height, commentWidget(serviceRequest: _serviceRequest), ], ), @@ -202,7 +201,7 @@ class _CreateCMRequestState extends State with TickerProviderSt crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ - context.translation.assetStatus.bodyText(context).custom(color: AppColor.black20), + context.translation.assetStatus.bodyText(context).custom(color: AppColor.textStyleColor(context)), 8.height, Wrap( runSpacing: 8, @@ -222,7 +221,7 @@ class _CreateCMRequestState extends State with TickerProviderSt if (states.contains(WidgetState.selected)) { return AppColor.primary10; // Thumb color when selected } - return Colors.grey; // Thumb color when unselected (grey) + return AppColor.icon2Color(context); // Thumb color when unselected (grey) }), groupValue: _serviceRequest.defectType, onChanged: (state) { @@ -232,7 +231,7 @@ class _CreateCMRequestState extends State with TickerProviderSt }), ), 8.width, - Text(element.name ?? '', style: AppTextStyles.tinyFont.copyWith(color: AppColor.neutral120)), + Text(element.name ?? '', style: AppTextStyles.tinyFont.copyWith(color: AppColor.icon2Color(context))), ], ) ], @@ -246,7 +245,7 @@ class _CreateCMRequestState extends State with TickerProviderSt return AssetPicker( device: _serviceRequest.device, showLoading: checkPendingRequest, - borderColor: AppColor.black20, + // borderColor: AppColor.black20, onPick: (asset) async { pendingAssetServiceRequest = null; _serviceRequest.device = asset; @@ -262,7 +261,7 @@ class _CreateCMRequestState extends State with TickerProviderSt return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - context.translation.highPriority.bodyText(context).custom(color: AppColor.black20), + context.translation.highPriority.bodyText(context).custom(color: AppColor.textStyleColor(context)), Consumer(builder: (cxt, snapshot, _) { if (snapshot.items.isNotEmpty) { _serviceRequest.priority ??= snapshot.items.firstWhere((element) => element.value == 0, orElse: () => Lookup()); diff --git a/lib/modules/tm_module/device_transfer/search_device_page.dart b/lib/modules/tm_module/device_transfer/search_device_page.dart index cc76e370..f2922165 100644 --- a/lib/modules/tm_module/device_transfer/search_device_page.dart +++ b/lib/modules/tm_module/device_transfer/search_device_page.dart @@ -8,6 +8,7 @@ import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart'; import 'package:test_sa/new_views/common_widgets/app_filled_button.dart'; import 'package:test_sa/new_views/common_widgets/app_text_form_field.dart'; +import 'package:test_sa/new_views/common_widgets/default_app_bar.dart'; import 'package:test_sa/views/widgets/equipment/asset_item_listview.dart'; import 'package:test_sa/views/widgets/horizontal_list_widget.dart'; import 'package:test_sa/views/widgets/loaders/lazy_loading.dart'; @@ -67,27 +68,7 @@ class _SearchDevicePageState extends State { return Scaffold( resizeToAvoidBottomInset: false, - appBar: CustomAppBar( - title: context.translation.searchAsset, - - /// comment reset button because it isn't exist in new design - // actions: [ - // if (_showResetButton()) - // Row( - // crossAxisAlignment: CrossAxisAlignment.center, - // children: [ - // Text( - // context.translation.reset, - // style: AppTextStyles.bodyText2.copyWith(color: const Color(0xFF4A8DB7)), - // ).paddingAll(8).onPress(() { - // setState(() { - // _searchController.text = ""; - // }); - // }), - // ], - // ) - // ], - ), + appBar: DefaultAppBar(title: context.translation.searchAsset), body: Column( children: [ HorizontalListWidget( @@ -117,10 +98,10 @@ class _SearchDevicePageState extends State { _setValue(value); }, suffixIcon: IconButton( - icon: const Icon(Icons.search), + icon: Icon(Icons.search, color: AppColor.icon2Color(context)), splashColor: Colors.transparent, onPressed: _searchController.text.isNotEmpty ? _search : null, - color: AppColor.neutral20, + color: AppColor.icon2Color(context), ).paddingOnly(end: 0), ).paddingOnly(top: 16, start: 16, end: 16, bottom: 8), ), @@ -171,68 +152,67 @@ class _SearchDevicePageState extends State { ).expanded, if (widget.multiSelection && selectedAssets.isNotEmpty) FooterActionButton.footerContainer( - context: context, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Expanded( - child: AppFilledButton( - label: "Clear", - buttonColor: AppColor.white60, - textColor: AppColor.black10, - loading: false, - onPressed: () async { - selectedAssets.clear(); - setState(() {}); - }, + context: context, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Expanded( + child: AppFilledButton( + label: "Clear", + buttonColor: AppColor.white60, + textColor: AppColor.black10, + loading: false, + onPressed: () async { + selectedAssets.clear(); + setState(() {}); + }, + ), ), - ), - 12.width, - Expanded( - child: AppFilledButton( - label: context.translation.select, - buttonColor: AppColor.primary10, - loading: false, - onPressed: () async { - Navigator.of(context).pop(); - List assets = _searchableList.where((asset) => selectedAssets.contains(asset.id)).toList(); - Navigator.of(context).pop(assets); - }, + 12.width, + Expanded( + child: AppFilledButton( + label: context.translation.select, + buttonColor: AppColor.primary10, + loading: false, + onPressed: () async { + Navigator.of(context).pop(); + List assets = _searchableList.where((asset) => selectedAssets.contains(asset.id)).toList(); + Navigator.of(context).pop(assets); + }, + ), ), - ), - ], - ) - ), - // Row( - // mainAxisSize: MainAxisSize.min, - // children: [ - // Expanded( - // child: AppFilledButton( - // label: "Clear", - // buttonColor: AppColor.white60, - // textColor: AppColor.black10, - // loading: false, - // onPressed: () async { - // selectedAssets.clear(); - // setState(() {}); - // }, - // ), - // ), - // 12.width, - // Expanded( - // child: AppFilledButton( - // label: context.translation.select, - // buttonColor: AppColor.primary10, - // loading: false, - // onPressed: () async { - // Navigator.of(context).pop(); - // List assets = _searchableList.where((asset) => selectedAssets.contains(asset.id)).toList(); - // Navigator.of(context).pop(assets); - // }, - // ), - // ), - // ], - // ).toShadowContainer(context), + ], + )), + // Row( + // mainAxisSize: MainAxisSize.min, + // children: [ + // Expanded( + // child: AppFilledButton( + // label: "Clear", + // buttonColor: AppColor.white60, + // textColor: AppColor.black10, + // loading: false, + // onPressed: () async { + // selectedAssets.clear(); + // setState(() {}); + // }, + // ), + // ), + // 12.width, + // Expanded( + // child: AppFilledButton( + // label: context.translation.select, + // buttonColor: AppColor.primary10, + // loading: false, + // onPressed: () async { + // Navigator.of(context).pop(); + // List assets = _searchableList.where((asset) => selectedAssets.contains(asset.id)).toList(); + // Navigator.of(context).pop(assets); + // }, + // ), + // ), + // ], + // ).toShadowContainer(context), ], ), ), diff --git a/lib/new_views/common_widgets/app_dashed_button.dart b/lib/new_views/common_widgets/app_dashed_button.dart index 2e733ef9..e1c94621 100644 --- a/lib/new_views/common_widgets/app_dashed_button.dart +++ b/lib/new_views/common_widgets/app_dashed_button.dart @@ -28,7 +28,7 @@ class AppDashedButton extends StatelessWidget { child: DottedBorder( strokeWidth: 1, padding: padding ?? EdgeInsets.symmetric(vertical: 16.toScreenHeight, horizontal: 16.toScreenWidth), - color: context.isDark ? AppColor.primary40 : buttonColor ?? AppColor.black20, + color: AppColor.primary10, dashPattern: const [4, 3], radius: const Radius.circular(10), borderType: BorderType.RRect, @@ -38,10 +38,10 @@ class AppDashedButton extends StatelessWidget { children: [ icon!, 7.width, - title.heading6(context).custom(color: context.isDark ? AppColor.primary40 : buttonColor ?? AppColor.black10).center, + title.heading6(context).custom(color: AppColor.primary10).center, ], ) - : title.heading6(context).custom(color: context.isDark ? AppColor.primary40 : buttonColor ?? AppColor.primary10).center, + : title.heading6(context).custom(color: AppColor.primary10).center, ), ).onPress(onPressed); } diff --git a/lib/new_views/common_widgets/app_text_form_field.dart b/lib/new_views/common_widgets/app_text_form_field.dart index 360272ae..5b485df7 100644 --- a/lib/new_views/common_widgets/app_text_form_field.dart +++ b/lib/new_views/common_widgets/app_text_form_field.dart @@ -46,6 +46,7 @@ class AppTextFormField extends StatefulWidget { final bool showSpeechToText; final Color? enableColor; final bool makeMultiLinesNull; + final bool isBackgroundTransparent; const AppTextFormField({ Key? key, @@ -81,6 +82,7 @@ class AppTextFormField extends StatefulWidget { this.alignLabelWithHint = false, // Provide default value this.makeMultiLinesNull = false, this.onTap, + this.isBackgroundTransparent = false, this.enableColor, }) : super(key: key); @@ -209,12 +211,14 @@ class _AppTextFormFieldState extends State { contentPadding: widget.contentPadding ?? EdgeInsets.symmetric(vertical: 12.toScreenHeight, horizontal: 16.toScreenWidth), constraints: const BoxConstraints(), suffixIconConstraints: const BoxConstraints(minWidth: 0), - filled: true, - fillColor: (context.isDark && !widget.enable - ? AppColor.neutral50 - : !widget.enable - ? (widget.enableColor ?? AppColor.disableDark) - : AppColor.dropDownBackground(context)), + filled: !widget.isBackgroundTransparent, + fillColor: widget.isBackgroundTransparent + ? null + : (context.isDark && !widget.enable + ? AppColor.neutral50 + : !widget.enable + ? (widget.enableColor ?? AppColor.disableDark) + : AppColor.dropDownBackground(context)), errorStyle: AppTextStyle.tiny.copyWith(color: context.isDark ? AppColor.red50 : AppColor.red30), // floatingLabelStyle: widget.floatingLabelStyle ?? AppTextStyle.body1.copyWith(fontWeight: FontWeight.w500, color: context.isDark ? AppColor.white10 : AppColor.neutral20), diff --git a/lib/views/pages/user/requests/create_service_request_page.dart b/lib/views/pages/user/requests/create_service_request_page.dart deleted file mode 100644 index 3c94b7de..00000000 --- a/lib/views/pages/user/requests/create_service_request_page.dart +++ /dev/null @@ -1,407 +0,0 @@ -// import 'dart:convert'; -// import 'dart:io'; -// -// import 'package:flutter/cupertino.dart'; -// import 'package:flutter/material.dart'; -// import 'package:provider/provider.dart'; -// import 'package:test_sa/controllers/providers/api/service_requests_provider.dart'; -// import 'package:test_sa/controllers/providers/api/user_provider.dart'; -// import 'package:test_sa/controllers/providers/settings/setting_provider.dart'; -// import 'package:test_sa/extensions/context_extension.dart'; -// import 'package:test_sa/extensions/int_extensions.dart'; -// import 'package:test_sa/extensions/widget_extensions.dart'; -// import 'package:test_sa/models/generic_attachment_model.dart'; -// import 'package:test_sa/models/service_request/pending_service_request_model.dart'; -// import 'package:test_sa/models/service_request/service_request.dart'; -// import 'package:test_sa/modules/cm_module/utilities/cm_request_utils.dart'; -// import 'package:test_sa/new_views/common_widgets/app_filled_button.dart'; -// import 'package:test_sa/providers/service_request_providers/equipment_status_provider.dart'; -// import 'package:test_sa/providers/service_request_providers/requested_through_provider.dart'; -// import 'package:test_sa/views/pages/user/requests/pending_requests_screen.dart'; -// import 'package:test_sa/views/widgets/bottom_sheets/pending_request_bottom_sheet.dart'; -// import 'package:test_sa/views/widgets/equipment/asset_picker.dart'; -// import 'package:test_sa/views/widgets/images/multi_image_picker.dart'; -// import 'package:test_sa/views/widgets/loaders/loading_manager.dart'; -// import 'package:test_sa/views/widgets/sound/TextSpeechRecordWidget.dart'; -// -// import '../../../../new_views/app_style/app_color.dart'; -// import '../../../../new_views/common_widgets/default_app_bar.dart'; -// import '../../../../providers/service_request_providers/priority_provider.dart'; -// import '../../../../providers/service_request_providers/type_of_request_provider.dart'; -// -// class CreateServiceRequestPage extends StatefulWidget { -// static const String id = "/create-request"; -// final ServiceRequest? serviceRequest; -// -// const CreateServiceRequestPage({this.serviceRequest, Key? key}) : super(key: key); -// -// @override -// CreateServiceRequestPageState createState() => CreateServiceRequestPageState(); -// } -// -// class CreateServiceRequestPageState extends State { -// late TextEditingController _commentController; -// -// late double _height; -// late UserProvider _userProvider; -// late SettingProvider _settingProvider; -// late ServiceRequestsProvider _serviceRequestsProvider; -// late ServiceRequest _serviceRequest; -// final List attachments = []; -// final bool _isLoading = false; -// bool _showDatePicker = false; -// final GlobalKey _formKey = GlobalKey(); -// final GlobalKey _scaffoldKey = GlobalKey(); -// DateTime? _dateTime; -// -// bool isFirstActionSubmitted = false; -// -// @override -// void initState() { -// _commentController = TextEditingController(); -// if (widget.serviceRequest != null) { -// _serviceRequest = widget.serviceRequest!; -// attachments.addAll(_serviceRequest.devicePhotos!.map((e) => GenericAttachmentModel(name: e)).toList()); -// _showDatePicker = _serviceRequest.firstAction != null && _serviceRequest.firstAction?.name == "Need a visit"; -// if (_showDatePicker && _serviceRequest.visitDate != null) { -// _dateTime = DateTime.tryParse(_serviceRequest.visitDate!); -// } -// } else { -// _serviceRequest = ServiceRequest(); -// } -// isFirstActionSubmitted = _serviceRequest.firstAction != null; -// super.initState(); -// } -// -// // -// // getServiceRequestById(String id) async { -// // try { -// // ServiceRequest request = await _serviceRequestsProvider.getServiceRequestObjectById(requestId: id) ?? ""; -// // _serviceRequest = request; -// // _device = _serviceRequest.device; -// // attachments.addAll(_serviceRequest.devicePhotos.map((e) { -// // return File(e); -// // }).toList()); -// // _showDatePicker = _serviceRequest.firstAction != null && _serviceRequest.firstAction.name == "Need a visit"; -// // if (_showDatePicker && _serviceRequest.visitDate != null) { -// // _dateTime = DateTime.tryParse(_serviceRequest.visitDate); -// // } -// // _isLoading = false; -// // } catch (ex) { -// // _isLoading = false; -// // } -// // setState(() {}); -// // } -// -// @override -// void dispose() { -// _commentController.dispose(); -// super.dispose(); -// } -// -// bool _isLocalUrl(String url) { -// if (url.isEmpty != false) return false; -// return url.startsWith("/") || url.startsWith("file://") || url.substring(1).startsWith(':\\'); -// } -// -// // bool priority; -// -// void getData() { -// Provider.of(context).getDate(); -// Provider.of(context).getDate(); -// Provider.of(context).getDate(); -// Provider.of(context).getDate(); -// } -// -// PendingAssetServiceRequest? pendingAssetServiceRequest; -// -// @override -// Widget build(BuildContext context) { -// _height = MediaQuery.of(context).size.height; -// _userProvider = Provider.of(context); -// -// _serviceRequestsProvider = Provider.of(context); -// -// return Scaffold( -// key: _scaffoldKey, -// appBar: DefaultAppBar(title: context.translation.newServiceRequest), -// body: SafeArea( -// child: LoadingManager( -// isLoading: _isLoading, -// isFailedLoading: false, -// stateCode: 200, -// onRefresh: () async {}, -// child: Form( -// key: _formKey, -// child: Column( -// children: [ -// SingleChildScrollView( -// child: Column( -// crossAxisAlignment: CrossAxisAlignment.start, -// children: [ -// Column( -// crossAxisAlignment: CrossAxisAlignment.start, -// mainAxisSize: MainAxisSize.min, -// children: [ -// AssetPicker( -// device: _serviceRequest.device, -// showLoading: checkPendingRequest, -// onPick: (asset) async { -// pendingAssetServiceRequest = null; -// _serviceRequest.device = asset; -// await checkAssetForPendingServiceRequest(asset.id!.toInt()); -// -// if (pendingAssetServiceRequest != null && pendingAssetServiceRequest!.details!.isNotEmpty) { -// showPendingRequestBottomSheet(); -// } -// }, -// ), -// if (pendingAssetServiceRequest != null && pendingAssetServiceRequest!.details!.isNotEmpty) ...[ -// 8.height, -// Row( -// children: [ -// const Icon(Icons.warning, color: Color(0xffEE404C), size: 14), -// 8.width, -// Text( -// "This asset already have ${pendingAssetServiceRequest!.details!.length} request pending", -// style: const TextStyle(fontSize: 12, fontWeight: FontWeight.w500, color: Color(0xff7D859A), decoration: TextDecoration.underline), -// ).expanded, -// ], -// ).onPress(() { -// showPendingRequests(); -// }), -// ], -// 16.height, -// Row( -// mainAxisAlignment: MainAxisAlignment.spaceBetween, -// children: [ -// Text(context.translation.priority, style: Theme.of(context).textTheme.bodyLarge), -// Consumer(builder: (cxt, snapshot, _) { -// _serviceRequest.priority ??= snapshot.items.firstWhere((element) => element.value == 0, orElse: null); -// -// return Transform.scale( -// scale: 0.8, -// child: CupertinoSwitch( -// thumbColor: _serviceRequest.priority?.value != 0 ? const Color(0xffF63939) : Colors.blueGrey.withOpacity(.5), -// activeColor: AppColor.blueStatus(context).withOpacity(.25), -// value: _serviceRequest.priority?.value != 0, -// onChanged: (state) { -// if (state) { -// _serviceRequest.priority = snapshot.items.firstWhere((element) => element.value == 1, orElse: null); -// } else { -// _serviceRequest.priority = snapshot.items.firstWhere((element) => element.value == 0, orElse: null); -// } -// setState(() {}); -// }).toShimmer(isShow: snapshot.loading,context: context), -// ); -// }), -// ], -// ), -// 16.height, -// Consumer(builder: (cxt, snapshot, _) { -// try { -// _serviceRequest.defectType ??= snapshot.items.first; -// } catch (ex) { -// print("snapshot.items:${snapshot.items.length}"); -// } -// -// return Column( -// crossAxisAlignment: CrossAxisAlignment.start, -// mainAxisSize: MainAxisSize.min, -// children: [ -// Text(context.translation.equipmentStatus, style: Theme.of(context).textTheme.bodyLarge), -// 8.height, -// Wrap( -// runSpacing: 8, -// spacing: 8, -// children: [ -// for (var element in snapshot.items) -// Row( -// mainAxisSize: MainAxisSize.min, -// children: [ -// SizedBox( -// width: 24, -// height: 24, -// child: Radio( -// value: element, -// activeColor: Colors.red, -// fillColor: WidgetStateColor.resolveWith((states) { -// if (states.contains(WidgetState.selected)) return const Color(0xff3DA5E5); -// return const Color(0xffE0E0E0); -// }), -// groupValue: _serviceRequest.defectType, -// onChanged: (state) { -// setState(() { -// _serviceRequest.defectType = element; -// }); -// }), -// ), -// 8.width, -// Text(element.name!, style: Theme.of(context).textTheme.bodySmall), -// ], -// ) -// ], -// ).toShimmer(isShow: snapshot.loading,context: context), -// ], -// ); -// }), -// 16.height, -// AttachmentPicker(label: context.translation.attachImage, attachment: attachments, showAsGrid: true), -// ], -// ).toShadowContainer(context), -// -// // SingleItemDropDownMenu( -// // context: context, -// // title: context.translation.priority, -// // initialValue: _serviceRequest?.priority, -// // onSelect: (value) { -// // _serviceRequest.priority = value; -// // }, -// // ), -// // 8.height, -// // SingleItemDropDownMenu( -// // context: context, -// // title: context.translation.equipmentStatus, -// // initialValue: _serviceRequest?.defectType, -// // onSelect: (value) { -// // _serviceRequest.defectType = value; -// // }, -// // ), -// -// // Consumer(builder: (context, snapshot, _) { -// // return SingleItemDropDownMenu( -// // context: context, -// // enabled: false, -// // title: context.translation.source, -// // initialValue: snapshot.items?.firstWhere((element) => element.value == 3, orElse: null), -// // ); -// // }), -// // 8.height, -// // Consumer(builder: (context, snapshot, _) { -// // return SingleItemDropDownMenu( -// // context: context, -// // title: context.translation.requestType, -// // enabled: false, -// // initialValue: snapshot.items?.firstWhere((element) => element.value == 1, orElse: null), -// // // onSelect: (value) { -// // // _serviceRequest.type = value; -// // // }, -// // ); -// // }), -// -// // Align( -// // alignment: AlignmentDirectional.centerStart, -// // child: context.translation.callComments.heading5(context).custom(color: AppColor.textStyleColor(context)), -// // ), -// 8.height, -// // SpeechToTextButton( -// // controller: _commentController, -// // ), -// // 8.height, -// // AppTextFormField( -// // controller: _commentController, -// // labelText: context.translation.problemDesc, -// // suffixIcon: "warning".toSvgAsset(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20, width: 24).paddingOnly(end: 16), -// // initialValue: _serviceRequest.callComments, -// // onSaved: (text) { -// // _serviceRequest.callComments = text; -// // }, -// // ), -// // 8.height, -// // RecordSound( -// // onRecord: (audio) { -// // _serviceRequest.audio = audio; -// // }, -// // enabled: widget.serviceRequest == null ? true : false, -// // ), -// 8.height, -// TextSpeechRecordWidget( -// initialMessage: _serviceRequest.callComments!, -// onMessageChange: (message) { -// _serviceRequest.callComments = message; -// }, -// onRecord: (audio) { -// _serviceRequest.audio = audio; -// }, -// enabled: widget.serviceRequest == null ? true : false, -// ), -// 16.height, -// ], -// ), -// ).expanded, -// AppFilledButton( -// onPressed: checkPendingRequest ? null : _submit, -// loading: checkPendingRequest, -// label: (pendingAssetServiceRequest != null && (pendingAssetServiceRequest!.details?.isNotEmpty ?? false)) ? "Submit Duplicate Request" : "Submit New Request", -// ), -// ], -// ), -// ).paddingOnly(start: 16, end: 16, bottom: 24, top: 16), -// ), -// ), -// ); -// } -// -// bool checkPendingRequest = false; -// -// void showPendingRequests() { -// Navigator.of(context).push(MaterialPageRoute(builder: (_) => PendingServiceRequestScreen(pendingAssetServiceRequest!))); -// } -// -// void showPendingRequestBottomSheet() async { -// bool view = (await showModalBottomSheet( -// context: context, -// isDismissible: false, -// shape: const RoundedRectangleBorder( -// borderRadius: BorderRadius.vertical( -// top: Radius.circular(20), -// ), -// ), -// clipBehavior: Clip.antiAliasWithSaveLayer, -// builder: (BuildContext context) => PendingRequestBottomSheet(pendingAssetServiceRequest!, _serviceRequest.device!), -// )) as bool; -// if (view) { -// showPendingRequests(); -// } -// } -// -// Future checkAssetForPendingServiceRequest(int assetId) async { -// checkPendingRequest = true; -// setState(() {}); -// -// pendingAssetServiceRequest = await _serviceRequestsProvider.checkAssetPendingRequest(assetId); -// await Future.delayed(const Duration(milliseconds: 250)); -// -// checkPendingRequest = false; -// setState(() {}); -// } -// -// Future _submit() async { -// _serviceRequest.requestedThrough = Provider.of(context, listen: false).items.firstWhere((element) => element.value == 3, orElse: null); -// _serviceRequest.type = Provider.of(context, listen: false).items.firstWhere((element) => element.value == 1, orElse: null); -// -// if (_formKey.currentState!.validate() && await _serviceRequest.validateNewRequest(context)) { -// _formKey.currentState!.save(); -// -// // bool canSubmitRequest = await checkAssetForPendingServiceRequest(_serviceRequest.device.id); -// // if (!canSubmitRequest) { -// // return; -// // } -// -// -// _serviceRequest.devicePhotos = attachments.map((item) => ServiceRequestUtils.isLocalUrl(item.name??'') ? "${item.name?.split("/").last}|${base64Encode(File(item.name??'').readAsBytesSync())}" : item.name??'').toList(); -// if (_serviceRequest.audio != null) { -// if (_isLocalUrl(_serviceRequest.audio!)) { -// final File file = File(_serviceRequest.audio!); -// _serviceRequest.audio = "${file.path.split("/").last}|${base64Encode(file.readAsBytesSync())}"; -// } -// } -// await _serviceRequestsProvider.createRequest( -// context: context, -// user: _userProvider.user!, -// host: _settingProvider.host!, -// serviceRequest: _serviceRequest, -// ); -// } -// } -// } diff --git a/lib/views/widgets/equipment/asset_picker.dart b/lib/views/widgets/equipment/asset_picker.dart index fcb827d5..ff8a06a5 100644 --- a/lib/views/widgets/equipment/asset_picker.dart +++ b/lib/views/widgets/equipment/asset_picker.dart @@ -4,6 +4,8 @@ import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/text_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/views/widgets/bottom_sheets/asset_detail_bottom_sheet.dart'; +import 'package:test_sa/views/widgets/item_views/info_header_widget.dart'; +import 'package:test_sa/views/widgets/item_views/info_text_widget.dart'; import 'package:test_sa/views/widgets/qr/asset_scan_qr.dart'; import '../../../models/device/asset.dart'; @@ -65,7 +67,7 @@ class AssetPicker extends StatelessWidget { height: 50.toScreenHeight, alignment: Alignment.center, decoration: BoxDecoration( - color: buttonColor ?? backgroundColor ?? AppColor.blueStatus(context), + color: buttonColor ?? backgroundColor ?? AppColor.primary10, borderRadius: BorderRadius.circular(10), border: showBorder ? Border.all(color: borderColor ?? AppColor.blueStatus(context), width: 2) : null, // boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.03), blurRadius: 14)], @@ -74,9 +76,9 @@ class AssetPicker extends StatelessWidget { child: Row( mainAxisSize: MainAxisSize.min, children: [ - "scan_asset".toSvgAsset(height: 22, fit: BoxFit.fitHeight, color: context.isDark ? AppColor.neutral20 : iconColor ?? Colors.white), + "scan_asset".toSvgAsset(height: 22, fit: BoxFit.fitHeight, color: AppColor.icon2Color(context)), 8.width, - ' ${label ?? "Scan or Pick Asset"}'.bodyText(context).custom(color: context.isDark ? AppColor.neutral20 : labelColor ?? Colors.white), + ' ${label ?? "Scan or Pick Asset"}'.bodyText(context).custom(color: AppColor.icon2Color(context)), ], ), ).onPress(() async { @@ -107,16 +109,18 @@ class AssetPicker extends StatelessWidget { height: 50, alignment: Alignment.center, decoration: BoxDecoration( - color: Colors.white, borderRadius: BorderRadius.circular(10), border: Border.all(color: borderColor ?? AppColor.blueStatus(context), width: 2), + // color: Colors.white, + borderRadius: BorderRadius.circular(10), + border: Border.all(color: borderColor ?? AppColor.border2Color(context), width: 1), // boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.03), blurRadius: 14)], ), padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth, vertical: 8.toScreenHeight), child: Row( mainAxisSize: MainAxisSize.min, children: [ - "scan_asset".toSvgAsset(height: 22, fit: BoxFit.fitHeight, color: context.isDark ? AppColor.neutral20 : AppColor.neutral120), + "scan_asset".toSvgAsset(height: 22, fit: BoxFit.fitHeight, color: AppColor.icon2Color(context)), 8.width, - "Re-Scan or Pick Asset".bodyText(context).custom(color: context.isDark ? AppColor.neutral20 : AppColor.black20), + "Re-Scan or Pick Asset".bodyText(context).custom(color: AppColor.textStyleColor(context)), ], ), ).onPress(() async { @@ -159,39 +163,25 @@ class AssetPicker extends StatelessWidget { return Container( padding: const EdgeInsets.all(12), decoration: BoxDecoration( - color: showLoading ? Colors.white : const Color(0xffF4F6FC), - borderRadius: BorderRadius.circular(12), - border: Border.all( - color: const Color(0xff212936).withOpacity(.03), - ), + color: showLoading ? Colors.white : AppColor.background(context), + borderRadius: BorderRadius.circular(16), + border: Border.all(color: borderColor ?? AppColor.borderColor(context)), ), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Row( children: [ - Text( + InfoHeaderWidget( device.modelDefinition?.assetName?.cleanupWhitespace.capitalizeFirstOfEach ?? "", - style: TextStyle( - fontSize: 14.toScreenWidth, - fontWeight: FontWeight.w500, - fontStyle: FontStyle.normal, - color: Colors.black87, - decoration: TextDecoration.none, - ), ).toShimmer(isShow: showLoading, context: context).expanded, - const Icon( - Icons.info, - color: Color(0xff7D859A), - size: 20, - ).onPress(() { + Icon(Icons.info, color: AppColor.icon2Color(context), size: 20).onPress(() { showModalBottomSheet( context: context, isScrollControlled: true, + backgroundColor: AppColor.bottomSheetColor(context), shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.vertical( - top: Radius.circular(20), - ), + borderRadius: BorderRadius.vertical(top: Radius.circular(20)), ), clipBehavior: Clip.antiAliasWithSaveLayer, builder: (BuildContext context) => AssetDetailBottomSheet(device), @@ -206,10 +196,12 @@ class AssetPicker extends StatelessWidget { ], ), 8.height, - "${context.translation.assetNo}: ${device.assetNumber}".bodyText2(context).toShimmer(isShow: showLoading, context: context), - 2.height, + InfoTextWidget(label: context.translation.assetNo, value: device.assetNumber).toShimmer(isShow: showLoading, context: context), + // 2.height, // "${context.translation.manufacture}: ${device.modelDefinition?.manufacturerName}".bodyText(context), - "${context.translation.model}: ${device.modelDefinition?.modelName}".bodyText2(context).toShimmer(isShow: showLoading, context: context), + InfoTextWidget(label: context.translation.model, value: device.modelDefinition?.modelName).toShimmer(isShow: showLoading, context: context), + + // "${context.translation.model}: ${device.modelDefinition?.modelName}".bodyText2(context).toShimmer(isShow: showLoading, context: context), // "${context.translation.serialNumber}: ${device.assetNumber}".bodyText(context), // const Divider().defaultStyle(context), // "${context.translation.department}: ${device.department?.departmentName}".bodyText(context), diff --git a/lib/views/widgets/horizontal_list_widget.dart b/lib/views/widgets/horizontal_list_widget.dart index 6905aa8c..32ae76b0 100644 --- a/lib/views/widgets/horizontal_list_widget.dart +++ b/lib/views/widgets/horizontal_list_widget.dart @@ -22,23 +22,25 @@ class _HorizontalListWidgetState extends State { Widget build(BuildContext context) { return SizedBox( height: 35.toScreenHeight, - child: ListView.builder( + child: ListView.separated( itemCount: widget.list.length, scrollDirection: Axis.horizontal, shrinkWrap: true, padding: EdgeInsetsDirectional.only(start: 16.toScreenWidth, end: 16), + separatorBuilder: (cxt, index) => 8.width, itemBuilder: (context, index) => Container( - margin: EdgeInsets.symmetric(horizontal: 4.toScreenWidth), - padding: EdgeInsets.symmetric(horizontal: 20.toScreenWidth), + // margin: EdgeInsets.symmetric(horizontal: 4.toScreenWidth), + padding: EdgeInsets.symmetric(vertical: 8.toScreenHeight, horizontal: 12.toScreenWidth), alignment: Alignment.center, decoration: ShapeDecoration( - color: _selectedIndex == index ? Colors.transparent : AppColor.selectedButtonColor(context), + color: AppColor.background(context), + shadows: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 14, offset: const Offset(0, 0), spreadRadius: 0)], shape: RoundedRectangleBorder( - side: _selectedIndex == index ? BorderSide(width: 2, color: (context.isDark ? AppColor.backgroundLight : AppColor.backgroundDark)) : BorderSide.none, - borderRadius: BorderRadius.circular(7), + side: BorderSide(width: 1, color: _selectedIndex == index ? AppColor.primary10 : AppColor.border2Color(context)), + borderRadius: BorderRadius.circular(6), ), ), - child: (widget.list[index]).tinyFont(context).custom(color: AppColor.filterButtonTextColor(context)), + child: widget.list[index].tinyFont(context).custom(color: _selectedIndex == index ? AppColor.primary10 : AppColor.filterButtonTextColor(context)), ).onPress(() { setState(() { _selectedIndex = index; diff --git a/lib/views/widgets/sound/TextSpeechRecordWidget.dart b/lib/views/widgets/sound/TextSpeechRecordWidget.dart index 74ce8e09..6c9cae44 100644 --- a/lib/views/widgets/sound/TextSpeechRecordWidget.dart +++ b/lib/views/widgets/sound/TextSpeechRecordWidget.dart @@ -29,7 +29,7 @@ class TextSpeechRecordWidget extends StatefulWidget { final Function(String) onMessageChange; final String initialMessage; - const TextSpeechRecordWidget({Key? key, required this.onRecord, this.onStop, this.enabled = true,required this.onMessageChange,required this.initialMessage}) : super(key: key); + const TextSpeechRecordWidget({Key? key, required this.onRecord, this.onStop, this.enabled = true, required this.onMessageChange, required this.initialMessage}) : super(key: key); @override State createState() => _RecordSoundState(); @@ -75,7 +75,7 @@ class _RecordSoundState extends State { _commentController = TextEditingController(); node.unfocus(); _recorderIsOpened = true; - _settingProvider = Provider.of(context,listen: false); + _settingProvider = Provider.of(context, listen: false); } @override @@ -189,8 +189,9 @@ class _RecordSoundState extends State { controller: _commentController, labelText: _speechToText.isListening ? "Listening..." : context.translation.callComments, alignLabelWithHint: true, + isBackgroundTransparent: true, showWithoutDecoration: true, - backgroundColor: Colors.transparent, + // backgroundColor: Colors.transparent, textInputType: TextInputType.multiline, // suffixIcon: // (_recording ? "record".toLottieAsset(height: 24) : (_record != null ? "trash" : "mic").toSvgAsset(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20, height: 24)) @@ -204,20 +205,14 @@ class _RecordSoundState extends State { }, ).expanded, (_speechToText.isListening - ? SizedBox( - height: 24.toScreenHeight, - width: 24.toScreenWidth, - child: const Icon( - Icons.fiber_manual_record, - color: Colors.red, - )).onPress(() { + ? SizedBox(height: 24.toScreenHeight, width: 24.toScreenWidth, child: const Icon(Icons.fiber_manual_record, color: AppColor.red30)).onPress(() { _stopListening(); }) : PopupMenuButton( child: SizedBox( height: 24.toScreenHeight, width: 24.toScreenWidth, - child: "speech_to_text".toSvgAsset(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20, height: 24, width: 24), + child: "speech_to_text".toSvgAsset(color: AppColor.icon2Color(context), height: 24, width: 24), ), onSelected: (String selectedLanguage) { _settingProvider.setSpeechToText(selectedLanguage); @@ -243,9 +238,9 @@ class _RecordSoundState extends State { AppTextFormField( enable: widget.enabled, node: node, - backgroundColor: Colors.transparent, - showWithoutDecoration: true, + isBackgroundTransparent: true, controller: _timeController, + showBorder: false, labelText: context.translation.recordVoice, textInputType: TextInputType.multiline, alignLabelWithHint: true, @@ -290,9 +285,7 @@ class _RecordSoundState extends State { SizedBox( height: _recording ? 40 : 24.toScreenHeight, width: _recording ? 40 : 24.toScreenWidth, - child: (_recording - ? "record".toLottieAsset(height: 24) - : (_record != null ? "trash" : "mic").toSvgAsset(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20, height: 24, width: 24)), + child: (_recording ? "record".toLottieAsset(height: 24) : (_record != null ? "trash" : "mic").toSvgAsset(color: AppColor.icon2Color(context), height: 24, width: 24)), ).paddingOnly(end: 16, top: 16).onPress(() { if (_recording) { _stopRecording(); diff --git a/lib/views/widgets/sound/sound_player.dart b/lib/views/widgets/sound/sound_player.dart index a9368299..93a25a01 100644 --- a/lib/views/widgets/sound/sound_player.dart +++ b/lib/views/widgets/sound/sound_player.dart @@ -1,6 +1,7 @@ import 'package:audioplayers/audioplayers.dart'; import 'package:flutter/material.dart'; import 'package:test_sa/extensions/context_extension.dart'; +import 'package:test_sa/extensions/text_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/new_views/app_style/app_color.dart'; import 'package:test_sa/new_views/app_style/app_text_style.dart'; @@ -32,15 +33,11 @@ class _ASoundPlayerState extends State { decoration: ShapeDecoration( color: AppColor.background(context), shape: RoundedRectangleBorder( - side: BorderSide(width: 1, color: (context.isDark ? AppColor.neutral20 : AppColor.neutral30)), + side: BorderSide(width: 1, color: AppColor.border2Color(context)), borderRadius: BorderRadius.circular(32), ), ), - child: Icon( - icon, - size: 30, - color: (context.isDark ? AppColor.primary40 : AppColor.primary70).withOpacity(0.5), - ), + child: Icon(icon, size: 30, color: (AppColor.primary10)), ).onPress(onpress); } @@ -182,8 +179,8 @@ class _ASoundPlayerState extends State { value: _audioPosition?.inMilliseconds.toDouble() ?? 0.0, min: 0, max: _audioTime?.inMilliseconds.toDouble() ?? 60.0, - activeColor: context.isDark ? AppColor.primary40 : AppColor.primary70, - inactiveColor: context.isDark ? AppColor.neutral20 : AppColor.neutral30, + activeColor: AppColor.primary10, + inactiveColor: AppColor.border2Color(context), onChangeStart: (value) { _sliderMoving = true; }, @@ -199,9 +196,8 @@ class _ASoundPlayerState extends State { ), ).paddingOnly(start: 8, end: 8).expanded, _failedToLoad - ? Text("Failed to load", style: AppTextStyle.tiny.copyWith(color: context.isDark ? AppColor.red50 : AppColor.red60)) - : Text("${format(_audioPosition ?? Duration.zero)}/${format(_audioTime ?? Duration.zero)}", - style: AppTextStyle.tiny.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)), + ? Text("Failed to load", style: AppTextStyles.tinyFont.copyWith(color: AppColor.textStyleColor(context))) + : Text("${format(_audioPosition ?? Duration.zero)}/${format(_audioTime ?? Duration.zero)}", style: AppTextStyles.tinyFont.copyWith(color: AppColor.textStyleColor(context))), ], ), ],