From 129a021ed96c5783190d1708a21a3ca3b8400153 Mon Sep 17 00:00:00 2001 From: komekh Date: Tue, 27 Aug 2024 09:53:55 +0500 Subject: [PATCH] developed --- assets/locale/ru-RU.json | 7 ++- assets/locale/tr-TR.json | 5 +- lib/core/constants/api.dart | 3 +- .../remote/order_remote_data_source.dart | 4 +- lib/data/models/order/order_model.dart | 60 ++++++++++-------- lib/domain/entities/order/order.dart | 6 ++ lib/presentation/screens/order_details.dart | 61 +++++++++++-------- lib/presentation/widgets/order_card.dart | 4 +- 8 files changed, 89 insertions(+), 61 deletions(-) diff --git a/assets/locale/ru-RU.json b/assets/locale/ru-RU.json index e775a60..6d4e001 100644 --- a/assets/locale/ru-RU.json +++ b/assets/locale/ru-RU.json @@ -20,7 +20,7 @@ "login_hint": "Öz loginiňizi ýazyň", "password": "Açar sözi", "password_hint": "Öz açar sözüni ýazyň", - "credentials_validation_header": "'Invalid credentials", + "credentials_validation_header": "Invalid credentials", "credentials_validation_body": "Username or Password Wrong!", "required_validation": "This field can't be empty", "order": "Sargyt", @@ -43,5 +43,8 @@ "order_details": "Giňişleýin", "order_from_card": "Nireden", "order_to_card": "Nirä", - "order_sent": "Ugradylan senesi" + "order_sent": "Ugradylan senesi", + "Reserved": "Rezerw", + "Received": "Kabul edildi", + "Delivered": "Gowşuryldy" } diff --git a/assets/locale/tr-TR.json b/assets/locale/tr-TR.json index e775a60..3816a10 100644 --- a/assets/locale/tr-TR.json +++ b/assets/locale/tr-TR.json @@ -43,5 +43,8 @@ "order_details": "Giňişleýin", "order_from_card": "Nireden", "order_to_card": "Nirä", - "order_sent": "Ugradylan senesi" + "order_sent": "Ugradylan senesi", + "Reserved":"Rezerw", + "Received":"Kabul edildi", + "Delivered":"Gowşuryldy" } diff --git a/lib/core/constants/api.dart b/lib/core/constants/api.dart index 29fc01b..68b33df 100644 --- a/lib/core/constants/api.dart +++ b/lib/core/constants/api.dart @@ -1,3 +1,4 @@ -const String baseUrl = 'https://192.168.99.64:5001/api'; +// const String baseUrl = 'https://192.168.99.64:5001/api'; +const String baseUrl = 'https://cargo.tpsadvertising.com/api'; const String defaultApiKey = ''; const String defaultSources = ''; diff --git a/lib/data/data_sources/remote/order_remote_data_source.dart b/lib/data/data_sources/remote/order_remote_data_source.dart index 6f62971..aa9e33e 100644 --- a/lib/data/data_sources/remote/order_remote_data_source.dart +++ b/lib/data/data_sources/remote/order_remote_data_source.dart @@ -37,9 +37,9 @@ class OrderRemoteDataSourceImpl implements OrderRemoteDataSource { } @override - Future getRoutes(String orderId) async { + Future getRoutes(String cargoId) async { final response = await client.get( - Uri.parse('$baseUrl/Cargo/Route/$orderId'), + Uri.parse('$baseUrl/Cargo/Route/$cargoId'), headers: { 'Content-Type': 'application/json', 'accept': '*/*', diff --git a/lib/data/models/order/order_model.dart b/lib/data/models/order/order_model.dart index 23d8248..33ab80f 100644 --- a/lib/data/models/order/order_model.dart +++ b/lib/data/models/order/order_model.dart @@ -21,6 +21,9 @@ class OrderModel extends OrderEntity { required super.depth, required super.width, required super.height, + required super.image1, + required super.image2, + required super.image3, }); // Factory method to create an instance of CargoEntity from JSON factory OrderModel.fromJson(Map json) { @@ -31,42 +34,45 @@ class OrderModel extends OrderEntity { clientId: json['ClientId'], cargoId: json['CargoId'], state: json['State'], - no: json['No'], - name: json['Name'], - shopNo: json['ShopNo'], + no: json['No'] ?? '', + name: json['Name'] ?? '', + shopNo: json['ShopNo'] ?? '', volume: json['Volume'].toDouble(), placesCount: json['PlacesCount'], - carrier: json['Carrier'], - from: json['From'], - to: json['To'], + carrier: json['Carrier'] ?? '', + from: json['From'] ?? '', + to: json['To'] ?? '', departedAt: DateUtil.formatDateTimeToDDMMYYYY(departedAt), arrivedAt: DateUtil.formatDateTimeToDDMMYYYY(arrivedAt), depth: json['Depth'].toDouble(), width: json['Width'].toDouble(), height: json['Height'].toDouble(), + image1: json['Image1'] ?? '', + image2: json['Image2'] ?? '', + image3: json['Image3'] ?? '', ); } // Method to convert CargoEntity to JSON - Map toJson() { - return { - 'Oid': oid, - 'ClientId': clientId, - 'CargoId': cargoId, - 'State': state, - 'No': no, - 'Name': name, - 'ShopNo': shopNo, - 'Volume': volume, - 'PlacesCount': placesCount, - 'Carrier': carrier, - 'From': from, - 'To': to, - 'DepartedAt': departedAt, - 'ArrivedAt': arrivedAt, - 'Depth': depth, - 'Width': width, - 'Height': height, - }; - } + // Map toJson() { + // return { + // 'Oid': oid, + // 'ClientId': clientId, + // 'CargoId': cargoId, + // 'State': state, + // 'No': no, + // 'Name': name, + // 'ShopNo': shopNo, + // 'Volume': volume, + // 'PlacesCount': placesCount, + // 'Carrier': carrier, + // 'From': from, + // 'To': to, + // 'DepartedAt': departedAt, + // 'ArrivedAt': arrivedAt, + // 'Depth': depth, + // 'Width': width, + // 'Height': height, + // }; + // } } diff --git a/lib/domain/entities/order/order.dart b/lib/domain/entities/order/order.dart index dcc15dd..6d328a0 100644 --- a/lib/domain/entities/order/order.dart +++ b/lib/domain/entities/order/order.dart @@ -18,6 +18,9 @@ class OrderEntity extends Equatable { final double depth; final double width; final double height; + final String image1; + final String image2; + final String image3; const OrderEntity({ required this.oid, @@ -37,6 +40,9 @@ class OrderEntity extends Equatable { required this.depth, required this.width, required this.height, + required this.image1, + required this.image2, + required this.image3, }); @override diff --git a/lib/presentation/screens/order_details.dart b/lib/presentation/screens/order_details.dart index 0841838..f09a73e 100644 --- a/lib/presentation/screens/order_details.dart +++ b/lib/presentation/screens/order_details.dart @@ -21,13 +21,22 @@ class OrderDetailsScreen extends StatefulWidget { class _OrderDetailsScreenState extends State { bool _isFullScreen = false; // Track fullscreen mode + bool _showLocation = true; @override void initState() { context.read().add(GetRoutes(widget.order.cargoId)); + _checkLocationStatus(); super.initState(); } + void _checkLocationStatus() { + setState(() { + debugPrint('NAME: ${GoodsState.Reserved.name}'); + _showLocation = widget.order.state != GoodsState.Reserved.name; + }); + } + void _toggleFullScreen() { setState(() { _isFullScreen = !_isFullScreen; @@ -62,17 +71,18 @@ class _OrderDetailsScreenState extends State { body: CustomScrollView( slivers: [ /// map - SliverToBoxAdapter( - child: SizedBox( - height: _isFullScreen - ? MediaQuery.of(context).size.height // Full screen height - : AppDimensions.normalize(130), - child: ClusteringPage( - onFullScreenToggle: _toggleFullScreen, - isFullScreen: _isFullScreen, + if (_showLocation) + SliverToBoxAdapter( + child: SizedBox( + height: _isFullScreen + ? MediaQuery.of(context).size.height // Full screen height + : AppDimensions.normalize(130), + child: ClusteringPage( + onFullScreenToggle: _toggleFullScreen, + isFullScreen: _isFullScreen, + ), ), ), - ), if (!_isFullScreen) ...[ /// info text @@ -98,26 +108,27 @@ class _OrderDetailsScreenState extends State { ), /// current location info - SliverToBoxAdapter( - child: Padding( - padding: Space.all(1, 1), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'route'.tr(), - style: AppText.b1b, - ), + if (_showLocation) + SliverToBoxAdapter( + child: Padding( + padding: Space.all(1, 1), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'route'.tr(), + style: AppText.b1b, + ), - /// gap - Space.y!, + /// gap + Space.y!, - /// location card - LocationCard(cargoId: widget.order.cargoId), - ], + /// location card + LocationCard(cargoId: widget.order.cargoId), + ], + ), ), ), - ), ], ], ), diff --git a/lib/presentation/widgets/order_card.dart b/lib/presentation/widgets/order_card.dart index bdd658c..6e575d1 100644 --- a/lib/presentation/widgets/order_card.dart +++ b/lib/presentation/widgets/order_card.dart @@ -90,7 +90,7 @@ class OrderCard extends StatelessWidget { width: AppDimensions.normalize(1), height: AppDimensions.normalize(2.5), topColor: AppColors.green, - bottomColor: AppColors.grey, + bottomColor: order.state == GoodsState.Delivered.name ? AppColors.green : AppColors.grey, ), ), @@ -133,8 +133,6 @@ class OrderCard extends StatelessWidget { ), ], ), - - /* */ ), // const Spacer(flex: 1), Expanded(