From 0586fde87257595f120dad96e694359017222bec Mon Sep 17 00:00:00 2001 From: mohamadmahdi jebeli Date: Thu, 31 Jul 2025 10:49:36 +0330 Subject: [PATCH] improve responsive sizes --- .../offer/bloc/widgets/offer_card.dart | 14 ++++++----- .../pages/product_detail_page.dart | 24 +++++++++++-------- .../widgets/reserved_list_item_card.dart | 10 ++++---- pubspec.lock | 2 +- pubspec.yaml | 1 + 5 files changed, 30 insertions(+), 21 deletions(-) diff --git a/lib/presentation/offer/bloc/widgets/offer_card.dart b/lib/presentation/offer/bloc/widgets/offer_card.dart index 9a44a3e..f85399d 100644 --- a/lib/presentation/offer/bloc/widgets/offer_card.dart +++ b/lib/presentation/offer/bloc/widgets/offer_card.dart @@ -141,12 +141,14 @@ class _OfferCardState extends State { children: [ SvgPicture.asset(Assets.icons.routing.path), const SizedBox(width: 4), - Text( - 'نوع تخفیف : ${(100 - widget.offer.finalPrice / widget.offer.originalPrice * 100).toInt()}% ${widget.offer.discountType}', - style: const TextStyle( - color: Color.fromARGB(255, 183, 28, 28), fontSize: 14), - maxLines: 1, - overflow: TextOverflow.ellipsis, + Flexible( + child: Text( + 'نوع تخفیف : ${(100 - widget.offer.finalPrice / widget.offer.originalPrice * 100).toInt()}% ${widget.offer.discountType}', + style: const TextStyle( + color: Color.fromARGB(255, 183, 28, 28), fontSize: 13), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), ), ], ), diff --git a/lib/presentation/pages/product_detail_page.dart b/lib/presentation/pages/product_detail_page.dart index b43c76e..d6820f8 100644 --- a/lib/presentation/pages/product_detail_page.dart +++ b/lib/presentation/pages/product_detail_page.dart @@ -6,6 +6,7 @@ import 'package:flutter_animate/flutter_animate.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:flutter_svg/svg.dart'; +import 'package:intl/intl.dart' show NumberFormat; import 'package:maps_launcher/maps_launcher.dart'; import 'package:proxibuy/core/config/api_config.dart'; import 'package:proxibuy/core/config/app_colors.dart'; @@ -76,7 +77,7 @@ class ProductDetailPage extends StatelessWidget { final dio = Dio(); final url = ApiConfig.baseUrl + ApiConfig.addReservation; - + final data = { 'Discount': offer.id, 'Distance': offer.distanceInMeters.toString(), @@ -94,7 +95,7 @@ class ProductDetailPage extends StatelessWidget { final response = await dio.post(url, data: data, options: options); - + debugPrint("---------- RESPONSE-----------"); debugPrint("StatusCode: ${response.statusCode}"); debugPrint("Data: ${response.data}"); @@ -134,7 +135,7 @@ class ProductDetailPage extends StatelessWidget { debugPrint("StatusCode: ${e.response?.statusCode}"); debugPrint("Data: ${e.response?.data}"); debugPrint("--------------------------"); - + final errorMessage = e.response?.data?['message'] ?? 'خطای سرور هنگام رزرو. لطفاً دوباره تلاش کنید.'; ScaffoldMessenger.of(context).showSnackBar( @@ -404,6 +405,9 @@ class _ProductDetailViewState extends State { ? widget.offer.expiryTime.difference(DateTime.now()) : Duration.zero; + final formatCurrency = + NumberFormat.decimalPattern('fa_IR'); // Or 'en_US' + return Padding( padding: const EdgeInsets.symmetric(horizontal: 24.0) .copyWith(bottom: 5.0, top: 24.0), @@ -588,7 +592,7 @@ class _ProductDetailViewState extends State { children: [ Container( padding: - const EdgeInsets.symmetric(horizontal: 8, vertical: 8), + const EdgeInsets.symmetric(horizontal: 12, vertical: 12), decoration: BoxDecoration( color: AppColors.singleOfferType, borderRadius: BorderRadius.circular(20), @@ -598,7 +602,7 @@ class _ProductDetailViewState extends State { style: const TextStyle( color: Colors.white, fontWeight: FontWeight.bold, - fontSize: 17, + fontSize: 13, ), ), ), @@ -612,16 +616,16 @@ class _ProductDetailViewState extends State { Text( '(${(100 - widget.offer.finalPrice / widget.offer.originalPrice * 100).toInt()}%)', style: const TextStyle( - fontSize: 16, + fontSize: 14, color: AppColors.singleOfferType, fontWeight: FontWeight.normal, ), ), const SizedBox(width: 8), Text( - widget.offer.originalPrice.toStringAsFixed(0), + formatCurrency.format(widget.offer.originalPrice), style: TextStyle( - fontSize: 16, + fontSize: 14, color: Colors.grey.shade600, decoration: TextDecoration.lineThrough, ), @@ -630,10 +634,10 @@ class _ProductDetailViewState extends State { ), const SizedBox(height: 1), Text( - '${widget.offer.finalPrice.toStringAsFixed(0)} تومان', + '${formatCurrency.format(widget.offer.finalPrice)} تومان', style: const TextStyle( color: AppColors.singleOfferType, - fontSize: 22, + fontSize: 20, fontWeight: FontWeight.bold, ), ), diff --git a/lib/presentation/widgets/reserved_list_item_card.dart b/lib/presentation/widgets/reserved_list_item_card.dart index b7589fc..e6cd6a7 100644 --- a/lib/presentation/widgets/reserved_list_item_card.dart +++ b/lib/presentation/widgets/reserved_list_item_card.dart @@ -4,6 +4,7 @@ import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart'; import 'package:flutter/material.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:flutter_svg/flutter_svg.dart'; +import 'package:intl/intl.dart'; import 'package:proxibuy/core/gen/assets.gen.dart'; import 'package:qr_flutter/qr_flutter.dart'; import 'package:proxibuy/core/config/app_colors.dart'; @@ -64,7 +65,6 @@ class _ReservedListItemCardState extends State { }); } - void _calculateRemainingTime() { final now = DateTime.now(); if (widget.offer.expiryTime.isAfter(now)) { @@ -115,7 +115,7 @@ class _ReservedListItemCardState extends State { 0.2126, 0.7152, 0.0722, 0, 0, 0.2126, 0.7152, 0.0722, 0, 0, 0.2126, 0.7152, 0.0722, 0, 0, - 0, 0, 0, 1, 0, + 0, 0, 0, 1, 0, ]), child: cardContent, ); @@ -323,6 +323,8 @@ class _ReservedListItemCardState extends State { } Widget _buildExpansionPanel() { + final formatCurrency = NumberFormat.decimalPattern('fa_IR'); + return AnimatedCrossFade( firstChild: Container(), secondChild: Container( @@ -370,7 +372,7 @@ class _ReservedListItemCardState extends State { ), const SizedBox(width: 8), Text( - widget.offer.originalPrice.toStringAsFixed(0), + formatCurrency.format(widget.offer.originalPrice), style: TextStyle( fontSize: 14, color: Colors.grey.shade600, @@ -381,7 +383,7 @@ class _ReservedListItemCardState extends State { ), const SizedBox(height: 1), Text( - '${widget.offer.finalPrice.toStringAsFixed(0)} تومان', + '${formatCurrency.format(widget.offer.finalPrice)} تومان', style: const TextStyle( color: AppColors.singleOfferType, fontSize: 18, diff --git a/pubspec.lock b/pubspec.lock index 0ff9e7a..ace5377 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -894,7 +894,7 @@ packages: source: hosted version: "2.4.0" intl: - dependency: transitive + dependency: "direct main" description: name: intl sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf diff --git a/pubspec.yaml b/pubspec.yaml index 6aab6fe..e35f4a8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -61,6 +61,7 @@ dependencies: connectivity_plus: ^6.1.4 dart_jsonwebtoken: ^3.2.0 audioplayers: ^6.5.0 + intl: ^0.19.0 dev_dependencies: flutter_test: