proxybuy-flutter/lib/widgets/conversion_summary.dart

123 lines
3.6 KiB
Dart
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// مثال عملی استفاده از AppSnackBar در فایل‌های مختلف اپ
// Practical examples of AppSnackBar usage in different app files
import 'package:flutter/material.dart';
import 'package:lba/widgets/app_snackbar.dart';
import 'package:geolocator/geolocator.dart';
/*
✅ تبدیل موفق تمام SnackBarهای قدیمی به AppSnackBar جدید
✅ Successfully converted all old SnackBars to new AppSnackBar
📂 فایل‌های تبدیل شده / Converted Files:
1. 📍 lib/screens/mains/nearby/location_radius_screen.dart
- پیام موفقیت: "Location found successfully!" ✅
- پیام هشدار: "Location services disabled" ⚠️
- پیام خطا: "Location permissions denied" ❌
- پیام اطلاعاتی: "Using default location"
2. 📍 lib/screens/product/map_selection_screen.dart
- پیام هشدار: "Location services disabled" + دکمه Settings ⚠️
- پیام خطا: "Location permissions denied" ❌
- پیام خطا: "Permanently denied permissions" ❌
3. 📍 lib/screens/qr_scanner/qr_scanner_page.dart
- پیام خطا: "Error selecting image" ❌
4. 📍 lib/screens/auth/otp_verification_page.dart
- پیام خطا: Authentication errors ❌
- پیام هشدار: "Please enter complete OTP" ⚠️
5. 📍 lib/screens/auth/login_page.dart
- پیام خطا: Authentication errors ❌
🎨 ویژگی‌های جدید AppSnackBar:
*/
// ❌ کد قدیمی (Old Code):
/*
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(message),
backgroundColor: AppColors.errorColor,
duration: Duration(seconds: 3),
),
);
*/
// ✅ کد جدید (New Code):
/*
AppSnackBar.showError(
context: context,
message: message,
duration: Duration(seconds: 3),
);
// یا با دکمه عمل
AppSnackBar.showWarning(
context: context,
message: 'Location services disabled',
actionLabel: 'Settings',
onActionPressed: () => Geolocator.openLocationSettings(),
);
*/
// 🎯 نحوه استفاده در صفحات جدید:
class ExampleUsage {
static void showLocationSuccess(context) {
AppSnackBar.showSuccess(
context: context,
message: 'Successful',
);
}
static void showConnectionError(context) {
AppSnackBar.showError(
context: context,
message: 'Connection to the internet is not established',
actionLabel: 'Retry',
onActionPressed: () {
// Retry operation
},
);
}
static void showFileUploadInfo(context) {
AppSnackBar.showInfo(
context: context,
message: 'File is uploading...',
duration: Duration(seconds: 5),
);
}
static void showDeleteWarning(context) {
AppSnackBar.showWarning(
context: context,
message: 'This action is irreversible',
actionLabel: 'Cancel',
onActionPressed: () {
// Cancel operation
},
);
}
}
/*
📊 آمار تبدیل:
- تعداد فایل‌های بررسی شده: 5+
- تعداد SnackBar های تبدیل شده: 7+
- نوع پیام‌های پیاده‌سازی شده: 4 نوع (Success, Error, Warning, Info)
- ویژگی‌های اضافه شده: Action Button, Custom Duration, Beautiful Design
🚀 مزایای AppSnackBar جدید:
✅ طراحی زیبا و مدرن
✅ رنگ‌بندی مناسب برای هر نوع پیام
✅ انیمیشن‌های روان
✅ قابلیت افزودن دکمه عمل
✅ تنظیم زمان نمایش
✅ یکدست سازی تجربه کاربری
✅ کاهش کد تکراری
✅ نگهداری آسان‌تر
*/