diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 43024b7..c49ad18 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -1,3 +1,6 @@ +import java.util.Properties +import java.io.FileInputStream + plugins { id("com.android.application") // START: FlutterFire Configuration @@ -8,8 +11,14 @@ plugins { id("dev.flutter.flutter-gradle-plugin") } +val keystoreProperties = Properties() +val keystorePropertiesFile = rootProject.file("key.properties") +if (keystorePropertiesFile.exists()) { + keystoreProperties.load(FileInputStream(keystorePropertiesFile)) +} + android { - namespace = "com.emart.customer" + namespace = "felix.fondex.uz" compileSdk = 36 ndkVersion = flutter.ndkVersion @@ -25,7 +34,7 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId = "com.emart.customer" + applicationId = "felix.fondex.uz" // You can update the following values to match your application needs. // For more information, see: https://flutter.dev/to/review-gradle-config. minSdk = 26 @@ -34,11 +43,20 @@ android { versionName = flutter.versionName } + signingConfigs { + create("release") { + keyAlias = keystoreProperties["keyAlias"] as String + keyPassword = keystoreProperties["keyPassword"] as String + storeFile = keystoreProperties["storeFile"]?.let { file(it) } + storePassword = keystoreProperties["storePassword"] as String + } + } + buildTypes { release { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. - signingConfig = signingConfigs.getByName("debug") + signingConfig = signingConfigs.getByName("release") isMinifyEnabled = false isShrinkResources = false } diff --git a/android/app/google-services.json b/android/app/google-services.json index 4d10887..3b964b4 100644 --- a/android/app/google-services.json +++ b/android/app/google-services.json @@ -8,9 +8,9 @@ "client": [ { "client_info": { - "mobilesdk_app_id": "1:893074789710:android:05002c15a64cf1e0c4ba1f", + "mobilesdk_app_id": "1:893074789710:android:70c2e98114a8ef1ac4ba1f", "android_client_info": { - "package_name": "com.emart.customer" + "package_name": "felix.fondex.driver" } }, "oauth_client": [ @@ -32,10 +32,46 @@ "client_type": 3 }, { - "client_id": "893074789710-pv12m4nhe82a4ueg9sb2pgt42r0e5da3.apps.googleusercontent.com", + "client_id": "893074789710-7am77oq925d324gvpga8g6r6ggul4v9i.apps.googleusercontent.com", "client_type": 2, "ios_info": { - "bundle_id": "com.emart.customer" + "bundle_id": "com.emart.driver" + } + } + ] + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:893074789710:android:e932bc88da6665b3c4ba1f", + "android_client_info": { + "package_name": "felix.fondex.uz" + } + }, + "oauth_client": [ + { + "client_id": "893074789710-nqkeis20f6b64luas7g44c836fvi0qms.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyALZhdy7Rw3jffipxsDvvz7_C_b4teVg1k" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "893074789710-nqkeis20f6b64luas7g44c836fvi0qms.apps.googleusercontent.com", + "client_type": 3 + }, + { + "client_id": "893074789710-7am77oq925d324gvpga8g6r6ggul4v9i.apps.googleusercontent.com", + "client_type": 2, + "ios_info": { + "bundle_id": "com.emart.driver" } } ] diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 305ac58..1121885 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -10,7 +10,7 @@ - + @@ -46,14 +46,14 @@ + android:scheme="felix.fondex.uz" /> @@ -102,7 +102,7 @@ + android:scheme="felix.fondex.uz" /> diff --git a/android/app/src/main/kotlin/com/emart/customer/MainActivity.kt b/android/app/src/main/kotlin/com/emart/customer/MainActivity.kt index 21c78d3..af32cc7 100644 --- a/android/app/src/main/kotlin/com/emart/customer/MainActivity.kt +++ b/android/app/src/main/kotlin/com/emart/customer/MainActivity.kt @@ -1,4 +1,4 @@ -package com.emart.customer +package felix.fondex.uz import io.flutter.embedding.android.FlutterFragmentActivity diff --git a/android/app/src/main/res/ic_launcher-web.png b/android/app/src/main/res/ic_launcher-web.png new file mode 100644 index 0000000..97553a3 Binary files /dev/null and b/android/app/src/main/res/ic_launcher-web.png differ diff --git a/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml index 345888d..79d695e 100644 --- a/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +++ b/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -1,6 +1,4 @@ - - + - \ No newline at end of file diff --git a/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..79d695e --- /dev/null +++ b/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png index c18ca62..4db8057 100644 Binary files a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher_background.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher_background.png deleted file mode 100644 index 328a8d4..0000000 Binary files a/android/app/src/main/res/mipmap-hdpi/ic_launcher_background.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png index 0edd7e3..c4efae6 100644 Binary files a/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png and b/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher_monochrome.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher_monochrome.png deleted file mode 100644 index 0edd7e3..0000000 Binary files a/android/app/src/main/res/mipmap-hdpi/ic_launcher_monochrome.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..c514656 Binary files /dev/null and b/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/android/app/src/main/res/mipmap-ldpi/ic_launcher.png b/android/app/src/main/res/mipmap-ldpi/ic_launcher.png new file mode 100644 index 0000000..2c35d1c Binary files /dev/null and b/android/app/src/main/res/mipmap-ldpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-ldpi/ic_launcher_round.png b/android/app/src/main/res/mipmap-ldpi/ic_launcher_round.png new file mode 100644 index 0000000..44892be Binary files /dev/null and b/android/app/src/main/res/mipmap-ldpi/ic_launcher_round.png differ diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png index b4f1709..ff032c6 100644 Binary files a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher_background.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher_background.png deleted file mode 100644 index 3d14d2d..0000000 Binary files a/android/app/src/main/res/mipmap-mdpi/ic_launcher_background.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png index 13a4c4f..e659390 100644 Binary files a/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png and b/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher_monochrome.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher_monochrome.png deleted file mode 100644 index 13a4c4f..0000000 Binary files a/android/app/src/main/res/mipmap-mdpi/ic_launcher_monochrome.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..b52b03b Binary files /dev/null and b/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png index 3cb9936..fc6063d 100644 Binary files a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher_background.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher_background.png deleted file mode 100644 index e7f70bb..0000000 Binary files a/android/app/src/main/res/mipmap-xhdpi/ic_launcher_background.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png index ac80499..ccf837d 100644 Binary files a/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png and b/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher_monochrome.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher_monochrome.png deleted file mode 100644 index ac80499..0000000 Binary files a/android/app/src/main/res/mipmap-xhdpi/ic_launcher_monochrome.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..6265150 Binary files /dev/null and b/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png index 0ad321f..8f64f98 100644 Binary files a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_background.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_background.png deleted file mode 100644 index e1a9322..0000000 Binary files a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_background.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png index 0f79dc8..f9f903b 100644 Binary files a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png and b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_monochrome.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_monochrome.png deleted file mode 100644 index 0f79dc8..0000000 Binary files a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_monochrome.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..1a70683 Binary files /dev/null and b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png index 89b8d05..62a0b51 100644 Binary files a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_background.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_background.png deleted file mode 100644 index 2ffee54..0000000 Binary files a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_background.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png index d3a6e5b..263b3ed 100644 Binary files a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png and b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_monochrome.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_monochrome.png deleted file mode 100644 index d3a6e5b..0000000 Binary files a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_monochrome.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..bdf769a Binary files /dev/null and b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/android/app/src/main/res/play_store_512.png b/android/app/src/main/res/play_store_512.png deleted file mode 100644 index f0c67d2..0000000 Binary files a/android/app/src/main/res/play_store_512.png and /dev/null differ diff --git a/android/app/src/main/res/playstore-icon.png b/android/app/src/main/res/playstore-icon.png new file mode 100644 index 0000000..566d741 Binary files /dev/null and b/android/app/src/main/res/playstore-icon.png differ diff --git a/android/app/src/main/res/values/ic_launcher_background.xml b/android/app/src/main/res/values/ic_launcher_background.xml new file mode 100644 index 0000000..4db2c8a --- /dev/null +++ b/android/app/src/main/res/values/ic_launcher_background.xml @@ -0,0 +1,3 @@ + + #ff643c + \ No newline at end of file diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml deleted file mode 100644 index d2aa524..0000000 --- a/android/app/src/main/res/values/styles.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index afa1e8e..efdcc4a 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-all.zip diff --git a/android/settings.gradle.kts b/android/settings.gradle.kts index 36fd3a3..c4b6403 100644 --- a/android/settings.gradle.kts +++ b/android/settings.gradle.kts @@ -18,7 +18,7 @@ pluginManagement { plugins { id("dev.flutter.flutter-plugin-loader") version "1.0.0" - id("com.android.application") version "8.7.0" apply false + id("com.android.application") version "8.9.1" apply false // START: FlutterFire Configuration id("com.google.gms.google-services") version("4.3.15") apply false // END: FlutterFire Configuration diff --git a/assets/images/click_logo.png b/assets/images/click_logo.png new file mode 100644 index 0000000..1709cdb Binary files /dev/null and b/assets/images/click_logo.png differ diff --git a/assets/images/cosmetics_img.png b/assets/images/cosmetics_img.png new file mode 100644 index 0000000..b4e7a00 Binary files /dev/null and b/assets/images/cosmetics_img.png differ diff --git a/assets/images/delivery_img.png b/assets/images/delivery_img.png new file mode 100644 index 0000000..cedb056 Binary files /dev/null and b/assets/images/delivery_img.png differ diff --git a/assets/images/fondex_logo.png b/assets/images/fondex_logo.png new file mode 100644 index 0000000..50fc8f2 Binary files /dev/null and b/assets/images/fondex_logo.png differ diff --git a/assets/images/fondex_logo_main.png b/assets/images/fondex_logo_main.png new file mode 100644 index 0000000..5d701dd Binary files /dev/null and b/assets/images/fondex_logo_main.png differ diff --git a/assets/images/food_img.png b/assets/images/food_img.png new file mode 100644 index 0000000..b7e9b5c Binary files /dev/null and b/assets/images/food_img.png differ diff --git a/assets/images/garderob_img.png b/assets/images/garderob_img.png new file mode 100644 index 0000000..ef351e1 Binary files /dev/null and b/assets/images/garderob_img.png differ diff --git a/assets/images/ic_pick_drop_location.png b/assets/images/ic_pick_drop_location.png new file mode 100644 index 0000000..f384623 Binary files /dev/null and b/assets/images/ic_pick_drop_location.png differ diff --git a/assets/images/keys_img.png b/assets/images/keys_img.png new file mode 100644 index 0000000..9a7c835 Binary files /dev/null and b/assets/images/keys_img.png differ diff --git a/assets/images/location_indicatorl b/assets/images/location_indicatorl new file mode 100644 index 0000000..a48f948 Binary files /dev/null and b/assets/images/location_indicatorl differ diff --git a/assets/images/money_logo.png b/assets/images/money_logo.png new file mode 100644 index 0000000..b8b8421 Binary files /dev/null and b/assets/images/money_logo.png differ diff --git a/assets/images/outer_city_taxi_option.png b/assets/images/outer_city_taxi_option.png new file mode 100644 index 0000000..0af0c0d Binary files /dev/null and b/assets/images/outer_city_taxi_option.png differ diff --git a/assets/images/payme_logo.png b/assets/images/payme_logo.png new file mode 100644 index 0000000..5e33868 Binary files /dev/null and b/assets/images/payme_logo.png differ diff --git a/assets/images/products_img.png b/assets/images/products_img.png new file mode 100644 index 0000000..85e4a3b Binary files /dev/null and b/assets/images/products_img.png differ diff --git a/assets/images/taxi_img.png b/assets/images/taxi_img.png new file mode 100644 index 0000000..58bfadf Binary files /dev/null and b/assets/images/taxi_img.png differ diff --git a/assets/images/taxi_option.png b/assets/images/taxi_option.png new file mode 100644 index 0000000..340f726 Binary files /dev/null and b/assets/images/taxi_option.png differ diff --git a/assets/translations/en.json b/assets/translations/en.json new file mode 100644 index 0000000..eb8d5ad --- /dev/null +++ b/assets/translations/en.json @@ -0,0 +1,157 @@ +{ + "loginToExplore" : "Log in to explore your all in one vendor app favourites and shop effortlessly.", + "emailAddress": "Email Address*", + "password": "Password*", + "enterPassword": "Enter password", + "forgotPassword": "Forgot Password", + "login": "Log in", + "orContinueWith": "or continue with", + "withGoogle": "with Google", + "withApple": "with Apple", + "dontHaveAccount": "Didn't have an account?", + "signUp": "Sign up", + "skip": "Skip", + "signUpToExplore": "Sign up to explore all our services and start shopping, riding, and more.", + "firstName": "First Name*", + "lastName": "Last Name*", + "enterMobileNumber": "Enter Mobile number", + "confirmPassword": "Confirm Password*", + "enterConfirmPassword": "Enter confirm password", + "referralCode": "Referral Code", + "enterReferralCode": "Enter referral code", + "alreadyHaveAccount":"Already have an account?", + "enterYourregisteredEmail": "Enter your registered email to receive a reset link.", + "sendLink": "Send Link", + "rememberPassword": "Remember Password?", + "enterOtpSent": "Enter the OTP sent to your mobile", + "resendOTP": "Resend OTP", + "verify": "Verify", + "useYourMobileNumber": "Use your mobile number to Log in easily and securely.", + "sendCode":"Send Code", + "serviceIsUnavailable": "Service is unavailable at the selected address.", + "pickUpLocation": "Pickup Location", + "destinationLocation": "Destination Location", + "continueT":"Continue", + "plsSelectSourceLocation": "Please select source location", + "plsSelectDestinationLocations": "Please select destination location", + "selectVehicleType": "Select Your Vehicle Type", + "plsSelectVehicleTypeFirst": "Please select a vehicle type first.", + "plsSelectPaymentMethod": "Please select a payment method", + "insufficientWallet": "Insufficient wallet balance. Please select another payment method.", + "promoCode": "Promo code", + "thisOfferNotEligible": "This offer not eligible for this booking", + "viewAll": "View All", + "writeCoupon": "Write coupon Code", + "redeemNow": "Redeem now", + "plsEnterCouponCode":"Please enter a coupon code", + "couponApplied": "Coupon applied successfully", + "couponExpired": "This coupon code has been expired", + "invalidCouponCode": "Invalid coupon code", + "orderSummary": "Order Summary", + "subtotal": "Subtotal", + "discount": "Discount", + "orderTotal": "Order Total", + "confirmBooking": "Confirm Booking", + "waitingForDriver": "Waiting for driver....", + "cancelRide": "Cancel Ride", + "riderCancelledSucces": "Ride cancelled successfully", + "failedToCancel": "Failed to cancel ride", + "pleaseWait": "Please wait...", + "change": "Change", + "yourSosRequest": "Your SOS request has been submitted to admin", + "yourSosrequestAlreadySubmitted": "Your SOS request is already submitted", + "payNow": "Pay Now", + "youDoNothaveSufficientwalletBalance": "You do not have sufficient wallet balance", + "somethingWentWrong": "Something went wrong, please contact admin.", + "cash": "Cash", + "coupon": "Coupon", + "couponNotFound": "Coupon not found.", + "tapToApply": "Tap To Apply", + "home": "Home", + "myBookings": "My Bookings", + "profile": "profile", + "wallet": "Wallet", + "cabServiceType": "Cab Service Type", + "everyRideVerified": "Every Ride. Every Driver. Verified.", + "allDriversIDCheck": "All drivers go through ID checks and background verification for your safety.", + "intercity": "Intercity", + "aroundTheCity": "Around the city", + "rideDetails": "Ride Details", + "orderId": "Order Id:", + "bookingData": "Booking Date:", + "rideAndFareSummary": "Ride & Fare Summary", + "updateReview": "Update Review", + "addReview": "Add Review", + "complain": "Complain", + "distance": "Distance", + "km": "KM", + "duration": "Duration", + "howWasTrip": "How was your trip?", + "yourFeedbackWillHelp": "Your feedback will help us improve \n driving experience better", + "rateFor": "Rate for", + "typeComment": "Type comment....", + "title": "Title", + "typeDescription": "Type Description...", + "save": "Save", + "popularDestinations": "Popular Destinations", + "selectPaymentMethod": "Select Payment Method", + "prefferedPayment": "Preferred Payment", + "otherPaymentOptions": "Other Payment Options", + "rideHistory": "Ride History", + "plsLoginToAcc": "Please Log In to Continue", + "youAreNotLoggedIn": "You’re not logged in. Please sign in to access your account and explore all features.", + "noOrderfound": "No order found", + "reset_password_link_sent": "A reset link has been sent to {email}", + "pay_amount": "Pay Amount: {amount}", + "otherServices": "Other Services", + "foodDelivery": "Food Delivery", + "delivery": "Delivery", + "bookingTaxi": "Booking \nTaxi", + "updateYourWardrobe": "Update your wardrobe", + "weDeliverSafely": "We deliver safely", + "rent": "Rent", + "hugeSelectionOfAds": "Huge selection of ads!", + "cosmetics": "Cosmetics", + "moreThan1000Products": "More than 1000 products", + "foodProducts": "Food products", + "enableLocation": "Enable Location for a Personalized Experience", + "allowLocation": "Allow location access to discover beauty stores and services near you.", + "useCurrentLocation": "Use current location", + "setFromMap": "Set from map", + "enterManuallyLocation": "Enter Manually location", + + + "changeLanguage": "Change Language", + "selectPrefferedLanguage": "Select your preferred language for a personalized app experience.", + "searchStoreItem": "Search the store, item and more...", + "category": "Category", + "highlightsForU": "Highlights for you", + "newArrival": "New Arrivals", + "topBrands": "Top Brands", + "styleUp": "Style up with the latest fits, now at unbeatable prices.", + "additionlOffers": "Additional Offers", + "largestDiscounts": "Largest Discounts", + "newArrivals": "New Arrivals", + "popularStores": "Popular Stores", + "allStores": "All Stores", + "alert": "Alert", + "cancel": "Cancel", + "ok": "Ok", + "doYouWantChangeTheDeliverOption": "Do you really want to change the delivery option? Your cart will be empty.", + "freeDelivery": "Free Delivery", + "upto": "Upto", + "viewCart": "View Cart", + "viewTimings": "View Timings", + "timingIsNotAdded": "Timing is not added by store", + "alsoApplicableOnTable": "Also applicable on table booking", + "tableBooking": "Table Booking", + "quickConformations": "Quick Conformations", + "menu": "Menu", + "searchAndMore": "Search the item and more...", + "veg": "Veg", + "nonVeg": "Non Veg", + "favourites": "Favourites", + "orders": "Orders", + "takeAway": "TakeAway" + +} \ No newline at end of file diff --git a/assets/translations/ru.json b/assets/translations/ru.json new file mode 100644 index 0000000..cf45701 --- /dev/null +++ b/assets/translations/ru.json @@ -0,0 +1,124 @@ +{ + "loginToExplore" : "Войдите, чтобы исследовать наш универсальный сервис и делать покупки с удобством.", + "emailAddress": "Адрес электронной почты*", + "password": "Пароль*", + "enterPassword": "Введите пароль", + "forgotPassword": "Забыли пароль", + "login": "Войти", + "orContinueWith": "или продолжить с", + "withGoogle": "с Google", + "withApple": "с Apple", + "dontHaveAccount": "Нет аккаунта?", + "signUp": "Зарегистрироваться", + "skip": "Пропустить", + "signUpToExplore": "Зарегистрируйтесь, чтобы получить доступ ко всем нашим услугам и начать делать покупки, поездки и многое другое.", + "firstName": "Имя*", + "lastName": "Фамилия*", + "enterMobileNumber": "Введите номер телефона", + "confirmPassword": "Подтвердите пароль*", + "enterConfirmPassword": "Введите подтверждение пароля", + "referralCode": "Реферальный код", + "enterReferralCode": "Введите реферальный код", + "alreadyHaveAccount": "Уже есть аккаунт?", + "enterYourregisteredEmail": "Введите свою зарегистрированную почту, чтобы получить ссылку для сброса.", + "sendLink": "Отправить ссылку", + "rememberPassword": "Вспомнили пароль?", + "enterOtpSent": "Введите код, отправленный на ваш телефон", + "resendOTP": "Отправить код повторно", + "verify": "Подтвердить", + "useYourMobileNumber": "Используйте номер телефона для быстрого и безопасного входа.", + "sendCode": "Отправить код", + "serviceIsUnavailable": "Услуга недоступна по выбранному адресу.", + "pickUpLocation": "Место отправления", + "destinationLocation": "Место назначения", + "continueT": "Продолжить", + "plsSelectSourceLocation": "Пожалуйста, выберите место отправления", + "plsSelectDestinationLocations": "Пожалуйста, выберите место назначения", + "selectVehicleType": "Выберите тип транспорта", + "plsSelectVehicleTypeFirst": "Сначала выберите тип транспорта.", + "plsSelectPaymentMethod": "Пожалуйста, выберите способ оплаты", + "insufficientWallet": "Недостаточно средств в кошельке. Пожалуйста, выберите другой способ оплаты.", + "promoCode": "Промокод", + "thisOfferNotEligible": "Это предложение недоступно для данного заказа", + "viewAll": "Показать все", + "writeCoupon": "Введите промокод", + "redeemNow": "Применить", + "plsEnterCouponCode": "Пожалуйста, введите промокод", + "couponApplied": "Промокод успешно применён", + "couponExpired": "Срок действия этого промокода истёк", + "invalidCouponCode": "Неверный промокод", + "orderSummary": "Сводка заказа", + "subtotal": "Промежуточный итог", + "discount": "Скидка", + "orderTotal": "Итого", + "confirmBooking": "Подтвердить заказ", + "waitingForDriver": "Ожидание водителя....", + "cancelRide": "Отменить поездку", + "riderCancelledSucces": "Поездка успешно отменена", + "failedToCancel": "Не удалось отменить поездку", + "pleaseWait": "Пожалуйста, подождите...", + "change": "Изменить", + "yourSosRequest": "Ваш SOS-запрос отправлен администратору", + "yourSosrequestAlreadySubmitted": "Ваш SOS-запрос уже отправлен", + "payNow": "Оплатить сейчас", + "youDoNothaveSufficientwalletBalance": "Недостаточно средств в кошельке", + "somethingWentWrong": "Произошла ошибка, пожалуйста, свяжитесь с администратором.", + "cash": "Наличные", + "coupon": "Промокод", + "couponNotFound": "Промокод не найден.", + "tapToApply": "Нажмите, чтобы применить", + "home": "Главная", + "myBookings": "Мои заказы", + "profile": "Профиль", + "wallet": "Кошелёк", + "cabServiceType": "Тип такси", + "everyRideVerified": "Каждая поездка. Каждый водитель. Проверены.", + "allDriversIDCheck": "Все водители проходят проверку документов и биографии для вашей безопасности.", + "intercity": "Междугородние", + "aroundTheCity": "По городу", + "rideDetails": "Детали поездки", + "orderId": "ID заказа:", + "bookingData": "Дата заказа:", + "rideAndFareSummary": "Детали поездки и стоимость", + "updateReview": "Обновить отзыв", + "addReview": "Добавить отзыв", + "complain": "Жалоба", + "distance": "Расстояние", + "km": "км", + "duration": "Продолжительность", + "howWasTrip": "Как прошла поездка?", + "yourFeedbackWillHelp": "Ваш отзыв поможет нам улучшить \n качество поездок", + "rateFor": "Оценка для", + "typeComment": "Введите комментарий....", + "title": "Заголовок", + "typeDescription": "Введите описание...", + "save": "Сохранить", + "popularDestinations": "Популярные направления", + "selectPaymentMethod": "Выберите способ оплаты", + "prefferedPayment": "Предпочтительный способ оплаты", + "otherPaymentOptions": "Другие способы оплаты", + "rideHistory": "История поездок", + "plsLoginToAcc": "Пожалуйста, войдите, чтобы продолжить", + "youAreNotLoggedIn": "Вы не вошли в систему. Пожалуйста, войдите, чтобы получить доступ к аккаунту и функциям.", + "noOrderfound": "Заказов не найдено", + "reset_password_link_sent": "Ссылка для сброса отправлена на {email}", + "pay_amount": "Сумма к оплате: {amount}", + "otherServices": "Другие услуги", + "foodDelivery": "Доставка еды", + "delivery": "Доставка", + "bookingTaxi": "Заказ \nТакси", + "updateYourWardrobe": "Обновите гардероб", + "weDeliverSafely": "Мы доставляем безопасно", + "rent": "Аренда", + "hugeSelectionOfAds": "Огромный выбор объявлений!", + "cosmetics": "Косметика", + "moreThan1000Products": "Более 1000 товаров", + "foodProducts": "Продукты питания", + "enableLocation": "Включите геолокацию", + "allowLocation": "Разрешите доступ к геолокации, чтобы найти магазины и услуги рядом с вами.", + "useCurrentLocation": "Использовать текущую геолокацию", + "setFromMap": "Выбрать на карте", + "enterManuallyLocation": "Введите адрес вручную", + "changeLanguage": "Изменить язык", + "selectPrefferedLanguage": "Выберите предпочитаемый язык для персонализированного использования приложения." +} diff --git a/assets/translations/uz.json b/assets/translations/uz.json new file mode 100644 index 0000000..e8c3ee2 --- /dev/null +++ b/assets/translations/uz.json @@ -0,0 +1,124 @@ +{ + "loginToExplore" : "Barcha xizmatlarimizdan foydalanish va qulay xarid qilish uchun tizimga kiring.", + "emailAddress": "Email manzil*", + "password": "Parol*", + "enterPassword": "Parolni kiriting", + "forgotPassword": "Parolni unutdingizmi", + "login": "Kirish", + "orContinueWith": "yoki davom eting", + "withGoogle": "Google orqali", + "withApple": "Apple orqali", + "dontHaveAccount": "Hisobingiz yo‘qmi?", + "signUp": "Ro‘yxatdan o‘tish", + "skip": "O‘tkazib yuborish", + "signUpToExplore": "Ro‘yxatdan o‘ting va barcha xizmatlarimizdan foydalanishni boshlang.", + "firstName": "Ism*", + "lastName": "Familiya*", + "enterMobileNumber": "Telefon raqamini kiriting", + "confirmPassword": "Parolni tasdiqlang*", + "enterConfirmPassword": "Tasdiqlash parolini kiriting", + "referralCode": "Referal kod", + "enterReferralCode": "Referal kodni kiriting", + "alreadyHaveAccount": "Hisobingiz bormi?", + "enterYourregisteredEmail": "Email manzilingizni kiriting — sizga parolni tiklash havolasi yuboriladi.", + "sendLink": "Havolani yuborish", + "rememberPassword": "Parol esingizga tushdimi?", + "enterOtpSent": "Telefoningizga yuborilgan kodni kiriting", + "resendOTP": "Kod qayta yuborilsin", + "verify": "Tasdiqlash", + "useYourMobileNumber": "Telefon raqamingiz orqali oson va xavfsiz kirishingiz mumkin.", + "sendCode": "Kod yuborish", + "serviceIsUnavailable": "Tanlangan manzilda xizmat mavjud emas.", + "pickUpLocation": "Jo‘nash manzili", + "destinationLocation": "Borish manzili", + "continueT": "Davom etish", + "plsSelectSourceLocation": "Iltimos, jo‘nash manzilini tanlang", + "plsSelectDestinationLocations": "Iltimos, borish manzilini tanlang", + "selectVehicleType": "Transport turini tanlang", + "plsSelectVehicleTypeFirst": "Avval transport turini tanlang.", + "plsSelectPaymentMethod": "Iltimos, to‘lov usulini tanlang", + "insufficientWallet": "Hamyonda mablag‘ yetarli emas. Boshqa to‘lov usulini tanlang.", + "promoCode": "Promo kod", + "thisOfferNotEligible": "Bu taklif ushbu buyurtma uchun amal qilmaydi", + "viewAll": "Barchasini ko‘rish", + "writeCoupon": "Promo kodni kiriting", + "redeemNow": "Qo‘llash", + "plsEnterCouponCode": "Iltimos, promo kodni kiriting", + "couponApplied": "Promo kod muvaffaqiyatli qo‘llandi", + "couponExpired": "Ushbu promo kodning muddati tugagan", + "invalidCouponCode": "Noto‘g‘ri promo kod", + "orderSummary": "Buyurtma tafsilotlari", + "subtotal": "Oraliq summa", + "discount": "Chegirma", + "orderTotal": "Umumiy summa", + "confirmBooking": "Buyurtmani tasdiqlash", + "waitingForDriver": "Haydovchi kutilmoqda....", + "cancelRide": "Safarni bekor qilish", + "riderCancelledSucces": "Safar muvaffaqiyatli bekor qilindi", + "failedToCancel": "Safarni bekor qilish amalga oshmadi", + "pleaseWait": "Iltimos, kuting...", + "change": "O‘zgartirish", + "yourSosRequest": "Sizning SOS so‘rovingiz administratorga yuborildi", + "yourSosrequestAlreadySubmitted": "SOS so‘rovi allaqachon yuborilgan", + "payNow": "Hozir to‘lash", + "youDoNothaveSufficientwalletBalance": "Hamyonda mablag‘ yetarli emas", + "somethingWentWrong": "Xatolik yuz berdi, administrator bilan bog‘laning.", + "cash": "Naqd", + "coupon": "Promo kod", + "couponNotFound": "Promo kod topilmadi.", + "tapToApply": "Qo‘llash uchun bosing", + "home": "Bosh sahifa", + "myBookings": "Buyurtmalarim", + "profile": "Profil", + "wallet": "Hamyon", + "cabServiceType": "Taksi xizmati turi", + "everyRideVerified": "Har bir safar. Har bir haydovchi. Tasdiqlangan.", + "allDriversIDCheck": "Barcha haydovchilar hujjat va tekshiruvdan o‘tadi — xavfsizligingiz uchun.", + "intercity": "Shaharlararo", + "aroundTheCity": "Shahar bo‘ylab", + "rideDetails": "Safar tafsilotlari", + "orderId": "Buyurtma ID:", + "bookingData": "Buyurtma sanasi:", + "rideAndFareSummary": "Safar va to‘lov tafsilotlari", + "updateReview": "Sharhni yangilash", + "addReview": "Sharh qoldirish", + "complain": "Shikoyat", + "distance": "Masofa", + "km": "km", + "duration": "Davomiylik", + "howWasTrip": "Safar qanday o‘tdi?", + "yourFeedbackWillHelp": "Fikringiz safar sifatini yanada yaxshilashga yordam beradi", + "rateFor": "Baholash:", + "typeComment": "Izoh yozing....", + "title": "Sarlavha", + "typeDescription": "Tavsif yozing...", + "save": "Saqlash", + "popularDestinations": "Mashhur yo‘nalishlar", + "selectPaymentMethod": "To‘lov usulini tanlang", + "prefferedPayment": "Afzal to‘lov usuli", + "otherPaymentOptions": "Boshqa to‘lov usullari", + "rideHistory": "Safar tarixi", + "plsLoginToAcc": "Davom etish uchun tizimga kiring", + "youAreNotLoggedIn": "Siz tizimga kirmagansiz. Hisobingizga kirib barcha funksiyalardan foydalaning.", + "noOrderfound": "Buyurtmalar topilmadi", + "reset_password_link_sent": "Parol tiklash havolasi {email} manziliga yuborildi", + "pay_amount": "To‘lanadigan summa: {amount}", + "otherServices": "Boshqa xizmatlar", + "foodDelivery": "Oziq-ovqat yetkazib berish", + "delivery": "Yetkazib berish", + "bookingTaxi": "Taksi \nBuyurtma", + "updateYourWardrobe": "Garderobingizni yangilang", + "weDeliverSafely": "Biz xavfsiz yetkazib beramiz", + "rent": "Ijara", + "hugeSelectionOfAds": "Keng e’lonlar tanlovi!", + "cosmetics": "Kosmetika", + "moreThan1000Products": "1000 dan ortiq mahsulotlar", + "foodProducts": "Oziq-ovqat mahsulotlari", + "enableLocation": "Shaxsiylashtirilgan tajriba uchun geolokatsiyani yoqing", + "allowLocation": "Yaqin atrofdagi do‘kon va xizmatlarni topish uchun geolokatsiyaga ruxsat bering.", + "useCurrentLocation": "Joriy manzildan foydalanish", + "setFromMap": "Xaritadan tanlash", + "enterManuallyLocation": "Manzilni qo‘lda kiriting", + "changeLanguage": "Tilni o‘zgartirish", + "selectPrefferedLanguage": "Shaxsiylashtirilgan tajriba uchun afzal tilni tanlang." +} diff --git a/firebase.json b/firebase.json index 88cc8d5..0e7803d 100644 --- a/firebase.json +++ b/firebase.json @@ -1 +1 @@ -{"flutter":{"platforms":{"android":{"default":{"projectId":"fondexuzb","appId":"1:893074789710:android:05002c15a64cf1e0c4ba1f","fileOutput":"android/app/google-services.json"}},"dart":{"lib/firebase_options.dart":{"projectId":"fondexuzb","configurations":{"android":"1:893074789710:android:05002c15a64cf1e0c4ba1f","ios":"1:893074789710:ios:510ebf9e4ebed6a8c4ba1f"}}},"ios":{"default":{"projectId":"fondexuzb","appId":"1:893074789710:ios:510ebf9e4ebed6a8c4ba1f","uploadDebugSymbols":false,"fileOutput":"ios/Runner/GoogleService-Info.plist"}}}}} \ No newline at end of file +{"flutter":{"platforms":{"android":{"default":{"projectId":"fondexuzb","appId":"1:893074789710:android:e932bc88da6665b3c4ba1f","fileOutput":"android/app/google-services.json"}},"dart":{"lib/firebase_options.dart":{"projectId":"fondexuzb","configurations":{"android":"1:893074789710:android:e932bc88da6665b3c4ba1f","ios":"1:893074789710:ios:7dd456b65070f325c4ba1f"}}},"ios":{"default":{"projectId":"fondexuzb","appId":"1:893074789710:ios:7dd456b65070f325c4ba1f","uploadDebugSymbols":false,"fileOutput":"ios/Runner/GoogleService-Info.plist"}}}}} \ No newline at end of file diff --git a/ios/Podfile.lock b/ios/Podfile.lock index d3ba75c..bfc088c 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1317,6 +1317,8 @@ PODS: - Flutter (1.0.0) - flutter_local_notifications (0.0.1): - Flutter + - flutter_localization (0.0.1): + - Flutter - flutter_osm_plugin (0.0.1): - Alamofire - Flutter @@ -1500,7 +1502,9 @@ PODS: - Flutter - Polyline (5.1.0) - PromisesObjC (2.4.0) - - razorpay-pod (1.4.7) + - razorpay-core-pod (1.0.3) + - razorpay-pod (1.5.0): + - razorpay-core-pod - razorpay_flutter (1.1.10): - Flutter - razorpay-pod @@ -1592,6 +1596,7 @@ DEPENDENCIES: - firebase_storage (from `.symlinks/plugins/firebase_storage/ios`) - Flutter (from `Flutter`) - flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`) + - flutter_localization (from `.symlinks/plugins/flutter_localization/ios`) - flutter_osm_plugin (from `.symlinks/plugins/flutter_osm_plugin/ios`) - fluttertoast (from `.symlinks/plugins/fluttertoast/ios`) - geocoding_ios (from `.symlinks/plugins/geocoding_ios/ios`) @@ -1651,6 +1656,7 @@ SPEC REPOS: - OSMFlutterFramework - Polyline - PromisesObjC + - razorpay-core-pod - razorpay-pod - RecaptchaInterop - Stripe @@ -1682,6 +1688,8 @@ EXTERNAL SOURCES: :path: Flutter flutter_local_notifications: :path: ".symlinks/plugins/flutter_local_notifications/ios" + flutter_localization: + :path: ".symlinks/plugins/flutter_localization/ios" flutter_osm_plugin: :path: ".symlinks/plugins/flutter_osm_plugin/ios" fluttertoast: @@ -1758,13 +1766,14 @@ SPEC CHECKSUMS: FirebaseStorage: 20d6b56fb8a40ebaa03d6a2889fe33dac64adb73 Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467 flutter_local_notifications: a5a732f069baa862e728d839dd2ebb904737effb + flutter_localization: 72299fb6cb4e51cae587bd953ed0b958040b71e6 flutter_osm_plugin: 3fb57665b32a81fcffa57c6206658d3a0d0d1a96 fluttertoast: 2c67e14dce98bbdb200df9e1acf610d7a6264ea1 geocoding_ios: 33776c9ebb98d037b5e025bb0e7537f6dd19646e geolocator_apple: ab36aa0e8b7d7a2d7639b3b4e48308394e8cef5e Google-Maps-iOS-Utils: 0a484b05ed21d88c9f9ebbacb007956edd508a96 google_maps_flutter_ios: 0291eb2aa252298a769b04d075e4a9d747ff7264 - google_sign_in_ios: 205742c688aea0e64db9da03c33121694a365109 + google_sign_in_ios: 00dfa94252eb10278b64828c81bcb7158a81a53a GoogleDataTransport: aae35b7ea0c09004c3797d53c8c41f66f219d6a7 GoogleMaps: 0608099d4870cac8754bdba9b6953db543432438 GoogleSignIn: c7f09cfbc85a1abf69187be091997c317cc33b77 @@ -1773,7 +1782,7 @@ SPEC CHECKSUMS: gRPC-Core: 860978b7db482de8b4f5e10677216309b5ff6330 GTMAppAuth: 217a876b249c3c585a54fd6f73e6b58c4f5c4238 GTMSessionFetcher: 5aea5ba6bd522a239e236100971f10cb71b96ab6 - image_picker_ios: 7fe1ff8e34c1790d6fff70a32484959f563a928a + image_picker_ios: e0ece4aa2a75771a7de3fa735d26d90817041326 in_app_review: 7dd1ea365263f834b8464673f9df72c80c17c937 leveldb-library: cc8b8f8e013647a295ad3f8cd2ddf49a6f19be19 location: 155caecf9da4f280ab5fe4a55f94ceccfab838f8 @@ -1781,15 +1790,16 @@ SPEC CHECKSUMS: nanopb: fad817b59e0457d11a5dfbde799381cd727c1275 OSMFlutterFramework: 2f1260ac2854d3398b92403f2d5e012b4ca2c620 package_info_plus: af8e2ca6888548050f16fa2f1938db7b5a5df499 - path_provider_foundation: 080d55be775b7414fd5a5ef3ac137b97b097e564 + path_provider_foundation: bb55f6dbba17d0dccd6737fe6f7f34fbd0376880 permission_handler_apple: 4ed2196e43d0651e8ff7ca3483a069d469701f2d Polyline: 2a1f29f87f8d9b7de868940f4f76deb8c678a5b1 PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47 - razorpay-pod: 7bbc8748a93377d1705f9119b2f947faa9c9e3e1 + razorpay-core-pod: ef0309dbf8e3e5a1330f6cad89dcf9226d8ef758 + razorpay-pod: f634f1b8397eb54d547f25d35291f679545ddf17 razorpay_flutter: 0e98e4fcaae27ad50e011d85f66d85e0a008754a RecaptchaInterop: 11e0b637842dfb48308d242afc3f448062325aba share_plus: 50da8cb520a8f0f65671c6c6a99b3617ed10a58a - shared_preferences_foundation: 9e1978ff2562383bd5676f64ec4e9aa8fa06a6f7 + shared_preferences_foundation: 7036424c3d8ec98dfe75ff1667cb0cd531ec82bb sign_in_with_apple: c5dcc141574c8c54d5ac99dd2163c0c72ad22418 sqflite_darwin: 20b2a3a3b70e43edae938624ce550a3cbf66a3d0 Stripe: a4b6584549bac3698733ed564e55b0b067cfda8a @@ -1801,9 +1811,9 @@ SPEC CHECKSUMS: StripePaymentSheet: 7bc20a0ab10d91acc06dc449ab61bb2cf221b0f4 StripePaymentsUI: 1590647b3f635a58fb0e7058d86d3e9ff89250d4 StripeUICore: a63d95d604e70a5895f9d6b09c49a46757e86353 - url_launcher_ios: 694010445543906933d732453a59da0a173ae33d + url_launcher_ios: 7a95fa5b60cc718a708b8f2966718e93db0cef1b video_compress: f2133a07762889d67f0711ac831faa26f956980e - video_player_avfoundation: 2cef49524dd1f16c5300b9cd6efd9611ce03639b + video_player_avfoundation: dd410b52df6d2466a42d28550e33e4146928280a webview_flutter_wkwebview: 8ebf4fded22593026f7dbff1fbff31ea98573c8d Yams: e10dae147f517ed57ecae37c5e8681bdf8fcab65 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 844309b..108d164 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -496,7 +496,7 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 9J9XV5T2VN; + DEVELOPMENT_TEAM = N72LCPWT92; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = "Emart Customer"; @@ -504,10 +504,15 @@ "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.emart.customer; + PRODUCT_BUNDLE_IDENTIFIER = uz.felix.fondex.customer; PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = 1; VERSIONING_SYSTEM = "apple-generic"; }; name = Profile; @@ -521,7 +526,7 @@ CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.emart.customer.RunnerTests; + PRODUCT_BUNDLE_IDENTIFIER = felix.fondex.uz.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -539,7 +544,7 @@ CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.emart.customer.RunnerTests; + PRODUCT_BUNDLE_IDENTIFIER = felix.fondex.uz.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; @@ -555,7 +560,7 @@ CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.emart.customer.RunnerTests; + PRODUCT_BUNDLE_IDENTIFIER = felix.fondex.uzRunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; @@ -683,7 +688,7 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 9J9XV5T2VN; + DEVELOPMENT_TEAM = N72LCPWT92; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = "Emart Customer"; @@ -691,11 +696,16 @@ "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.emart.customer; + PRODUCT_BUNDLE_IDENTIFIER = uz.felix.fondex999; PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = 1; VERSIONING_SYSTEM = "apple-generic"; }; name = Debug; @@ -708,7 +718,7 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 9J9XV5T2VN; + DEVELOPMENT_TEAM = N72LCPWT92; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = "Emart Customer"; @@ -716,10 +726,15 @@ "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.emart.customer; + PRODUCT_BUNDLE_IDENTIFIER = uz.felix.fondex.customer; PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = 1; VERSIONING_SYSTEM = "apple-generic"; }; name = Release; diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-20@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-20@2x.png deleted file mode 100644 index eeb78fa..0000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-20@2x.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-20@2x~ipad.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-20@2x~ipad.png deleted file mode 100644 index eeb78fa..0000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-20@2x~ipad.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-20@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-20@3x.png deleted file mode 100644 index bb3559a..0000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-20@3x.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-20~ipad.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-20~ipad.png deleted file mode 100644 index 9cdf922..0000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-20~ipad.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-29.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-29.png deleted file mode 100644 index 49f84fc..0000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-29.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-29@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-29@2x.png deleted file mode 100644 index 4fb59b2..0000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-29@2x.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-29@2x~ipad.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-29@2x~ipad.png deleted file mode 100644 index 4fb59b2..0000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-29@2x~ipad.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-29@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-29@3x.png deleted file mode 100644 index 42f31df..0000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-29@3x.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-29~ipad.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-29~ipad.png deleted file mode 100644 index 49f84fc..0000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-29~ipad.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-40@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-40@2x.png deleted file mode 100644 index 17c0afc..0000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-40@2x.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-40@2x~ipad.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-40@2x~ipad.png deleted file mode 100644 index 17c0afc..0000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-40@2x~ipad.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-40@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-40@3x.png deleted file mode 100644 index 3fa4f47..0000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-40@3x.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-40~ipad.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-40~ipad.png deleted file mode 100644 index eeb78fa..0000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-40~ipad.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-60@2x~car.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-60@2x~car.png deleted file mode 100644 index 3fa4f47..0000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-60@2x~car.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-60@3x~car.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-60@3x~car.png deleted file mode 100644 index a9c049e..0000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-60@3x~car.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-83.5@2x~ipad.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-83.5@2x~ipad.png deleted file mode 100644 index 260eb41..0000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-83.5@2x~ipad.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon@2x.png deleted file mode 100644 index 3fa4f47..0000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon@2x.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon@2x~ipad.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon@2x~ipad.png deleted file mode 100644 index d96554e..0000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon@2x~ipad.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon@3x.png deleted file mode 100644 index a9c049e..0000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon@3x.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon~ios-marketing.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon~ios-marketing.png deleted file mode 100644 index c231fe8..0000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon~ios-marketing.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon~ipad.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon~ipad.png deleted file mode 100644 index 812adc6..0000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon~ipad.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json index bd04914..0344229 100644 --- a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -1,134 +1,128 @@ { - "images": [ + "images" : [ { - "filename": "AppIcon@2x.png", - "idiom": "iphone", - "scale": "2x", - "size": "60x60" + "filename" : "Icon-App-20x20@2x.png", + "idiom" : "iphone", + "scale" : "2x", + "size" : "20x20" }, { - "filename": "AppIcon@3x.png", - "idiom": "iphone", - "scale": "3x", - "size": "60x60" + "filename" : "Icon-App-20x20@3x.png", + "idiom" : "iphone", + "scale" : "3x", + "size" : "20x20" }, { - "filename": "AppIcon~ipad.png", - "idiom": "ipad", - "scale": "1x", - "size": "76x76" + "filename" : "Icon-App-29x29@1x.png", + "idiom" : "iphone", + "scale" : "1x", + "size" : "29x29" }, { - "filename": "AppIcon@2x~ipad.png", - "idiom": "ipad", - "scale": "2x", - "size": "76x76" + "filename" : "Icon-App-29x29@2x.png", + "idiom" : "iphone", + "scale" : "2x", + "size" : "29x29" }, { - "filename": "AppIcon-83.5@2x~ipad.png", - "idiom": "ipad", - "scale": "2x", - "size": "83.5x83.5" + "filename" : "Icon-App-29x29@3x.png", + "idiom" : "iphone", + "scale" : "3x", + "size" : "29x29" }, { - "filename": "AppIcon-40@2x.png", - "idiom": "iphone", - "scale": "2x", - "size": "40x40" + "filename" : "Icon-App-40x40@2x.png", + "idiom" : "iphone", + "scale" : "2x", + "size" : "40x40" }, { - "filename": "AppIcon-40@3x.png", - "idiom": "iphone", - "scale": "3x", - "size": "40x40" + "filename" : "Icon-App-40x40@3x.png", + "idiom" : "iphone", + "scale" : "3x", + "size" : "40x40" }, { - "filename": "AppIcon-40~ipad.png", - "idiom": "ipad", - "scale": "1x", - "size": "40x40" + "filename" : "Icon-App-60x60@2x.png", + "idiom" : "iphone", + "scale" : "2x", + "size" : "60x60" }, { - "filename": "AppIcon-40@2x~ipad.png", - "idiom": "ipad", - "scale": "2x", - "size": "40x40" + "filename" : "Icon-App-60x60@3x.png", + "idiom" : "iphone", + "scale" : "3x", + "size" : "60x60" }, { - "filename": "AppIcon-20@2x.png", - "idiom": "iphone", - "scale": "2x", - "size": "20x20" + "filename" : "Icon-App-20x20@1x.png", + "idiom" : "ipad", + "scale" : "1x", + "size" : "20x20" }, { - "filename": "AppIcon-20@3x.png", - "idiom": "iphone", - "scale": "3x", - "size": "20x20" + "filename" : "Icon-App-20x20@2x.png", + "idiom" : "ipad", + "scale" : "2x", + "size" : "20x20" }, { - "filename": "AppIcon-20~ipad.png", - "idiom": "ipad", - "scale": "1x", - "size": "20x20" + "filename" : "Icon-App-29x29@1x.png", + "idiom" : "ipad", + "scale" : "1x", + "size" : "29x29" }, { - "filename": "AppIcon-20@2x~ipad.png", - "idiom": "ipad", - "scale": "2x", - "size": "20x20" + "filename" : "Icon-App-29x29@2x.png", + "idiom" : "ipad", + "scale" : "2x", + "size" : "29x29" }, { - "filename": "AppIcon-29.png", - "idiom": "iphone", - "scale": "1x", - "size": "29x29" + "filename" : "Icon-App-40x40@1x.png", + "idiom" : "ipad", + "scale" : "1x", + "size" : "40x40" }, { - "filename": "AppIcon-29@2x.png", - "idiom": "iphone", - "scale": "2x", - "size": "29x29" + "filename" : "Icon-App-40x40@2x.png", + "idiom" : "ipad", + "scale" : "2x", + "size" : "40x40" }, { - "filename": "AppIcon-29@3x.png", - "idiom": "iphone", - "scale": "3x", - "size": "29x29" + "filename" : "Icon-App-76x76@1x.png", + "idiom" : "ipad", + "scale" : "1x", + "size" : "76x76" }, { - "filename": "AppIcon-29~ipad.png", - "idiom": "ipad", - "scale": "1x", - "size": "29x29" + "filename" : "Icon-App-76x76@2x.png", + "idiom" : "ipad", + "scale" : "2x", + "size" : "76x76" }, { - "filename": "AppIcon-29@2x~ipad.png", - "idiom": "ipad", - "scale": "2x", - "size": "29x29" + "filename" : "Icon-App-83.5x83.5@2x.png", + "idiom" : "ipad", + "scale" : "2x", + "size" : "83.5x83.5" }, { - "filename": "AppIcon-60@2x~car.png", - "idiom": "car", - "scale": "2x", - "size": "60x60" + "filename" : "ItunesArtwork@2x.png", + "idiom" : "ios-marketing", + "scale" : "1x", + "size" : "1024x1024" }, { - "filename": "AppIcon-60@3x~car.png", - "idiom": "car", - "scale": "3x", - "size": "60x60" - }, - { - "filename": "AppIcon~ios-marketing.png", - "idiom": "ios-marketing", - "scale": "1x", - "size": "1024x1024" + "filename" : "Icon-App-76x76@2x.png", + "idiom" : "iphone", + "scale" : "2x", + "size" : "76x76" } ], - "info": { - "author": "iconkitchen", - "version": 1 + "info" : { + "author" : "xcode", + "version" : 1 } -} \ No newline at end of file +} diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 0000000..663f227 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 0000000..c45bdd3 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 0000000..1df2afc Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 0000000..321eaed Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 0000000..9e006cf Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png new file mode 100644 index 0000000..fe6cc25 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png new file mode 100644 index 0000000..c45bdd3 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 0000000..f27f1aa Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 0000000..e4f0355 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 0000000..e4f0355 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 0000000..666179c Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 0000000..aaf36f3 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png new file mode 100644 index 0000000..40018a3 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 0000000..dfcac43 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/ItunesArtwork@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/ItunesArtwork@2x.png new file mode 100644 index 0000000..2e5a3d8 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/ItunesArtwork@2x.png differ diff --git a/ios/Runner/Assets.xcassets/Contents.json b/ios/Runner/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/ios/Runner/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ios/Runner/GoogleService-Info.plist b/ios/Runner/GoogleService-Info.plist index 59544f2..87acab5 100644 --- a/ios/Runner/GoogleService-Info.plist +++ b/ios/Runner/GoogleService-Info.plist @@ -3,9 +3,9 @@ CLIENT_ID - 893074789710-pv12m4nhe82a4ueg9sb2pgt42r0e5da3.apps.googleusercontent.com + 893074789710-tgc677brhj8902uu2nv6k53otbhbnp1e.apps.googleusercontent.com REVERSED_CLIENT_ID - com.googleusercontent.apps.893074789710-pv12m4nhe82a4ueg9sb2pgt42r0e5da3 + com.googleusercontent.apps.893074789710-tgc677brhj8902uu2nv6k53otbhbnp1e API_KEY AIzaSyD6Khoz4y93GCj3mOPi2FoluDipplH1av0 GCM_SENDER_ID @@ -13,7 +13,7 @@ PLIST_VERSION 1 BUNDLE_ID - com.emart.customer + uz.felix.fondex.customer PROJECT_ID fondexuzb STORAGE_BUCKET @@ -29,7 +29,7 @@ IS_SIGNIN_ENABLED GOOGLE_APP_ID - 1:893074789710:ios:510ebf9e4ebed6a8c4ba1f + 1:893074789710:ios:7dd456b65070f325c4ba1f DATABASE_URL https://fondexuzb-default-rtdb.firebaseio.com diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index b6fcdcb..3cab40b 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -2,51 +2,24 @@ - MinimumOSVersion - 15.0 - CFBundleURLTypes - - - CFBundleTypeRole - Editor - CFBundleURLSchemes - - com.googleusercontent.apps.841077018919-978flnqdu54q5lb5e56od2jr2oha90ll - - - - - GIDClientID - 841077018919-978flnqdu54q5lb5e56od2jr2oha90ll.apps.googleusercontent.com - - NSCameraUsageDescription - This app needs access to camera permission - NSLocationAlwaysAndWhenInUseUsageDescription - This app needs access to location when open and in the background. - NSLocationAlwaysUsageDescription - This app needs access to location when in the background. - NSLocationWhenInUseUsageDescription - This app needs access to location when open. - NSMicrophoneUsageDescription - Used to capture audio for image picker plugin - NSPhotoLibraryUsageDescription - This app needs access to your gallery photo. - UIBackgroundModes - - fetch - remote-notification - - + CADisableMinimumFrameDurationOnPhone + CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleDisplayName - Customer + Fondex CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 + CFBundleLocalizations + + en + ru + uz + CFBundleName customer CFBundlePackageType @@ -55,10 +28,44 @@ $(FLUTTER_BUILD_NAME) CFBundleSignature ???? + CFBundleURLTypes + + + CFBundleTypeRole + Editor + CFBundleURLSchemes + + com.googleusercontent.apps.841077018919-978flnqdu54q5lb5e56od2jr2oha90ll + + + CFBundleVersion $(FLUTTER_BUILD_NUMBER) + GIDClientID + 841077018919-978flnqdu54q5lb5e56od2jr2oha90ll.apps.googleusercontent.com LSRequiresIPhoneOS + MinimumOSVersion + 15.0 + NSCameraUsageDescription + This app needs access to camera permission + NSLocationAlwaysAndWhenInUseUsageDescription + This app needs access to location when open and in the background. + NSLocationAlwaysUsageDescription + This app needs access to location when in the background. + NSLocationWhenInUseUsageDescription + This app needs access to location when open. + NSMicrophoneUsageDescription + Used to capture audio for image picker plugin + NSPhotoLibraryUsageDescription + This app needs access to your gallery photo. + UIApplicationSupportsIndirectInputEvents + + UIBackgroundModes + + fetch + remote-notification + UILaunchStoryboardName LaunchScreen UIMainStoryboardFile @@ -76,9 +83,5 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight - CADisableMinimumFrameDurationOnPhone - - UIApplicationSupportsIndirectInputEvents - diff --git a/lib/constant/const_texts.dart b/lib/constant/const_texts.dart new file mode 100644 index 0000000..b44803e --- /dev/null +++ b/lib/constant/const_texts.dart @@ -0,0 +1,163 @@ +class ConstTexts { + static String loginToExplore = "loginToExplore"; + static String emailAddress = "emailAddress"; + static String password = "password"; + static String enterPassword = "enterPassword"; + static String forgotPassword = "forgotPassword"; + static String login = "login"; + static String orContinueWith = "orContinueWith"; + static String mobileNumber = "mobileNumber"; + static String withGoogle = "withGoogle"; + static String withApple = "withApple"; + static String dontHaveAccount = "dontHaveAccount"; + static String signUp = "signUp"; + static String skip = "skip"; + static String signUpToExplore = "signUpToExplore"; + static String firstName = "firstName"; + static String lastName = "lastName"; + static String enterMobileNumber = "enterMobileNumber"; + static String confirmPassword = "confirmPassword"; + static String enterConfirmPassword = "enterConfirmPassword"; + static String referralCode = "referralCode"; + static String enterReferralCode = "enterReferralCode"; + static String alreadyHaveAccount = "alreadyHaveAccount"; + static String enterYourregisteredEmail = "enterYourregisteredEmail"; + static String sendLink = "sendLink"; + static String rememberPassword = "rememberPassword"; + static String enterOtpSent = "enterOtpSent"; + static String resendOTP = "resendOTP"; + static String verify = "verify"; + static String useYourMobileNumber = "useYourMobileNumber"; + static String sendCode = "sendCode"; + static String serviceIsUnavailable = "serviceIsUnavailable"; + static String pickUpLocation = "pickUpLocation"; + static String destinationLocation = "destinationLocation"; + static String continueT = "continue"; + static String plsSelectSourceLocation = "plsSelectSourceLocation"; + static String plsSelectDestinationLocations = "plsSelectDestinationLocations"; + static String selectVehicleType = "selectVehicleType"; + static String plsSelectVehicleTypeFirst = "plsSelectVehicleTypeFirst"; + static String plsSelectPaymentMethod = "plsSelectPaymentMethod"; + static String insufficientWallet = "insufficientWallet"; + static String promoCode = "promoCode"; + static String thisOfferNotEligible = "thisOfferNotEligible"; + static String viewAll = "viewAll"; + static String writeCoupon = "writeCoupon"; + static String redeemNow = "redeemNow"; + static String plsEnterCouponCode = "plsEnterCouponCode"; + static String couponApplied = "couponApplied"; + static String couponExpired = "couponExpired"; + static String invalidCouponCode = "invalidCouponCode"; + static String orderSummary = "orderSummary"; + static String subtotal = "subtotal"; + static String discount = "discount"; + static String orderTotal = "orderTotal"; + static String confirmBooking = "confirmBooking"; + static String waitingForDriver = "waitingForDriver"; + static String cancelRide = "cancelRide"; + static String riderCancelledSucces = "riderCancelledSucces"; + static String failedToCancel = "failedToCancel"; + static String pleaseWait = "pleaseWait"; + static String change = "change"; + static String yourSosRequest = "yourSosRequest"; + static String yourSosrequestAlreadySubmitted = + "yourSosrequestAlreadySubmitted"; + static String payNow = "payNow"; + static String youDoNothaveSufficientwalletBalance = + "youDoNothaveSufficientwalletBalance"; + static String somethingWentWrong = "somethingWentWrong"; + static String cash = "cash"; + static String coupon = "coupon"; + static String couponNotFound = "couponNotFound"; + static String tapToApply = "tapToApply"; + static String home = "home"; + static String myBookings = "myBookings"; + static String profile = "profile"; + static String wallet = "wallet"; + static String cabServiceType = "cabServiceType"; + static String everyRideVerified = "everyRideVerified"; + static String allDriversIDCheck = "allDriversIDCheck"; + static String intercity = "intercity"; + static String aroundTheCity = "aroundTheCity"; + static String rideDetails = "rideDetails"; + static String orderId = "orderId"; + static String bookingData = "bookingData"; + static String rideAndFareSummary = "rideAndFareSummary"; + static String updateReview = "updateReview"; + static String addReview = "addReview"; + static String complain = "complain"; + static String distance = "distance"; + static String km = "km"; + static String duration = "duration"; + static String howWasTrip = "howWasTrip"; + static String yourFeedbackWillHelp = "yourFeedbackWillHelp"; + static String rateFor = "rateFor"; + static String typeComment = "typeComment"; + static String title = "title"; + static String typeDescription = "typeDescription"; + static String save = "save"; + static String popularDestinations = "popularDestinations"; + static String selectPaymentMethod = "selectPaymentMethod"; + static String prefferedPayment = "prefferedPayment"; + static String otherPaymentOptions = "otherPaymentOptions"; + static String rideHistory = "rideHistory"; + static String plsLoginToAcc = "plsLoginToAcc"; + static String youAreNotLoggedIn = "youAreNotLoggedIn"; + static String noOrderfound = "noOrderfound"; + static String otherServices = "otherServices"; + static String foodDelivery = "foodDelivery"; + static String delivery = "delivery"; + static String bookingTaxi = "bookingTaxi"; + static String updateYourWardrobe = "updateYourWardrobe"; + static String weDeliverSafely = "weDeliverSafely"; + static String rent = "rent"; + static String hugeSelectionOfAds = "hugeSelectionOfAds"; + static String cosmetics = "cosmetics"; + static String moreThan1000Products = "moreThan1000Products"; + static String foodProducts = "foodProducts"; + static String enableLocation = "enableLocation"; + static String allowLocation = "allowLocation"; + static String useCurrentLocation = "useCurrentLocation"; + static String setFromMap = "setFromMap"; + static String enterManuallyLocation = "enterManuallyLocation"; + static String changeLanguage = "changeLanguage"; + static String selectPrefferedLanguage = "selectPrefferedLanguage"; + static String searchStoreItem = "searchStoreItem"; + static String category = "category"; + static String highlightsForU = "highlightsForU"; + static String newArrival = "newArrivals"; + static String viewAllArrivals = "View All Arrivals"; + static String topBrands = "topBrands"; + static String styleUp = "styleUp"; + static String additionlOffers = "additionlOffers"; + static String largestDiscounts = "largestDiscounts"; + static String newArrivals = "newArrivals"; + static String popularStores = "popularStores"; + static String allStores = "allStores"; + static String alert = "alert"; + static String cancel = "cancel"; + static String ok = "ok"; + static String freeDelivery = "freeDelivery"; + static String upto = "upto"; + static String viewCart = "viewCart"; + static String viewTimings = "viewTimings"; + static String timingIsNotAdded = "timingIsNotAdded"; + static String alsoApplicableOnTable = "alsoApplicableOnTable"; + static String tableBooking = "tableBooking"; + static String quickConformations = "quickConformations"; + static String menu = "menu"; + static String searchAndMore = "searchAndMore"; + static String veg = "veg"; + static String nonVeg = "nonVeg"; + static String favourites = "favourites"; + static String orders = "orders"; + static String takeAway = "takeAway"; + // static String allStores = "allStores"; + // static String alert = "alert"; + // static String cancel = "cancel"; + // static String ok = "ok"; + // static String freeDelivery = "freeDelivery"; + // static String upto = "upto"; + // static String doYouWantChangeTheDeliverOption = "doYouWantChangeTheDeliverOption"; + // static String cash = "cash"; +} diff --git a/lib/constant/constant.dart b/lib/constant/constant.dart index 4d13a6b..10c4e2e 100644 --- a/lib/constant/constant.dart +++ b/lib/constant/constant.dart @@ -172,7 +172,10 @@ class Constant { static bool checkZoneCheck(double latitude, double longLatitude) { bool isZoneAvailable = false; for (var element in Constant.zoneList) { - if (Constant.isPointInPolygon(LatLng(latitude, longLatitude), element.area!)) { + if (Constant.isPointInPolygon( + LatLng(latitude, longLatitude), + element.area!, + )) { isZoneAvailable = true; break; } else { @@ -185,7 +188,10 @@ class Constant { static String? getZoneId(double latitude, double longLatitude) { String? zoneId; for (var element in Constant.zoneList) { - if (Constant.isPointInPolygon(LatLng(latitude, longLatitude), element.area!)) { + if (Constant.isPointInPolygon( + LatLng(latitude, longLatitude), + element.area!, + )) { zoneId = element.id; break; } @@ -198,13 +204,18 @@ class Constant { return (rng.nextInt(900000) + 100000).toString(); // 6 digit } - static Future checkPermission({required BuildContext context, required Function() onTap}) async { + static Future checkPermission({ + required BuildContext context, + required Function() onTap, + }) async { LocationPermission permission = await Geolocator.checkPermission(); if (permission == LocationPermission.denied) { permission = await Geolocator.requestPermission(); } if (permission == LocationPermission.denied) { - ShowToastDialog.showToast("You have to allow location permission to use your location"); + ShowToastDialog.showToast( + "You have to allow location permission to use your location", + ); } else if (permission == LocationPermission.deniedForever) { showDialog( context: context, @@ -241,7 +252,10 @@ class Constant { return isPlanExpire; } - static bool isExpireDate({required bool expiryDay, Timestamp? subscriptionExpiryDate}) { + static bool isExpireDate({ + required bool expiryDay, + Timestamp? subscriptionExpiryDate, + }) { bool isPlanExpire = false; if (expiryDay == true) { isPlanExpire = false; @@ -301,17 +315,49 @@ class Constant { String commission = "0"; if (sectionConstantModel!.adminCommision!.isEnabled == true) { if (vendorModel.adminCommission == null) { - if (sectionConstantModel!.adminCommision!.commissionType!.toLowerCase() == "Percent".toLowerCase() || - sectionConstantModel!.adminCommision!.commissionType?.toLowerCase() == "Percentage".toLowerCase()) { - commission = (double.parse(price) + (double.parse(price) * double.parse(sectionConstantModel!.adminCommision!.amount.toString()) / 100)).toString(); + if (sectionConstantModel!.adminCommision!.commissionType! + .toLowerCase() == + "Percent".toLowerCase() || + sectionConstantModel!.adminCommision!.commissionType + ?.toLowerCase() == + "Percentage".toLowerCase()) { + commission = + (double.parse(price) + + (double.parse(price) * + double.parse( + sectionConstantModel!.adminCommision!.amount + .toString(), + ) / + 100)) + .toString(); } else { - commission = (double.parse(price) + double.parse(sectionConstantModel!.adminCommision!.amount.toString())).toString(); + commission = + (double.parse(price) + + double.parse( + sectionConstantModel!.adminCommision!.amount.toString(), + )) + .toString(); } } else { - if (vendorModel.adminCommission!.commissionType!.toLowerCase() == "Percent".toLowerCase() || vendorModel.adminCommission!.commissionType?.toLowerCase() == "Percentage".toLowerCase()) { - commission = (double.parse(price) + (double.parse(price) * double.parse(vendorModel.adminCommission!.amount.toString()) / 100)).toString(); + if (vendorModel.adminCommission!.commissionType!.toLowerCase() == + "Percent".toLowerCase() || + vendorModel.adminCommission!.commissionType?.toLowerCase() == + "Percentage".toLowerCase()) { + commission = + (double.parse(price) + + (double.parse(price) * + double.parse( + vendorModel.adminCommission!.amount.toString(), + ) / + 100)) + .toString(); } else { - commission = (double.parse(price) + double.parse(vendorModel.adminCommission!.amount.toString())).toString(); + commission = + (double.parse(price) + + double.parse( + vendorModel.adminCommission!.amount.toString(), + )) + .toString(); } } } else { @@ -327,7 +373,10 @@ class Constant { if (taxModel.type == "fix") { taxAmount = double.parse(taxModel.tax.toString()); } else { - taxAmount = (double.parse(amount.toString()) * double.parse(taxModel.tax!.toString())) / 100; + taxAmount = + (double.parse(amount.toString()) * + double.parse(taxModel.tax!.toString())) / + 100; } } return taxAmount; @@ -336,8 +385,12 @@ class Constant { static double calculateDiscount({String? amount, CouponModel? offerModel}) { double taxAmount = 0.0; if (offerModel != null) { - if (offerModel.discountType == "Percentage" || offerModel.discountType == "percentage") { - taxAmount = (double.parse(amount.toString()) * double.parse(offerModel.discount.toString())) / 100; + if (offerModel.discountType == "Percentage" || + offerModel.discountType == "percentage") { + taxAmount = + (double.parse(amount.toString()) * + double.parse(offerModel.discount.toString())) / + 100; } else { taxAmount = double.parse(offerModel.discount.toString()); } @@ -345,11 +398,17 @@ class Constant { return taxAmount; } - static String calculateReview({required String? reviewCount, required String? reviewSum}) { - if (0 == double.parse(reviewSum.toString()) && 0 == double.parse(reviewSum.toString())) { + static String calculateReview({ + required String? reviewCount, + required String? reviewSum, + }) { + if (0 == double.parse(reviewSum.toString()) && + 0 == double.parse(reviewSum.toString())) { return "0"; } - return (double.parse(reviewSum.toString()) / double.parse(reviewCount.toString())).toStringAsFixed(1); + return (double.parse(reviewSum.toString()) / + double.parse(reviewCount.toString())) + .toStringAsFixed(1); } static String getUuid() { @@ -357,13 +416,24 @@ class Constant { } static Widget loader() { - return Center(child: CircularProgressIndicator(color: AppThemeData.primary300)); + return Center( + child: CircularProgressIndicator(color: AppThemeData.primary300), + ); } static Widget showEmptyView({required String message}) { final themeController = Get.find(); final isDark = themeController.isDark.value; - return Center(child: Text(message, style: TextStyle(fontFamily: AppThemeData.fontFamily, fontSize: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900))); + return Center( + child: Text( + message, + style: TextStyle( + fontFamily: AppThemeData.fontFamily, + fontSize: 18, + color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + ), + ), + ); } static String maskingString(String documentId, int maskingDigit) { @@ -382,7 +452,8 @@ class Constant { } String? validateEmail(String? value) { - String pattern = r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$'; + String pattern = + r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$'; RegExp regExp = RegExp(pattern); if (value == null || value.isEmpty) { return "Email is Required"; @@ -393,9 +464,19 @@ class Constant { } } - static String getDistance({required String lat1, required String lng1, required String lat2, required String lng2}) { + static String getDistance({ + required String lat1, + required String lng1, + required String lat2, + required String lng2, + }) { double distance; - double distanceInMeters = Geolocator.distanceBetween(double.parse(lat1), double.parse(lng1), double.parse(lat2), double.parse(lng2)); + double distanceInMeters = Geolocator.distanceBetween( + double.parse(lat1), + double.parse(lng1), + double.parse(lat2), + double.parse(lng2), + ); if (distanceType == "miles") { distance = distanceInMeters / 1609; } else { @@ -405,7 +486,8 @@ class Constant { } bool hasValidUrl(String? value) { - String pattern = r'(http|https)://[\w-]+(\.[\w-]+)+([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?'; + String pattern = + r'(http|https)://[\w-]+(\.[\w-]+)+([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?'; RegExp regExp = RegExp(pattern); if (value == null || value.isEmpty) { return false; @@ -415,10 +497,17 @@ class Constant { return true; } - static Future uploadUserImageToFireStorage(File image, String filePath, String fileName) async { - Reference upload = FirebaseStorage.instance.ref().child('$filePath/$fileName'); + static Future uploadUserImageToFireStorage( + File image, + String filePath, + String fileName, + ) async { + Reference upload = FirebaseStorage.instance.ref().child( + '$filePath/$fileName', + ); UploadTask uploadTask = upload.putFile(image); - var downloadUrl = await (await uploadTask.whenComplete(() {})).ref.getDownloadURL(); + var downloadUrl = + await (await uploadTask.whenComplete(() {})).ref.getDownloadURL(); return downloadUrl.toString(); } @@ -435,14 +524,22 @@ class Constant { Future getBytesFromAsset(String path, int width) async { ByteData data = await rootBundle.load(path); - ui.Codec codec = await ui.instantiateImageCodec(data.buffer.asUint8List(), targetWidth: width); + ui.Codec codec = await ui.instantiateImageCodec( + data.buffer.asUint8List(), + targetWidth: width, + ); ui.FrameInfo fi = await codec.getNextFrame(); - return (await fi.image.toByteData(format: ui.ImageByteFormat.png))!.buffer.asUint8List(); + return (await fi.image.toByteData( + format: ui.ImageByteFormat.png, + ))!.buffer.asUint8List(); } static Future selectTime(context) async { FocusScope.of(context).requestFocus(FocusNode()); //remove focus - TimeOfDay? newTime = await showTimePicker(context: context, initialTime: TimeOfDay.now()); + TimeOfDay? newTime = await showTimePicker( + context: context, + initialTime: TimeOfDay.now(), + ); if (newTime != null) { return newTime; } @@ -480,7 +577,11 @@ class Constant { static int calculateDifference(DateTime date) { DateTime now = DateTime.now(); - return DateTime(date.year, date.month, date.day).difference(DateTime(now.year, now.month, now.day)).inDays; + return DateTime( + date.year, + date.month, + date.day, + ).difference(DateTime(now.year, now.month, now.day)).inDays; } static String timestampToDate(Timestamp timestamp) { @@ -509,7 +610,15 @@ class Constant { } static DateTime stringToDate(String openDineTime) { - return DateFormat('HH:mm').parse(DateFormat('HH:mm').format(DateFormat("hh:mm a").parse((Intl.getCurrentLocale() == "en_US") ? openDineTime : openDineTime.toLowerCase()))); + return DateFormat('HH:mm').parse( + DateFormat('HH:mm').format( + DateFormat("hh:mm a").parse( + (Intl.getCurrentLocale() == "en_US") + ? openDineTime + : openDineTime.toLowerCase(), + ), + ), + ); } static LanguageModel getLanguage() { @@ -527,7 +636,10 @@ class Constant { int crossings = 0; for (int i = 0; i < polygon.length; i++) { int next = (i + 1) % polygon.length; - if (polygon[i].latitude <= point.latitude && polygon[next].latitude > point.latitude || polygon[i].latitude > point.latitude && polygon[next].latitude <= point.latitude) { + if (polygon[i].latitude <= point.latitude && + polygon[next].latitude > point.latitude || + polygon[i].latitude > point.latitude && + polygon[next].latitude <= point.latitude) { double edgeLong = polygon[next].longitude - polygon[i].longitude; double edgeLat = polygon[next].latitude - polygon[i].latitude; double interpol = (point.latitude - polygon[i].latitude) / edgeLat; @@ -549,7 +661,12 @@ class Constant { allowInsecure: true, ); - static Future sendMail({String? subject, String? body, bool? isAdmin = false, List? recipients}) async { + static Future sendMail({ + String? subject, + String? body, + bool? isAdmin = false, + List? recipients, + }) async { // Create our message. if (mailSettings != null) { if (isAdmin == true) { @@ -557,7 +674,10 @@ class Constant { } final message = Message() - ..from = Address(mailSettings!.userName.toString(), mailSettings!.fromName.toString()) + ..from = Address( + mailSettings!.userName.toString(), + mailSettings!.fromName.toString(), + ) ..recipients = recipients! ..subject = subject ..text = body @@ -581,10 +701,17 @@ class Constant { // await connection.send(message); } - static Uri createCoordinatesUrl(double latitude, double longitude, [String? label]) { + static Uri createCoordinatesUrl( + double latitude, + double longitude, [ + String? label, + ]) { Uri uri; if (kIsWeb) { - uri = Uri.https('www.google.com', '/maps/search/', {'api': '1', 'query': '$latitude,$longitude'}); + uri = Uri.https('www.google.com', '/maps/search/', { + 'api': '1', + 'query': '$latitude,$longitude', + }); } else if (Platform.isAndroid) { var query = '$latitude,$longitude'; if (label != null) query += '($label)'; @@ -594,14 +721,18 @@ class Constant { if (label != null) params['q'] = label; uri = Uri.https('maps.apple.com', '/', params); } else { - uri = Uri.https('www.google.com', '/maps/search/', {'api': '1', 'query': '$latitude,$longitude'}); + uri = Uri.https('www.google.com', '/maps/search/', { + 'api': '1', + 'query': '$latitude,$longitude', + }); } return uri; } static Future sendOrderEmail({required OrderModel orderModel}) async { - EmailTemplateModel? emailTemplateModel = await FireStoreUtils.getEmailTemplates(newOrderPlaced); + EmailTemplateModel? emailTemplateModel = + await FireStoreUtils.getEmailTemplates(newOrderPlaced); if (emailTemplateModel != null) { String firstHTML = """ @@ -618,11 +749,23 @@ class Constant { """; String newString = emailTemplateModel.message.toString(); - newString = newString.replaceAll("{username}", "${Constant.userModel!.firstName} ${Constant.userModel!.lastName}"); + newString = newString.replaceAll( + "{username}", + "${Constant.userModel!.firstName} ${Constant.userModel!.lastName}", + ); newString = newString.replaceAll("{orderid}", orderModel.id.toString()); - newString = newString.replaceAll("{date}", DateFormat('yyyy-MM-dd').format(orderModel.createdAt!.toDate())); - newString = newString.replaceAll("{address}", orderModel.address!.getFullAddress()); - newString = newString.replaceAll("{paymentmethod}", orderModel.paymentMethod.toString()); + newString = newString.replaceAll( + "{date}", + DateFormat('yyyy-MM-dd').format(orderModel.createdAt!.toDate()), + ); + newString = newString.replaceAll( + "{address}", + orderModel.address!.getFullAddress(), + ); + newString = newString.replaceAll( + "{paymentmethod}", + orderModel.paymentMethod.toString(), + ); double deliveryCharge = 0.0; double total = 0.0; @@ -630,7 +773,8 @@ class Constant { double discount = 0.0; double taxAmount = 0.0; double tipValue = 0.0; - String specialLabel = '(${orderModel.specialDiscount!['special_discount_label']}${orderModel.specialDiscount!['specialType'] == "amount" ? currencyModel!.symbol : "%"})'; + String specialLabel = + '(${orderModel.specialDiscount!['special_discount_label']}${orderModel.specialDiscount!['specialType'] == "amount" ? currencyModel!.symbol : "%"})'; List htmlList = []; if (orderModel.deliveryCharge != null) { @@ -640,15 +784,22 @@ class Constant { tipValue = double.parse(orderModel.tipAmount.toString()); } for (var element in orderModel.products!) { - if (element.extrasPrice != null && element.extrasPrice!.isNotEmpty && double.parse(element.extrasPrice!) != 0.0) { - total += double.parse(element.quantity.toString()) * double.parse(element.extrasPrice!); + if (element.extrasPrice != null && + element.extrasPrice!.isNotEmpty && + double.parse(element.extrasPrice!) != 0.0) { + total += + double.parse(element.quantity.toString()) * + double.parse(element.extrasPrice!); } - total += double.parse(element.quantity.toString()) * double.parse(element.price.toString()); + total += + double.parse(element.quantity.toString()) * + double.parse(element.price.toString()); List? addon = element.extras; String extrasDisVal = ''; for (int i = 0; i < addon!.length; i++) { - extrasDisVal += '${addon[i].toString().replaceAll("\"", "")} ${(i == addon.length - 1) ? "" : ","}'; + extrasDisVal += + '${addon[i].toString().replaceAll("\"", "")} ${(i == addon.length - 1) ? "" : ","}'; } String product = """ @@ -666,7 +817,9 @@ class Constant { } if (orderModel.specialDiscount!.isNotEmpty) { - specialDiscount = double.parse(orderModel.specialDiscount!['special_discount'].toString()); + specialDiscount = double.parse( + orderModel.specialDiscount!['special_discount'].toString(), + ); } if (orderModel.couponId != null && orderModel.couponId!.isNotEmpty) { @@ -675,35 +828,81 @@ class Constant { List taxHtmlList = []; for (var element in taxList) { - taxAmount = taxAmount + calculateTax(amount: (total - discount - specialDiscount).toString(), taxModel: element); + taxAmount = + taxAmount + + calculateTax( + amount: (total - discount - specialDiscount).toString(), + taxModel: element, + ); String taxHtml = """${element.title}: ${amountShow(amount: calculateTax(amount: (total - discount - specialDiscount).toString(), taxModel: element).toString())}${taxList.indexOf(element) == taxList.length - 1 ? "" : "
"}"""; taxHtmlList.add(taxHtml); } var totalamount = - orderModel.deliveryCharge == null || orderModel.deliveryCharge!.isEmpty + orderModel.deliveryCharge == null || + orderModel.deliveryCharge!.isEmpty ? total + taxAmount - discount - specialDiscount - : total + taxAmount + double.parse(orderModel.deliveryCharge!) + double.parse(orderModel.tipAmount!) - discount - specialDiscount; + : total + + taxAmount + + double.parse(orderModel.deliveryCharge!) + + double.parse(orderModel.tipAmount!) - + discount - + specialDiscount; - newString = newString.replaceAll("{subtotal}", amountShow(amount: total.toString())); - newString = newString.replaceAll("{coupon}", orderModel.couponId.toString()); - newString = newString.replaceAll("{discountamount}", amountShow(amount: orderModel.discount.toString())); + newString = newString.replaceAll( + "{subtotal}", + amountShow(amount: total.toString()), + ); + newString = newString.replaceAll( + "{coupon}", + orderModel.couponId.toString(), + ); + newString = newString.replaceAll( + "{discountamount}", + amountShow(amount: orderModel.discount.toString()), + ); newString = newString.replaceAll("{specialcoupon}", specialLabel); - newString = newString.replaceAll("{specialdiscountamount}", amountShow(amount: specialDiscount.toString())); - newString = newString.replaceAll("{shippingcharge}", amountShow(amount: deliveryCharge.toString())); - newString = newString.replaceAll("{tipamount}", amountShow(amount: tipValue.toString())); - newString = newString.replaceAll("{totalAmount}", amountShow(amount: totalamount.toString())); + newString = newString.replaceAll( + "{specialdiscountamount}", + amountShow(amount: specialDiscount.toString()), + ); + newString = newString.replaceAll( + "{shippingcharge}", + amountShow(amount: deliveryCharge.toString()), + ); + newString = newString.replaceAll( + "{tipamount}", + amountShow(amount: tipValue.toString()), + ); + newString = newString.replaceAll( + "{totalAmount}", + amountShow(amount: totalamount.toString()), + ); String tableHTML = htmlList.join(); String lastHTML = "
"; - newString = newString.replaceAll("{productdetails}", firstHTML + tableHTML + lastHTML); + newString = newString.replaceAll( + "{productdetails}", + firstHTML + tableHTML + lastHTML, + ); newString = newString.replaceAll("{taxdetails}", taxHtmlList.join()); - newString = newString.replaceAll("{newwalletbalance}.", amountShow(amount: Constant.userModel!.walletAmount.toString())); + newString = newString.replaceAll( + "{newwalletbalance}.", + amountShow(amount: Constant.userModel!.walletAmount.toString()), + ); String subjectNewString = emailTemplateModel.subject.toString(); - subjectNewString = subjectNewString.replaceAll("{orderid}", orderModel.id.toString()); - await sendMail(subject: subjectNewString, isAdmin: emailTemplateModel.isSendToAdmin, body: newString, recipients: [Constant.userModel!.email]); + subjectNewString = subjectNewString.replaceAll( + "{orderid}", + orderModel.id.toString(), + ); + await sendMail( + subject: subjectNewString, + isAdmin: emailTemplateModel.isSendToAdmin, + body: newString, + recipients: [Constant.userModel!.email], + ); } } @@ -711,7 +910,12 @@ class Constant { const R = 6371; // Earth's radius in km final dLat = _degToRad(lat2 - lat1); final dLon = _degToRad(lon2 - lon1); - final a = sin(dLat / 2) * sin(dLat / 2) + cos(_degToRad(lat1)) * cos(_degToRad(lat2)) * sin(dLon / 2) * sin(dLon / 2); + final a = + sin(dLat / 2) * sin(dLat / 2) + + cos(_degToRad(lat1)) * + cos(_degToRad(lat2)) * + sin(dLon / 2) * + sin(dLon / 2); final c = 2 * atan2(sqrt(a), sqrt(1 - a)); return R * c; } @@ -725,13 +929,19 @@ class Constant { } /// Calculate tax amount for a single tax model - static double getTaxValue({required String amount, required TaxModel taxModel}) { + static double getTaxValue({ + required String amount, + required TaxModel taxModel, + }) { double taxVal = 0.0; if (taxModel.enable == true) { if (taxModel.type == "fix") { taxVal = double.tryParse(taxModel.tax.toString()) ?? 0.0; } else { - taxVal = (double.tryParse(amount) ?? 0.0) * (double.tryParse(taxModel.tax.toString()) ?? 0.0) / 100; + taxVal = + (double.tryParse(amount) ?? 0.0) * + (double.tryParse(taxModel.tax.toString()) ?? 0.0) / + 100; } } return taxVal; @@ -743,10 +953,15 @@ class Constant { if (response.statusCode != 200) throw Exception("Failed to load image"); final Uint8List bytes = response.bodyBytes; - final ui.Codec codec = await ui.instantiateImageCodec(bytes, targetWidth: width); + final ui.Codec codec = await ui.instantiateImageCodec( + bytes, + targetWidth: width, + ); final ui.FrameInfo frameInfo = await codec.getNextFrame(); - final ByteData? byteData = await frameInfo.image.toByteData(format: ui.ImageByteFormat.png); + final ByteData? byteData = await frameInfo.image.toByteData( + format: ui.ImageByteFormat.png, + ); return byteData!.buffer.asUint8List(); } catch (e) { print("⚠️ getBytesFromUrl error: $e — using default cab icon"); diff --git a/lib/controllers/0n_demand_payment_controller.dart b/lib/controllers/0n_demand_payment_controller.dart index 9c496e6..fd66a94 100644 --- a/lib/controllers/0n_demand_payment_controller.dart +++ b/lib/controllers/0n_demand_payment_controller.dart @@ -1,5 +1,8 @@ import 'dart:convert'; import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:customer/constant/const_texts.dart'; +import 'package:customer/utils/app_router.dart'; + import 'package:get/get.dart'; import 'package:http/http.dart' as http; import '../../models/onprovider_order_model.dart'; @@ -47,7 +50,9 @@ import '../utils/preferences.dart'; import 'on_demand_dashboard_controller.dart'; class OnDemandPaymentController extends GetxController { - Rx onDemandOrderModel = Rx(null); + Rx onDemandOrderModel = Rx( + null, + ); RxDouble totalAmount = 0.0.obs; late bool isExtra; @@ -72,22 +77,40 @@ class OnDemandPaymentController extends GetxController { Future placeOrder() async { if (!isExtra) { // Normal Order - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); onDemandOrderModel.value?.payment_method = selectedPaymentMethod.value; - onDemandOrderModel.value?.paymentStatus = onDemandOrderModel.value?.provider.priceUnit == "Fixed" && selectedPaymentMethod.value == "cod" ? false : true; + onDemandOrderModel.value?.paymentStatus = + onDemandOrderModel.value?.provider.priceUnit == "Fixed" && + selectedPaymentMethod.value == "cod" + ? false + : true; onDemandOrderModel.value?.extraPaymentStatus = true; - await FireStoreUtils.onDemandOrderPlace(onDemandOrderModel.value!, totalAmount.value); + await FireStoreUtils.onDemandOrderPlace( + onDemandOrderModel.value!, + totalAmount.value, + ); if (onDemandOrderModel.value?.status == Constant.orderPlaced) { - await FireStoreUtils.sendOrderOnDemandServiceEmail(orderModel: onDemandOrderModel.value!); + await FireStoreUtils.sendOrderOnDemandServiceEmail( + orderModel: onDemandOrderModel.value!, + ); - final providerUser = await FireStoreUtils.getUserProfile(onDemandOrderModel.value!.provider.author!); + final providerUser = await FireStoreUtils.getUserProfile( + onDemandOrderModel.value!.provider.author!, + ); if (providerUser != null) { - final payLoad = {"type": 'provider_order', "orderId": onDemandOrderModel.value?.id}; - await SendNotification.sendFcmMessage(Constant.bookingPlaced, providerUser.fcmToken ?? '', payLoad); + final payLoad = { + "type": 'provider_order', + "orderId": onDemandOrderModel.value?.id, + }; + await SendNotification.sendFcmMessage( + Constant.bookingPlaced, + providerUser.fcmToken ?? '', + payLoad, + ); } ShowToastDialog.showToast("OnDemand Service successfully booked".tr); @@ -106,16 +129,23 @@ class OnDemandPaymentController extends GetxController { paymentStatus: "success".tr, ); - await FireStoreUtils.setWalletTransaction(transactionModel).then((value) async { + await FireStoreUtils.setWalletTransaction(transactionModel).then(( + value, + ) async { if (value == true) { - await FireStoreUtils.updateUserWallet(amount: "-${totalAmount.value.toString()}", userId: FireStoreUtils.getCurrentUid()).then((value) {}); + await FireStoreUtils.updateUserWallet( + amount: "-${totalAmount.value.toString()}", + userId: FireStoreUtils.getCurrentUid(), + ).then((value) {}); } }); } ShowToastDialog.closeLoader(); Get.offAll(const OnDemandDashboardScreen()); - OnDemandDashboardController controller = Get.put(OnDemandDashboardController()); + OnDemandDashboardController controller = Get.put( + OnDemandDashboardController(), + ); controller.selectedIndex.value = 2; } else { // Extra Charges Flow @@ -136,9 +166,14 @@ class OnDemandPaymentController extends GetxController { paymentStatus: "success".tr, ); - await FireStoreUtils.setWalletTransaction(transactionModel).then((value) async { + await FireStoreUtils.setWalletTransaction(transactionModel).then(( + value, + ) async { if (value == true) { - await FireStoreUtils.updateUserWallet(amount: "-${totalAmount.value.toString()}", userId: FireStoreUtils.getCurrentUid()).then((value) {}); + await FireStoreUtils.updateUserWallet( + amount: "-${totalAmount.value.toString()}", + userId: FireStoreUtils.getCurrentUid(), + ).then((value) {}); } }); } @@ -159,9 +194,14 @@ class OnDemandPaymentController extends GetxController { paymentStatus: "success".tr, ); - await FireStoreUtils.setWalletTransaction(transactionModel).then((value) async { + await FireStoreUtils.setWalletTransaction(transactionModel).then(( + value, + ) async { if (value == true) { - await FireStoreUtils.updateUserWallet(amount: "-$totalAmount", userId: FireStoreUtils.getCurrentUid()); + await FireStoreUtils.updateUserWallet( + amount: "-$totalAmount", + userId: FireStoreUtils.getCurrentUid(), + ); } }); } @@ -170,7 +210,9 @@ class OnDemandPaymentController extends GetxController { ShowToastDialog.closeLoader(); Get.offAll(const OnDemandDashboardScreen()); - OnDemandDashboardController controller = Get.put(OnDemandDashboardController()); + OnDemandDashboardController controller = Get.put( + OnDemandDashboardController(), + ); controller.selectedIndex.value = 2; } } @@ -193,19 +235,45 @@ class OnDemandPaymentController extends GetxController { Future getPaymentSettings() async { isLoading.value = true; await FireStoreUtils.getPaymentSettingsData().then((value) { - stripeModel.value = StripeModel.fromJson(jsonDecode(Preferences.getString(Preferences.stripeSettings))); - payPalModel.value = PayPalModel.fromJson(jsonDecode(Preferences.getString(Preferences.paypalSettings))); - payStackModel.value = PayStackModel.fromJson(jsonDecode(Preferences.getString(Preferences.payStack))); - mercadoPagoModel.value = MercadoPagoModel.fromJson(jsonDecode(Preferences.getString(Preferences.mercadoPago))); - flutterWaveModel.value = FlutterWaveModel.fromJson(jsonDecode(Preferences.getString(Preferences.flutterWave))); - paytmModel.value = PaytmModel.fromJson(jsonDecode(Preferences.getString(Preferences.paytmSettings))); - payFastModel.value = PayFastModel.fromJson(jsonDecode(Preferences.getString(Preferences.payFastSettings))); - razorPayModel.value = RazorPayModel.fromJson(jsonDecode(Preferences.getString(Preferences.razorpaySettings))); - midTransModel.value = MidTrans.fromJson(jsonDecode(Preferences.getString(Preferences.midTransSettings))); - orangeMoneyModel.value = OrangeMoney.fromJson(jsonDecode(Preferences.getString(Preferences.orangeMoneySettings))); - xenditModel.value = Xendit.fromJson(jsonDecode(Preferences.getString(Preferences.xenditSettings))); - walletSettingModel.value = WalletSettingModel.fromJson(jsonDecode(Preferences.getString(Preferences.walletSettings))); - cashOnDeliverySettingModel.value = CodSettingModel.fromJson(jsonDecode(Preferences.getString(Preferences.codSettings))); + stripeModel.value = StripeModel.fromJson( + jsonDecode(Preferences.getString(Preferences.stripeSettings)), + ); + payPalModel.value = PayPalModel.fromJson( + jsonDecode(Preferences.getString(Preferences.paypalSettings)), + ); + payStackModel.value = PayStackModel.fromJson( + jsonDecode(Preferences.getString(Preferences.payStack)), + ); + mercadoPagoModel.value = MercadoPagoModel.fromJson( + jsonDecode(Preferences.getString(Preferences.mercadoPago)), + ); + flutterWaveModel.value = FlutterWaveModel.fromJson( + jsonDecode(Preferences.getString(Preferences.flutterWave)), + ); + paytmModel.value = PaytmModel.fromJson( + jsonDecode(Preferences.getString(Preferences.paytmSettings)), + ); + payFastModel.value = PayFastModel.fromJson( + jsonDecode(Preferences.getString(Preferences.payFastSettings)), + ); + razorPayModel.value = RazorPayModel.fromJson( + jsonDecode(Preferences.getString(Preferences.razorpaySettings)), + ); + midTransModel.value = MidTrans.fromJson( + jsonDecode(Preferences.getString(Preferences.midTransSettings)), + ); + orangeMoneyModel.value = OrangeMoney.fromJson( + jsonDecode(Preferences.getString(Preferences.orangeMoneySettings)), + ); + xenditModel.value = Xendit.fromJson( + jsonDecode(Preferences.getString(Preferences.xenditSettings)), + ); + walletSettingModel.value = WalletSettingModel.fromJson( + jsonDecode(Preferences.getString(Preferences.walletSettings)), + ); + cashOnDeliverySettingModel.value = CodSettingModel.fromJson( + jsonDecode(Preferences.getString(Preferences.codSettings)), + ); if (walletSettingModel.value.isEnabled == true) { selectedPaymentMethod.value = PaymentGateway.wallet.name; @@ -248,20 +316,32 @@ class OnDemandPaymentController extends GetxController { Future stripeMakePayment({required String amount}) async { log(double.parse(amount).toStringAsFixed(0)); try { - Map? paymentIntentData = await createStripeIntent(amount: amount); + Map? paymentIntentData = await createStripeIntent( + amount: amount, + ); log("stripe Responce====>$paymentIntentData"); if (paymentIntentData!.containsKey("error")) { Get.back(); - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); } else { await Stripe.instance.initPaymentSheet( paymentSheetParameters: SetupPaymentSheetParameters( paymentIntentClientSecret: paymentIntentData['client_secret'], allowsDelayedPaymentMethods: false, - googlePay: const PaymentSheetGooglePay(merchantCountryCode: 'US', testEnv: true, currencyCode: "USD"), + googlePay: const PaymentSheetGooglePay( + merchantCountryCode: 'US', + testEnv: true, + currencyCode: "USD", + ), customFlow: true, style: ThemeMode.system, - appearance: PaymentSheetAppearance(colors: PaymentSheetAppearanceColors(primary: AppThemeData.primary300)), + appearance: PaymentSheetAppearance( + colors: PaymentSheetAppearanceColors( + primary: AppThemeData.primary300, + ), + ), merchantDisplayName: 'GoRide', ), ); @@ -307,7 +387,10 @@ class OnDemandPaymentController extends GetxController { var response = await http.post( Uri.parse('https://api.stripe.com/v1/payment_intents'), body: body, - headers: {'Authorization': 'Bearer $stripeSecret', 'Content-Type': 'application/x-www-form-urlencoded'}, + headers: { + 'Authorization': 'Bearer $stripeSecret', + 'Content-Type': 'application/x-www-form-urlencoded', + }, ); return jsonDecode(response.body); @@ -317,8 +400,14 @@ class OnDemandPaymentController extends GetxController { } //mercadoo - Future mercadoPagoMakePayment({required BuildContext context, required String amount}) async { - final headers = {'Authorization': 'Bearer ${mercadoPagoModel.value.accessToken}', 'Content-Type': 'application/json'}; + Future mercadoPagoMakePayment({ + required BuildContext context, + required String amount, + }) async { + final headers = { + 'Authorization': 'Bearer ${mercadoPagoModel.value.accessToken}', + 'Content-Type': 'application/json', + }; final body = jsonEncode({ "items": [ @@ -331,12 +420,20 @@ class OnDemandPaymentController extends GetxController { }, ], "payer": {"email": Constant.userModel?.email}, - "back_urls": {"failure": "${Constant.globalUrl}payment/failure", "pending": "${Constant.globalUrl}payment/pending", "success": "${Constant.globalUrl}payment/success"}, + "back_urls": { + "failure": "${Constant.globalUrl}payment/failure", + "pending": "${Constant.globalUrl}payment/pending", + "success": "${Constant.globalUrl}payment/success", + }, "auto_return": "approved", // Automatically return after payment is approved }); - final response = await http.post(Uri.parse("https://api.mercadopago.com/checkout/preferences"), headers: headers, body: body); + final response = await http.post( + Uri.parse("https://api.mercadopago.com/checkout/preferences"), + headers: headers, + body: body, + ); if (response.statusCode == 200 || response.statusCode == 201) { final data = jsonDecode(response.body); @@ -419,15 +516,23 @@ class OnDemandPaymentController extends GetxController { } }); } else { - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); } }); } //flutter wave Payment Method - Future flutterWaveInitiatePayment({required BuildContext context, required String amount}) async { + Future flutterWaveInitiatePayment({ + required BuildContext context, + required String amount, + }) async { final url = Uri.parse('https://api.flutterwave.com/v3/payments'); - final headers = {'Authorization': 'Bearer ${flutterWaveModel.value.secretKey}', 'Content-Type': 'application/json'}; + final headers = { + 'Authorization': 'Bearer ${flutterWaveModel.value.secretKey}', + 'Content-Type': 'application/json', + }; final body = jsonEncode({ "tx_ref": _ref, @@ -435,15 +540,24 @@ class OnDemandPaymentController extends GetxController { "currency": "NGN", "redirect_url": "${Constant.globalUrl}payment/success", "payment_options": "ussd, card, barter, payattitude", - "customer": {"email": Constant.userModel?.email.toString(), "phonenumber": Constant.userModel?.phoneNumber, "name": Constant.userModel?.fullName()}, - "customizations": {"title": "Payment for Services", "description": "Payment for XYZ services"}, + "customer": { + "email": Constant.userModel?.email.toString(), + "phonenumber": Constant.userModel?.phoneNumber, + "name": Constant.userModel?.fullName(), + }, + "customizations": { + "title": "Payment for Services", + "description": "Payment for XYZ services", + }, }); final response = await http.post(url, headers: headers, body: body); if (response.statusCode == 200) { final data = jsonDecode(response.body); - Get.to(MercadoPagoScreen(initialURl: data['data']['link']))!.then((value) { + Get.to(MercadoPagoScreen(initialURl: data['data']['link']))!.then(( + value, + ) { if (value) { ShowToastDialog.showToast("Payment Successful!!".tr); placeOrder(); @@ -472,8 +586,14 @@ class OnDemandPaymentController extends GetxController { // payFast void payFastPayment({required BuildContext context, required String amount}) { - PayStackURLGen.getPayHTML(payFastSettingData: payFastModel.value, amount: amount.toString(), userModel: Constant.userModel!).then((String? value) async { - bool isDone = await Get.to(PayFastScreen(htmlData: value!, payFastSettingData: payFastModel.value)); + PayStackURLGen.getPayHTML( + payFastSettingData: payFastModel.value, + amount: amount.toString(), + userModel: Constant.userModel!, + ).then((String? value) async { + bool isDone = await Get.to( + PayFastScreen(htmlData: value!, payFastSettingData: payFastModel.value), + ); if (isDone) { Get.back(); ShowToastDialog.showToast("Payment successfully".tr); @@ -493,26 +613,50 @@ class OnDemandPaymentController extends GetxController { final response = await http.post( Uri.parse(getChecksum), headers: {}, - body: {"mid": paytmModel.value.paytmMID.toString(), "order_id": orderId, "key_secret": paytmModel.value.pAYTMMERCHANTKEY.toString()}, + body: { + "mid": paytmModel.value.paytmMID.toString(), + "order_id": orderId, + "key_secret": paytmModel.value.pAYTMMERCHANTKEY.toString(), + }, ); final data = jsonDecode(response.body); - await verifyCheckSum(checkSum: data["code"], amount: amount, orderId: orderId).then((value) { + await verifyCheckSum( + checkSum: data["code"], + amount: amount, + orderId: orderId, + ).then((value) { initiatePayment(amount: amount, orderId: orderId).then((value) { String callback = ""; if (paytmModel.value.isSandboxEnabled == true) { - callback = "${callback}https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; + callback = + "${callback}https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; } else { - callback = "${callback}https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; + callback = + "${callback}https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; } GetPaymentTxtTokenModel result = value; - startTransaction(context, txnTokenBy: result.body.txnToken ?? '', orderId: orderId, amount: amount, callBackURL: callback, isStaging: paytmModel.value.isSandboxEnabled); + startTransaction( + context, + txnTokenBy: result.body.txnToken ?? '', + orderId: orderId, + amount: amount, + callBackURL: callback, + isStaging: paytmModel.value.isSandboxEnabled, + ); }); }); } - Future startTransaction(context, {required String txnTokenBy, required orderId, required double amount, required callBackURL, required isStaging}) async { + Future startTransaction( + context, { + required String txnTokenBy, + required orderId, + required double amount, + required callBackURL, + required isStaging, + }) async { // try { // var response = AllInOneSdk.startTransaction( // paytmModel.value.paytmMID.toString(), @@ -548,24 +692,38 @@ class OnDemandPaymentController extends GetxController { // } } - Future verifyCheckSum({required String checkSum, required double amount, required orderId}) async { + Future verifyCheckSum({ + required String checkSum, + required double amount, + required orderId, + }) async { String getChecksum = "${Constant.globalUrl}payments/validatechecksum"; final response = await http.post( Uri.parse(getChecksum), headers: {}, - body: {"mid": paytmModel.value.paytmMID.toString(), "order_id": orderId, "key_secret": paytmModel.value.pAYTMMERCHANTKEY.toString(), "checksum_value": checkSum}, + body: { + "mid": paytmModel.value.paytmMID.toString(), + "order_id": orderId, + "key_secret": paytmModel.value.pAYTMMERCHANTKEY.toString(), + "checksum_value": checkSum, + }, ); final data = jsonDecode(response.body); return data['status']; } - Future initiatePayment({required double amount, required orderId}) async { + Future initiatePayment({ + required double amount, + required orderId, + }) async { String initiateURL = "${Constant.globalUrl}payments/initiatepaytmpayment"; String callback = ""; if (paytmModel.value.isSandboxEnabled == true) { - callback = "${callback}https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; + callback = + "${callback}https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; } else { - callback = "${callback}https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; + callback = + "${callback}https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; } final response = await http.post( Uri.parse(initiateURL), @@ -583,9 +741,12 @@ class OnDemandPaymentController extends GetxController { ); log(response.body); final data = jsonDecode(response.body); - if (data["body"]["txnToken"] == null || data["body"]["txnToken"].toString().isEmpty) { + if (data["body"]["txnToken"] == null || + data["body"]["txnToken"].toString().isEmpty) { Get.back(); - ShowToastDialog.showToast("something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "something went wrong, please contact admin.".tr, + ); } return GetPaymentTxtTokenModel.fromJson(data); } @@ -603,7 +764,10 @@ class OnDemandPaymentController extends GetxController { 'description': 'wallet Topup', 'retry': {'enabled': true, 'max_count': 1}, 'send_sms_hash': true, - 'prefill': {'contact': Constant.userModel?.phoneNumber, 'email': Constant.userModel?.email}, + 'prefill': { + 'contact': Constant.userModel?.phoneNumber, + 'email': Constant.userModel?.email, + }, 'external': { 'wallets': ['paytm'], }, @@ -638,7 +802,10 @@ class OnDemandPaymentController extends GetxController { } //Midtrans payment - Future midtransMakePayment({required String amount, required BuildContext context}) async { + Future midtransMakePayment({ + required String amount, + required BuildContext context, + }) async { await createPaymentLink(amount: amount).then((url) { ShowToastDialog.closeLoader(); if (url != '') { @@ -656,15 +823,30 @@ class OnDemandPaymentController extends GetxController { Future createPaymentLink({required var amount}) async { var ordersId = const Uuid().v1(); - final url = Uri.parse(midTransModel.value.isSandbox! ? 'https://api.sandbox.midtrans.com/v1/payment-links' : 'https://api.midtrans.com/v1/payment-links'); + final url = Uri.parse( + midTransModel.value.isSandbox! + ? 'https://api.sandbox.midtrans.com/v1/payment-links' + : 'https://api.midtrans.com/v1/payment-links', + ); final response = await http.post( url, - headers: {'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': generateBasicAuthHeader(midTransModel.value.serverKey!)}, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': generateBasicAuthHeader( + midTransModel.value.serverKey!, + ), + }, body: jsonEncode({ - 'transaction_details': {'order_id': ordersId, 'gross_amount': double.parse(amount.toString()).toInt()}, + 'transaction_details': { + 'order_id': ordersId, + 'gross_amount': double.parse(amount.toString()).toInt(), + }, 'usage_limit': 2, - "callbacks": {"finish": "https://www.google.com?merchant_order_id=$ordersId"}, + "callbacks": { + "finish": "https://www.google.com?merchant_order_id=$ordersId", + }, }), ); @@ -672,7 +854,9 @@ class OnDemandPaymentController extends GetxController { final responseData = jsonDecode(response.body); return responseData['payment_url']; } else { - ShowToastDialog.showToast("something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "something went wrong, please contact admin.".tr, + ); return ''; } } @@ -691,16 +875,33 @@ class OnDemandPaymentController extends GetxController { static String orderId = ''; static String amount = ''; - Future orangeMakePayment({required String amount, required BuildContext context}) async { + Future orangeMakePayment({ + required String amount, + required BuildContext context, + }) async { reset(); var id = const Uuid().v4(); - var paymentURL = await fetchToken(context: context, orderId: id, amount: amount, currency: 'USD'); + var paymentURL = await fetchToken( + context: context, + orderId: id, + amount: amount, + currency: 'USD', + ); ShowToastDialog.closeLoader(); if (paymentURL.toString().isNotEmpty) { - Get.to(() => OrangeMoneyScreen(initialURl: paymentURL, accessToken: accessToken, amount: amount, orangePay: orangeMoneyModel.value, orderId: orderId, payToken: payToken))!.then((value) { + Get.to( + () => OrangeMoneyScreen( + initialURl: paymentURL, + accessToken: accessToken, + amount: amount, + orangePay: orangeMoneyModel.value, + orderId: orderId, + payToken: payToken, + ), + )!.then((value) { if (value == true) { ShowToastDialog.showToast("Payment Successful!!".tr); placeOrder(); @@ -711,13 +912,22 @@ class OnDemandPaymentController extends GetxController { } } - Future fetchToken({required String orderId, required String currency, required BuildContext context, required String amount}) async { + Future fetchToken({ + required String orderId, + required String currency, + required BuildContext context, + required String amount, + }) async { String apiUrl = 'https://api.orange.com/oauth/v3/token'; Map requestBody = {'grant_type': 'client_credentials'}; var response = await http.post( Uri.parse(apiUrl), - headers: {'Authorization': "Basic ${orangeMoneyModel.value.auth ?? ''}", 'Content-Type': 'application/x-www-form-urlencoded', 'Accept': 'application/json'}, + headers: { + 'Authorization': "Basic ${orangeMoneyModel.value.auth ?? ''}", + 'Content-Type': 'application/x-www-form-urlencoded', + 'Accept': 'application/json', + }, body: requestBody, ); @@ -730,21 +940,36 @@ class OnDemandPaymentController extends GetxController { return ''; } - return await webpayment(context: context, amountData: amount, currency: currency, orderIdData: orderId); + return await webpayment( + context: context, + amountData: amount, + currency: currency, + orderIdData: orderId, + ); } else { - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); return ''; } } - Future webpayment({required String orderIdData, required BuildContext context, required String currency, required String amountData}) async { + Future webpayment({ + required String orderIdData, + required BuildContext context, + required String currency, + required String amountData, + }) async { orderId = orderIdData; amount = amountData; // ✅ Null-safe handling bool isSandbox = orangeMoneyModel.value.isSandbox ?? false; - String apiUrl = isSandbox ? 'https://api.orange.com/orange-money-webpay/dev/v1/webpayment' : 'https://api.orange.com/orange-money-webpay/cm/v1/webpayment'; + String apiUrl = + isSandbox + ? 'https://api.orange.com/orange-money-webpay/dev/v1/webpayment' + : 'https://api.orange.com/orange-money-webpay/cm/v1/webpayment'; Map requestBody = { "merchant_key": orangeMoneyModel.value.merchantKey ?? '', @@ -760,7 +985,11 @@ class OnDemandPaymentController extends GetxController { var response = await http.post( Uri.parse(apiUrl), - headers: {'Authorization': 'Bearer $accessToken', 'Content-Type': 'application/json', 'Accept': 'application/json'}, + headers: { + 'Authorization': 'Bearer $accessToken', + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, body: json.encode(requestBody), ); @@ -773,7 +1002,9 @@ class OnDemandPaymentController extends GetxController { return ''; } } else { - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); return ''; } } @@ -887,7 +1118,13 @@ class OnDemandPaymentController extends GetxController { await createXenditInvoice(amount: amount).then((model) { ShowToastDialog.closeLoader(); if (model.id != null) { - Get.to(() => XenditScreen(initialURl: model.invoiceUrl ?? '', transId: model.id ?? '', apiKey: xenditModel.value.apiKey!.toString()))!.then((value) { + Get.to( + () => XenditScreen( + initialURl: model.invoiceUrl ?? '', + transId: model.id ?? '', + apiKey: xenditModel.value.apiKey!.toString(), + ), + )!.then((value) { if (value == true) { ShowToastDialog.showToast("Payment Successful!!".tr); placeOrder(); @@ -904,7 +1141,9 @@ class OnDemandPaymentController extends GetxController { const url = 'https://api.xendit.co/v2/invoices'; var headers = { 'Content-Type': 'application/json', - 'Authorization': generateBasicAuthHeader(xenditModel.value.apiKey!.toString()), + 'Authorization': generateBasicAuthHeader( + xenditModel.value.apiKey!.toString(), + ), // 'Cookie': '__cf_bm=yERkrx3xDITyFGiou0bbKY1bi7xEwovHNwxV1vCNbVc-1724155511-1.0.1.1-jekyYQmPCwY6vIJ524K0V6_CEw6O.dAwOmQnHtwmaXO_MfTrdnmZMka0KZvjukQgXu5B.K_6FJm47SGOPeWviQ', }; @@ -917,7 +1156,11 @@ class OnDemandPaymentController extends GetxController { }); try { - final response = await http.post(Uri.parse(url), headers: headers, body: body); + final response = await http.post( + Uri.parse(url), + headers: headers, + body: body, + ); if (response.statusCode == 200 || response.statusCode == 201) { XenditModel model = XenditModel.fromJson(jsonDecode(response.body)); diff --git a/lib/controllers/Intercity_home_controller.dart b/lib/controllers/Intercity_home_controller.dart index 2322405..5528c5e 100644 --- a/lib/controllers/Intercity_home_controller.dart +++ b/lib/controllers/Intercity_home_controller.dart @@ -42,6 +42,7 @@ import 'package:customer/payment/xenditScreen.dart'; import 'package:customer/service/fire_store_utils.dart'; import 'package:customer/themes/show_toast_dialog.dart'; import 'package:customer/utils/preferences.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart' as flutterMap; import 'package:flutter_paypal/flutter_paypal.dart'; @@ -64,10 +65,13 @@ class IntercityHomeController extends GetxController { late GoogleMapController mapController; final flutterMap.MapController mapOsmController = flutterMap.MapController(); - final Rx sourceTextEditController = TextEditingController().obs; - final Rx destinationTextEditController = TextEditingController().obs; + final Rx sourceTextEditController = + TextEditingController().obs; + final Rx destinationTextEditController = + TextEditingController().obs; - final Rx couponCodeTextEditController = TextEditingController().obs; + final Rx couponCodeTextEditController = + TextEditingController().obs; final Rx currentLocation = Location().obs; @@ -141,64 +145,99 @@ class IntercityHomeController extends GetxController { await getPaymentSettings(); - FireStoreUtils.fireStore.collection(CollectionName.users).doc(FireStoreUtils.getCurrentUid()).snapshots().listen((userSnapshot) async { - if (!userSnapshot.exists) return; + FireStoreUtils.fireStore + .collection(CollectionName.users) + .doc(FireStoreUtils.getCurrentUid()) + .snapshots() + .listen((userSnapshot) async { + if (!userSnapshot.exists) return; - userModel.value = UserModel.fromJson(userSnapshot.data()!); + userModel.value = UserModel.fromJson(userSnapshot.data()!); - if (userModel.value.inProgressOrderID != null && userModel.value.inProgressOrderID!.isNotEmpty) { - String? validRideId; + if (userModel.value.inProgressOrderID != null && + userModel.value.inProgressOrderID!.isNotEmpty) { + String? validRideId; - for (String id in userModel.value.inProgressOrderID!) { - final rideDoc = await FireStoreUtils.fireStore.collection(CollectionName.rides).doc(id).get(); + for (String id in userModel.value.inProgressOrderID!) { + final rideDoc = + await FireStoreUtils.fireStore + .collection(CollectionName.rides) + .doc(id) + .get(); - if (rideDoc.exists && (rideDoc.data()?['rideType'] ?? '').toString().toLowerCase() == "intercity") { - validRideId = userModel.value.inProgressOrderID!.first!; - break; - } - } - - FireStoreUtils.fireStore.collection(CollectionName.rides).doc(validRideId).snapshots().listen((rideSnapshot) async { - if (!rideSnapshot.exists) return; - - final rideData = rideSnapshot.data()!; - currentOrder.value = CabOrderModel.fromJson(rideData); - final status = currentOrder.value.status; - - if (status == Constant.driverAccepted || status == Constant.orderInTransit) { - FireStoreUtils.fireStore.collection(CollectionName.users).doc(currentOrder.value.driverId).snapshots().listen((event) async { - if (event.exists && event.data() != null) { - UserModel driverModel0 = UserModel.fromJson(event.data()!); - driverModel.value = driverModel0; - await updateDriverRoute(driverModel0); + if (rideDoc.exists && + (rideDoc.data()?['rideType'] ?? '') + .toString() + .toLowerCase() == + "intercity") { + validRideId = userModel.value.inProgressOrderID!.first!; + break; } - }); - } + } - print("Current Ride Status: $status"); - if (status == Constant.orderPlaced || status == Constant.driverPending || status == Constant.driverRejected || (status == Constant.orderAccepted && currentOrder.value.driverId == null)) { - bottomSheetType.value = 'waitingForDriver'; - } else if (status == Constant.driverAccepted || status == Constant.orderInTransit) { - bottomSheetType.value = 'driverDetails'; - sourceTextEditController.value.text = currentOrder.value.sourceLocationName ?? ''; - destinationTextEditController.value.text = currentOrder.value.destinationLocationName ?? ''; - selectedPaymentMethod.value = currentOrder.value.paymentMethod ?? ''; - calculateTotalAmountAfterAccept(); - } else if (status == Constant.orderCompleted) { - userModel.value.inProgressOrderID!.remove(validRideId); - await FireStoreUtils.updateUser(userModel.value); + FireStoreUtils.fireStore + .collection(CollectionName.rides) + .doc(validRideId) + .snapshots() + .listen((rideSnapshot) async { + if (!rideSnapshot.exists) return; + + final rideData = rideSnapshot.data()!; + currentOrder.value = CabOrderModel.fromJson(rideData); + final status = currentOrder.value.status; + + if (status == Constant.driverAccepted || + status == Constant.orderInTransit) { + FireStoreUtils.fireStore + .collection(CollectionName.users) + .doc(currentOrder.value.driverId) + .snapshots() + .listen((event) async { + if (event.exists && event.data() != null) { + UserModel driverModel0 = UserModel.fromJson( + event.data()!, + ); + driverModel.value = driverModel0; + await updateDriverRoute(driverModel0); + } + }); + } + + print("Current Ride Status: $status"); + if (status == Constant.orderPlaced || + status == Constant.driverPending || + status == Constant.driverRejected || + (status == Constant.orderAccepted && + currentOrder.value.driverId == null)) { + bottomSheetType.value = 'waitingForDriver'; + } else if (status == Constant.driverAccepted || + status == Constant.orderInTransit) { + bottomSheetType.value = 'driverDetails'; + sourceTextEditController.value.text = + currentOrder.value.sourceLocationName ?? ''; + destinationTextEditController.value.text = + currentOrder.value.destinationLocationName ?? ''; + selectedPaymentMethod.value = + currentOrder.value.paymentMethod ?? ''; + calculateTotalAmountAfterAccept(); + } else if (status == Constant.orderCompleted) { + userModel.value.inProgressOrderID!.remove(validRideId); + await FireStoreUtils.updateUser(userModel.value); + bottomSheetType.value = 'location'; + Get.back(); + } + }); + } else { bottomSheetType.value = 'location'; - Get.back(); + if (Constant.currentLocation != null) { + setDepartureMarker( + Constant.currentLocation!.latitude, + Constant.currentLocation!.longitude, + ); + searchPlaceNameOSM(); + } } }); - } else { - bottomSheetType.value = 'location'; - if (Constant.currentLocation != null) { - setDepartureMarker(Constant.currentLocation!.latitude, Constant.currentLocation!.longitude); - searchPlaceNameOSM(); - } - } - }); final coupons = await FireStoreUtils.getCabCoupon(); cabCouponList.value = coupons; @@ -225,18 +264,30 @@ class IntercityHomeController extends GetxController { if (order.status == Constant.driverAccepted) { // DRIVER → PICKUP - await fetchRouteWithWaypoints([latlong.LatLng(driverLat, driverLng), latlong.LatLng(pickupLat, pickupLng)]); + await fetchRouteWithWaypoints([ + latlong.LatLng(driverLat, driverLng), + latlong.LatLng(pickupLat, pickupLng), + ]); } else if (order.status == Constant.orderInTransit) { // PICKUP → DESTINATION - await fetchRouteWithWaypoints([latlong.LatLng(pickupLat, pickupLng), latlong.LatLng(destLat, destLng)]); + await fetchRouteWithWaypoints([ + latlong.LatLng(pickupLat, pickupLng), + latlong.LatLng(destLat, destLng), + ]); } updateRouteMarkers(driverModel); } else { /// For Google Maps if (order.status == Constant.driverAccepted) { - await fetchGoogleRouteBetween(LatLng(driverLat, driverLng), LatLng(pickupLat, pickupLng)); + await fetchGoogleRouteBetween( + LatLng(driverLat, driverLng), + LatLng(pickupLat, pickupLng), + ); } else if (order.status == Constant.orderInTransit) { - await fetchGoogleRouteBetween(LatLng(pickupLat, pickupLng), LatLng(destLat, destLng)); + await fetchGoogleRouteBetween( + LatLng(pickupLat, pickupLng), + LatLng(destLat, destLng), + ); } updateRouteMarkers(driverModel); } @@ -260,12 +311,24 @@ class IntercityHomeController extends GetxController { markers.clear(); osmMarker.clear(); - final departureBytes = await Constant().getBytesFromAsset('assets/images/location_black3x.png', 50); - final destinationBytes = await Constant().getBytesFromAsset('assets/images/location_orange3x.png', 50); + final departureBytes = await Constant().getBytesFromAsset( + 'assets/images/location_black3x.png', + 50, + ); + final destinationBytes = await Constant().getBytesFromAsset( + 'assets/images/location_orange3x.png', + 50, + ); final driverBytesRaw = (Constant.sectionConstantModel?.markerIcon?.isNotEmpty ?? false) - ? await Constant().getBytesFromUrl(Constant.sectionConstantModel!.markerIcon!, width: 120) - : await Constant().getBytesFromAsset('assets/images/ic_cab.png', 50); + ? await Constant().getBytesFromUrl( + Constant.sectionConstantModel!.markerIcon!, + width: 120, + ) + : await Constant().getBytesFromAsset( + 'assets/images/ic_cab.png', + 50, + ); departureIcon = BitmapDescriptor.fromBytes(departureBytes); destinationIcon = BitmapDescriptor.fromBytes(destinationBytes); @@ -274,7 +337,15 @@ class IntercityHomeController extends GetxController { if (Constant.selectedMapType == 'osm') { if (order.status == Constant.driverAccepted) { osmMarker.addAll([ - flutterMap.Marker(point: latlong.LatLng(pickupLat, pickupLng), width: 40, height: 40, child: Image.asset('assets/images/location_black3x.png', width: 40)), + flutterMap.Marker( + point: latlong.LatLng(pickupLat, pickupLng), + width: 40, + height: 40, + child: Image.asset( + 'assets/images/location_black3x.png', + width: 40, + ), + ), flutterMap.Marker( point: latlong.LatLng(driverLat, driverLng), width: 45, @@ -285,13 +356,26 @@ class IntercityHomeController extends GetxController { height: 50, imageUrl: Constant.sectionConstantModel!.markerIcon.toString(), placeholder: (context, url) => Constant.loader(), - errorWidget: (context, url, error) => SizedBox(width: 30, height: 30, child: CircularProgressIndicator(strokeWidth: 2)), + errorWidget: + (context, url, error) => SizedBox( + width: 30, + height: 30, + child: CircularProgressIndicator(strokeWidth: 2), + ), ), ), ]); } else if (order.status == Constant.orderInTransit) { osmMarker.addAll([ - flutterMap.Marker(point: latlong.LatLng(destLat, destLng), width: 40, height: 40, child: Image.asset('assets/images/location_orange3x.png', width: 40)), + flutterMap.Marker( + point: latlong.LatLng(destLat, destLng), + width: 40, + height: 40, + child: Image.asset( + 'assets/images/location_orange3x.png', + width: 40, + ), + ), flutterMap.Marker( point: latlong.LatLng(driverLat, driverLng), width: 45, @@ -302,7 +386,12 @@ class IntercityHomeController extends GetxController { height: 50, imageUrl: Constant.sectionConstantModel!.markerIcon.toString(), placeholder: (context, url) => Constant.loader(), - errorWidget: (context, url, error) => SizedBox(width: 30, height: 30, child: CircularProgressIndicator(strokeWidth: 2)), + errorWidget: + (context, url, error) => SizedBox( + width: 30, + height: 30, + child: CircularProgressIndicator(strokeWidth: 2), + ), ), ), ]); @@ -314,9 +403,18 @@ class IntercityHomeController extends GetxController { markerId: const MarkerId("pickup"), position: LatLng(pickupLat, pickupLng), infoWindow: InfoWindow(title: "Pickup Location".tr), - icon: departureIcon ?? BitmapDescriptor.defaultMarkerWithHue(BitmapDescriptor.hueGreen), + icon: + departureIcon ?? + BitmapDescriptor.defaultMarkerWithHue( + BitmapDescriptor.hueGreen, + ), + ), + Marker( + markerId: const MarkerId("driver"), + position: LatLng(driverLat, driverLng), + infoWindow: InfoWindow(title: "Driver at Pickup".tr), + icon: taxiIcon ?? BitmapDescriptor.defaultMarker, ), - Marker(markerId: const MarkerId("driver"), position: LatLng(driverLat, driverLng), infoWindow: InfoWindow(title: "Driver at Pickup".tr), icon: taxiIcon ?? BitmapDescriptor.defaultMarker), ]); } else if (order.status == Constant.orderInTransit) { markers.addAll([ @@ -324,9 +422,18 @@ class IntercityHomeController extends GetxController { markerId: const MarkerId("destination"), position: LatLng(destLat, destLng), infoWindow: InfoWindow(title: "Destination Location".tr), - icon: destinationIcon ?? BitmapDescriptor.defaultMarkerWithHue(BitmapDescriptor.hueRed), + icon: + destinationIcon ?? + BitmapDescriptor.defaultMarkerWithHue( + BitmapDescriptor.hueRed, + ), + ), + Marker( + markerId: const MarkerId("driver"), + position: LatLng(driverLat, driverLng), + infoWindow: InfoWindow(title: "Driver Location".tr), + icon: taxiIcon ?? BitmapDescriptor.defaultMarker, ), - Marker(markerId: const MarkerId("driver"), position: LatLng(driverLat, driverLng), infoWindow: InfoWindow(title: "Driver Location".tr), icon: taxiIcon ?? BitmapDescriptor.defaultMarker), ]); } } @@ -337,7 +444,10 @@ class IntercityHomeController extends GetxController { } } - Future fetchGoogleRouteBetween(LatLng originPoint, LatLng destPoint) async { + Future fetchGoogleRouteBetween( + LatLng originPoint, + LatLng destPoint, + ) async { final origin = '${originPoint.latitude},${originPoint.longitude}'; final destination = '${destPoint.latitude},${destPoint.longitude}'; final url = Uri.parse( @@ -354,7 +464,8 @@ class IntercityHomeController extends GetxController { final route = data['routes'][0]; final encodedPolyline = route['overview_polyline']['points']; final decodedPoints = PolylinePoints.decodePolyline(encodedPolyline); - final coordinates = decodedPoints.map((e) => LatLng(e.latitude, e.longitude)).toList(); + final coordinates = + decodedPoints.map((e) => LatLng(e.latitude, e.longitude)).toList(); addPolyLine(coordinates); @@ -381,7 +492,12 @@ class IntercityHomeController extends GetxController { if (currentOrder.value.taxSetting != null) { for (var element in currentOrder.value.taxSetting!) { - taxAmount.value = (taxAmount.value + Constant.calculateTax(amount: (subTotal.value - discount.value).toString(), taxModel: element)); + taxAmount.value = + (taxAmount.value + + Constant.calculateTax( + amount: (subTotal.value - discount.value).toString(), + taxModel: element, + )); } } @@ -397,11 +513,19 @@ class IntercityHomeController extends GetxController { subTotal.value = getAmount(selectedVehicleType.value); if (selectedCouponModel.value.id != null) { - discount.value = Constant.calculateDiscount(amount: subTotal.value.toString(), offerModel: selectedCouponModel.value); + discount.value = Constant.calculateDiscount( + amount: subTotal.value.toString(), + offerModel: selectedCouponModel.value, + ); } for (var element in Constant.taxList) { - taxAmount.value = (taxAmount.value + Constant.calculateTax(amount: (subTotal.value - discount.value).toString(), taxModel: element)); + taxAmount.value = + (taxAmount.value + + Constant.calculateTax( + amount: (subTotal.value - discount.value).toString(), + taxModel: element, + )); } totalAmount.value = (subTotal.value - discount.value) + taxAmount.value; @@ -438,9 +562,14 @@ class IntercityHomeController extends GetxController { serviceType: Constant.parcelServiceType, ); - await FireStoreUtils.setWalletTransaction(transactionModel).then((value) async { + await FireStoreUtils.setWalletTransaction(transactionModel).then(( + value, + ) async { if (value == true) { - await FireStoreUtils.updateUserWallet(amount: "-${totalAmount.value.toString()}", userId: FireStoreUtils.getCurrentUid()); + await FireStoreUtils.updateUserWallet( + amount: "-${totalAmount.value.toString()}", + userId: FireStoreUtils.getCurrentUid(), + ); } }); } @@ -454,13 +583,25 @@ class IntercityHomeController extends GetxController { Future placeOrder() async { DestinationLocation sourceLocation = DestinationLocation( - latitude: Constant.selectedMapType == 'osm' ? departureLatLongOsm.value.latitude : departureLatLong.value.latitude, - longitude: Constant.selectedMapType == 'osm' ? departureLatLongOsm.value.longitude : departureLatLong.value.longitude, + latitude: + Constant.selectedMapType == 'osm' + ? departureLatLongOsm.value.latitude + : departureLatLong.value.latitude, + longitude: + Constant.selectedMapType == 'osm' + ? departureLatLongOsm.value.longitude + : departureLatLong.value.longitude, ); DestinationLocation destinationLocation = DestinationLocation( - latitude: Constant.selectedMapType == 'osm' ? destinationLatLongOsm.value.latitude : destinationLatLong.value.latitude, - longitude: Constant.selectedMapType == 'osm' ? destinationLatLongOsm.value.longitude : destinationLatLong.value.longitude, + latitude: + Constant.selectedMapType == 'osm' + ? destinationLatLongOsm.value.latitude + : destinationLatLong.value.latitude, + longitude: + Constant.selectedMapType == 'osm' + ? destinationLatLongOsm.value.longitude + : destinationLatLong.value.longitude, ); CabOrderModel orderModel = CabOrderModel(); @@ -471,7 +612,8 @@ class IntercityHomeController extends GetxController { orderModel.vehicleType = selectedVehicleType.value; orderModel.authorID = FireStoreUtils.getCurrentUid(); orderModel.sourceLocationName = sourceTextEditController.value.text; - orderModel.destinationLocationName = destinationTextEditController.value.text; + orderModel.destinationLocationName = + destinationTextEditController.value.text; orderModel.sourceLocation = sourceLocation; orderModel.destinationLocation = destinationLocation; @@ -483,11 +625,14 @@ class IntercityHomeController extends GetxController { orderModel.taxSetting = Constant.taxList; orderModel.adminCommissionType = - Constant.sectionConstantModel!.adminCommision != null && Constant.sectionConstantModel!.adminCommision!.isEnabled == true - ? Constant.sectionConstantModel!.adminCommision!.commissionType.toString() + Constant.sectionConstantModel!.adminCommision != null && + Constant.sectionConstantModel!.adminCommision!.isEnabled == true + ? Constant.sectionConstantModel!.adminCommision!.commissionType + .toString() : null; orderModel.adminCommission = - Constant.sectionConstantModel!.adminCommision != null && Constant.sectionConstantModel!.adminCommision!.isEnabled == true + Constant.sectionConstantModel!.adminCommision != null && + Constant.sectionConstantModel!.adminCommision!.isEnabled == true ? Constant.sectionConstantModel!.adminCommision!.amount.toString() : null; orderModel.couponCode = couponCodeTextEditController.value.text; @@ -500,7 +645,9 @@ class IntercityHomeController extends GetxController { orderModel.roundTrip = false; orderModel.sectionId = Constant.sectionConstantModel!.id; orderModel.createdAt = Timestamp.now(); - orderModel.otpCode = (maths.Random().nextInt(9000) + 1000).toString(); // Generate a 4-digit OTP + orderModel.otpCode = + (maths.Random().nextInt(9000) + 1000) + .toString(); // Generate a 4-digit OTP orderModel.status = Constant.orderPlaced; orderModel.scheduleDateTime = Timestamp.now(); log("Order Model : ${orderModel.toJson()}"); @@ -515,8 +662,10 @@ class IntercityHomeController extends GetxController { double getAmount(VehicleType vehicleType) { final double currentDistance = distance.value; - if (currentDistance <= (vehicleType.minimum_delivery_charges_within_km ?? 0)) { - return double.tryParse(vehicleType.minimum_delivery_charges.toString()) ?? 0.0; + if (currentDistance <= + (vehicleType.minimum_delivery_charges_within_km ?? 0)) { + return double.tryParse(vehicleType.minimum_delivery_charges.toString()) ?? + 0.0; } else { return (vehicleType.delivery_charges_per_km ?? 0.0) * currentDistance; } @@ -541,28 +690,50 @@ class IntercityHomeController extends GetxController { void setStopMarker(double lat, double lng, int index) { if (Constant.selectedMapType == 'osm') { // Add new stop marker without clearing - osmMarker.add(flutterMap.Marker(point: latlong.LatLng(lat, lng), width: 40, height: 40, child: stopIconOsm!)); + osmMarker.add( + flutterMap.Marker( + point: latlong.LatLng(lat, lng), + width: 40, + height: 40, + child: stopIconOsm!, + ), + ); getDirections(isStopMarker: true); } else { final markerId = MarkerId('Stop $index'); markers.removeWhere((marker) => marker.markerId == markerId); - markers.add(Marker(markerId: markerId, infoWindow: InfoWindow(title: 'Stop ${String.fromCharCode(index + 65)}'), position: LatLng(lat, lng), icon: stopIcon!)); + markers.add( + Marker( + markerId: markerId, + infoWindow: InfoWindow( + title: 'Stop ${String.fromCharCode(index + 65)}', + ), + position: LatLng(lat, lng), + icon: stopIcon!, + ), + ); getDirections(); } } void _setOsmMarker(double lat, double lng, {required bool isDeparture}) { - final marker = flutterMap.Marker(point: latlong.LatLng(lat, lng), width: 40, height: 40, child: isDeparture ? departureIconOsm! : destinationIconOsm!); + final marker = flutterMap.Marker( + point: latlong.LatLng(lat, lng), + width: 40, + height: 40, + child: isDeparture ? departureIconOsm! : destinationIconOsm!, + ); if (isDeparture) { departureLatLongOsm.value = latlong.LatLng(lat, lng); } else { destinationLatLongOsm.value = latlong.LatLng(lat, lng); } osmMarker.add(marker); - if (departureLatLongOsm.value.latitude != 0 && destinationLatLongOsm.value.latitude != 0) { + if (departureLatLongOsm.value.latitude != 0 && + destinationLatLongOsm.value.latitude != 0) { getDirections(); animateToSource(lat, lng); } @@ -584,14 +755,26 @@ class IntercityHomeController extends GetxController { markers.removeWhere((marker) => marker.markerId == markerId); // Add new marker - markers.add(Marker(markerId: markerId, position: pos, icon: icon, infoWindow: InfoWindow(title: title))); + markers.add( + Marker( + markerId: markerId, + position: pos, + icon: icon, + infoWindow: InfoWindow(title: title), + ), + ); mapController.animateCamera(CameraUpdate.newLatLngZoom(pos, 14)); - if (departureLatLong.value.latitude != 0 && destinationLatLong.value.latitude != 0) { + if (departureLatLong.value.latitude != 0 && + destinationLatLong.value.latitude != 0) { getDirections(); } else { - mapController.animateCamera(CameraUpdate.newCameraPosition(CameraPosition(target: LatLng(lat, lng), zoom: 14))); + mapController.animateCamera( + CameraUpdate.newCameraPosition( + CameraPosition(target: LatLng(lat, lng), zoom: 14), + ), + ); } } @@ -600,25 +783,43 @@ class IntercityHomeController extends GetxController { final wayPoints = []; // Only add valid source - if (departureLatLongOsm.value.latitude != 0.0 && departureLatLongOsm.value.longitude != 0.0) { + if (departureLatLongOsm.value.latitude != 0.0 && + departureLatLongOsm.value.longitude != 0.0) { wayPoints.add(departureLatLongOsm.value); } // Only add valid destination - if (destinationLatLongOsm.value.latitude != 0.0 && destinationLatLongOsm.value.longitude != 0.0) { + if (destinationLatLongOsm.value.latitude != 0.0 && + destinationLatLongOsm.value.longitude != 0.0) { wayPoints.add(destinationLatLongOsm.value); } if (!isStopMarker) osmMarker.clear(); // Add source marker - if (departureLatLongOsm.value.latitude != 0.0 && departureLatLongOsm.value.longitude != 0.0) { - osmMarker.add(flutterMap.Marker(point: departureLatLongOsm.value, width: 40, height: 40, child: departureIconOsm!)); + if (departureLatLongOsm.value.latitude != 0.0 && + departureLatLongOsm.value.longitude != 0.0) { + osmMarker.add( + flutterMap.Marker( + point: departureLatLongOsm.value, + width: 40, + height: 40, + child: departureIconOsm!, + ), + ); } // Add destination marker - if (destinationLatLongOsm.value.latitude != 0.0 && destinationLatLongOsm.value.longitude != 0.0) { - osmMarker.add(flutterMap.Marker(point: destinationLatLongOsm.value, width: 40, height: 40, child: destinationIconOsm!)); + if (destinationLatLongOsm.value.latitude != 0.0 && + destinationLatLongOsm.value.longitude != 0.0) { + osmMarker.add( + flutterMap.Marker( + point: destinationLatLongOsm.value, + width: 40, + height: 40, + child: destinationIconOsm!, + ), + ); } if (wayPoints.length >= 2) { @@ -631,10 +832,14 @@ class IntercityHomeController extends GetxController { } Future fetchGoogleRouteWithWaypoints() async { - if (departureLatLong.value.latitude == 0.0 || destinationLatLong.value.latitude == 0.0) return; + if (departureLatLong.value.latitude == 0.0 || + destinationLatLong.value.latitude == 0.0) + return; - final origin = '${departureLatLong.value.latitude},${departureLatLong.value.longitude}'; - final destination = '${destinationLatLong.value.latitude},${destinationLatLong.value.longitude}'; + final origin = + '${departureLatLong.value.latitude},${departureLatLong.value.longitude}'; + final destination = + '${destinationLatLong.value.latitude},${destinationLatLong.value.longitude}'; final url = Uri.parse( 'https://maps.googleapis.com/maps/api/directions/json' @@ -653,7 +858,8 @@ class IntercityHomeController extends GetxController { // Polyline final encodedPolyline = route['overview_polyline']['points']; final decodedPoints = PolylinePoints.decodePolyline(encodedPolyline); - final coordinates = decodedPoints.map((e) => LatLng(e.latitude, e.longitude)).toList(); + final coordinates = + decodedPoints.map((e) => LatLng(e.latitude, e.longitude)).toList(); addPolyLine(coordinates); @@ -685,19 +891,26 @@ class IntercityHomeController extends GetxController { } Future fetchRouteWithWaypoints(List points) async { - final coordinates = points.map((p) => '${p.longitude},${p.latitude}').join(';'); - final url = Uri.parse('https://router.project-osrm.org/route/v1/driving/$coordinates?overview=full&geometries=geojson'); + final coordinates = points + .map((p) => '${p.longitude},${p.latitude}') + .join(';'); + final url = Uri.parse( + 'https://router.project-osrm.org/route/v1/driving/$coordinates?overview=full&geometries=geojson', + ); try { final response = await http.get(url); if (response.statusCode == 200) { final decoded = json.decode(response.body); - final geometry = decoded['routes'][0]['geometry']['coordinates'] as List; + final geometry = + decoded['routes'][0]['geometry']['coordinates'] as List; final dist = decoded['routes'][0]['distance']; final dur = decoded['routes'][0]['duration']; routePoints.clear(); - routePoints.addAll(geometry.map((coord) => latlong.LatLng(coord[1], coord[0]))); + routePoints.addAll( + geometry.map((coord) => latlong.LatLng(coord[1], coord[0])), + ); if (Constant.distanceType.toLowerCase() == "KM".toLowerCase()) { distance.value = dist / 1000.00; @@ -722,7 +935,10 @@ class IntercityHomeController extends GetxController { void zoomToPolylineOSM() { if (routePoints.isEmpty) return; // LatLngBounds requires at least two points - final bounds = flutterMap.LatLngBounds(routePoints.first, routePoints.first); + final bounds = flutterMap.LatLngBounds( + routePoints.first, + routePoints.first, + ); for (final point in routePoints) { bounds.extend(point); } @@ -734,8 +950,10 @@ class IntercityHomeController extends GetxController { double getBoundsZoomLevel(flutterMap.LatLngBounds bounds) { // Simple heuristic: zoom out for larger bounds - final latDiff = (bounds.northEast.latitude - bounds.southWest.latitude).abs(); - final lngDiff = (bounds.northEast.longitude - bounds.southWest.longitude).abs(); + final latDiff = + (bounds.northEast.latitude - bounds.southWest.latitude).abs(); + final lngDiff = + (bounds.northEast.longitude - bounds.southWest.longitude).abs(); double maxDiff = math.max(latDiff, lngDiff); if (maxDiff < 0.005) return 18.0; if (maxDiff < 0.01) return 16.0; @@ -747,7 +965,13 @@ class IntercityHomeController extends GetxController { void addPolyLine(List points) { final id = const PolylineId("poly"); - final polyline = Polyline(polylineId: id, color: AppThemeData.primary300, points: points, width: 6, geodesic: true); + final polyline = Polyline( + polylineId: id, + color: AppThemeData.primary300, + points: points, + width: 6, + geodesic: true, + ); polyLines[id] = polyline; if (points.length >= 2) { @@ -756,7 +980,10 @@ class IntercityHomeController extends GetxController { } } - Future updateCameraLocationToFitPolyline(List points, GoogleMapController? mapController) async { + Future updateCameraLocationToFitPolyline( + List points, + GoogleMapController? mapController, + ) async { if (mapController == null || points.isEmpty) return; double minLat = points.first.latitude, maxLat = points.first.latitude; double minLng = points.first.longitude, maxLng = points.first.longitude; @@ -766,16 +993,24 @@ class IntercityHomeController extends GetxController { if (p.longitude < minLng) minLng = p.longitude; if (p.longitude > maxLng) maxLng = p.longitude; } - final bounds = LatLngBounds(southwest: LatLng(minLat, minLng), northeast: LatLng(maxLat, maxLng)); + final bounds = LatLngBounds( + southwest: LatLng(minLat, minLng), + northeast: LatLng(maxLat, maxLng), + ); final cameraUpdate = CameraUpdate.newLatLngBounds(bounds, 50); await checkCameraLocation(cameraUpdate, mapController); } Future animateToSource(double lat, double long) async { - final hasBothCoords = departureLatLongOsm.value.latitude != 0.0 && destinationLatLongOsm.value.latitude != 0.0; + final hasBothCoords = + departureLatLongOsm.value.latitude != 0.0 && + destinationLatLongOsm.value.latitude != 0.0; if (hasBothCoords) { - await calculateZoomLevel(source: departureLatLongOsm.value, destination: destinationLatLongOsm.value); + await calculateZoomLevel( + source: departureLatLongOsm.value, + destination: destinationLatLongOsm.value, + ); } else { mapOsmController.move(latlong.LatLng(lat, long), 10); } @@ -783,15 +1018,25 @@ class IntercityHomeController extends GetxController { RxMap polyLines = {}.obs; - Future calculateZoomLevel({required latlong.LatLng source, required latlong.LatLng destination, double paddingFraction = 0.001}) async { + Future calculateZoomLevel({ + required latlong.LatLng source, + required latlong.LatLng destination, + double paddingFraction = 0.001, + }) async { final bounds = flutterMap.LatLngBounds.fromPoints([source, destination]); final screenSize = Size(Get.width, Get.height * 0.5); const double worldDimension = 256.0; const double maxZoom = 10.0; - double latToRad(double lat) => math.log((1 + math.sin(lat * math.pi / 180)) / (1 - math.sin(lat * math.pi / 180))) / 2; + double latToRad(double lat) => + math.log( + (1 + math.sin(lat * math.pi / 180)) / + (1 - math.sin(lat * math.pi / 180)), + ) / + 2; - double computeZoom(double screenPx, double worldPx, double fraction) => math.log(screenPx / worldPx / fraction) / math.ln2; + double computeZoom(double screenPx, double worldPx, double fraction) => + math.log(screenPx / worldPx / fraction) / math.ln2; final north = bounds.northEast.latitude; final south = bounds.southWest.latitude; @@ -809,27 +1054,48 @@ class IntercityHomeController extends GetxController { final latFraction = (latToRad(north) - latToRad(south)) / math.pi; final lngFraction = ((east - west + 360) % 360) / 360; - final latZoom = computeZoom(screenSize.height, worldDimension, latFraction + paddingFraction); - final lngZoom = computeZoom(screenSize.width, worldDimension, lngFraction + paddingFraction); + final latZoom = computeZoom( + screenSize.height, + worldDimension, + latFraction + paddingFraction, + ); + final lngZoom = computeZoom( + screenSize.width, + worldDimension, + lngFraction + paddingFraction, + ); final zoomLevel = math.min(latZoom, lngZoom).clamp(0.0, maxZoom); mapOsmController.move(center, zoomLevel); } } - Future updateCameraLocation(LatLng source, LatLng destination, GoogleMapController? mapController) async { + Future updateCameraLocation( + LatLng source, + LatLng destination, + GoogleMapController? mapController, + ) async { if (mapController == null) return; final bounds = LatLngBounds( - southwest: LatLng(math.min(source.latitude, destination.latitude), math.min(source.longitude, destination.longitude)), - northeast: LatLng(math.max(source.latitude, destination.latitude), math.max(source.longitude, destination.longitude)), + southwest: LatLng( + math.min(source.latitude, destination.latitude), + math.min(source.longitude, destination.longitude), + ), + northeast: LatLng( + math.max(source.latitude, destination.latitude), + math.max(source.longitude, destination.longitude), + ), ); final cameraUpdate = CameraUpdate.newLatLngBounds(bounds, 90); await checkCameraLocation(cameraUpdate, mapController); } - Future checkCameraLocation(CameraUpdate cameraUpdate, GoogleMapController mapController) async { + Future checkCameraLocation( + CameraUpdate cameraUpdate, + GoogleMapController mapController, + ) async { await mapController.animateCamera(cameraUpdate); final l1 = await mapController.getVisibleRegion(); final l2 = await mapController.getVisibleRegion(); @@ -842,16 +1108,44 @@ class IntercityHomeController extends GetxController { Future setIcons() async { try { if (Constant.selectedMapType == 'osm') { - departureIconOsm = Image.asset("assets/icons/pickup.png", width: 30, height: 30); - destinationIconOsm = Image.asset("assets/icons/dropoff.png", width: 30, height: 30); - taxiIconOsm = Image.asset("assets/icons/ic_taxi.png", width: 30, height: 30); - stopIconOsm = Image.asset("assets/icons/location.png", width: 26, height: 26); + departureIconOsm = Image.asset( + "assets/icons/pickup.png", + width: 30, + height: 30, + ); + destinationIconOsm = Image.asset( + "assets/icons/dropoff.png", + width: 30, + height: 30, + ); + taxiIconOsm = Image.asset( + "assets/icons/ic_taxi.png", + width: 30, + height: 30, + ); + stopIconOsm = Image.asset( + "assets/icons/location.png", + width: 26, + height: 26, + ); } else { const config = ImageConfiguration(size: Size(48, 48)); - departureIcon = await BitmapDescriptor.fromAssetImage(config, "assets/icons/pickup.png"); - destinationIcon = await BitmapDescriptor.fromAssetImage(config, "assets/icons/dropoff.png"); - taxiIcon = await BitmapDescriptor.fromAssetImage(config, "assets/icons/ic_taxi.png"); - stopIcon = await BitmapDescriptor.fromAssetImage(config, "assets/icons/location.png"); + departureIcon = await BitmapDescriptor.fromAssetImage( + config, + "assets/icons/pickup.png", + ); + destinationIcon = await BitmapDescriptor.fromAssetImage( + config, + "assets/icons/dropoff.png", + ); + taxiIcon = await BitmapDescriptor.fromAssetImage( + config, + "assets/icons/ic_taxi.png", + ); + stopIcon = await BitmapDescriptor.fromAssetImage( + config, + "assets/icons/location.png", + ); } } catch (e) { print('Error loading icons: $e'); @@ -859,8 +1153,12 @@ class IntercityHomeController extends GetxController { } void clearMapDataIfLocationsRemoved() { - final isSourceEmpty = departureLatLongOsm.value.latitude == 0.0 && departureLatLongOsm.value.longitude == 0.0; - final isDestinationEmpty = destinationLatLongOsm.value.latitude == 0.0 && destinationLatLongOsm.value.longitude == 0.0; + final isSourceEmpty = + departureLatLongOsm.value.latitude == 0.0 && + departureLatLongOsm.value.longitude == 0.0; + final isDestinationEmpty = + destinationLatLongOsm.value.latitude == 0.0 && + destinationLatLongOsm.value.longitude == 0.0; if (isSourceEmpty || isDestinationEmpty) { // Clear polylines @@ -889,7 +1187,9 @@ class IntercityHomeController extends GetxController { // Remove marker if (Constant.selectedMapType == 'osm') { - osmMarker.removeWhere((marker) => marker.point == departureLatLongOsm.value); + osmMarker.removeWhere( + (marker) => marker.point == departureLatLongOsm.value, + ); } else { markers.removeWhere((marker) => marker.markerId.value == 'Departure'); } @@ -905,7 +1205,9 @@ class IntercityHomeController extends GetxController { destinationTextEditController.value.clear(); if (Constant.selectedMapType == 'osm') { - osmMarker.removeWhere((marker) => marker.point == destinationLatLongOsm.value); + osmMarker.removeWhere( + (marker) => marker.point == destinationLatLongOsm.value, + ); } else { markers.removeWhere((marker) => marker.markerId.value == 'Destination'); } @@ -915,9 +1217,16 @@ class IntercityHomeController extends GetxController { } Future searchPlaceNameOSM() async { - final url = Uri.parse('https://nominatim.openstreetmap.org/reverse?lat=${departureLatLongOsm.value.latitude}&lon=${departureLatLongOsm.value.longitude}&format=json'); + final url = Uri.parse( + 'https://nominatim.openstreetmap.org/reverse?lat=${departureLatLongOsm.value.latitude}&lon=${departureLatLongOsm.value.longitude}&format=json', + ); - final response = await http.get(url, headers: {'User-Agent': 'FlutterMapApp/1.0 (menil.siddhiinfosoft@gmail.com)'}); + final response = await http.get( + url, + headers: { + 'User-Agent': 'FlutterMapApp/1.0 (menil.siddhiinfosoft@gmail.com)', + }, + ); if (response.statusCode == 200) { log("response.body :: ${response.body}"); @@ -930,7 +1239,9 @@ class IntercityHomeController extends GetxController { final lat = departureLatLong.value.latitude; final lng = departureLatLong.value.longitude; - final url = Uri.parse('https://maps.googleapis.com/maps/api/geocode/json?latlng=$lat,$lng&key=${Constant.mapAPIKey}'); + final url = Uri.parse( + 'https://maps.googleapis.com/maps/api/geocode/json?latlng=$lat,$lng&key=${Constant.mapAPIKey}', + ); final response = await http.get(url); @@ -973,19 +1284,45 @@ class IntercityHomeController extends GetxController { Future getPaymentSettings() async { await FireStoreUtils.getPaymentSettingsData().then((value) { - stripeModel.value = StripeModel.fromJson(jsonDecode(Preferences.getString(Preferences.stripeSettings))); - payPalModel.value = PayPalModel.fromJson(jsonDecode(Preferences.getString(Preferences.paypalSettings))); - payStackModel.value = PayStackModel.fromJson(jsonDecode(Preferences.getString(Preferences.payStack))); - mercadoPagoModel.value = MercadoPagoModel.fromJson(jsonDecode(Preferences.getString(Preferences.mercadoPago))); - flutterWaveModel.value = FlutterWaveModel.fromJson(jsonDecode(Preferences.getString(Preferences.flutterWave))); - paytmModel.value = PaytmModel.fromJson(jsonDecode(Preferences.getString(Preferences.paytmSettings))); - payFastModel.value = PayFastModel.fromJson(jsonDecode(Preferences.getString(Preferences.payFastSettings))); - razorPayModel.value = RazorPayModel.fromJson(jsonDecode(Preferences.getString(Preferences.razorpaySettings))); - midTransModel.value = MidTrans.fromJson(jsonDecode(Preferences.getString(Preferences.midTransSettings))); - orangeMoneyModel.value = OrangeMoney.fromJson(jsonDecode(Preferences.getString(Preferences.orangeMoneySettings))); - xenditModel.value = Xendit.fromJson(jsonDecode(Preferences.getString(Preferences.xenditSettings))); - walletSettingModel.value = WalletSettingModel.fromJson(jsonDecode(Preferences.getString(Preferences.walletSettings))); - cashOnDeliverySettingModel.value = CodSettingModel.fromJson(jsonDecode(Preferences.getString(Preferences.codSettings))); + stripeModel.value = StripeModel.fromJson( + jsonDecode(Preferences.getString(Preferences.stripeSettings)), + ); + payPalModel.value = PayPalModel.fromJson( + jsonDecode(Preferences.getString(Preferences.paypalSettings)), + ); + payStackModel.value = PayStackModel.fromJson( + jsonDecode(Preferences.getString(Preferences.payStack)), + ); + mercadoPagoModel.value = MercadoPagoModel.fromJson( + jsonDecode(Preferences.getString(Preferences.mercadoPago)), + ); + flutterWaveModel.value = FlutterWaveModel.fromJson( + jsonDecode(Preferences.getString(Preferences.flutterWave)), + ); + paytmModel.value = PaytmModel.fromJson( + jsonDecode(Preferences.getString(Preferences.paytmSettings)), + ); + payFastModel.value = PayFastModel.fromJson( + jsonDecode(Preferences.getString(Preferences.payFastSettings)), + ); + razorPayModel.value = RazorPayModel.fromJson( + jsonDecode(Preferences.getString(Preferences.razorpaySettings)), + ); + midTransModel.value = MidTrans.fromJson( + jsonDecode(Preferences.getString(Preferences.midTransSettings)), + ); + orangeMoneyModel.value = OrangeMoney.fromJson( + jsonDecode(Preferences.getString(Preferences.orangeMoneySettings)), + ); + xenditModel.value = Xendit.fromJson( + jsonDecode(Preferences.getString(Preferences.xenditSettings)), + ); + walletSettingModel.value = WalletSettingModel.fromJson( + jsonDecode(Preferences.getString(Preferences.walletSettings)), + ); + cashOnDeliverySettingModel.value = CodSettingModel.fromJson( + jsonDecode(Preferences.getString(Preferences.codSettings)), + ); if (walletSettingModel.value.isEnabled == true) { selectedPaymentMethod.value = PaymentGateway.wallet.name; @@ -1027,20 +1364,32 @@ class IntercityHomeController extends GetxController { Future stripeMakePayment({required String amount}) async { log(double.parse(amount).toStringAsFixed(0)); try { - Map? paymentIntentData = await createStripeIntent(amount: amount); + Map? paymentIntentData = await createStripeIntent( + amount: amount, + ); log("stripe Responce====>$paymentIntentData"); if (paymentIntentData!.containsKey("error")) { Get.back(); - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); } else { await Stripe.instance.initPaymentSheet( paymentSheetParameters: SetupPaymentSheetParameters( paymentIntentClientSecret: paymentIntentData['client_secret'], allowsDelayedPaymentMethods: false, - googlePay: const PaymentSheetGooglePay(merchantCountryCode: 'US', testEnv: true, currencyCode: "USD"), + googlePay: const PaymentSheetGooglePay( + merchantCountryCode: 'US', + testEnv: true, + currencyCode: "USD", + ), customFlow: true, style: ThemeMode.system, - appearance: PaymentSheetAppearance(colors: PaymentSheetAppearanceColors(primary: AppThemeData.primary300)), + appearance: PaymentSheetAppearance( + colors: PaymentSheetAppearanceColors( + primary: AppThemeData.primary300, + ), + ), merchantDisplayName: 'GoRide', ), ); @@ -1086,7 +1435,10 @@ class IntercityHomeController extends GetxController { var response = await http.post( Uri.parse('https://api.stripe.com/v1/payment_intents'), body: body, - headers: {'Authorization': 'Bearer $stripeSecret', 'Content-Type': 'application/x-www-form-urlencoded'}, + headers: { + 'Authorization': 'Bearer $stripeSecret', + 'Content-Type': 'application/x-www-form-urlencoded', + }, ); return jsonDecode(response.body); @@ -1096,8 +1448,14 @@ class IntercityHomeController extends GetxController { } //mercadoo - Future mercadoPagoMakePayment({required BuildContext context, required String amount}) async { - final headers = {'Authorization': 'Bearer ${mercadoPagoModel.value.accessToken}', 'Content-Type': 'application/json'}; + Future mercadoPagoMakePayment({ + required BuildContext context, + required String amount, + }) async { + final headers = { + 'Authorization': 'Bearer ${mercadoPagoModel.value.accessToken}', + 'Content-Type': 'application/json', + }; final body = jsonEncode({ "items": [ @@ -1110,12 +1468,20 @@ class IntercityHomeController extends GetxController { }, ], "payer": {"email": userModel.value.email}, - "back_urls": {"failure": "${Constant.globalUrl}payment/failure", "pending": "${Constant.globalUrl}payment/pending", "success": "${Constant.globalUrl}payment/success"}, + "back_urls": { + "failure": "${Constant.globalUrl}payment/failure", + "pending": "${Constant.globalUrl}payment/pending", + "success": "${Constant.globalUrl}payment/success", + }, "auto_return": "approved", // Automatically return after payment is approved }); - final response = await http.post(Uri.parse("https://api.mercadopago.com/checkout/preferences"), headers: headers, body: body); + final response = await http.post( + Uri.parse("https://api.mercadopago.com/checkout/preferences"), + headers: headers, + body: body, + ); if (response.statusCode == 200 || response.statusCode == 201) { final data = jsonDecode(response.body); @@ -1173,9 +1539,12 @@ class IntercityHomeController extends GetxController { ///PayStack Payment Method Future payStackPayment(String totalAmount) async { - await PayStackURLGen.payStackURLGen(amount: (double.parse(totalAmount) * 100).toString(), currency: "ZAR", secretKey: payStackModel.value.secretKey.toString(), userModel: userModel.value).then(( - value, - ) async { + await PayStackURLGen.payStackURLGen( + amount: (double.parse(totalAmount) * 100).toString(), + currency: "ZAR", + secretKey: payStackModel.value.secretKey.toString(), + userModel: userModel.value, + ).then((value) async { if (value != null) { PayStackUrlModel payStackModel0 = value; Get.to( @@ -1195,15 +1564,23 @@ class IntercityHomeController extends GetxController { } }); } else { - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); } }); } //flutter wave Payment Method - Future flutterWaveInitiatePayment({required BuildContext context, required String amount}) async { + Future flutterWaveInitiatePayment({ + required BuildContext context, + required String amount, + }) async { final url = Uri.parse('https://api.flutterwave.com/v3/payments'); - final headers = {'Authorization': 'Bearer ${flutterWaveModel.value.secretKey}', 'Content-Type': 'application/json'}; + final headers = { + 'Authorization': 'Bearer ${flutterWaveModel.value.secretKey}', + 'Content-Type': 'application/json', + }; final body = jsonEncode({ "tx_ref": _ref, @@ -1216,14 +1593,19 @@ class IntercityHomeController extends GetxController { "phonenumber": userModel.value.phoneNumber, // Add a real phone number "name": userModel.value.fullName(), // Add a real customer name }, - "customizations": {"title": "Payment for Services", "description": "Payment for XYZ services"}, + "customizations": { + "title": "Payment for Services", + "description": "Payment for XYZ services", + }, }); final response = await http.post(url, headers: headers, body: body); if (response.statusCode == 200) { final data = jsonDecode(response.body); - Get.to(MercadoPagoScreen(initialURl: data['data']['link']))!.then((value) { + Get.to(MercadoPagoScreen(initialURl: data['data']['link']))!.then(( + value, + ) { if (value) { ShowToastDialog.showToast("Payment Successful!!".tr); completeOrder(); @@ -1252,8 +1634,14 @@ class IntercityHomeController extends GetxController { // payFast void payFastPayment({required BuildContext context, required String amount}) { - PayStackURLGen.getPayHTML(payFastSettingData: payFastModel.value, amount: amount.toString(), userModel: userModel.value).then((String? value) async { - bool isDone = await Get.to(PayFastScreen(htmlData: value!, payFastSettingData: payFastModel.value)); + PayStackURLGen.getPayHTML( + payFastSettingData: payFastModel.value, + amount: amount.toString(), + userModel: userModel.value, + ).then((String? value) async { + bool isDone = await Get.to( + PayFastScreen(htmlData: value!, payFastSettingData: payFastModel.value), + ); if (isDone) { Get.back(); ShowToastDialog.showToast("Payment successfully".tr); @@ -1292,7 +1680,14 @@ class IntercityHomeController extends GetxController { // }); } - Future startTransaction(context, {required String txnTokenBy, required orderId, required double amount, required callBackURL, required isStaging}) async { + Future startTransaction( + context, { + required String txnTokenBy, + required orderId, + required double amount, + required callBackURL, + required isStaging, + }) async { // try { // var response = AllInOneSdk.startTransaction( // paytmModel.value.paytmMID.toString(), @@ -1328,24 +1723,38 @@ class IntercityHomeController extends GetxController { // } } - Future verifyCheckSum({required String checkSum, required double amount, required orderId}) async { + Future verifyCheckSum({ + required String checkSum, + required double amount, + required orderId, + }) async { String getChecksum = "${Constant.globalUrl}payments/validatechecksum"; final response = await http.post( Uri.parse(getChecksum), headers: {}, - body: {"mid": paytmModel.value.paytmMID.toString(), "order_id": orderId, "key_secret": paytmModel.value.pAYTMMERCHANTKEY.toString(), "checksum_value": checkSum}, + body: { + "mid": paytmModel.value.paytmMID.toString(), + "order_id": orderId, + "key_secret": paytmModel.value.pAYTMMERCHANTKEY.toString(), + "checksum_value": checkSum, + }, ); final data = jsonDecode(response.body); return data['status']; } - Future initiatePayment({required double amount, required orderId}) async { + Future initiatePayment({ + required double amount, + required orderId, + }) async { String initiateURL = "${Constant.globalUrl}payments/initiatepaytmpayment"; String callback = ""; if (paytmModel.value.isSandboxEnabled == true) { - callback = "${callback}https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; + callback = + "${callback}https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; } else { - callback = "${callback}https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; + callback = + "${callback}https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; } final response = await http.post( Uri.parse(initiateURL), @@ -1363,9 +1772,12 @@ class IntercityHomeController extends GetxController { ); log(response.body); final data = jsonDecode(response.body); - if (data["body"]["txnToken"] == null || data["body"]["txnToken"].toString().isEmpty) { + if (data["body"]["txnToken"] == null || + data["body"]["txnToken"].toString().isEmpty) { Get.back(); - ShowToastDialog.showToast("something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "something went wrong, please contact admin.".tr, + ); } return GetPaymentTxtTokenModel.fromJson(data); } @@ -1383,7 +1795,10 @@ class IntercityHomeController extends GetxController { 'description': 'wallet Topup', 'retry': {'enabled': true, 'max_count': 1}, 'send_sms_hash': true, - 'prefill': {'contact': userModel.value.phoneNumber, 'email': userModel.value.email}, + 'prefill': { + 'contact': userModel.value.phoneNumber, + 'email': userModel.value.email, + }, 'external': { 'wallets': ['paytm'], }, @@ -1418,7 +1833,10 @@ class IntercityHomeController extends GetxController { } //Midtrans payment - Future midtransMakePayment({required String amount, required BuildContext context}) async { + Future midtransMakePayment({ + required String amount, + required BuildContext context, + }) async { await createPaymentLink(amount: amount).then((url) { ShowToastDialog.closeLoader(); if (url != '') { @@ -1436,15 +1854,30 @@ class IntercityHomeController extends GetxController { Future createPaymentLink({required var amount}) async { var ordersId = const Uuid().v1(); - final url = Uri.parse(midTransModel.value.isSandbox! ? 'https://api.sandbox.midtrans.com/v1/payment-links' : 'https://api.midtrans.com/v1/payment-links'); + final url = Uri.parse( + midTransModel.value.isSandbox! + ? 'https://api.sandbox.midtrans.com/v1/payment-links' + : 'https://api.midtrans.com/v1/payment-links', + ); final response = await http.post( url, - headers: {'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': generateBasicAuthHeader(midTransModel.value.serverKey!)}, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': generateBasicAuthHeader( + midTransModel.value.serverKey!, + ), + }, body: jsonEncode({ - 'transaction_details': {'order_id': ordersId, 'gross_amount': double.parse(amount.toString()).toInt()}, + 'transaction_details': { + 'order_id': ordersId, + 'gross_amount': double.parse(amount.toString()).toInt(), + }, 'usage_limit': 2, - "callbacks": {"finish": "https://www.google.com?merchant_order_id=$ordersId"}, + "callbacks": { + "finish": "https://www.google.com?merchant_order_id=$ordersId", + }, }), ); @@ -1452,7 +1885,9 @@ class IntercityHomeController extends GetxController { final responseData = jsonDecode(response.body); return responseData['payment_url']; } else { - ShowToastDialog.showToast("something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "something went wrong, please contact admin.".tr, + ); return ''; } } @@ -1469,13 +1904,30 @@ class IntercityHomeController extends GetxController { static String orderId = ''; static String amount = ''; - Future orangeMakePayment({required String amount, required BuildContext context}) async { + Future orangeMakePayment({ + required String amount, + required BuildContext context, + }) async { reset(); var id = const Uuid().v4(); - var paymentURL = await fetchToken(context: context, orderId: id, amount: amount, currency: 'USD'); + var paymentURL = await fetchToken( + context: context, + orderId: id, + amount: amount, + currency: 'USD', + ); ShowToastDialog.closeLoader(); if (paymentURL.toString() != '') { - Get.to(() => OrangeMoneyScreen(initialURl: paymentURL, accessToken: accessToken, amount: amount, orangePay: orangeMoneyModel.value, orderId: orderId, payToken: payToken))!.then((value) { + Get.to( + () => OrangeMoneyScreen( + initialURl: paymentURL, + accessToken: accessToken, + amount: amount, + orangePay: orangeMoneyModel.value, + orderId: orderId, + payToken: payToken, + ), + )!.then((value) { if (value == true) { ShowToastDialog.showToast("Payment Successful!!".tr); completeOrder(); @@ -1487,13 +1939,22 @@ class IntercityHomeController extends GetxController { } } - Future fetchToken({required String orderId, required String currency, required BuildContext context, required String amount}) async { + Future fetchToken({ + required String orderId, + required String currency, + required BuildContext context, + required String amount, + }) async { String apiUrl = 'https://api.orange.com/oauth/v3/token'; Map requestBody = {'grant_type': 'client_credentials'}; var response = await http.post( Uri.parse(apiUrl), - headers: {'Authorization': "Basic ${orangeMoneyModel.value.auth!}", 'Content-Type': 'application/x-www-form-urlencoded', 'Accept': 'application/json'}, + headers: { + 'Authorization': "Basic ${orangeMoneyModel.value.auth!}", + 'Content-Type': 'application/x-www-form-urlencoded', + 'Accept': 'application/json', + }, body: requestBody, ); @@ -1504,17 +1965,32 @@ class IntercityHomeController extends GetxController { accessToken = responseData['access_token']; // ignore: use_build_context_synchronously - return await webpayment(context: context, amountData: amount, currency: currency, orderIdData: orderId); + return await webpayment( + context: context, + amountData: amount, + currency: currency, + orderIdData: orderId, + ); } else { - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); return ''; } } - Future webpayment({required String orderIdData, required BuildContext context, required String currency, required String amountData}) async { + Future webpayment({ + required String orderIdData, + required BuildContext context, + required String currency, + required String amountData, + }) async { orderId = orderIdData; amount = amountData; - String apiUrl = orangeMoneyModel.value.isSandbox! == true ? 'https://api.orange.com/orange-money-webpay/dev/v1/webpayment' : 'https://api.orange.com/orange-money-webpay/cm/v1/webpayment'; + String apiUrl = + orangeMoneyModel.value.isSandbox! == true + ? 'https://api.orange.com/orange-money-webpay/dev/v1/webpayment' + : 'https://api.orange.com/orange-money-webpay/cm/v1/webpayment'; Map requestBody = { "merchant_key": orangeMoneyModel.value.merchantKey ?? '', "currency": orangeMoneyModel.value.isSandbox == true ? "OUV" : currency, @@ -1529,7 +2005,11 @@ class IntercityHomeController extends GetxController { var response = await http.post( Uri.parse(apiUrl), - headers: {'Authorization': 'Bearer $accessToken', 'Content-Type': 'application/json', 'Accept': 'application/json'}, + headers: { + 'Authorization': 'Bearer $accessToken', + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, body: json.encode(requestBody), ); @@ -1543,7 +2023,9 @@ class IntercityHomeController extends GetxController { return ''; } } else { - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); return ''; } } @@ -1560,7 +2042,13 @@ class IntercityHomeController extends GetxController { await createXenditInvoice(amount: amount).then((model) { ShowToastDialog.closeLoader(); if (model.id != null) { - Get.to(() => XenditScreen(initialURl: model.invoiceUrl ?? '', transId: model.id ?? '', apiKey: xenditModel.value.apiKey!.toString()))!.then((value) { + Get.to( + () => XenditScreen( + initialURl: model.invoiceUrl ?? '', + transId: model.id ?? '', + apiKey: xenditModel.value.apiKey!.toString(), + ), + )!.then((value) { if (value == true) { ShowToastDialog.showToast("Payment Successful!!".tr); completeOrder(); @@ -1577,7 +2065,9 @@ class IntercityHomeController extends GetxController { const url = 'https://api.xendit.co/v2/invoices'; var headers = { 'Content-Type': 'application/json', - 'Authorization': generateBasicAuthHeader(xenditModel.value.apiKey!.toString()), + 'Authorization': generateBasicAuthHeader( + xenditModel.value.apiKey!.toString(), + ), // 'Cookie': '__cf_bm=yERkrx3xDITyFGiou0bbKY1bi7xEwovHNwxV1vCNbVc-1724155511-1.0.1.1-jekyYQmPCwY6vIJ524K0V6_CEw6O.dAwOmQnHtwmaXO_MfTrdnmZMka0KZvjukQgXu5B.K_6FJm47SGOPeWviQ', }; @@ -1590,7 +2080,11 @@ class IntercityHomeController extends GetxController { }); try { - final response = await http.post(Uri.parse(url), headers: headers, body: body); + final response = await http.post( + Uri.parse(url), + headers: headers, + body: body, + ); if (response.statusCode == 200 || response.statusCode == 201) { XenditModel model = XenditModel.fromJson(jsonDecode(response.body)); diff --git a/lib/controllers/address_list_controller.dart b/lib/controllers/address_list_controller.dart index 3a90915..7efd69a 100644 --- a/lib/controllers/address_list_controller.dart +++ b/lib/controllers/address_list_controller.dart @@ -1,6 +1,5 @@ import 'package:customer/models/user_model.dart'; import 'package:get/get.dart'; - import '../constant/constant.dart'; import '../service/fire_store_utils.dart'; @@ -18,7 +17,9 @@ class AddressListController extends GetxController { } Future getUser() async { - await FireStoreUtils.getUserProfile(FireStoreUtils.getCurrentUid()).then((value) { + await FireStoreUtils.getUserProfile(FireStoreUtils.getCurrentUid()).then(( + value, + ) { if (value != null) { userModel.value = value; if (userModel.value.shippingAddress != null) { diff --git a/lib/controllers/all_brand_product_controller.dart b/lib/controllers/all_brand_product_controller.dart index 5ffaec1..f167094 100644 --- a/lib/controllers/all_brand_product_controller.dart +++ b/lib/controllers/all_brand_product_controller.dart @@ -27,19 +27,27 @@ class AllBrandProductController extends GetxController { } Future getProductByCategoryId() async { - List productDataList = await FireStoreUtils.getProductListByBrandId(brandModel.value.id.toString()); + List productDataList = + await FireStoreUtils.getProductListByBrandId( + brandModel.value.id.toString(), + ); List vendorList = await FireStoreUtils.getAllStoresFuture(); List allProduct = []; for (var vendor in vendorList) { await FireStoreUtils.getAllProducts(vendor.id.toString()).then((value) { - if (Constant.isSubscriptionModelApplied == true || vendor.adminCommission?.isEnabled == true) { - if (vendor.subscriptionPlan != null && Constant.isExpire(vendor) == false) { + if (Constant.isSubscriptionModelApplied == true || + vendor.adminCommission?.isEnabled == true) { + if (vendor.subscriptionPlan != null && + Constant.isExpire(vendor) == false) { if (vendor.subscriptionPlan?.itemLimit == '-1') { allProduct.addAll(value); } else { int selectedProduct = - value.length < int.parse(vendor.subscriptionPlan?.itemLimit ?? '0') ? (value.isEmpty ? 0 : (value.length)) : int.parse(vendor.subscriptionPlan?.itemLimit ?? '0'); + value.length < + int.parse(vendor.subscriptionPlan?.itemLimit ?? '0') + ? (value.isEmpty ? 0 : (value.length)) + : int.parse(vendor.subscriptionPlan?.itemLimit ?? '0'); allProduct.addAll(value.sublist(0, selectedProduct)); } } @@ -49,7 +57,9 @@ class AllBrandProductController extends GetxController { }); } for (var element in productDataList) { - final bool productIsInList = allProduct.any((product) => product.id == element.id); + final bool productIsInList = allProduct.any( + (product) => product.id == element.id, + ); if (productIsInList) { productList.add(element); } diff --git a/lib/controllers/all_category_product_controller.dart b/lib/controllers/all_category_product_controller.dart index d5454f6..a1fe34f 100644 --- a/lib/controllers/all_category_product_controller.dart +++ b/lib/controllers/all_category_product_controller.dart @@ -25,6 +25,8 @@ class AllCategoryProductController extends GetxController { } Future getProductByCategoryId() async { - productList.value = await FireStoreUtils.getProductListByCategoryId(categoryModel.value.id.toString()); + productList.value = await FireStoreUtils.getProductListByCategoryId( + categoryModel.value.id.toString(), + ); } } diff --git a/lib/controllers/book_parcel_controller.dart b/lib/controllers/book_parcel_controller.dart index 7edc29d..3dcf92f 100644 --- a/lib/controllers/book_parcel_controller.dart +++ b/lib/controllers/book_parcel_controller.dart @@ -3,6 +3,7 @@ import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:customer/models/vendor_model.dart'; import 'package:customer/widget/geoflutterfire/src/geoflutterfire.dart'; import 'package:dropdown_textfield/dropdown_textfield.dart'; + import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:geocoding/geocoding.dart'; @@ -22,26 +23,39 @@ import '../themes/show_toast_dialog.dart'; class BookParcelController extends GetxController { // Sender details - final Rx senderLocationController = TextEditingController().obs; - final Rx senderNameController = TextEditingController().obs; - final Rx senderMobileController = TextEditingController().obs; - final Rx senderWeightController = SingleValueDropDownController().obs; - final Rx senderNoteController = TextEditingController().obs; - final Rx senderCountryCodeController = TextEditingController(text: Constant.defaultCountryCode).obs; + final Rx senderLocationController = + TextEditingController().obs; + final Rx senderNameController = + TextEditingController().obs; + final Rx senderMobileController = + TextEditingController().obs; + final Rx senderWeightController = + SingleValueDropDownController().obs; + final Rx senderNoteController = + TextEditingController().obs; + final Rx senderCountryCodeController = + TextEditingController(text: Constant.defaultCountryCode).obs; // Receiver details - final Rx receiverLocationController = TextEditingController().obs; - final Rx receiverNameController = TextEditingController().obs; - final Rx receiverMobileController = TextEditingController().obs; - final Rx receiverNoteController = TextEditingController().obs; - final Rx receiverCountryCodeController = TextEditingController(text: Constant.defaultCountryCode).obs; + final Rx receiverLocationController = + TextEditingController().obs; + final Rx receiverNameController = + TextEditingController().obs; + final Rx receiverMobileController = + TextEditingController().obs; + final Rx receiverNoteController = + TextEditingController().obs; + final Rx receiverCountryCodeController = + TextEditingController(text: Constant.defaultCountryCode).obs; // Delivery type final RxString selectedDeliveryType = 'now'.obs; // Scheduled delivery fields - final Rx scheduledDateController = TextEditingController().obs; - final Rx scheduledTimeController = TextEditingController().obs; + final Rx scheduledDateController = + TextEditingController().obs; + final Rx scheduledTimeController = + TextEditingController().obs; final RxString scheduledDate = ''.obs; final RxString scheduledTime = ''.obs; @@ -82,7 +96,12 @@ class BookParcelController extends GetxController { } Future pickScheduledDate(BuildContext context) async { - final DateTime? picked = await showDatePicker(context: context, initialDate: DateTime.now(), firstDate: DateTime.now(), lastDate: DateTime.now().add(const Duration(days: 365))); + final DateTime? picked = await showDatePicker( + context: context, + initialDate: DateTime.now(), + firstDate: DateTime.now(), + lastDate: DateTime.now().add(const Duration(days: 365)), + ); if (picked != null) { final formattedDate = "${picked.day}/${picked.month}/${picked.year}"; scheduledDate.value = formattedDate; @@ -91,7 +110,10 @@ class BookParcelController extends GetxController { } Future pickScheduledTime(BuildContext context) async { - final TimeOfDay? picked = await showTimePicker(context: context, initialTime: TimeOfDay.now()); + final TimeOfDay? picked = await showTimePicker( + context: context, + initialTime: TimeOfDay.now(), + ); if (picked != null) { final formattedTime = picked.format(context); scheduledTime.value = formattedTime; @@ -101,7 +123,10 @@ class BookParcelController extends GetxController { void onCameraClick(BuildContext context) { final action = CupertinoActionSheet( - message: Text('Add your parcel image.'.tr, style: const TextStyle(fontSize: 15.0)), + message: Text( + 'Add your parcel image.'.tr, + style: const TextStyle(fontSize: 15.0), + ), actions: [ CupertinoActionSheetAction( child: Text('Choose image from gallery'.tr), @@ -117,14 +142,19 @@ class BookParcelController extends GetxController { child: Text('Take a picture'.tr), onPressed: () async { Navigator.pop(context); - final XFile? photo = await _picker.pickImage(source: ImageSource.camera); + final XFile? photo = await _picker.pickImage( + source: ImageSource.camera, + ); if (photo != null) { images.add(photo); } }, ), ], - cancelButton: CupertinoActionSheetAction(child: Text('Cancel'.tr), onPressed: () => Navigator.pop(context)), + cancelButton: CupertinoActionSheetAction( + child: Text('Cancel'.tr), + onPressed: () => Navigator.pop(context), + ), ); showCupertinoModalPopup(context: context, builder: (context) => action); } @@ -133,11 +163,18 @@ class BookParcelController extends GetxController { try { await Geolocator.requestPermission(); final position = await Geolocator.getCurrentPosition(); - final placemarks = await placemarkFromCoordinates(position.latitude, position.longitude); + final placemarks = await placemarkFromCoordinates( + position.latitude, + position.longitude, + ); final place = placemarks.first; - final address = "${place.name}, ${place.subLocality}, ${place.locality}, ${place.administrativeArea}, ${place.postalCode}, ${place.country}"; + final address = + "${place.name}, ${place.subLocality}, ${place.locality}, ${place.administrativeArea}, ${place.postalCode}, ${place.country}"; - final userLocation = UserLocation(latitude: position.latitude, longitude: position.longitude); + final userLocation = UserLocation( + latitude: position.latitude, + longitude: position.longitude, + ); senderLocation.value = userLocation; senderLocationController.value.text = address; } catch (e) { @@ -178,7 +215,9 @@ class BookParcelController extends GetxController { ShowToastDialog.showToast("Please select parcel weight".tr); return false; } else if (senderLocation.value == null || receiverLocation.value == null) { - ShowToastDialog.showToast("Please select both sender and receiver locations".tr); + ShowToastDialog.showToast( + "Please select both sender and receiver locations".tr, + ); return false; } return true; @@ -192,22 +231,37 @@ class BookParcelController extends GetxController { if (Constant.selectedMapType == 'osm') { print("Fetching route using OSM"); - print("Sender Location: ${senderLocation.value?.latitude}, ${senderLocation.value?.longitude}"); - print("Receiver Location: ${receiverLocation.value?.latitude}, ${receiverLocation.value?.longitude}"); + print( + "Sender Location: ${senderLocation.value?.latitude}, ${senderLocation.value?.longitude}", + ); + print( + "Receiver Location: ${receiverLocation.value?.latitude}, ${receiverLocation.value?.longitude}", + ); await fetchRouteWithWaypoints([ - latlong.LatLng(senderLocation.value?.latitude ?? 0.0, senderLocation.value?.longitude ?? 0.0), - latlong.LatLng(receiverLocation.value?.latitude ?? 0.0, receiverLocation.value?.longitude ?? 0.0), + latlong.LatLng( + senderLocation.value?.latitude ?? 0.0, + senderLocation.value?.longitude ?? 0.0, + ), + latlong.LatLng( + receiverLocation.value?.latitude ?? 0.0, + receiverLocation.value?.longitude ?? 0.0, + ), ]); } else { await fetchGoogleRouteWithWaypoints(); } if (distance.value < 0.5) { - ShowToastDialog.showToast("Sender's location to receiver's location should be more than 1 km.".tr); + ShowToastDialog.showToast( + "Sender's location to receiver's location should be more than 1 km." + .tr, + ); return; } - subTotal.value = (distance.value * double.parse(selectedWeight!.deliveryCharge.toString())); + subTotal.value = + (distance.value * + double.parse(selectedWeight!.deliveryCharge.toString())); goToCart(); } catch (e) { ShowToastDialog.showToast("Something went wrong while booking.".tr); @@ -216,7 +270,10 @@ class BookParcelController extends GetxController { } void goToCart() { - DateTime senderPickup = isScheduled.value ? parseScheduledDateTime(scheduledDate.value, scheduledTime.value) : DateTime.now(); + DateTime senderPickup = + isScheduled.value + ? parseScheduledDateTime(scheduledDate.value, scheduledTime.value) + : DateTime.now(); print("Sender Pickup: $distance"); ParcelOrderModel order = ParcelOrderModel( @@ -235,22 +292,42 @@ class BookParcelController extends GetxController { taxSetting: Constant.taxList, isSchedule: isScheduled.value, sourcePoint: G( - geopoint: GeoPoint(senderLocation.value!.latitude ?? 0.0, senderLocation.value!.longitude ?? 0.0), - geohash: Geoflutterfire().point(latitude: senderLocation.value!.latitude ?? 0.0, longitude: senderLocation.value!.longitude ?? 0.0).hash, + geopoint: GeoPoint( + senderLocation.value!.latitude ?? 0.0, + senderLocation.value!.longitude ?? 0.0, + ), + geohash: + Geoflutterfire() + .point( + latitude: senderLocation.value!.latitude ?? 0.0, + longitude: senderLocation.value!.longitude ?? 0.0, + ) + .hash, ), destinationPoint: G( - geopoint: GeoPoint(receiverLocation.value!.latitude ?? 0.0, receiverLocation.value!.longitude ?? 0.0), - geohash: Geoflutterfire().point(latitude: receiverLocation.value!.latitude ?? 0.0, longitude: receiverLocation.value!.longitude ?? 0.0).hash, + geopoint: GeoPoint( + receiverLocation.value!.latitude ?? 0.0, + receiverLocation.value!.longitude ?? 0.0, + ), + geohash: + Geoflutterfire() + .point( + latitude: receiverLocation.value!.latitude ?? 0.0, + longitude: receiverLocation.value!.longitude ?? 0.0, + ) + .hash, ), sender: LocationInformation( address: senderLocationController.value.text, name: senderNameController.value.text, - phone: "(${senderCountryCodeController.value.text}) ${senderMobileController.value.text}", + phone: + "(${senderCountryCodeController.value.text}) ${senderMobileController.value.text}", ), receiver: LocationInformation( address: receiverLocationController.value.text, name: receiverNameController.value.text, - phone: "(${receiverCountryCodeController.value.text}) ${receiverMobileController.value.text}", + phone: + "(${receiverCountryCodeController.value.text}) ${receiverMobileController.value.text}", ), receiverLatLong: receiverLocation.value, senderLatLong: senderLocation.value, @@ -261,7 +338,10 @@ class BookParcelController extends GetxController { debugPrint("Subtotal: ${subTotal.value}"); debugPrint("Order JSON: ${order.toJson()}"); - Get.to(() => ParcelOrderConfirmationScreen(), arguments: {'parcelOrder': order, 'images': images}); + Get.to( + () => ParcelOrderConfirmationScreen(), + arguments: {'parcelOrder': order, 'images': images}, + ); } DateTime parseScheduledDateTime(String dateStr, String timeStr) { @@ -271,7 +351,10 @@ class BookParcelController extends GetxController { final month = int.parse(dateParts[1]); final year = int.parse(dateParts[2]); - final time = TimeOfDay(hour: int.parse(timeStr.split(':')[0]), minute: int.parse(timeStr.split(':')[1].split(' ')[0])); + final time = TimeOfDay( + hour: int.parse(timeStr.split(':')[0]), + minute: int.parse(timeStr.split(':')[1].split(' ')[0]), + ); final isPM = timeStr.toLowerCase().contains('pm'); final hour24 = isPM && time.hour < 12 ? time.hour + 12 : time.hour; @@ -283,9 +366,13 @@ class BookParcelController extends GetxController { } Future fetchGoogleRouteWithWaypoints() async { - final origin = '${senderLocation.value!.latitude},${senderLocation.value!.longitude}'; - final destination = '${receiverLocation.value!.latitude},${receiverLocation.value!.longitude}'; - final url = Uri.parse('https://maps.googleapis.com/maps/api/directions/json?origin=$origin&destination=$destination&mode=driving&key=${Constant.mapAPIKey}'); + final origin = + '${senderLocation.value!.latitude},${senderLocation.value!.longitude}'; + final destination = + '${receiverLocation.value!.latitude},${receiverLocation.value!.longitude}'; + final url = Uri.parse( + 'https://maps.googleapis.com/maps/api/directions/json?origin=$origin&destination=$destination&mode=driving&key=${Constant.mapAPIKey}', + ); try { final response = await http.get(url); @@ -314,8 +401,12 @@ class BookParcelController extends GetxController { } Future fetchRouteWithWaypoints(List points) async { - final coordinates = points.map((p) => '${p.longitude},${p.latitude}').join(';'); - final url = Uri.parse('https://router.project-osrm.org/route/v1/driving/$coordinates?overview=full&geometries=geojson'); + final coordinates = points + .map((p) => '${p.longitude},${p.latitude}') + .join(';'); + final url = Uri.parse( + 'https://router.project-osrm.org/route/v1/driving/$coordinates?overview=full&geometries=geojson', + ); try { final response = await http.get(url); diff --git a/lib/controllers/cab_booking_controller.dart b/lib/controllers/cab_booking_controller.dart index 9b80a10..f894af3 100644 --- a/lib/controllers/cab_booking_controller.dart +++ b/lib/controllers/cab_booking_controller.dart @@ -40,6 +40,7 @@ import 'package:customer/payment/xenditScreen.dart'; import 'package:customer/service/fire_store_utils.dart'; import 'package:customer/themes/show_toast_dialog.dart'; import 'package:customer/utils/preferences.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart' as flutterMap; import 'package:flutter_paypal/flutter_paypal.dart'; @@ -59,10 +60,13 @@ class CabBookingController extends GetxController { late GoogleMapController mapController; final flutterMap.MapController mapOsmController = flutterMap.MapController(); - final Rx sourceTextEditController = TextEditingController().obs; - final Rx destinationTextEditController = TextEditingController().obs; + final Rx sourceTextEditController = + TextEditingController().obs; + final Rx destinationTextEditController = + TextEditingController().obs; - final Rx couponCodeTextEditController = TextEditingController().obs; + final Rx couponCodeTextEditController = + TextEditingController().obs; final Rx currentLocation = Location().obs; @@ -132,64 +136,99 @@ class CabBookingController extends GetxController { await getPaymentSettings(); - FireStoreUtils.fireStore.collection(CollectionName.users).doc(FireStoreUtils.getCurrentUid()).snapshots().listen((userSnapshot) async { - if (!userSnapshot.exists) return; + FireStoreUtils.fireStore + .collection(CollectionName.users) + .doc(FireStoreUtils.getCurrentUid()) + .snapshots() + .listen((userSnapshot) async { + if (!userSnapshot.exists) return; - userModel.value = UserModel.fromJson(userSnapshot.data()!); + userModel.value = UserModel.fromJson(userSnapshot.data()!); - if (userModel.value.inProgressOrderID != null && userModel.value.inProgressOrderID!.isNotEmpty) { - String? validRideId; + if (userModel.value.inProgressOrderID != null && + userModel.value.inProgressOrderID!.isNotEmpty) { + String? validRideId; - for (String id in userModel.value.inProgressOrderID!) { - final rideDoc = await FireStoreUtils.fireStore.collection(CollectionName.rides).doc(id).get(); + for (String id in userModel.value.inProgressOrderID!) { + final rideDoc = + await FireStoreUtils.fireStore + .collection(CollectionName.rides) + .doc(id) + .get(); - if (rideDoc.exists && (rideDoc.data()?['rideType'] ?? '').toString().toLowerCase() == "ride") { - validRideId = userModel.value.inProgressOrderID!.first!; - break; - } - } - - FireStoreUtils.fireStore.collection(CollectionName.rides).doc(validRideId).snapshots().listen((rideSnapshot) async { - if (!rideSnapshot.exists) return; - - final rideData = rideSnapshot.data()!; - currentOrder.value = CabOrderModel.fromJson(rideData); - final status = currentOrder.value.status; - - if (status == Constant.driverAccepted || status == Constant.orderInTransit) { - FireStoreUtils.fireStore.collection(CollectionName.users).doc(currentOrder.value.driverId).snapshots().listen((event) async { - if (event.exists && event.data() != null) { - UserModel driverModel0 = UserModel.fromJson(event.data()!); - driverModel.value = driverModel0; - await updateDriverRoute(driverModel0); + if (rideDoc.exists && + (rideDoc.data()?['rideType'] ?? '') + .toString() + .toLowerCase() == + "ride") { + validRideId = userModel.value.inProgressOrderID!.first!; + break; } - }); - } + } - print("Current Ride Status: $status"); - if (status == Constant.orderPlaced || status == Constant.driverPending || status == Constant.driverRejected || (status == Constant.orderAccepted && currentOrder.value.driverId == null)) { - bottomSheetType.value = 'waitingForDriver'; - } else if (status == Constant.driverAccepted || status == Constant.orderInTransit) { - bottomSheetType.value = 'driverDetails'; - sourceTextEditController.value.text = currentOrder.value.sourceLocationName ?? ''; - destinationTextEditController.value.text = currentOrder.value.destinationLocationName ?? ''; - selectedPaymentMethod.value = currentOrder.value.paymentMethod ?? ''; - calculateTotalAmountAfterAccept(); - } else if (status == Constant.orderCompleted) { - userModel.value.inProgressOrderID!.remove(validRideId); - await FireStoreUtils.updateUser(userModel.value); + FireStoreUtils.fireStore + .collection(CollectionName.rides) + .doc(validRideId) + .snapshots() + .listen((rideSnapshot) async { + if (!rideSnapshot.exists) return; + + final rideData = rideSnapshot.data()!; + currentOrder.value = CabOrderModel.fromJson(rideData); + final status = currentOrder.value.status; + + if (status == Constant.driverAccepted || + status == Constant.orderInTransit) { + FireStoreUtils.fireStore + .collection(CollectionName.users) + .doc(currentOrder.value.driverId) + .snapshots() + .listen((event) async { + if (event.exists && event.data() != null) { + UserModel driverModel0 = UserModel.fromJson( + event.data()!, + ); + driverModel.value = driverModel0; + await updateDriverRoute(driverModel0); + } + }); + } + + print("Current Ride Status: $status"); + if (status == Constant.orderPlaced || + status == Constant.driverPending || + status == Constant.driverRejected || + (status == Constant.orderAccepted && + currentOrder.value.driverId == null)) { + bottomSheetType.value = 'waitingForDriver'; + } else if (status == Constant.driverAccepted || + status == Constant.orderInTransit) { + bottomSheetType.value = 'driverDetails'; + sourceTextEditController.value.text = + currentOrder.value.sourceLocationName ?? ''; + destinationTextEditController.value.text = + currentOrder.value.destinationLocationName ?? ''; + selectedPaymentMethod.value = + currentOrder.value.paymentMethod ?? ''; + calculateTotalAmountAfterAccept(); + } else if (status == Constant.orderCompleted) { + userModel.value.inProgressOrderID!.remove(validRideId); + await FireStoreUtils.updateUser(userModel.value); + bottomSheetType.value = 'location'; + Get.back(); + } + }); + } else { bottomSheetType.value = 'location'; - Get.back(); + if (Constant.currentLocation != null) { + setDepartureMarker( + Constant.currentLocation!.latitude, + Constant.currentLocation!.longitude, + ); + searchPlaceNameOSM(); + } } }); - } else { - bottomSheetType.value = 'location'; - if (Constant.currentLocation != null) { - setDepartureMarker(Constant.currentLocation!.latitude, Constant.currentLocation!.longitude); - searchPlaceNameOSM(); - } - } - }); final coupons = await FireStoreUtils.getCabCoupon(); cabCouponList.value = coupons; @@ -216,18 +255,30 @@ class CabBookingController extends GetxController { if (order.status == Constant.driverAccepted) { // DRIVER → PICKUP - await fetchRouteWithWaypoints([latlong.LatLng(driverLat, driverLng), latlong.LatLng(pickupLat, pickupLng)]); + await fetchRouteWithWaypoints([ + latlong.LatLng(driverLat, driverLng), + latlong.LatLng(pickupLat, pickupLng), + ]); } else if (order.status == Constant.orderInTransit) { // PICKUP → DESTINATION - await fetchRouteWithWaypoints([latlong.LatLng(driverLat, driverLng), latlong.LatLng(destLat, destLng)]); + await fetchRouteWithWaypoints([ + latlong.LatLng(driverLat, driverLng), + latlong.LatLng(destLat, destLng), + ]); } updateRouteMarkers(driverModel); } else { /// For Google Maps if (order.status == Constant.driverAccepted) { - await fetchGoogleRouteBetween(LatLng(driverLat, driverLng), LatLng(pickupLat, pickupLng)); + await fetchGoogleRouteBetween( + LatLng(driverLat, driverLng), + LatLng(pickupLat, pickupLng), + ); } else if (order.status == Constant.orderInTransit) { - await fetchGoogleRouteBetween(LatLng(driverLat, driverLng), LatLng(destLat, destLng)); + await fetchGoogleRouteBetween( + LatLng(driverLat, driverLng), + LatLng(destLat, destLng), + ); } updateRouteMarkers(driverModel); } @@ -251,12 +302,24 @@ class CabBookingController extends GetxController { markers.clear(); osmMarker.clear(); - final departureBytes = await Constant().getBytesFromAsset('assets/images/location_black3x.png', 50); - final destinationBytes = await Constant().getBytesFromAsset('assets/images/location_orange3x.png', 50); + final departureBytes = await Constant().getBytesFromAsset( + 'assets/images/location_black3x.png', + 50, + ); + final destinationBytes = await Constant().getBytesFromAsset( + 'assets/images/location_orange3x.png', + 50, + ); final driverBytesRaw = (Constant.sectionConstantModel?.markerIcon?.isNotEmpty ?? false) - ? await Constant().getBytesFromUrl(Constant.sectionConstantModel!.markerIcon!, width: 120) - : await Constant().getBytesFromAsset('assets/images/ic_cab.png', 50); + ? await Constant().getBytesFromUrl( + Constant.sectionConstantModel!.markerIcon!, + width: 120, + ) + : await Constant().getBytesFromAsset( + 'assets/images/ic_cab.png', + 50, + ); departureIcon = BitmapDescriptor.fromBytes(departureBytes); destinationIcon = BitmapDescriptor.fromBytes(destinationBytes); @@ -265,7 +328,15 @@ class CabBookingController extends GetxController { if (Constant.selectedMapType == 'osm') { if (order.status == Constant.driverAccepted) { osmMarker.addAll([ - flutterMap.Marker(point: latlong.LatLng(pickupLat, pickupLng), width: 40, height: 40, child: Image.asset('assets/images/location_black3x.png', width: 40)), + flutterMap.Marker( + point: latlong.LatLng(pickupLat, pickupLng), + width: 40, + height: 40, + child: Image.asset( + 'assets/images/location_black3x.png', + width: 40, + ), + ), flutterMap.Marker( point: latlong.LatLng(driverLat, driverLng), width: 45, @@ -276,13 +347,26 @@ class CabBookingController extends GetxController { height: 50, imageUrl: Constant.sectionConstantModel!.markerIcon.toString(), placeholder: (context, url) => Constant.loader(), - errorWidget: (context, url, error) => SizedBox(width: 30, height: 30, child: CircularProgressIndicator(strokeWidth: 2)), + errorWidget: + (context, url, error) => SizedBox( + width: 30, + height: 30, + child: CircularProgressIndicator(strokeWidth: 2), + ), ), ), ]); } else if (order.status == Constant.orderInTransit) { osmMarker.addAll([ - flutterMap.Marker(point: latlong.LatLng(destLat, destLng), width: 40, height: 40, child: Image.asset('assets/images/location_orange3x.png', width: 40)), + flutterMap.Marker( + point: latlong.LatLng(destLat, destLng), + width: 40, + height: 40, + child: Image.asset( + 'assets/images/location_orange3x.png', + width: 40, + ), + ), flutterMap.Marker( point: latlong.LatLng(driverLat, driverLng), width: 45, @@ -293,7 +377,12 @@ class CabBookingController extends GetxController { height: 50, imageUrl: Constant.sectionConstantModel!.markerIcon.toString(), placeholder: (context, url) => Constant.loader(), - errorWidget: (context, url, error) => SizedBox(width: 30, height: 30, child: CircularProgressIndicator(strokeWidth: 2)), + errorWidget: + (context, url, error) => SizedBox( + width: 30, + height: 30, + child: CircularProgressIndicator(strokeWidth: 2), + ), ), ), ]); @@ -305,9 +394,18 @@ class CabBookingController extends GetxController { markerId: const MarkerId("pickup"), position: LatLng(pickupLat, pickupLng), infoWindow: InfoWindow(title: "Pickup Location".tr), - icon: departureIcon ?? BitmapDescriptor.defaultMarkerWithHue(BitmapDescriptor.hueGreen), + icon: + departureIcon ?? + BitmapDescriptor.defaultMarkerWithHue( + BitmapDescriptor.hueGreen, + ), + ), + Marker( + markerId: const MarkerId("driver"), + position: LatLng(driverLat, driverLng), + infoWindow: InfoWindow(title: "Driver at Pickup".tr), + icon: taxiIcon ?? BitmapDescriptor.defaultMarker, ), - Marker(markerId: const MarkerId("driver"), position: LatLng(driverLat, driverLng), infoWindow: InfoWindow(title: "Driver at Pickup".tr), icon: taxiIcon ?? BitmapDescriptor.defaultMarker), ]); } else if (order.status == Constant.orderInTransit) { markers.addAll([ @@ -315,9 +413,18 @@ class CabBookingController extends GetxController { markerId: const MarkerId("destination"), position: LatLng(destLat, destLng), infoWindow: InfoWindow(title: "Destination Location".tr), - icon: destinationIcon ?? BitmapDescriptor.defaultMarkerWithHue(BitmapDescriptor.hueRed), + icon: + destinationIcon ?? + BitmapDescriptor.defaultMarkerWithHue( + BitmapDescriptor.hueRed, + ), + ), + Marker( + markerId: const MarkerId("driver"), + position: LatLng(driverLat, driverLng), + infoWindow: InfoWindow(title: "Driver Location".tr), + icon: taxiIcon ?? BitmapDescriptor.defaultMarker, ), - Marker(markerId: const MarkerId("driver"), position: LatLng(driverLat, driverLng), infoWindow: InfoWindow(title: "Driver Location".tr), icon: taxiIcon ?? BitmapDescriptor.defaultMarker), ]); } } @@ -328,7 +435,10 @@ class CabBookingController extends GetxController { } } - Future fetchGoogleRouteBetween(LatLng originPoint, LatLng destPoint) async { + Future fetchGoogleRouteBetween( + LatLng originPoint, + LatLng destPoint, + ) async { final origin = '${originPoint.latitude},${originPoint.longitude}'; final destination = '${destPoint.latitude},${destPoint.longitude}'; final url = Uri.parse( @@ -345,7 +455,8 @@ class CabBookingController extends GetxController { final route = data['routes'][0]; final encodedPolyline = route['overview_polyline']['points']; final decodedPoints = PolylinePoints.decodePolyline(encodedPolyline); - final coordinates = decodedPoints.map((e) => LatLng(e.latitude, e.longitude)).toList(); + final coordinates = + decodedPoints.map((e) => LatLng(e.latitude, e.longitude)).toList(); addPolyLine(coordinates); @@ -372,7 +483,12 @@ class CabBookingController extends GetxController { if (currentOrder.value.taxSetting != null) { for (var element in currentOrder.value.taxSetting!) { - taxAmount.value = (taxAmount.value + Constant.calculateTax(amount: (subTotal.value - discount.value).toString(), taxModel: element)); + taxAmount.value = + (taxAmount.value + + Constant.calculateTax( + amount: (subTotal.value - discount.value).toString(), + taxModel: element, + )); } } @@ -388,11 +504,19 @@ class CabBookingController extends GetxController { subTotal.value = getAmount(selectedVehicleType.value); if (selectedCouponModel.value.id != null) { - discount.value = Constant.calculateDiscount(amount: subTotal.value.toString(), offerModel: selectedCouponModel.value); + discount.value = Constant.calculateDiscount( + amount: subTotal.value.toString(), + offerModel: selectedCouponModel.value, + ); } for (var element in Constant.taxList) { - taxAmount.value = (taxAmount.value + Constant.calculateTax(amount: (subTotal.value - discount.value).toString(), taxModel: element)); + taxAmount.value = + (taxAmount.value + + Constant.calculateTax( + amount: (subTotal.value - discount.value).toString(), + taxModel: element, + )); } totalAmount.value = (subTotal.value - discount.value) + taxAmount.value; @@ -429,9 +553,14 @@ class CabBookingController extends GetxController { serviceType: Constant.parcelServiceType, ); - await FireStoreUtils.setWalletTransaction(transactionModel).then((value) async { + await FireStoreUtils.setWalletTransaction(transactionModel).then(( + value, + ) async { if (value == true) { - await FireStoreUtils.updateUserWallet(amount: "-${totalAmount.value.toString()}", userId: FireStoreUtils.getCurrentUid()); + await FireStoreUtils.updateUserWallet( + amount: "-${totalAmount.value.toString()}", + userId: FireStoreUtils.getCurrentUid(), + ); } }); } @@ -445,13 +574,25 @@ class CabBookingController extends GetxController { Future placeOrder() async { DestinationLocation sourceLocation = DestinationLocation( - latitude: Constant.selectedMapType == 'osm' ? departureLatLongOsm.value.latitude : departureLatLong.value.latitude, - longitude: Constant.selectedMapType == 'osm' ? departureLatLongOsm.value.longitude : departureLatLong.value.longitude, + latitude: + Constant.selectedMapType == 'osm' + ? departureLatLongOsm.value.latitude + : departureLatLong.value.latitude, + longitude: + Constant.selectedMapType == 'osm' + ? departureLatLongOsm.value.longitude + : departureLatLong.value.longitude, ); DestinationLocation destinationLocation = DestinationLocation( - latitude: Constant.selectedMapType == 'osm' ? destinationLatLongOsm.value.latitude : destinationLatLong.value.latitude, - longitude: Constant.selectedMapType == 'osm' ? destinationLatLongOsm.value.longitude : destinationLatLong.value.longitude, + latitude: + Constant.selectedMapType == 'osm' + ? destinationLatLongOsm.value.latitude + : destinationLatLong.value.latitude, + longitude: + Constant.selectedMapType == 'osm' + ? destinationLatLongOsm.value.longitude + : destinationLatLong.value.longitude, ); CabOrderModel orderModel = CabOrderModel(); @@ -462,7 +603,8 @@ class CabBookingController extends GetxController { orderModel.vehicleType = selectedVehicleType.value; orderModel.authorID = FireStoreUtils.getCurrentUid(); orderModel.sourceLocationName = sourceTextEditController.value.text; - orderModel.destinationLocationName = destinationTextEditController.value.text; + orderModel.destinationLocationName = + destinationTextEditController.value.text; orderModel.sourceLocation = sourceLocation; orderModel.destinationLocation = destinationLocation; @@ -474,11 +616,14 @@ class CabBookingController extends GetxController { orderModel.taxSetting = Constant.taxList; orderModel.adminCommissionType = - Constant.sectionConstantModel!.adminCommision != null && Constant.sectionConstantModel!.adminCommision!.isEnabled == true - ? Constant.sectionConstantModel!.adminCommision!.commissionType.toString() + Constant.sectionConstantModel!.adminCommision != null && + Constant.sectionConstantModel!.adminCommision!.isEnabled == true + ? Constant.sectionConstantModel!.adminCommision!.commissionType + .toString() : null; orderModel.adminCommission = - Constant.sectionConstantModel!.adminCommision != null && Constant.sectionConstantModel!.adminCommision!.isEnabled == true + Constant.sectionConstantModel!.adminCommision != null && + Constant.sectionConstantModel!.adminCommision!.isEnabled == true ? Constant.sectionConstantModel!.adminCommision!.amount.toString() : null; orderModel.couponCode = couponCodeTextEditController.value.text; @@ -491,7 +636,9 @@ class CabBookingController extends GetxController { orderModel.roundTrip = false; orderModel.sectionId = Constant.sectionConstantModel!.id; orderModel.createdAt = Timestamp.now(); - orderModel.otpCode = (maths.Random().nextInt(9000) + 1000).toString(); // Generate a 4-digit OTP + orderModel.otpCode = + (maths.Random().nextInt(9000) + 1000) + .toString(); // Generate a 4-digit OTP orderModel.status = Constant.orderPlaced; orderModel.scheduleDateTime = Timestamp.now(); log("Order Model : ${orderModel.toJson()}"); @@ -506,8 +653,10 @@ class CabBookingController extends GetxController { double getAmount(VehicleType vehicleType) { final double currentDistance = distance.value; - if (currentDistance <= (vehicleType.minimum_delivery_charges_within_km ?? 0)) { - return double.tryParse(vehicleType.minimum_delivery_charges.toString()) ?? 0.0; + if (currentDistance <= + (vehicleType.minimum_delivery_charges_within_km ?? 0)) { + return double.tryParse(vehicleType.minimum_delivery_charges.toString()) ?? + 0.0; } else { return (vehicleType.delivery_charges_per_km ?? 0.0) * currentDistance; } @@ -532,28 +681,50 @@ class CabBookingController extends GetxController { void setStopMarker(double lat, double lng, int index) { if (Constant.selectedMapType == 'osm') { // Add new stop marker without clearing - osmMarker.add(flutterMap.Marker(point: latlong.LatLng(lat, lng), width: 40, height: 40, child: stopIconOsm!)); + osmMarker.add( + flutterMap.Marker( + point: latlong.LatLng(lat, lng), + width: 40, + height: 40, + child: stopIconOsm!, + ), + ); getDirections(isStopMarker: true); } else { final markerId = MarkerId('Stop $index'); markers.removeWhere((marker) => marker.markerId == markerId); - markers.add(Marker(markerId: markerId, infoWindow: InfoWindow(title: '${'Stop'.tr} ${String.fromCharCode(index + 65)}'), position: LatLng(lat, lng), icon: stopIcon!)); + markers.add( + Marker( + markerId: markerId, + infoWindow: InfoWindow( + title: '${'Stop'.tr} ${String.fromCharCode(index + 65)}', + ), + position: LatLng(lat, lng), + icon: stopIcon!, + ), + ); getDirections(); } } void _setOsmMarker(double lat, double lng, {required bool isDeparture}) { - final marker = flutterMap.Marker(point: latlong.LatLng(lat, lng), width: 40, height: 40, child: isDeparture ? departureIconOsm! : destinationIconOsm!); + final marker = flutterMap.Marker( + point: latlong.LatLng(lat, lng), + width: 40, + height: 40, + child: isDeparture ? departureIconOsm! : destinationIconOsm!, + ); if (isDeparture) { departureLatLongOsm.value = latlong.LatLng(lat, lng); } else { destinationLatLongOsm.value = latlong.LatLng(lat, lng); } osmMarker.add(marker); - if (departureLatLongOsm.value.latitude != 0 && destinationLatLongOsm.value.latitude != 0) { + if (departureLatLongOsm.value.latitude != 0 && + destinationLatLongOsm.value.latitude != 0) { getDirections(); animateToSource(lat, lng); } @@ -575,14 +746,26 @@ class CabBookingController extends GetxController { markers.removeWhere((marker) => marker.markerId == markerId); // Add new marker - markers.add(Marker(markerId: markerId, position: pos, icon: icon, infoWindow: InfoWindow(title: title))); + markers.add( + Marker( + markerId: markerId, + position: pos, + icon: icon, + infoWindow: InfoWindow(title: title), + ), + ); mapController.animateCamera(CameraUpdate.newLatLngZoom(pos, 14)); - if (departureLatLong.value.latitude != 0 && destinationLatLong.value.latitude != 0) { + if (departureLatLong.value.latitude != 0 && + destinationLatLong.value.latitude != 0) { getDirections(); } else { - mapController.animateCamera(CameraUpdate.newCameraPosition(CameraPosition(target: LatLng(lat, lng), zoom: 14))); + mapController.animateCamera( + CameraUpdate.newCameraPosition( + CameraPosition(target: LatLng(lat, lng), zoom: 14), + ), + ); } } @@ -591,25 +774,43 @@ class CabBookingController extends GetxController { final wayPoints = []; // Only add valid source - if (departureLatLongOsm.value.latitude != 0.0 && departureLatLongOsm.value.longitude != 0.0) { + if (departureLatLongOsm.value.latitude != 0.0 && + departureLatLongOsm.value.longitude != 0.0) { wayPoints.add(departureLatLongOsm.value); } // Only add valid destination - if (destinationLatLongOsm.value.latitude != 0.0 && destinationLatLongOsm.value.longitude != 0.0) { + if (destinationLatLongOsm.value.latitude != 0.0 && + destinationLatLongOsm.value.longitude != 0.0) { wayPoints.add(destinationLatLongOsm.value); } if (!isStopMarker) osmMarker.clear(); // Add source marker - if (departureLatLongOsm.value.latitude != 0.0 && departureLatLongOsm.value.longitude != 0.0) { - osmMarker.add(flutterMap.Marker(point: departureLatLongOsm.value, width: 40, height: 40, child: departureIconOsm!)); + if (departureLatLongOsm.value.latitude != 0.0 && + departureLatLongOsm.value.longitude != 0.0) { + osmMarker.add( + flutterMap.Marker( + point: departureLatLongOsm.value, + width: 40, + height: 40, + child: departureIconOsm!, + ), + ); } // Add destination marker - if (destinationLatLongOsm.value.latitude != 0.0 && destinationLatLongOsm.value.longitude != 0.0) { - osmMarker.add(flutterMap.Marker(point: destinationLatLongOsm.value, width: 40, height: 40, child: destinationIconOsm!)); + if (destinationLatLongOsm.value.latitude != 0.0 && + destinationLatLongOsm.value.longitude != 0.0) { + osmMarker.add( + flutterMap.Marker( + point: destinationLatLongOsm.value, + width: 40, + height: 40, + child: destinationIconOsm!, + ), + ); } if (wayPoints.length >= 2) { @@ -622,10 +823,14 @@ class CabBookingController extends GetxController { } Future fetchGoogleRouteWithWaypoints() async { - if (departureLatLong.value.latitude == 0.0 || destinationLatLong.value.latitude == 0.0) return; + if (departureLatLong.value.latitude == 0.0 || + destinationLatLong.value.latitude == 0.0) + return; - final origin = '${departureLatLong.value.latitude},${departureLatLong.value.longitude}'; - final destination = '${destinationLatLong.value.latitude},${destinationLatLong.value.longitude}'; + final origin = + '${departureLatLong.value.latitude},${departureLatLong.value.longitude}'; + final destination = + '${destinationLatLong.value.latitude},${destinationLatLong.value.longitude}'; final url = Uri.parse( 'https://maps.googleapis.com/maps/api/directions/json' @@ -644,7 +849,8 @@ class CabBookingController extends GetxController { // Polyline final encodedPolyline = route['overview_polyline']['points']; final decodedPoints = PolylinePoints.decodePolyline(encodedPolyline); - final coordinates = decodedPoints.map((e) => LatLng(e.latitude, e.longitude)).toList(); + final coordinates = + decodedPoints.map((e) => LatLng(e.latitude, e.longitude)).toList(); addPolyLine(coordinates); @@ -676,19 +882,26 @@ class CabBookingController extends GetxController { } Future fetchRouteWithWaypoints(List points) async { - final coordinates = points.map((p) => '${p.longitude},${p.latitude}').join(';'); - final url = Uri.parse('https://router.project-osrm.org/route/v1/driving/$coordinates?overview=full&geometries=geojson'); + final coordinates = points + .map((p) => '${p.longitude},${p.latitude}') + .join(';'); + final url = Uri.parse( + 'https://router.project-osrm.org/route/v1/driving/$coordinates?overview=full&geometries=geojson', + ); try { final response = await http.get(url); if (response.statusCode == 200) { final decoded = json.decode(response.body); - final geometry = decoded['routes'][0]['geometry']['coordinates'] as List; + final geometry = + decoded['routes'][0]['geometry']['coordinates'] as List; final dist = decoded['routes'][0]['distance']; final dur = decoded['routes'][0]['duration']; routePoints.clear(); - routePoints.addAll(geometry.map((coord) => latlong.LatLng(coord[1], coord[0]))); + routePoints.addAll( + geometry.map((coord) => latlong.LatLng(coord[1], coord[0])), + ); if (Constant.distanceType.toLowerCase() == "KM".toLowerCase()) { distance.value = dist / 1000.00; @@ -713,7 +926,10 @@ class CabBookingController extends GetxController { void zoomToPolylineOSM() { if (routePoints.isEmpty) return; // LatLngBounds requires at least two points - final bounds = flutterMap.LatLngBounds(routePoints.first, routePoints.first); + final bounds = flutterMap.LatLngBounds( + routePoints.first, + routePoints.first, + ); for (final point in routePoints) { bounds.extend(point); } @@ -725,8 +941,10 @@ class CabBookingController extends GetxController { double getBoundsZoomLevel(flutterMap.LatLngBounds bounds) { // Simple heuristic: zoom out for larger bounds - final latDiff = (bounds.northEast.latitude - bounds.southWest.latitude).abs(); - final lngDiff = (bounds.northEast.longitude - bounds.southWest.longitude).abs(); + final latDiff = + (bounds.northEast.latitude - bounds.southWest.latitude).abs(); + final lngDiff = + (bounds.northEast.longitude - bounds.southWest.longitude).abs(); double maxDiff = math.max(latDiff, lngDiff); if (maxDiff < 0.005) return 18.0; if (maxDiff < 0.01) return 16.0; @@ -738,7 +956,13 @@ class CabBookingController extends GetxController { void addPolyLine(List points) { final id = const PolylineId("poly"); - final polyline = Polyline(polylineId: id, color: AppThemeData.primary300, points: points, width: 6, geodesic: true); + final polyline = Polyline( + polylineId: id, + color: AppThemeData.primary300, + points: points, + width: 6, + geodesic: true, + ); polyLines[id] = polyline; if (points.length >= 2) { @@ -747,7 +971,10 @@ class CabBookingController extends GetxController { } } - Future updateCameraLocationToFitPolyline(List points, GoogleMapController? mapController) async { + Future updateCameraLocationToFitPolyline( + List points, + GoogleMapController? mapController, + ) async { if (mapController == null || points.isEmpty) return; double minLat = points.first.latitude, maxLat = points.first.latitude; double minLng = points.first.longitude, maxLng = points.first.longitude; @@ -757,16 +984,24 @@ class CabBookingController extends GetxController { if (p.longitude < minLng) minLng = p.longitude; if (p.longitude > maxLng) maxLng = p.longitude; } - final bounds = LatLngBounds(southwest: LatLng(minLat, minLng), northeast: LatLng(maxLat, maxLng)); + final bounds = LatLngBounds( + southwest: LatLng(minLat, minLng), + northeast: LatLng(maxLat, maxLng), + ); final cameraUpdate = CameraUpdate.newLatLngBounds(bounds, 50); await checkCameraLocation(cameraUpdate, mapController); } Future animateToSource(double lat, double long) async { - final hasBothCoords = departureLatLongOsm.value.latitude != 0.0 && destinationLatLongOsm.value.latitude != 0.0; + final hasBothCoords = + departureLatLongOsm.value.latitude != 0.0 && + destinationLatLongOsm.value.latitude != 0.0; if (hasBothCoords) { - await calculateZoomLevel(source: departureLatLongOsm.value, destination: destinationLatLongOsm.value); + await calculateZoomLevel( + source: departureLatLongOsm.value, + destination: destinationLatLongOsm.value, + ); } else { mapOsmController.move(latlong.LatLng(lat, long), 10); } @@ -774,15 +1009,25 @@ class CabBookingController extends GetxController { RxMap polyLines = {}.obs; - Future calculateZoomLevel({required latlong.LatLng source, required latlong.LatLng destination, double paddingFraction = 0.001}) async { + Future calculateZoomLevel({ + required latlong.LatLng source, + required latlong.LatLng destination, + double paddingFraction = 0.001, + }) async { final bounds = flutterMap.LatLngBounds.fromPoints([source, destination]); final screenSize = Size(Get.width, Get.height * 0.5); const double worldDimension = 256.0; const double maxZoom = 10.0; - double latToRad(double lat) => math.log((1 + math.sin(lat * math.pi / 180)) / (1 - math.sin(lat * math.pi / 180))) / 2; + double latToRad(double lat) => + math.log( + (1 + math.sin(lat * math.pi / 180)) / + (1 - math.sin(lat * math.pi / 180)), + ) / + 2; - double computeZoom(double screenPx, double worldPx, double fraction) => math.log(screenPx / worldPx / fraction) / math.ln2; + double computeZoom(double screenPx, double worldPx, double fraction) => + math.log(screenPx / worldPx / fraction) / math.ln2; final north = bounds.northEast.latitude; final south = bounds.southWest.latitude; @@ -800,27 +1045,48 @@ class CabBookingController extends GetxController { final latFraction = (latToRad(north) - latToRad(south)) / math.pi; final lngFraction = ((east - west + 360) % 360) / 360; - final latZoom = computeZoom(screenSize.height, worldDimension, latFraction + paddingFraction); - final lngZoom = computeZoom(screenSize.width, worldDimension, lngFraction + paddingFraction); + final latZoom = computeZoom( + screenSize.height, + worldDimension, + latFraction + paddingFraction, + ); + final lngZoom = computeZoom( + screenSize.width, + worldDimension, + lngFraction + paddingFraction, + ); final zoomLevel = math.min(latZoom, lngZoom).clamp(0.0, maxZoom); mapOsmController.move(center, zoomLevel); } } - Future updateCameraLocation(LatLng source, LatLng destination, GoogleMapController? mapController) async { + Future updateCameraLocation( + LatLng source, + LatLng destination, + GoogleMapController? mapController, + ) async { if (mapController == null) return; final bounds = LatLngBounds( - southwest: LatLng(math.min(source.latitude, destination.latitude), math.min(source.longitude, destination.longitude)), - northeast: LatLng(math.max(source.latitude, destination.latitude), math.max(source.longitude, destination.longitude)), + southwest: LatLng( + math.min(source.latitude, destination.latitude), + math.min(source.longitude, destination.longitude), + ), + northeast: LatLng( + math.max(source.latitude, destination.latitude), + math.max(source.longitude, destination.longitude), + ), ); final cameraUpdate = CameraUpdate.newLatLngBounds(bounds, 90); await checkCameraLocation(cameraUpdate, mapController); } - Future checkCameraLocation(CameraUpdate cameraUpdate, GoogleMapController mapController) async { + Future checkCameraLocation( + CameraUpdate cameraUpdate, + GoogleMapController mapController, + ) async { await mapController.animateCamera(cameraUpdate); final l1 = await mapController.getVisibleRegion(); final l2 = await mapController.getVisibleRegion(); @@ -833,16 +1099,44 @@ class CabBookingController extends GetxController { Future setIcons() async { try { if (Constant.selectedMapType == 'osm') { - departureIconOsm = Image.asset("assets/icons/pickup.png", width: 30, height: 30); - destinationIconOsm = Image.asset("assets/icons/dropoff.png", width: 30, height: 30); - taxiIconOsm = Image.asset("assets/icons/ic_taxi.png", width: 30, height: 30); - stopIconOsm = Image.asset("assets/icons/location.png", width: 26, height: 26); + departureIconOsm = Image.asset( + "assets/icons/pickup.png", + width: 30, + height: 30, + ); + destinationIconOsm = Image.asset( + "assets/icons/dropoff.png", + width: 30, + height: 30, + ); + taxiIconOsm = Image.asset( + "assets/icons/ic_taxi.png", + width: 30, + height: 30, + ); + stopIconOsm = Image.asset( + "assets/icons/location.png", + width: 26, + height: 26, + ); } else { const config = ImageConfiguration(size: Size(48, 48)); - departureIcon = await BitmapDescriptor.fromAssetImage(config, "assets/icons/pickup.png"); - destinationIcon = await BitmapDescriptor.fromAssetImage(config, "assets/icons/dropoff.png"); - taxiIcon = await BitmapDescriptor.fromAssetImage(config, "assets/icons/ic_taxi.png"); - stopIcon = await BitmapDescriptor.fromAssetImage(config, "assets/icons/location.png"); + departureIcon = await BitmapDescriptor.fromAssetImage( + config, + "assets/icons/pickup.png", + ); + destinationIcon = await BitmapDescriptor.fromAssetImage( + config, + "assets/icons/dropoff.png", + ); + taxiIcon = await BitmapDescriptor.fromAssetImage( + config, + "assets/icons/ic_taxi.png", + ); + stopIcon = await BitmapDescriptor.fromAssetImage( + config, + "assets/icons/location.png", + ); } } catch (e) { print('Error loading icons: $e'); @@ -850,8 +1144,12 @@ class CabBookingController extends GetxController { } void clearMapDataIfLocationsRemoved() { - final isSourceEmpty = departureLatLongOsm.value.latitude == 0.0 && departureLatLongOsm.value.longitude == 0.0; - final isDestinationEmpty = destinationLatLongOsm.value.latitude == 0.0 && destinationLatLongOsm.value.longitude == 0.0; + final isSourceEmpty = + departureLatLongOsm.value.latitude == 0.0 && + departureLatLongOsm.value.longitude == 0.0; + final isDestinationEmpty = + destinationLatLongOsm.value.latitude == 0.0 && + destinationLatLongOsm.value.longitude == 0.0; if (isSourceEmpty || isDestinationEmpty) { // Clear polylines @@ -880,7 +1178,9 @@ class CabBookingController extends GetxController { // Remove marker if (Constant.selectedMapType == 'osm') { - osmMarker.removeWhere((marker) => marker.point == departureLatLongOsm.value); + osmMarker.removeWhere( + (marker) => marker.point == departureLatLongOsm.value, + ); } else { markers.removeWhere((marker) => marker.markerId.value == 'Departure'); } @@ -896,7 +1196,9 @@ class CabBookingController extends GetxController { destinationTextEditController.value.clear(); if (Constant.selectedMapType == 'osm') { - osmMarker.removeWhere((marker) => marker.point == destinationLatLongOsm.value); + osmMarker.removeWhere( + (marker) => marker.point == destinationLatLongOsm.value, + ); } else { markers.removeWhere((marker) => marker.markerId.value == 'Destination'); } @@ -906,9 +1208,16 @@ class CabBookingController extends GetxController { } Future searchPlaceNameOSM() async { - final url = Uri.parse('https://nominatim.openstreetmap.org/reverse?lat=${departureLatLongOsm.value.latitude}&lon=${departureLatLongOsm.value.longitude}&format=json'); + final url = Uri.parse( + 'https://nominatim.openstreetmap.org/reverse?lat=${departureLatLongOsm.value.latitude}&lon=${departureLatLongOsm.value.longitude}&format=json', + ); - final response = await http.get(url, headers: {'User-Agent': 'FlutterMapApp/1.0 (menil.siddhiinfosoft@gmail.com)'}); + final response = await http.get( + url, + headers: { + 'User-Agent': 'FlutterMapApp/1.0 (menil.siddhiinfosoft@gmail.com)', + }, + ); if (response.statusCode == 200) { log("response.body :: ${response.body}"); @@ -921,7 +1230,9 @@ class CabBookingController extends GetxController { final lat = departureLatLong.value.latitude; final lng = departureLatLong.value.longitude; - final url = Uri.parse('https://maps.googleapis.com/maps/api/geocode/json?latlng=$lat,$lng&key=${Constant.mapAPIKey}'); + final url = Uri.parse( + 'https://maps.googleapis.com/maps/api/geocode/json?latlng=$lat,$lng&key=${Constant.mapAPIKey}', + ); final response = await http.get(url); @@ -964,19 +1275,45 @@ class CabBookingController extends GetxController { Future getPaymentSettings() async { await FireStoreUtils.getPaymentSettingsData().then((value) { - stripeModel.value = StripeModel.fromJson(jsonDecode(Preferences.getString(Preferences.stripeSettings))); - payPalModel.value = PayPalModel.fromJson(jsonDecode(Preferences.getString(Preferences.paypalSettings))); - payStackModel.value = PayStackModel.fromJson(jsonDecode(Preferences.getString(Preferences.payStack))); - mercadoPagoModel.value = MercadoPagoModel.fromJson(jsonDecode(Preferences.getString(Preferences.mercadoPago))); - flutterWaveModel.value = FlutterWaveModel.fromJson(jsonDecode(Preferences.getString(Preferences.flutterWave))); - paytmModel.value = PaytmModel.fromJson(jsonDecode(Preferences.getString(Preferences.paytmSettings))); - payFastModel.value = PayFastModel.fromJson(jsonDecode(Preferences.getString(Preferences.payFastSettings))); - razorPayModel.value = RazorPayModel.fromJson(jsonDecode(Preferences.getString(Preferences.razorpaySettings))); - midTransModel.value = MidTrans.fromJson(jsonDecode(Preferences.getString(Preferences.midTransSettings))); - orangeMoneyModel.value = OrangeMoney.fromJson(jsonDecode(Preferences.getString(Preferences.orangeMoneySettings))); - xenditModel.value = Xendit.fromJson(jsonDecode(Preferences.getString(Preferences.xenditSettings))); - walletSettingModel.value = WalletSettingModel.fromJson(jsonDecode(Preferences.getString(Preferences.walletSettings))); - cashOnDeliverySettingModel.value = CodSettingModel.fromJson(jsonDecode(Preferences.getString(Preferences.codSettings))); + stripeModel.value = StripeModel.fromJson( + jsonDecode(Preferences.getString(Preferences.stripeSettings)), + ); + payPalModel.value = PayPalModel.fromJson( + jsonDecode(Preferences.getString(Preferences.paypalSettings)), + ); + payStackModel.value = PayStackModel.fromJson( + jsonDecode(Preferences.getString(Preferences.payStack)), + ); + mercadoPagoModel.value = MercadoPagoModel.fromJson( + jsonDecode(Preferences.getString(Preferences.mercadoPago)), + ); + flutterWaveModel.value = FlutterWaveModel.fromJson( + jsonDecode(Preferences.getString(Preferences.flutterWave)), + ); + paytmModel.value = PaytmModel.fromJson( + jsonDecode(Preferences.getString(Preferences.paytmSettings)), + ); + payFastModel.value = PayFastModel.fromJson( + jsonDecode(Preferences.getString(Preferences.payFastSettings)), + ); + razorPayModel.value = RazorPayModel.fromJson( + jsonDecode(Preferences.getString(Preferences.razorpaySettings)), + ); + midTransModel.value = MidTrans.fromJson( + jsonDecode(Preferences.getString(Preferences.midTransSettings)), + ); + orangeMoneyModel.value = OrangeMoney.fromJson( + jsonDecode(Preferences.getString(Preferences.orangeMoneySettings)), + ); + xenditModel.value = Xendit.fromJson( + jsonDecode(Preferences.getString(Preferences.xenditSettings)), + ); + walletSettingModel.value = WalletSettingModel.fromJson( + jsonDecode(Preferences.getString(Preferences.walletSettings)), + ); + cashOnDeliverySettingModel.value = CodSettingModel.fromJson( + jsonDecode(Preferences.getString(Preferences.codSettings)), + ); if (walletSettingModel.value.isEnabled == true) { selectedPaymentMethod.value = PaymentGateway.wallet.name; @@ -1018,20 +1355,32 @@ class CabBookingController extends GetxController { Future stripeMakePayment({required String amount}) async { log(double.parse(amount).toStringAsFixed(0)); try { - Map? paymentIntentData = await createStripeIntent(amount: amount); + Map? paymentIntentData = await createStripeIntent( + amount: amount, + ); log("stripe Responce====>$paymentIntentData"); if (paymentIntentData!.containsKey("error")) { Get.back(); - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); } else { await Stripe.instance.initPaymentSheet( paymentSheetParameters: SetupPaymentSheetParameters( paymentIntentClientSecret: paymentIntentData['client_secret'], allowsDelayedPaymentMethods: false, - googlePay: const PaymentSheetGooglePay(merchantCountryCode: 'US', testEnv: true, currencyCode: "USD"), + googlePay: const PaymentSheetGooglePay( + merchantCountryCode: 'US', + testEnv: true, + currencyCode: "USD", + ), customFlow: true, style: ThemeMode.system, - appearance: PaymentSheetAppearance(colors: PaymentSheetAppearanceColors(primary: AppThemeData.primary300)), + appearance: PaymentSheetAppearance( + colors: PaymentSheetAppearanceColors( + primary: AppThemeData.primary300, + ), + ), merchantDisplayName: 'GoRide', ), ); @@ -1077,7 +1426,10 @@ class CabBookingController extends GetxController { var response = await http.post( Uri.parse('https://api.stripe.com/v1/payment_intents'), body: body, - headers: {'Authorization': 'Bearer $stripeSecret', 'Content-Type': 'application/x-www-form-urlencoded'}, + headers: { + 'Authorization': 'Bearer $stripeSecret', + 'Content-Type': 'application/x-www-form-urlencoded', + }, ); return jsonDecode(response.body); @@ -1087,8 +1439,14 @@ class CabBookingController extends GetxController { } //mercadoo - Future mercadoPagoMakePayment({required BuildContext context, required String amount}) async { - final headers = {'Authorization': 'Bearer ${mercadoPagoModel.value.accessToken}', 'Content-Type': 'application/json'}; + Future mercadoPagoMakePayment({ + required BuildContext context, + required String amount, + }) async { + final headers = { + 'Authorization': 'Bearer ${mercadoPagoModel.value.accessToken}', + 'Content-Type': 'application/json', + }; final body = jsonEncode({ "items": [ @@ -1101,12 +1459,20 @@ class CabBookingController extends GetxController { }, ], "payer": {"email": userModel.value.email}, - "back_urls": {"failure": "${Constant.globalUrl}payment/failure", "pending": "${Constant.globalUrl}payment/pending", "success": "${Constant.globalUrl}payment/success"}, + "back_urls": { + "failure": "${Constant.globalUrl}payment/failure", + "pending": "${Constant.globalUrl}payment/pending", + "success": "${Constant.globalUrl}payment/success", + }, "auto_return": "approved", // Automatically return after payment is approved }); - final response = await http.post(Uri.parse("https://api.mercadopago.com/checkout/preferences"), headers: headers, body: body); + final response = await http.post( + Uri.parse("https://api.mercadopago.com/checkout/preferences"), + headers: headers, + body: body, + ); if (response.statusCode == 200 || response.statusCode == 201) { final data = jsonDecode(response.body); @@ -1164,9 +1530,12 @@ class CabBookingController extends GetxController { ///PayStack Payment Method Future payStackPayment(String totalAmount) async { - await PayStackURLGen.payStackURLGen(amount: (double.parse(totalAmount) * 100).toString(), currency: "ZAR", secretKey: payStackModel.value.secretKey.toString(), userModel: userModel.value).then(( - value, - ) async { + await PayStackURLGen.payStackURLGen( + amount: (double.parse(totalAmount) * 100).toString(), + currency: "ZAR", + secretKey: payStackModel.value.secretKey.toString(), + userModel: userModel.value, + ).then((value) async { if (value != null) { PayStackUrlModel payStackModel0 = value; Get.to( @@ -1186,15 +1555,23 @@ class CabBookingController extends GetxController { } }); } else { - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); } }); } //flutter wave Payment Method - Future flutterWaveInitiatePayment({required BuildContext context, required String amount}) async { + Future flutterWaveInitiatePayment({ + required BuildContext context, + required String amount, + }) async { final url = Uri.parse('https://api.flutterwave.com/v3/payments'); - final headers = {'Authorization': 'Bearer ${flutterWaveModel.value.secretKey}', 'Content-Type': 'application/json'}; + final headers = { + 'Authorization': 'Bearer ${flutterWaveModel.value.secretKey}', + 'Content-Type': 'application/json', + }; final body = jsonEncode({ "tx_ref": _ref, @@ -1207,14 +1584,19 @@ class CabBookingController extends GetxController { "phonenumber": userModel.value.phoneNumber, // Add a real phone number "name": userModel.value.fullName(), // Add a real customer name }, - "customizations": {"title": "Payment for Services", "description": "Payment for XYZ services"}, + "customizations": { + "title": "Payment for Services", + "description": "Payment for XYZ services", + }, }); final response = await http.post(url, headers: headers, body: body); if (response.statusCode == 200) { final data = jsonDecode(response.body); - Get.to(MercadoPagoScreen(initialURl: data['data']['link']))!.then((value) { + Get.to(MercadoPagoScreen(initialURl: data['data']['link']))!.then(( + value, + ) { if (value) { ShowToastDialog.showToast("Payment Successful!!".tr); completeOrder(); @@ -1243,8 +1625,14 @@ class CabBookingController extends GetxController { // payFast void payFastPayment({required BuildContext context, required String amount}) { - PayStackURLGen.getPayHTML(payFastSettingData: payFastModel.value, amount: amount.toString(), userModel: userModel.value).then((String? value) async { - bool isDone = await Get.to(PayFastScreen(htmlData: value!, payFastSettingData: payFastModel.value)); + PayStackURLGen.getPayHTML( + payFastSettingData: payFastModel.value, + amount: amount.toString(), + userModel: userModel.value, + ).then((String? value) async { + bool isDone = await Get.to( + PayFastScreen(htmlData: value!, payFastSettingData: payFastModel.value), + ); if (isDone) { Get.back(); ShowToastDialog.showToast("Payment successfully".tr); @@ -1283,7 +1671,14 @@ class CabBookingController extends GetxController { // }); } - Future startTransaction(context, {required String txnTokenBy, required orderId, required double amount, required callBackURL, required isStaging}) async { + Future startTransaction( + context, { + required String txnTokenBy, + required orderId, + required double amount, + required callBackURL, + required isStaging, + }) async { // try { // var response = AllInOneSdk.startTransaction( // paytmModel.value.paytmMID.toString(), @@ -1319,24 +1714,38 @@ class CabBookingController extends GetxController { // } } - Future verifyCheckSum({required String checkSum, required double amount, required orderId}) async { + Future verifyCheckSum({ + required String checkSum, + required double amount, + required orderId, + }) async { String getChecksum = "${Constant.globalUrl}payments/validatechecksum"; final response = await http.post( Uri.parse(getChecksum), headers: {}, - body: {"mid": paytmModel.value.paytmMID.toString(), "order_id": orderId, "key_secret": paytmModel.value.pAYTMMERCHANTKEY.toString(), "checksum_value": checkSum}, + body: { + "mid": paytmModel.value.paytmMID.toString(), + "order_id": orderId, + "key_secret": paytmModel.value.pAYTMMERCHANTKEY.toString(), + "checksum_value": checkSum, + }, ); final data = jsonDecode(response.body); return data['status']; } - Future initiatePayment({required double amount, required orderId}) async { + Future initiatePayment({ + required double amount, + required orderId, + }) async { String initiateURL = "${Constant.globalUrl}payments/initiatepaytmpayment"; String callback = ""; if (paytmModel.value.isSandboxEnabled == true) { - callback = "${callback}https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; + callback = + "${callback}https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; } else { - callback = "${callback}https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; + callback = + "${callback}https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; } final response = await http.post( Uri.parse(initiateURL), @@ -1354,9 +1763,12 @@ class CabBookingController extends GetxController { ); log(response.body); final data = jsonDecode(response.body); - if (data["body"]["txnToken"] == null || data["body"]["txnToken"].toString().isEmpty) { + if (data["body"]["txnToken"] == null || + data["body"]["txnToken"].toString().isEmpty) { Get.back(); - ShowToastDialog.showToast("something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "something went wrong, please contact admin.".tr, + ); } return GetPaymentTxtTokenModel.fromJson(data); } @@ -1374,7 +1786,10 @@ class CabBookingController extends GetxController { 'description': 'wallet Topup', 'retry': {'enabled': true, 'max_count': 1}, 'send_sms_hash': true, - 'prefill': {'contact': userModel.value.phoneNumber, 'email': userModel.value.email}, + 'prefill': { + 'contact': userModel.value.phoneNumber, + 'email': userModel.value.email, + }, 'external': { 'wallets': ['paytm'], }, @@ -1409,7 +1824,10 @@ class CabBookingController extends GetxController { } //Midtrans payment - Future midtransMakePayment({required String amount, required BuildContext context}) async { + Future midtransMakePayment({ + required String amount, + required BuildContext context, + }) async { await createPaymentLink(amount: amount).then((url) { ShowToastDialog.closeLoader(); if (url != '') { @@ -1427,15 +1845,30 @@ class CabBookingController extends GetxController { Future createPaymentLink({required var amount}) async { var ordersId = const Uuid().v1(); - final url = Uri.parse(midTransModel.value.isSandbox! ? 'https://api.sandbox.midtrans.com/v1/payment-links' : 'https://api.midtrans.com/v1/payment-links'); + final url = Uri.parse( + midTransModel.value.isSandbox! + ? 'https://api.sandbox.midtrans.com/v1/payment-links' + : 'https://api.midtrans.com/v1/payment-links', + ); final response = await http.post( url, - headers: {'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': generateBasicAuthHeader(midTransModel.value.serverKey!)}, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': generateBasicAuthHeader( + midTransModel.value.serverKey!, + ), + }, body: jsonEncode({ - 'transaction_details': {'order_id': ordersId, 'gross_amount': double.parse(amount.toString()).toInt()}, + 'transaction_details': { + 'order_id': ordersId, + 'gross_amount': double.parse(amount.toString()).toInt(), + }, 'usage_limit': 2, - "callbacks": {"finish": "https://www.google.com?merchant_order_id=$ordersId"}, + "callbacks": { + "finish": "https://www.google.com?merchant_order_id=$ordersId", + }, }), ); @@ -1443,7 +1876,9 @@ class CabBookingController extends GetxController { final responseData = jsonDecode(response.body); return responseData['payment_url']; } else { - ShowToastDialog.showToast("something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "something went wrong, please contact admin.".tr, + ); return ''; } } @@ -1460,13 +1895,30 @@ class CabBookingController extends GetxController { static String orderId = ''; static String amount = ''; - Future orangeMakePayment({required String amount, required BuildContext context}) async { + Future orangeMakePayment({ + required String amount, + required BuildContext context, + }) async { reset(); var id = const Uuid().v4(); - var paymentURL = await fetchToken(context: context, orderId: id, amount: amount, currency: 'USD'); + var paymentURL = await fetchToken( + context: context, + orderId: id, + amount: amount, + currency: 'USD', + ); ShowToastDialog.closeLoader(); if (paymentURL.toString() != '') { - Get.to(() => OrangeMoneyScreen(initialURl: paymentURL, accessToken: accessToken, amount: amount, orangePay: orangeMoneyModel.value, orderId: orderId, payToken: payToken))!.then((value) { + Get.to( + () => OrangeMoneyScreen( + initialURl: paymentURL, + accessToken: accessToken, + amount: amount, + orangePay: orangeMoneyModel.value, + orderId: orderId, + payToken: payToken, + ), + )!.then((value) { if (value == true) { ShowToastDialog.showToast("Payment Successful!!".tr); completeOrder(); @@ -1478,13 +1930,22 @@ class CabBookingController extends GetxController { } } - Future fetchToken({required String orderId, required String currency, required BuildContext context, required String amount}) async { + Future fetchToken({ + required String orderId, + required String currency, + required BuildContext context, + required String amount, + }) async { String apiUrl = 'https://api.orange.com/oauth/v3/token'; Map requestBody = {'grant_type': 'client_credentials'}; var response = await http.post( Uri.parse(apiUrl), - headers: {'Authorization': "Basic ${orangeMoneyModel.value.auth!}", 'Content-Type': 'application/x-www-form-urlencoded', 'Accept': 'application/json'}, + headers: { + 'Authorization': "Basic ${orangeMoneyModel.value.auth!}", + 'Content-Type': 'application/x-www-form-urlencoded', + 'Accept': 'application/json', + }, body: requestBody, ); @@ -1495,17 +1956,32 @@ class CabBookingController extends GetxController { accessToken = responseData['access_token']; // ignore: use_build_context_synchronously - return await webpayment(context: context, amountData: amount, currency: currency, orderIdData: orderId); + return await webpayment( + context: context, + amountData: amount, + currency: currency, + orderIdData: orderId, + ); } else { - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); return ''; } } - Future webpayment({required String orderIdData, required BuildContext context, required String currency, required String amountData}) async { + Future webpayment({ + required String orderIdData, + required BuildContext context, + required String currency, + required String amountData, + }) async { orderId = orderIdData; amount = amountData; - String apiUrl = orangeMoneyModel.value.isSandbox! == true ? 'https://api.orange.com/orange-money-webpay/dev/v1/webpayment' : 'https://api.orange.com/orange-money-webpay/cm/v1/webpayment'; + String apiUrl = + orangeMoneyModel.value.isSandbox! == true + ? 'https://api.orange.com/orange-money-webpay/dev/v1/webpayment' + : 'https://api.orange.com/orange-money-webpay/cm/v1/webpayment'; Map requestBody = { "merchant_key": orangeMoneyModel.value.merchantKey ?? '', "currency": orangeMoneyModel.value.isSandbox == true ? "OUV" : currency, @@ -1520,7 +1996,11 @@ class CabBookingController extends GetxController { var response = await http.post( Uri.parse(apiUrl), - headers: {'Authorization': 'Bearer $accessToken', 'Content-Type': 'application/json', 'Accept': 'application/json'}, + headers: { + 'Authorization': 'Bearer $accessToken', + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, body: json.encode(requestBody), ); @@ -1534,7 +2014,9 @@ class CabBookingController extends GetxController { return ''; } } else { - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); return ''; } } @@ -1551,7 +2033,13 @@ class CabBookingController extends GetxController { await createXenditInvoice(amount: amount).then((model) { ShowToastDialog.closeLoader(); if (model.id != null) { - Get.to(() => XenditScreen(initialURl: model.invoiceUrl ?? '', transId: model.id ?? '', apiKey: xenditModel.value.apiKey!.toString()))!.then((value) { + Get.to( + () => XenditScreen( + initialURl: model.invoiceUrl ?? '', + transId: model.id ?? '', + apiKey: xenditModel.value.apiKey!.toString(), + ), + )!.then((value) { if (value == true) { ShowToastDialog.showToast("Payment Successful!!".tr); completeOrder(); @@ -1568,7 +2056,9 @@ class CabBookingController extends GetxController { const url = 'https://api.xendit.co/v2/invoices'; var headers = { 'Content-Type': 'application/json', - 'Authorization': generateBasicAuthHeader(xenditModel.value.apiKey!.toString()), + 'Authorization': generateBasicAuthHeader( + xenditModel.value.apiKey!.toString(), + ), // 'Cookie': '__cf_bm=yERkrx3xDITyFGiou0bbKY1bi7xEwovHNwxV1vCNbVc-1724155511-1.0.1.1-jekyYQmPCwY6vIJ524K0V6_CEw6O.dAwOmQnHtwmaXO_MfTrdnmZMka0KZvjukQgXu5B.K_6FJm47SGOPeWviQ', }; @@ -1581,7 +2071,11 @@ class CabBookingController extends GetxController { }); try { - final response = await http.post(Uri.parse(url), headers: headers, body: body); + final response = await http.post( + Uri.parse(url), + headers: headers, + body: body, + ); if (response.statusCode == 200 || response.statusCode == 201) { XenditModel model = XenditModel.fromJson(jsonDecode(response.body)); diff --git a/lib/controllers/cab_coupon_code_controller.dart b/lib/controllers/cab_coupon_code_controller.dart index 8d57707..12dc0e1 100644 --- a/lib/controllers/cab_coupon_code_controller.dart +++ b/lib/controllers/cab_coupon_code_controller.dart @@ -12,10 +12,10 @@ class CabCouponCodeController extends GetxController { super.onInit(); } - - void getData(){ + void getData() { getCouponCode(); } + RxBool isLoading = true.obs; RxList cabCouponList = [].obs; diff --git a/lib/controllers/cab_dashboard_controller.dart b/lib/controllers/cab_dashboard_controller.dart index 309907f..dc8e92a 100644 --- a/lib/controllers/cab_dashboard_controller.dart +++ b/lib/controllers/cab_dashboard_controller.dart @@ -13,18 +13,28 @@ class CabDashboardController extends GetxController { @override void onInit() { - // TODO: implement onInit getTaxList(); if (Constant.walletSetting == false) { - pageList.value = [CabHomeScreen(), const MyCabBookingScreen(), const ProfileScreen()]; + pageList.value = [ + CabHomeScreen(), + const MyCabBookingScreen(), + const ProfileScreen(), + ]; } else { - pageList.value = [CabHomeScreen(), const MyCabBookingScreen(), const WalletScreen(), const ProfileScreen()]; + pageList.value = [ + CabHomeScreen(), + const MyCabBookingScreen(), + const WalletScreen(), + const ProfileScreen(), + ]; } super.onInit(); } Future getTaxList() async { - await FireStoreUtils.getTaxList(Constant.sectionConstantModel!.id).then((value) { + await FireStoreUtils.getTaxList(Constant.sectionConstantModel!.id).then(( + value, + ) { if (value != null) { Constant.taxList = value; } diff --git a/lib/controllers/cab_order_details_controller.dart b/lib/controllers/cab_order_details_controller.dart index 0106e98..a16cdfd 100644 --- a/lib/controllers/cab_order_details_controller.dart +++ b/lib/controllers/cab_order_details_controller.dart @@ -56,14 +56,18 @@ class CabOrderDetailsController extends GetxController { Future fetchDriverDetails() async { if (cabOrder.value.driverId != null) { - await FireStoreUtils.getUserProfile(cabOrder.value.driverId ?? '').then((value) { + await FireStoreUtils.getUserProfile(cabOrder.value.driverId ?? '').then(( + value, + ) { if (value != null) { driverUser.value = value; } }); print(driverUser.value.toJson()); - await FireStoreUtils.getReviewsbyID(cabOrder.value.id.toString()).then((value) { + await FireStoreUtils.getReviewsbyID(cabOrder.value.id.toString()).then(( + value, + ) { if (value != null) { ratingModel.value = value; } @@ -79,7 +83,12 @@ class CabOrderDetailsController extends GetxController { if (cabOrder.value.taxSetting != null) { for (var element in cabOrder.value.taxSetting!) { - taxAmount.value = (taxAmount.value + Constant.calculateTax(amount: (subTotal.value - discount.value).toString(), taxModel: element)); + taxAmount.value = + (taxAmount.value + + Constant.calculateTax( + amount: (subTotal.value - discount.value).toString(), + taxModel: element, + )); } } @@ -94,8 +103,20 @@ class CabOrderDetailsController extends GetxController { final destLng = cabOrder.value.destinationLocation!.longitude; googleMarkers.value = { - gmap.Marker(markerId: const gmap.MarkerId('source'), position: gmap.LatLng(sourceLat!, sourceLng!), icon: gmap.BitmapDescriptor.defaultMarkerWithHue(gmap.BitmapDescriptor.hueGreen)), - gmap.Marker(markerId: const gmap.MarkerId('destination'), position: gmap.LatLng(destLat!, destLng!), icon: gmap.BitmapDescriptor.defaultMarkerWithHue(gmap.BitmapDescriptor.hueRed)), + gmap.Marker( + markerId: const gmap.MarkerId('source'), + position: gmap.LatLng(sourceLat!, sourceLng!), + icon: gmap.BitmapDescriptor.defaultMarkerWithHue( + gmap.BitmapDescriptor.hueGreen, + ), + ), + gmap.Marker( + markerId: const gmap.MarkerId('destination'), + position: gmap.LatLng(destLat!, destLng!), + icon: gmap.BitmapDescriptor.defaultMarkerWithHue( + gmap.BitmapDescriptor.hueRed, + ), + ), }; } @@ -104,7 +125,8 @@ class CabOrderDetailsController extends GetxController { final src = cabOrder.value.sourceLocation; final dest = cabOrder.value.destinationLocation; - final url = "https://maps.googleapis.com/maps/api/directions/json?origin=${src!.latitude},${src.longitude}&destination=${dest!.latitude},${dest.longitude}&key=$googleApiKey"; + final url = + "https://maps.googleapis.com/maps/api/directions/json?origin=${src!.latitude},${src.longitude}&destination=${dest!.latitude},${dest.longitude}&key=$googleApiKey"; final response = await http.get(Uri.parse(url)); final data = jsonDecode(response.body); @@ -113,9 +135,19 @@ class CabOrderDetailsController extends GetxController { final points = data["routes"][0]["overview_polyline"]["points"]; final polylinePoints = PolylinePoints.decodePolyline(points); - final polylineCoords = polylinePoints.map((p) => gmap.LatLng(p.latitude, p.longitude)).toList(); + final polylineCoords = + polylinePoints + .map((p) => gmap.LatLng(p.latitude, p.longitude)) + .toList(); - googlePolylines.value = {gmap.Polyline(polylineId: const gmap.PolylineId("google_route"), color: AppThemeData.onDemandDark100, width: 5, points: polylineCoords)}; + googlePolylines.value = { + gmap.Polyline( + polylineId: const gmap.PolylineId("google_route"), + color: AppThemeData.onDemandDark100, + width: 5, + points: polylineCoords, + ), + }; } } @@ -124,15 +156,20 @@ class CabOrderDetailsController extends GetxController { final src = cabOrder.value.sourceLocation; final dest = cabOrder.value.destinationLocation; - final url = "http://router.project-osrm.org/route/v1/driving/${src!.longitude},${src.latitude};${dest!.longitude},${dest.latitude}?overview=full&geometries=geojson"; + final url = + "http://router.project-osrm.org/route/v1/driving/${src!.longitude},${src.latitude};${dest!.longitude},${dest.latitude}?overview=full&geometries=geojson"; final response = await http.get(Uri.parse(url)); final data = jsonDecode(response.body); if (data["routes"].isNotEmpty) { - final coords = data["routes"][0]["geometry"]["coordinates"] as List; + final coords = + data["routes"][0]["geometry"]["coordinates"] as List; - osmPolyline.value = coords.map((c) => osm.LatLng(c[1].toDouble(), c[0].toDouble())).toList(); + osmPolyline.value = + coords + .map((c) => osm.LatLng(c[1].toDouble(), c[0].toDouble())) + .toList(); } } } diff --git a/lib/controllers/cab_rental_dashboard_controllers.dart b/lib/controllers/cab_rental_dashboard_controllers.dart index add5017..c7f5b95 100644 --- a/lib/controllers/cab_rental_dashboard_controllers.dart +++ b/lib/controllers/cab_rental_dashboard_controllers.dart @@ -4,7 +4,6 @@ import 'package:customer/screen_ui/multi_vendor_service/wallet_screen/wallet_scr import 'package:customer/screen_ui/rental_service/rental_home_screen.dart'; import 'package:customer/service/fire_store_utils.dart'; import 'package:get/get.dart'; - import '../screen_ui/rental_service/my_rental_booking_screen.dart'; class CabRentalDashboardControllers extends GetxController { @@ -17,15 +16,26 @@ class CabRentalDashboardControllers extends GetxController { // TODO: implement onInit getTaxList(); if (Constant.walletSetting == false) { - pageList.value = [RentalHomeScreen(), MyRentalBookingScreen(), const ProfileScreen()]; + pageList.value = [ + RentalHomeScreen(), + MyRentalBookingScreen(), + const ProfileScreen(), + ]; } else { - pageList.value = [RentalHomeScreen(), MyRentalBookingScreen(), const WalletScreen(), const ProfileScreen()]; + pageList.value = [ + RentalHomeScreen(), + MyRentalBookingScreen(), + const WalletScreen(), + const ProfileScreen(), + ]; } super.onInit(); } Future getTaxList() async { - await FireStoreUtils.getTaxList(Constant.sectionConstantModel!.id).then((value) { + await FireStoreUtils.getTaxList(Constant.sectionConstantModel!.id).then(( + value, + ) { if (value != null) { Constant.taxList = value; } diff --git a/lib/controllers/cab_review_controller.dart b/lib/controllers/cab_review_controller.dart index 8815b61..baa473b 100644 --- a/lib/controllers/cab_review_controller.dart +++ b/lib/controllers/cab_review_controller.dart @@ -1,5 +1,6 @@ import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:customer/models/cab_order_model.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../constant/collection_name.dart'; @@ -43,12 +44,17 @@ class CabReviewController extends GetxController { } }); - await FireStoreUtils.getUserProfile(order.value?.driverId ?? '').then((value) { + await FireStoreUtils.getUserProfile(order.value?.driverId ?? '').then(( + value, + ) { if (value != null) { driverUser.value = value; - final int userReviewsCount = int.tryParse(driverUser.value!.reviewsCount?.toString() ?? "0") ?? 0; - final int userReviewsSum = int.tryParse(driverUser.value!.reviewsSum?.toString() ?? "0") ?? 0; + final int userReviewsCount = + int.tryParse(driverUser.value!.reviewsCount?.toString() ?? "0") ?? + 0; + final int userReviewsSum = + int.tryParse(driverUser.value!.reviewsSum?.toString() ?? "0") ?? 0; if (ratingModel.value != null) { final int oldRating = ratingModel.value?.rating?.toInt() ?? 0; @@ -73,7 +79,9 @@ class CabReviewController extends GetxController { ShowToastDialog.showLoader("Submit in...".tr); - final user = await FireStoreUtils.getUserProfile(order.value?.driverId ?? ''); + final user = await FireStoreUtils.getUserProfile( + order.value?.driverId ?? '', + ); if (user != null) { user.reviewsCount = (futureCount.value + 1).toString(); @@ -90,7 +98,8 @@ class CabReviewController extends GetxController { driverId: ratingModel.value!.driverId, customerId: ratingModel.value!.customerId, vendorId: ratingModel.value?.vendorId, - uname: "${Constant.userModel?.firstName ?? ''} ${Constant.userModel?.lastName ?? ''}", + uname: + "${Constant.userModel?.firstName ?? ''} ${Constant.userModel?.lastName ?? ''}", profile: Constant.userModel?.profilePictureURL, createdAt: Timestamp.now(), ); @@ -101,7 +110,8 @@ class CabReviewController extends GetxController { } } else { /// New review - final docRef = FireStoreUtils.fireStore.collection(CollectionName.itemsReview).doc(); + final docRef = + FireStoreUtils.fireStore.collection(CollectionName.itemsReview).doc(); final newRating = RatingModel( id: docRef.id, comment: comment.value.text, @@ -110,7 +120,8 @@ class CabReviewController extends GetxController { orderId: order.value?.id, driverId: order.value?.driverId.toString(), customerId: Constant.userModel?.id, - uname: "${Constant.userModel?.firstName ?? ''} ${Constant.userModel?.lastName ?? ''}", + uname: + "${Constant.userModel?.firstName ?? ''} ${Constant.userModel?.lastName ?? ''}", profile: Constant.userModel?.profilePictureURL, createdAt: Timestamp.now(), ); diff --git a/lib/controllers/cart_controller.dart b/lib/controllers/cart_controller.dart index 4335f0f..b4cbca6 100644 --- a/lib/controllers/cart_controller.dart +++ b/lib/controllers/cart_controller.dart @@ -4,6 +4,7 @@ import 'dart:io'; import 'dart:math' as maths; import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:customer/constant/const_texts.dart'; import 'package:customer/constant/constant.dart'; import 'package:customer/models/cart_product_model.dart'; import 'package:customer/models/coupon_model.dart'; @@ -13,6 +14,7 @@ import 'package:customer/models/user_model.dart'; import 'package:customer/models/vendor_model.dart'; import 'package:customer/themes/app_them_data.dart'; import 'package:customer/utils/preferences.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_paypal/flutter_paypal.dart'; import 'package:flutter_stripe/flutter_stripe.dart'; @@ -107,7 +109,9 @@ class CartController extends GetxController { cartItem.addAll(event); if (cartItem.isNotEmpty) { - await FireStoreUtils.getVendorById(cartItem.first.vendorID.toString()).then((value) { + await FireStoreUtils.getVendorById( + cartItem.first.vendorID.toString(), + ).then((value) { if (value != null) { vendorModel.value = value; } @@ -115,9 +119,14 @@ class CartController extends GetxController { } calculatePrice(); }); - selectedFoodType.value = Preferences.getString(Preferences.foodDeliveryType, defaultValue: "Delivery"); + selectedFoodType.value = Preferences.getString( + Preferences.foodDeliveryType, + defaultValue: "Delivery", + ); - await FireStoreUtils.getUserProfile(FireStoreUtils.getCurrentUid()).then((value) { + await FireStoreUtils.getUserProfile(FireStoreUtils.getCurrentUid()).then(( + value, + ) { if (value != null) { userModel.value = value; } @@ -126,16 +135,22 @@ class CartController extends GetxController { await FireStoreUtils.getDeliveryCharge().then((value) { if (value != null) { deliveryChargeModel.value = value; - print("===> Delivery Charge Model: ${deliveryChargeModel.value.toJson()}"); + print( + "===> Delivery Charge Model: ${deliveryChargeModel.value.toJson()}", + ); calculatePrice(); } }); - await FireStoreUtils.getAllVendorPublicCoupons(vendorModel.value.id.toString()).then((value) { + await FireStoreUtils.getAllVendorPublicCoupons( + vendorModel.value.id.toString(), + ).then((value) { couponList.value = value; }); - await FireStoreUtils.getAllVendorCoupons(vendorModel.value.id.toString()).then((value) { + await FireStoreUtils.getAllVendorCoupons( + vendorModel.value.id.toString(), + ).then((value) { allCouponList.value = value; }); } @@ -149,8 +164,11 @@ class CartController extends GetxController { totalAmount.value = 0.0; if (cartItem.isNotEmpty) { - if (Constant.sectionConstantModel!.serviceTypeFlag == "ecommerce-service") { - deliveryCharges.value = double.parse(Constant.sectionConstantModel!.delivery_charge ?? "0"); + if (Constant.sectionConstantModel!.serviceTypeFlag == + "ecommerce-service") { + deliveryCharges.value = double.parse( + Constant.sectionConstantModel!.delivery_charge ?? "0", + ); } else { if (selectedFoodType.value == "Delivery") { totalDistance.value = double.parse( @@ -161,26 +179,50 @@ class CartController extends GetxController { lng2: vendorModel.value.longitude.toString(), ), ); - if (vendorModel.value.isSelfDelivery == true && Constant.isSelfDeliveryFeature == true) { + if (vendorModel.value.isSelfDelivery == true && + Constant.isSelfDeliveryFeature == true) { deliveryCharges.value = 0.0; } else if (deliveryChargeModel.value.vendorCanModify == false) { - if (totalDistance.value > deliveryChargeModel.value.minimumDeliveryChargesWithinKm!) { - deliveryCharges.value = totalDistance.value * deliveryChargeModel.value.deliveryChargesPerKm!; + if (totalDistance.value > + deliveryChargeModel.value.minimumDeliveryChargesWithinKm!) { + deliveryCharges.value = + totalDistance.value * + deliveryChargeModel.value.deliveryChargesPerKm!; } else { - deliveryCharges.value = (deliveryChargeModel.value.minimumDeliveryCharges)!.toDouble(); + deliveryCharges.value = + (deliveryChargeModel.value.minimumDeliveryCharges)! + .toDouble(); } } else { if (vendorModel.value.deliveryCharge != null) { - if (totalDistance.value > vendorModel.value.deliveryCharge!.minimumDeliveryChargesWithinKm!) { - deliveryCharges.value = (totalDistance.value * vendorModel.value.deliveryCharge!.deliveryChargesPerKm!).toDouble(); + if (totalDistance.value > + vendorModel + .value + .deliveryCharge! + .minimumDeliveryChargesWithinKm!) { + deliveryCharges.value = + (totalDistance.value * + vendorModel + .value + .deliveryCharge! + .deliveryChargesPerKm!) + .toDouble(); } else { - deliveryCharges.value = vendorModel.value.deliveryCharge!.minimumDeliveryCharges!.toDouble(); + deliveryCharges.value = + vendorModel.value.deliveryCharge!.minimumDeliveryCharges! + .toDouble(); } } else { - if (totalDistance.value > deliveryChargeModel.value.minimumDeliveryChargesWithinKm!) { - deliveryCharges.value = (totalDistance.value * deliveryChargeModel.value.deliveryChargesPerKm!).toDouble(); + if (totalDistance.value > + deliveryChargeModel.value.minimumDeliveryChargesWithinKm!) { + deliveryCharges.value = + (totalDistance.value * + deliveryChargeModel.value.deliveryChargesPerKm!) + .toDouble(); } else { - deliveryCharges.value = deliveryChargeModel.value.minimumDeliveryCharges!.toDouble(); + deliveryCharges.value = + deliveryChargeModel.value.minimumDeliveryCharges! + .toDouble(); } } } @@ -194,21 +236,29 @@ class CartController extends GetxController { if (double.parse(element.discountPrice.toString()) <= 0) { subTotal.value = subTotal.value + - double.parse(element.price.toString()) * double.parse(element.quantity.toString()) + - (double.parse(element.extrasPrice.toString()) * double.parse(element.quantity.toString())); + double.parse(element.price.toString()) * + double.parse(element.quantity.toString()) + + (double.parse(element.extrasPrice.toString()) * + double.parse(element.quantity.toString())); } else { subTotal.value = subTotal.value + - double.parse(element.discountPrice.toString()) * double.parse(element.quantity.toString()) + - (double.parse(element.extrasPrice.toString()) * double.parse(element.quantity.toString())); + double.parse(element.discountPrice.toString()) * + double.parse(element.quantity.toString()) + + (double.parse(element.extrasPrice.toString()) * + double.parse(element.quantity.toString())); } } if (selectedCouponModel.value.id != null) { - couponAmount.value = Constant.calculateDiscount(amount: subTotal.value.toString(), offerModel: selectedCouponModel.value); + couponAmount.value = Constant.calculateDiscount( + amount: subTotal.value.toString(), + offerModel: selectedCouponModel.value, + ); } - if (vendorModel.value.specialDiscountEnable == true && Constant.specialDiscountOffer == true) { + if (vendorModel.value.specialDiscountEnable == true && + Constant.specialDiscountOffer == true) { final now = DateTime.now(); var day = DateFormat('EEEE', 'en_US').format(now); var date = DateFormat('dd-MM-yyyy').format(now); @@ -217,13 +267,20 @@ class CartController extends GetxController { if (element.timeslot!.isNotEmpty) { for (var element in element.timeslot!) { if (element.discountType == "delivery") { - var start = DateFormat("dd-MM-yyyy HH:mm").parse("$date ${element.from}"); - var end = DateFormat("dd-MM-yyyy HH:mm").parse("$date ${element.to}"); + var start = DateFormat( + "dd-MM-yyyy HH:mm", + ).parse("$date ${element.from}"); + var end = DateFormat( + "dd-MM-yyyy HH:mm", + ).parse("$date ${element.to}"); if (isCurrentDateInRange(start, end)) { - specialDiscount.value = double.parse(element.discount.toString()); + specialDiscount.value = double.parse( + element.discount.toString(), + ); specialType.value = element.type.toString(); if (element.type == "percentage") { - specialDiscountAmount.value = subTotal * specialDiscount.value / 100; + specialDiscountAmount.value = + subTotal * specialDiscount.value / 100; } else { specialDiscountAmount.value = specialDiscount.value; } @@ -239,10 +296,23 @@ class CartController extends GetxController { } for (var element in Constant.taxList) { - taxAmount.value = taxAmount.value + Constant.calculateTax(amount: (subTotal.value - couponAmount.value - specialDiscountAmount.value).toString(), taxModel: element); + taxAmount.value = + taxAmount.value + + Constant.calculateTax( + amount: + (subTotal.value - + couponAmount.value - + specialDiscountAmount.value) + .toString(), + taxModel: element, + ); } - totalAmount.value = (subTotal.value - couponAmount.value - specialDiscountAmount.value) + taxAmount.value + deliveryCharges.value + deliveryTips.value; + totalAmount.value = + (subTotal.value - couponAmount.value - specialDiscountAmount.value) + + taxAmount.value + + deliveryCharges.value + + deliveryTips.value; getCashback(); } @@ -263,17 +333,31 @@ class CartController extends GetxController { if (startDate == null || endDate == null) continue; - final withinDateRange = startDate.toDate().isBefore(now) && endDate.toDate().isAfter(now); - final meetsMinAmount = orderTotal >= (cashback.minimumPurchaseAmount ?? 0); + final withinDateRange = + startDate.toDate().isBefore(now) && endDate.toDate().isAfter(now); + final meetsMinAmount = + orderTotal >= (cashback.minimumPurchaseAmount ?? 0); final allPayment = cashback.allPayment ?? false; - final paymentMatch = allPayment || (cashback.paymentMethods ?? []).contains(paymentMethod); + final paymentMatch = + allPayment || + (cashback.paymentMethods ?? []).contains(paymentMethod); final allCustomer = cashback.allCustomer ?? false; - final customerMatch = allCustomer || (cashback.customerIds ?? []).contains(FireStoreUtils.getCurrentUid()); + final customerMatch = + allCustomer || + (cashback.customerIds ?? []).contains( + FireStoreUtils.getCurrentUid(), + ); - final redeemData = await FireStoreUtils.getRedeemedCashbacks(cashback.id ?? ''); + final redeemData = await FireStoreUtils.getRedeemedCashbacks( + cashback.id ?? '', + ); final underLimit = redeemData.length < (cashback.redeemLimit ?? 0); - if (withinDateRange && meetsMinAmount && paymentMatch && customerMatch && underLimit) { + if (withinDateRange && + meetsMinAmount && + paymentMatch && + customerMatch && + underLimit) { eligibleCashbacks.add(cashback); } } @@ -311,7 +395,11 @@ class CartController extends GetxController { } } - Future addToCart({required CartProductModel cartProductModel, required bool isIncrement, required int quantity}) async { + Future addToCart({ + required CartProductModel cartProductModel, + required bool isIncrement, + required int quantity, + }) async { if (isIncrement) { cartProvider.addToCart(Get.context!, cartProductModel, quantity); } else { @@ -324,10 +412,13 @@ class CartController extends GetxController { Future placeOrder() async { if (selectedPaymentMethod.value == PaymentGateway.wallet.name) { - if (double.parse(userModel.value.walletAmount.toString()) >= totalAmount.value) { + if (double.parse(userModel.value.walletAmount.toString()) >= + totalAmount.value) { setOrder(); } else { - ShowToastDialog.showToast("You don't have sufficient wallet balance to place order".tr); + ShowToastDialog.showToast( + "You don't have sufficient wallet balance to place order".tr, + ); } } else { setOrder(); @@ -335,13 +426,21 @@ class CartController extends GetxController { } Future setOrder() async { - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); - if ((Constant.isSubscriptionModelApplied == true || Constant.sectionConstantModel?.adminCommision?.isEnabled == true) && vendorModel.value.subscriptionPlan != null) { - await FireStoreUtils.getVendorById(vendorModel.value.id!).then((vender) async { - if (vender?.subscriptionTotalOrders == '0' || vender?.subscriptionTotalOrders == null) { + if ((Constant.isSubscriptionModelApplied == true || + Constant.sectionConstantModel?.adminCommision?.isEnabled == true) && + vendorModel.value.subscriptionPlan != null) { + await FireStoreUtils.getVendorById(vendorModel.value.id!).then(( + vender, + ) async { + if (vender?.subscriptionTotalOrders == '0' || + vender?.subscriptionTotalOrders == null) { ShowToastDialog.closeLoader(); - ShowToastDialog.showToast("This vendor has reached their maximum order capacity. Please select a different vendor or try again later.".tr); + ShowToastDialog.showToast( + "This vendor has reached their maximum order capacity. Please select a different vendor or try again later." + .tr, + ); return; } }); @@ -355,7 +454,11 @@ class CartController extends GetxController { tempProduc.add(tempCart); } - Map specialDiscountMap = {'special_discount': specialDiscountAmount.value, 'special_discount_label': specialDiscount.value, 'specialType': specialType.value}; + Map specialDiscountMap = { + 'special_discount': specialDiscountAmount.value, + 'special_discount_label': specialDiscount.value, + 'specialType': specialType.value, + }; OrderModel orderModel = OrderModel(); orderModel.id = Constant.getUuid(); @@ -390,8 +493,12 @@ class CartController extends GetxController { orderModel.notes = reMarkController.value.text; orderModel.takeAway = selectedFoodType.value == "Delivery" ? false : true; orderModel.createdAt = Timestamp.now(); - orderModel.scheduleTime = deliveryType.value == "schedule" ? Timestamp.fromDate(scheduleDateTime.value) : null; - orderModel.cashback = bestCashback.value.id == null ? null : bestCashback.value; + orderModel.scheduleTime = + deliveryType.value == "schedule" + ? Timestamp.fromDate(scheduleDateTime.value) + : null; + orderModel.cashback = + bestCashback.value.id == null ? null : bestCashback.value; if (selectedPaymentMethod.value == PaymentGateway.wallet.name) { WalletTransactionModel transactionModel = WalletTransactionModel( id: Constant.getUuid(), @@ -406,33 +513,57 @@ class CartController extends GetxController { paymentStatus: "success".tr, ); - await FireStoreUtils.setWalletTransaction(transactionModel).then((value) async { + await FireStoreUtils.setWalletTransaction(transactionModel).then(( + value, + ) async { if (value == true) { - await FireStoreUtils.updateUserWallet(amount: "-${totalAmount.value.toString()}", userId: FireStoreUtils.getCurrentUid()).then((value) {}); + await FireStoreUtils.updateUserWallet( + amount: "-${totalAmount.value.toString()}", + userId: FireStoreUtils.getCurrentUid(), + ).then((value) {}); } }); } for (int i = 0; i < tempProduc.length; i++) { - await FireStoreUtils.getProductById(tempProduc[i].id!.split('~').first).then((value) async { + await FireStoreUtils.getProductById( + tempProduc[i].id!.split('~').first, + ).then((value) async { ProductModel? productModel = value; if (tempProduc[i].variantInfo != null) { if (productModel!.itemAttribute != null) { - for (int j = 0; j < productModel.itemAttribute!.variants!.length; j++) { - if (productModel.itemAttribute!.variants![j].variantId == tempProduc[i].id!.split('~').last) { - if (productModel.itemAttribute!.variants![j].variantQuantity != "-1") { - productModel.itemAttribute!.variants![j].variantQuantity = (int.parse(productModel.itemAttribute!.variants![j].variantQuantity.toString()) - tempProduc[i].quantity!).toString(); + for ( + int j = 0; + j < productModel.itemAttribute!.variants!.length; + j++ + ) { + if (productModel.itemAttribute!.variants![j].variantId == + tempProduc[i].id!.split('~').last) { + if (productModel.itemAttribute!.variants![j].variantQuantity != + "-1") { + productModel.itemAttribute!.variants![j].variantQuantity = + (int.parse( + productModel + .itemAttribute! + .variants![j] + .variantQuantity + .toString(), + ) - + tempProduc[i].quantity!) + .toString(); } } } } else { if (productModel.quantity != -1) { - productModel.quantity = (productModel.quantity! - tempProduc[i].quantity!); + productModel.quantity = + (productModel.quantity! - tempProduc[i].quantity!); } } } else { if (productModel!.quantity != -1) { - productModel.quantity = (productModel.quantity! - tempProduc[i].quantity!); + productModel.quantity = + (productModel.quantity! - tempProduc[i].quantity!); } } @@ -450,18 +581,31 @@ class CartController extends GetxController { await FireStoreUtils.setCashbackRedeemModel(cashbackRedeemModel); } await FireStoreUtils.setOrder(orderModel).then((value) async { - await FireStoreUtils.getUserProfile(orderModel.vendor!.author.toString()).then((value) async { + await FireStoreUtils.getUserProfile( + orderModel.vendor!.author.toString(), + ).then((value) async { if (value != null) { if (orderModel.scheduleTime != null) { - await SendNotification.sendFcmMessage(Constant.scheduleOrder, value.fcmToken ?? '', {}); + await SendNotification.sendFcmMessage( + Constant.scheduleOrder, + value.fcmToken ?? '', + {}, + ); } else { - await SendNotification.sendFcmMessage(Constant.newOrderPlaced, value.fcmToken ?? '', {}); + await SendNotification.sendFcmMessage( + Constant.newOrderPlaced, + value.fcmToken ?? '', + {}, + ); } } }); await Constant.sendOrderEmail(orderModel: orderModel); ShowToastDialog.closeLoader(); - Get.off(const OrderPlacingScreen(), arguments: {"orderModel": orderModel}); + Get.off( + const OrderPlacingScreen(), + arguments: {"orderModel": orderModel}, + ); }); } @@ -482,19 +626,45 @@ class CartController extends GetxController { Future getPaymentSettings() async { await FireStoreUtils.getPaymentSettingsData().then((value) { - stripeModel.value = StripeModel.fromJson(jsonDecode(Preferences.getString(Preferences.stripeSettings))); - payPalModel.value = PayPalModel.fromJson(jsonDecode(Preferences.getString(Preferences.paypalSettings))); - payStackModel.value = PayStackModel.fromJson(jsonDecode(Preferences.getString(Preferences.payStack))); - mercadoPagoModel.value = MercadoPagoModel.fromJson(jsonDecode(Preferences.getString(Preferences.mercadoPago))); - flutterWaveModel.value = FlutterWaveModel.fromJson(jsonDecode(Preferences.getString(Preferences.flutterWave))); - paytmModel.value = PaytmModel.fromJson(jsonDecode(Preferences.getString(Preferences.paytmSettings))); - payFastModel.value = PayFastModel.fromJson(jsonDecode(Preferences.getString(Preferences.payFastSettings))); - razorPayModel.value = RazorPayModel.fromJson(jsonDecode(Preferences.getString(Preferences.razorpaySettings))); - midTransModel.value = MidTrans.fromJson(jsonDecode(Preferences.getString(Preferences.midTransSettings))); - orangeMoneyModel.value = OrangeMoney.fromJson(jsonDecode(Preferences.getString(Preferences.orangeMoneySettings))); - xenditModel.value = Xendit.fromJson(jsonDecode(Preferences.getString(Preferences.xenditSettings))); - walletSettingModel.value = WalletSettingModel.fromJson(jsonDecode(Preferences.getString(Preferences.walletSettings))); - cashOnDeliverySettingModel.value = CodSettingModel.fromJson(jsonDecode(Preferences.getString(Preferences.codSettings))); + stripeModel.value = StripeModel.fromJson( + jsonDecode(Preferences.getString(Preferences.stripeSettings)), + ); + payPalModel.value = PayPalModel.fromJson( + jsonDecode(Preferences.getString(Preferences.paypalSettings)), + ); + payStackModel.value = PayStackModel.fromJson( + jsonDecode(Preferences.getString(Preferences.payStack)), + ); + mercadoPagoModel.value = MercadoPagoModel.fromJson( + jsonDecode(Preferences.getString(Preferences.mercadoPago)), + ); + flutterWaveModel.value = FlutterWaveModel.fromJson( + jsonDecode(Preferences.getString(Preferences.flutterWave)), + ); + paytmModel.value = PaytmModel.fromJson( + jsonDecode(Preferences.getString(Preferences.paytmSettings)), + ); + payFastModel.value = PayFastModel.fromJson( + jsonDecode(Preferences.getString(Preferences.payFastSettings)), + ); + razorPayModel.value = RazorPayModel.fromJson( + jsonDecode(Preferences.getString(Preferences.razorpaySettings)), + ); + midTransModel.value = MidTrans.fromJson( + jsonDecode(Preferences.getString(Preferences.midTransSettings)), + ); + orangeMoneyModel.value = OrangeMoney.fromJson( + jsonDecode(Preferences.getString(Preferences.orangeMoneySettings)), + ); + xenditModel.value = Xendit.fromJson( + jsonDecode(Preferences.getString(Preferences.xenditSettings)), + ); + walletSettingModel.value = WalletSettingModel.fromJson( + jsonDecode(Preferences.getString(Preferences.walletSettings)), + ); + cashOnDeliverySettingModel.value = CodSettingModel.fromJson( + jsonDecode(Preferences.getString(Preferences.codSettings)), + ); if (walletSettingModel.value.isEnabled == true) { selectedPaymentMethod.value = PaymentGateway.wallet.name; @@ -536,20 +706,32 @@ class CartController extends GetxController { Future stripeMakePayment({required String amount}) async { log(double.parse(amount).toStringAsFixed(0)); try { - Map? paymentIntentData = await createStripeIntent(amount: amount); + Map? paymentIntentData = await createStripeIntent( + amount: amount, + ); log("stripe Responce====>$paymentIntentData"); if (paymentIntentData!.containsKey("error")) { Get.back(); - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); } else { await Stripe.instance.initPaymentSheet( paymentSheetParameters: SetupPaymentSheetParameters( paymentIntentClientSecret: paymentIntentData['client_secret'], allowsDelayedPaymentMethods: false, - googlePay: const PaymentSheetGooglePay(merchantCountryCode: 'US', testEnv: true, currencyCode: "USD"), + googlePay: const PaymentSheetGooglePay( + merchantCountryCode: 'US', + testEnv: true, + currencyCode: "USD", + ), customFlow: true, style: ThemeMode.system, - appearance: PaymentSheetAppearance(colors: PaymentSheetAppearanceColors(primary: AppThemeData.primary300)), + appearance: PaymentSheetAppearance( + colors: PaymentSheetAppearanceColors( + primary: AppThemeData.primary300, + ), + ), merchantDisplayName: 'GoRide', ), ); @@ -595,7 +777,10 @@ class CartController extends GetxController { var response = await http.post( Uri.parse('https://api.stripe.com/v1/payment_intents'), body: body, - headers: {'Authorization': 'Bearer $stripeSecret', 'Content-Type': 'application/x-www-form-urlencoded'}, + headers: { + 'Authorization': 'Bearer $stripeSecret', + 'Content-Type': 'application/x-www-form-urlencoded', + }, ); return jsonDecode(response.body); @@ -605,8 +790,14 @@ class CartController extends GetxController { } //mercadoo - Future mercadoPagoMakePayment({required BuildContext context, required String amount}) async { - final headers = {'Authorization': 'Bearer ${mercadoPagoModel.value.accessToken}', 'Content-Type': 'application/json'}; + Future mercadoPagoMakePayment({ + required BuildContext context, + required String amount, + }) async { + final headers = { + 'Authorization': 'Bearer ${mercadoPagoModel.value.accessToken}', + 'Content-Type': 'application/json', + }; final body = jsonEncode({ "items": [ @@ -619,12 +810,20 @@ class CartController extends GetxController { }, ], "payer": {"email": userModel.value.email}, - "back_urls": {"failure": "${Constant.globalUrl}payment/failure", "pending": "${Constant.globalUrl}payment/pending", "success": "${Constant.globalUrl}payment/success"}, + "back_urls": { + "failure": "${Constant.globalUrl}payment/failure", + "pending": "${Constant.globalUrl}payment/pending", + "success": "${Constant.globalUrl}payment/success", + }, "auto_return": "approved", // Automatically return after payment is approved }); - final response = await http.post(Uri.parse("https://api.mercadopago.com/checkout/preferences"), headers: headers, body: body); + final response = await http.post( + Uri.parse("https://api.mercadopago.com/checkout/preferences"), + headers: headers, + body: body, + ); if (response.statusCode == 200 || response.statusCode == 201) { final data = jsonDecode(response.body); @@ -682,9 +881,12 @@ class CartController extends GetxController { ///PayStack Payment Method Future payStackPayment(String totalAmount) async { - await PayStackURLGen.payStackURLGen(amount: (double.parse(totalAmount) * 100).toString(), currency: "ZAR", secretKey: payStackModel.value.secretKey.toString(), userModel: userModel.value).then(( - value, - ) async { + await PayStackURLGen.payStackURLGen( + amount: (double.parse(totalAmount) * 100).toString(), + currency: "ZAR", + secretKey: payStackModel.value.secretKey.toString(), + userModel: userModel.value, + ).then((value) async { if (value != null) { PayStackUrlModel payStackModel0 = value; Get.to( @@ -704,15 +906,23 @@ class CartController extends GetxController { } }); } else { - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); } }); } //flutter wave Payment Method - Future flutterWaveInitiatePayment({required BuildContext context, required String amount}) async { + Future flutterWaveInitiatePayment({ + required BuildContext context, + required String amount, + }) async { final url = Uri.parse('https://api.flutterwave.com/v3/payments'); - final headers = {'Authorization': 'Bearer ${flutterWaveModel.value.secretKey}', 'Content-Type': 'application/json'}; + final headers = { + 'Authorization': 'Bearer ${flutterWaveModel.value.secretKey}', + 'Content-Type': 'application/json', + }; final body = jsonEncode({ "tx_ref": _ref, @@ -725,14 +935,19 @@ class CartController extends GetxController { "phonenumber": userModel.value.phoneNumber, // Add a real phone number "name": userModel.value.fullName(), // Add a real customer name }, - "customizations": {"title": "Payment for Services", "description": "Payment for XYZ services"}, + "customizations": { + "title": "Payment for Services", + "description": "Payment for XYZ services", + }, }); final response = await http.post(url, headers: headers, body: body); if (response.statusCode == 200) { final data = jsonDecode(response.body); - Get.to(MercadoPagoScreen(initialURl: data['data']['link']))!.then((value) { + Get.to(MercadoPagoScreen(initialURl: data['data']['link']))!.then(( + value, + ) { if (value) { ShowToastDialog.showToast("Payment Successful!!".tr); placeOrder(); @@ -761,8 +976,14 @@ class CartController extends GetxController { // payFast void payFastPayment({required BuildContext context, required String amount}) { - PayStackURLGen.getPayHTML(payFastSettingData: payFastModel.value, amount: amount.toString(), userModel: userModel.value).then((String? value) async { - bool isDone = await Get.to(PayFastScreen(htmlData: value!, payFastSettingData: payFastModel.value)); + PayStackURLGen.getPayHTML( + payFastSettingData: payFastModel.value, + amount: amount.toString(), + userModel: userModel.value, + ).then((String? value) async { + bool isDone = await Get.to( + PayFastScreen(htmlData: value!, payFastSettingData: payFastModel.value), + ); if (isDone) { Get.back(); ShowToastDialog.showToast("Payment successfully".tr); @@ -782,26 +1003,50 @@ class CartController extends GetxController { final response = await http.post( Uri.parse(getChecksum), headers: {}, - body: {"mid": paytmModel.value.paytmMID.toString(), "order_id": orderId, "key_secret": paytmModel.value.pAYTMMERCHANTKEY.toString()}, + body: { + "mid": paytmModel.value.paytmMID.toString(), + "order_id": orderId, + "key_secret": paytmModel.value.pAYTMMERCHANTKEY.toString(), + }, ); final data = jsonDecode(response.body); - await verifyCheckSum(checkSum: data["code"], amount: amount, orderId: orderId).then((value) { + await verifyCheckSum( + checkSum: data["code"], + amount: amount, + orderId: orderId, + ).then((value) { initiatePayment(amount: amount, orderId: orderId).then((value) { String callback = ""; if (paytmModel.value.isSandboxEnabled == true) { - callback = "${callback}https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; + callback = + "${callback}https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; } else { - callback = "${callback}https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; + callback = + "${callback}https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; } GetPaymentTxtTokenModel result = value; - startTransaction(context, txnTokenBy: result.body.txnToken ?? '', orderId: orderId, amount: amount, callBackURL: callback, isStaging: paytmModel.value.isSandboxEnabled); + startTransaction( + context, + txnTokenBy: result.body.txnToken ?? '', + orderId: orderId, + amount: amount, + callBackURL: callback, + isStaging: paytmModel.value.isSandboxEnabled, + ); }); }); } - Future startTransaction(context, {required String txnTokenBy, required orderId, required double amount, required callBackURL, required isStaging}) async { + Future startTransaction( + context, { + required String txnTokenBy, + required orderId, + required double amount, + required callBackURL, + required isStaging, + }) async { // try { // var response = AllInOneSdk.startTransaction( // paytmModel.value.paytmMID.toString(), @@ -837,24 +1082,38 @@ class CartController extends GetxController { // } } - Future verifyCheckSum({required String checkSum, required double amount, required orderId}) async { + Future verifyCheckSum({ + required String checkSum, + required double amount, + required orderId, + }) async { String getChecksum = "${Constant.globalUrl}payments/validatechecksum"; final response = await http.post( Uri.parse(getChecksum), headers: {}, - body: {"mid": paytmModel.value.paytmMID.toString(), "order_id": orderId, "key_secret": paytmModel.value.pAYTMMERCHANTKEY.toString(), "checksum_value": checkSum}, + body: { + "mid": paytmModel.value.paytmMID.toString(), + "order_id": orderId, + "key_secret": paytmModel.value.pAYTMMERCHANTKEY.toString(), + "checksum_value": checkSum, + }, ); final data = jsonDecode(response.body); return data['status']; } - Future initiatePayment({required double amount, required orderId}) async { + Future initiatePayment({ + required double amount, + required orderId, + }) async { String initiateURL = "${Constant.globalUrl}payments/initiatepaytmpayment"; String callback = ""; if (paytmModel.value.isSandboxEnabled == true) { - callback = "${callback}https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; + callback = + "${callback}https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; } else { - callback = "${callback}https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; + callback = + "${callback}https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; } final response = await http.post( Uri.parse(initiateURL), @@ -872,9 +1131,12 @@ class CartController extends GetxController { ); log(response.body); final data = jsonDecode(response.body); - if (data["body"]["txnToken"] == null || data["body"]["txnToken"].toString().isEmpty) { + if (data["body"]["txnToken"] == null || + data["body"]["txnToken"].toString().isEmpty) { Get.back(); - ShowToastDialog.showToast("something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "something went wrong, please contact admin.".tr, + ); } return GetPaymentTxtTokenModel.fromJson(data); } @@ -892,7 +1154,10 @@ class CartController extends GetxController { 'description': 'wallet Topup', 'retry': {'enabled': true, 'max_count': 1}, 'send_sms_hash': true, - 'prefill': {'contact': userModel.value.phoneNumber, 'email': userModel.value.email}, + 'prefill': { + 'contact': userModel.value.phoneNumber, + 'email': userModel.value.email, + }, 'external': { 'wallets': ['paytm'], }, @@ -926,7 +1191,10 @@ class CartController extends GetxController { } //Midtrans payment - Future midtransMakePayment({required String amount, required BuildContext context}) async { + Future midtransMakePayment({ + required String amount, + required BuildContext context, + }) async { await createPaymentLink(amount: amount).then((url) { ShowToastDialog.closeLoader(); if (url != '') { @@ -944,15 +1212,30 @@ class CartController extends GetxController { Future createPaymentLink({required var amount}) async { var ordersId = const Uuid().v1(); - final url = Uri.parse(midTransModel.value.isSandbox! ? 'https://api.sandbox.midtrans.com/v1/payment-links' : 'https://api.midtrans.com/v1/payment-links'); + final url = Uri.parse( + midTransModel.value.isSandbox! + ? 'https://api.sandbox.midtrans.com/v1/payment-links' + : 'https://api.midtrans.com/v1/payment-links', + ); final response = await http.post( url, - headers: {'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': generateBasicAuthHeader(midTransModel.value.serverKey!)}, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': generateBasicAuthHeader( + midTransModel.value.serverKey!, + ), + }, body: jsonEncode({ - 'transaction_details': {'order_id': ordersId, 'gross_amount': double.parse(amount.toString()).toInt()}, + 'transaction_details': { + 'order_id': ordersId, + 'gross_amount': double.parse(amount.toString()).toInt(), + }, 'usage_limit': 2, - "callbacks": {"finish": "https://www.google.com?merchant_order_id=$ordersId"}, + "callbacks": { + "finish": "https://www.google.com?merchant_order_id=$ordersId", + }, }), ); @@ -960,7 +1243,9 @@ class CartController extends GetxController { final responseData = jsonDecode(response.body); return responseData['payment_url']; } else { - ShowToastDialog.showToast("something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "something went wrong, please contact admin.".tr, + ); return ''; } } @@ -977,13 +1262,30 @@ class CartController extends GetxController { static String orderId = ''; static String amount = ''; - Future orangeMakePayment({required String amount, required BuildContext context}) async { + Future orangeMakePayment({ + required String amount, + required BuildContext context, + }) async { reset(); var id = const Uuid().v4(); - var paymentURL = await fetchToken(context: context, orderId: id, amount: amount, currency: 'USD'); + var paymentURL = await fetchToken( + context: context, + orderId: id, + amount: amount, + currency: 'USD', + ); ShowToastDialog.closeLoader(); if (paymentURL.toString() != '') { - Get.to(() => OrangeMoneyScreen(initialURl: paymentURL, accessToken: accessToken, amount: amount, orangePay: orangeMoneyModel.value, orderId: orderId, payToken: payToken))!.then((value) { + Get.to( + () => OrangeMoneyScreen( + initialURl: paymentURL, + accessToken: accessToken, + amount: amount, + orangePay: orangeMoneyModel.value, + orderId: orderId, + payToken: payToken, + ), + )!.then((value) { if (value == true) { ShowToastDialog.showToast("Payment Successful!!".tr); placeOrder(); @@ -995,13 +1297,22 @@ class CartController extends GetxController { } } - Future fetchToken({required String orderId, required String currency, required BuildContext context, required String amount}) async { + Future fetchToken({ + required String orderId, + required String currency, + required BuildContext context, + required String amount, + }) async { String apiUrl = 'https://api.orange.com/oauth/v3/token'; Map requestBody = {'grant_type': 'client_credentials'}; var response = await http.post( Uri.parse(apiUrl), - headers: {'Authorization': "Basic ${orangeMoneyModel.value.auth!}", 'Content-Type': 'application/x-www-form-urlencoded', 'Accept': 'application/json'}, + headers: { + 'Authorization': "Basic ${orangeMoneyModel.value.auth!}", + 'Content-Type': 'application/x-www-form-urlencoded', + 'Accept': 'application/json', + }, body: requestBody, ); @@ -1012,17 +1323,32 @@ class CartController extends GetxController { accessToken = responseData['access_token']; // ignore: use_build_context_synchronously - return await webpayment(context: context, amountData: amount, currency: currency, orderIdData: orderId); + return await webpayment( + context: context, + amountData: amount, + currency: currency, + orderIdData: orderId, + ); } else { - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); return ''; } } - Future webpayment({required String orderIdData, required BuildContext context, required String currency, required String amountData}) async { + Future webpayment({ + required String orderIdData, + required BuildContext context, + required String currency, + required String amountData, + }) async { orderId = orderIdData; amount = amountData; - String apiUrl = orangeMoneyModel.value.isSandbox! == true ? 'https://api.orange.com/orange-money-webpay/dev/v1/webpayment' : 'https://api.orange.com/orange-money-webpay/cm/v1/webpayment'; + String apiUrl = + orangeMoneyModel.value.isSandbox! == true + ? 'https://api.orange.com/orange-money-webpay/dev/v1/webpayment' + : 'https://api.orange.com/orange-money-webpay/cm/v1/webpayment'; Map requestBody = { "merchant_key": orangeMoneyModel.value.merchantKey ?? '', "currency": orangeMoneyModel.value.isSandbox == true ? "OUV" : currency, @@ -1037,7 +1363,11 @@ class CartController extends GetxController { var response = await http.post( Uri.parse(apiUrl), - headers: {'Authorization': 'Bearer $accessToken', 'Content-Type': 'application/json', 'Accept': 'application/json'}, + headers: { + 'Authorization': 'Bearer $accessToken', + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, body: json.encode(requestBody), ); @@ -1051,7 +1381,9 @@ class CartController extends GetxController { return ''; } } else { - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); return ''; } } @@ -1068,7 +1400,13 @@ class CartController extends GetxController { await createXenditInvoice(amount: amount).then((model) { ShowToastDialog.closeLoader(); if (model.id != null) { - Get.to(() => XenditScreen(initialURl: model.invoiceUrl ?? '', transId: model.id ?? '', apiKey: xenditModel.value.apiKey!.toString()))!.then((value) { + Get.to( + () => XenditScreen( + initialURl: model.invoiceUrl ?? '', + transId: model.id ?? '', + apiKey: xenditModel.value.apiKey!.toString(), + ), + )!.then((value) { if (value == true) { ShowToastDialog.showToast("Payment Successful!!".tr); placeOrder(); @@ -1085,7 +1423,9 @@ class CartController extends GetxController { const url = 'https://api.xendit.co/v2/invoices'; var headers = { 'Content-Type': 'application/json', - 'Authorization': generateBasicAuthHeader(xenditModel.value.apiKey!.toString()), + 'Authorization': generateBasicAuthHeader( + xenditModel.value.apiKey!.toString(), + ), // 'Cookie': '__cf_bm=yERkrx3xDITyFGiou0bbKY1bi7xEwovHNwxV1vCNbVc-1724155511-1.0.1.1-jekyYQmPCwY6vIJ524K0V6_CEw6O.dAwOmQnHtwmaXO_MfTrdnmZMka0KZvjukQgXu5B.K_6FJm47SGOPeWviQ', }; @@ -1098,7 +1438,11 @@ class CartController extends GetxController { }); try { - final response = await http.post(Uri.parse(url), headers: headers, body: body); + final response = await http.post( + Uri.parse(url), + headers: headers, + body: body, + ); if (response.statusCode == 200 || response.statusCode == 201) { XenditModel model = XenditModel.fromJson(jsonDecode(response.body)); diff --git a/lib/controllers/category_restaurant_controller.dart b/lib/controllers/category_restaurant_controller.dart index bd8e41a..dbf3077 100644 --- a/lib/controllers/category_restaurant_controller.dart +++ b/lib/controllers/category_restaurant_controller.dart @@ -33,9 +33,10 @@ class CategoryRestaurantController extends GetxController { } Future getRestaurant() async { - FireStoreUtils.getAllNearestRestaurantByCategoryId(categoryId: vendorCategoryModel.value.id.toString(), isDining: dineIn.value).listen(( - event, - ) async { + FireStoreUtils.getAllNearestRestaurantByCategoryId( + categoryId: vendorCategoryModel.value.id.toString(), + isDining: dineIn.value, + ).listen((event) async { allNearestRestaurant.clear(); allNearestRestaurant.addAll(event); }); @@ -46,7 +47,10 @@ class CategoryRestaurantController extends GetxController { if (value != null) { for (int i = 0; i < value.length; i++) { if (Constant.isPointInPolygon( - LatLng(Constant.selectedLocation.location!.latitude ?? 0.0, Constant.selectedLocation.location!.longitude ?? 0.0), + LatLng( + Constant.selectedLocation.location!.latitude ?? 0.0, + Constant.selectedLocation.location!.longitude ?? 0.0, + ), value[i].area!, )) { Constant.selectedZone = value[i]; diff --git a/lib/controllers/change_language_controller.dart b/lib/controllers/change_language_controller.dart index aad7891..2b89879 100644 --- a/lib/controllers/change_language_controller.dart +++ b/lib/controllers/change_language_controller.dart @@ -3,7 +3,6 @@ import 'package:customer/models/language_model.dart'; import '../service/fire_store_utils.dart'; import 'package:customer/utils/preferences.dart'; import 'package:get/get.dart'; - import '../constant/collection_name.dart'; class ChangeLanguageController extends GetxController { @@ -20,24 +19,30 @@ class ChangeLanguageController extends GetxController { } Future getLanguage() async { - await FireStoreUtils.fireStore.collection(CollectionName.settings).doc("languages").get().then((event) { - if (event.exists) { - List languageListTemp = event.data()!["list"]; - for (var element in languageListTemp) { - LanguageModel languageModel = LanguageModel.fromJson(element); - languageList.add(languageModel); - } + await FireStoreUtils.fireStore + .collection(CollectionName.settings) + .doc("languages") + .get() + .then((event) { + if (event.exists) { + List languageListTemp = event.data()!["list"]; + for (var element in languageListTemp) { + LanguageModel languageModel = LanguageModel.fromJson(element); + languageList.add(languageModel); + } - if (Preferences.getString(Preferences.languageCodeKey).toString().isNotEmpty) { - LanguageModel pref = Constant.getLanguage(); - for (var element in languageList) { - if (element.slug == pref.slug) { - selectedLanguage.value = element; + if (Preferences.getString( + Preferences.languageCodeKey, + ).toString().isNotEmpty) { + LanguageModel pref = Constant.getLanguage(); + for (var element in languageList) { + if (element.slug == pref.slug) { + selectedLanguage.value = element; + } + } } } - } - } - }); + }); isLoading.value = false; } diff --git a/lib/controllers/chat_controller.dart b/lib/controllers/chat_controller.dart index bf091d8..1923bef 100644 --- a/lib/controllers/chat_controller.dart +++ b/lib/controllers/chat_controller.dart @@ -1,5 +1,6 @@ import 'dart:async'; import 'package:cloud_firestore/cloud_firestore.dart'; + import 'package:image_picker/image_picker.dart'; import '../models/conversation_model.dart'; @@ -20,7 +21,11 @@ class ChatController extends GetxController { void onInit() { // TODO: implement onInit if (scrollController.hasClients) { - Timer(const Duration(milliseconds: 500), () => scrollController.jumpTo(scrollController.position.maxScrollExtent)); + Timer( + const Duration(milliseconds: 500), + () => + scrollController.jumpTo(scrollController.position.maxScrollExtent), + ); } getArgument(); super.onInit(); @@ -46,14 +51,20 @@ class ChatController extends GetxController { customerProfileImage.value = argumentData['customerProfileImage'] ?? ""; restaurantId.value = argumentData['restaurantId']; restaurantName.value = argumentData['restaurantName']; - restaurantProfileImage.value = argumentData['restaurantProfileImage'] ?? ""; + restaurantProfileImage.value = + argumentData['restaurantProfileImage'] ?? ""; token.value = argumentData['token'] ?? ""; chatType.value = argumentData['chatType']; } isLoading.value = false; } - Future sendMessage(String message, Url? url, String videoThumbnail, String messageType) async { + Future sendMessage( + String message, + Url? url, + String videoThumbnail, + String messageType, + ) async { InboxModel inboxModel = InboxModel( lastSenderId: customerId.value, customerId: customerId.value, @@ -112,18 +123,23 @@ class ChatController extends GetxController { } //await SendNotification.sendChatFcmMessage(customerName.value, conversationModel.message.toString(), token.value, {}); - await SendNotification.sendChatFcmMessage(customerName.value, conversationModel.message.toString(), token.value, { - "type": "chat", - "chatType": chatType.value, - "orderId": orderId.value, - "customerId": customerId.value, - "customerName": customerName.value, - "customerProfileImage": customerProfileImage.value, - "restaurantId": restaurantId.value, - "restaurantName": restaurantName.value, - "restaurantProfileImage": restaurantProfileImage.value, - "token": token.value, - }); + await SendNotification.sendChatFcmMessage( + customerName.value, + conversationModel.message.toString(), + token.value, + { + "type": "chat", + "chatType": chatType.value, + "orderId": orderId.value, + "customerId": customerId.value, + "customerName": customerName.value, + "customerProfileImage": customerProfileImage.value, + "restaurantId": restaurantId.value, + "restaurantName": restaurantName.value, + "restaurantProfileImage": restaurantProfileImage.value, + "token": token.value, + }, + ); } final ImagePicker imagePicker = ImagePicker(); diff --git a/lib/controllers/complain_controller.dart b/lib/controllers/complain_controller.dart index 4d22e89..5fa362e 100644 --- a/lib/controllers/complain_controller.dart +++ b/lib/controllers/complain_controller.dart @@ -29,7 +29,9 @@ class ComplainController extends GetxController { Future getComplain() async { isLoading.value = true; try { - final data = await FireStoreUtils.getRideComplainData(order.value.id ?? ''); + final data = await FireStoreUtils.getRideComplainData( + order.value.id ?? '', + ); if (data != null) { title.value.text = data['title'] ?? ''; comment.value.text = data['description'] ?? ''; @@ -58,7 +60,9 @@ class ComplainController extends GetxController { try { // Check if complaint already exists - bool exists = await FireStoreUtils.isRideComplainAdded(order.value.id ?? ''); + bool exists = await FireStoreUtils.isRideComplainAdded( + order.value.id ?? '', + ); if (!exists) { await FireStoreUtils.setRideComplain( @@ -66,13 +70,19 @@ class ComplainController extends GetxController { title: title.value.text.trim(), description: comment.value.text.trim(), customerID: order.value.authorID ?? '', - customerName: "${order.value.author?.firstName ?? ''} ${order.value.author?.lastName ?? ''}".trim(), + customerName: + "${order.value.author?.firstName ?? ''} ${order.value.author?.lastName ?? ''}" + .trim(), driverID: order.value.driverId ?? '', - driverName: "${order.value.driver?.firstName ?? ''} ${order.value.driver?.lastName ?? ''}".trim(), + driverName: + "${order.value.driver?.firstName ?? ''} ${order.value.driver?.lastName ?? ''}" + .trim(), ); ShowToastDialog.closeLoader(); - ShowToastDialog.showToast("Your complaint has been submitted to admin".tr); + ShowToastDialog.showToast( + "Your complaint has been submitted to admin".tr, + ); Get.back(); } else { ShowToastDialog.closeLoader(); diff --git a/lib/controllers/dash_board_controller.dart b/lib/controllers/dash_board_controller.dart index ae6445f..f336ca5 100644 --- a/lib/controllers/dash_board_controller.dart +++ b/lib/controllers/dash_board_controller.dart @@ -19,22 +19,46 @@ class DashBoardController extends GetxController { getTaxList(); if (Constant.sectionConstantModel!.theme == "theme_2") { if (Constant.walletSetting == false) { - pageList.value = [const HomeScreen(), const FavouriteScreen(), const OrderScreen(), const ProfileScreen()]; + pageList.value = [ + const HomeScreen(), + const FavouriteScreen(), + const OrderScreen(), + const ProfileScreen(), + ]; } else { - pageList.value = [const HomeScreen(), const FavouriteScreen(), const WalletScreen(), const OrderScreen(), const ProfileScreen()]; + pageList.value = [ + const HomeScreen(), + const FavouriteScreen(), + const WalletScreen(), + const OrderScreen(), + const ProfileScreen(), + ]; } } else { if (Constant.walletSetting == false) { - pageList.value = [const HomeScreenTwo(), const FavouriteScreen(), const OrderScreen(), const ProfileScreen()]; + pageList.value = [ + const HomeScreenTwo(), + const FavouriteScreen(), + const OrderScreen(), + const ProfileScreen(), + ]; } else { - pageList.value = [const HomeScreenTwo(), const FavouriteScreen(), const WalletScreen(), const OrderScreen(), const ProfileScreen()]; + pageList.value = [ + const HomeScreenTwo(), + const FavouriteScreen(), + const WalletScreen(), + const OrderScreen(), + const ProfileScreen(), + ]; } } super.onInit(); } Future getTaxList() async { - await FireStoreUtils.getTaxList(Constant.sectionConstantModel!.id).then((value) { + await FireStoreUtils.getTaxList(Constant.sectionConstantModel!.id).then(( + value, + ) { if (value != null) { Constant.taxList = value; } diff --git a/lib/controllers/dash_board_ecommarce_controller.dart b/lib/controllers/dash_board_ecommarce_controller.dart index 02bb9ce..b690994 100644 --- a/lib/controllers/dash_board_ecommarce_controller.dart +++ b/lib/controllers/dash_board_ecommarce_controller.dart @@ -17,15 +17,28 @@ class DashBoardEcommerceController extends GetxController { // TODO: implement onInit getTaxList(); if (Constant.walletSetting == false) { - pageList.value = [const HomeECommerceScreen(), const FavouriteScreen(), const OrderScreen(), const ProfileScreen()]; + pageList.value = [ + const HomeECommerceScreen(), + const FavouriteScreen(), + const OrderScreen(), + const ProfileScreen(), + ]; } else { - pageList.value = [const HomeECommerceScreen(), const FavouriteScreen(), const WalletScreen(), const OrderScreen(), const ProfileScreen()]; + pageList.value = [ + const HomeECommerceScreen(), + const FavouriteScreen(), + const WalletScreen(), + const OrderScreen(), + const ProfileScreen(), + ]; } super.onInit(); } Future getTaxList() async { - await FireStoreUtils.getTaxList(Constant.sectionConstantModel!.id).then((value) { + await FireStoreUtils.getTaxList(Constant.sectionConstantModel!.id).then(( + value, + ) { if (value != null) { Constant.taxList = value; } diff --git a/lib/controllers/dine_in_booking_controller.dart b/lib/controllers/dine_in_booking_controller.dart index e273284..482e3cd 100644 --- a/lib/controllers/dine_in_booking_controller.dart +++ b/lib/controllers/dine_in_booking_controller.dart @@ -18,16 +18,12 @@ class DineInBookingController extends GetxController { } Future getDineInBooking() async { - await FireStoreUtils.getDineInBooking(true).then( - (value) { - featureList.value = value; - }, - ); - await FireStoreUtils.getDineInBooking(false).then( - (value) { - historyList.value = value; - }, - ); + await FireStoreUtils.getDineInBooking(true).then((value) { + featureList.value = value; + }); + await FireStoreUtils.getDineInBooking(false).then((value) { + historyList.value = value; + }); isLoading.value = false; } diff --git a/lib/controllers/dine_in_controller.dart b/lib/controllers/dine_in_controller.dart index b582900..d4d5339 100644 --- a/lib/controllers/dine_in_controller.dart +++ b/lib/controllers/dine_in_controller.dart @@ -28,7 +28,8 @@ class DineInController extends GetxController { RxList popularRestaurantList = [].obs; RxList bannerBottomModel = [].obs; - Rx pageBottomController = PageController(viewportFraction: 0.877).obs; + Rx pageBottomController = + PageController(viewportFraction: 0.877).obs; RxInt currentBottomPage = 0.obs; RxList favouriteList = [].obs; @@ -37,7 +38,9 @@ class DineInController extends GetxController { isLoading.value = true; await getZone(); - FireStoreUtils.getAllNearestRestaurant(isDining: true).listen((event) async { + FireStoreUtils.getAllNearestRestaurant(isDining: true).listen(( + event, + ) async { newArrivalRestaurantList.clear(); allNearestRestaurant.clear(); popularRestaurantList.clear(); @@ -47,12 +50,21 @@ class DineInController extends GetxController { popularRestaurantList.addAll(event); popularRestaurantList.sort( - (a, b) => Constant.calculateReview(reviewCount: b.reviewsCount.toString(), reviewSum: b.reviewsSum.toString()) - .compareTo(Constant.calculateReview(reviewCount: a.reviewsCount.toString(), reviewSum: a.reviewsSum.toString())), + (a, b) => Constant.calculateReview( + reviewCount: b.reviewsCount.toString(), + reviewSum: b.reviewsSum.toString(), + ).compareTo( + Constant.calculateReview( + reviewCount: a.reviewsCount.toString(), + reviewSum: a.reviewsSum.toString(), + ), + ), ); newArrivalRestaurantList.sort( - (a, b) => (b.createdAt ?? Timestamp.now()).toDate().compareTo((a.createdAt ?? Timestamp.now()).toDate()), + (a, b) => (b.createdAt ?? Timestamp.now()).toDate().compareTo( + (a.createdAt ?? Timestamp.now()).toDate(), + ), ); }); @@ -61,23 +73,17 @@ class DineInController extends GetxController { } Future getCategory() async { - await FireStoreUtils.getHomeVendorCategory().then( - (value) { - vendorCategoryModel.value = value; - }, - ); + await FireStoreUtils.getHomeVendorCategory().then((value) { + vendorCategoryModel.value = value; + }); - await FireStoreUtils.getHomeBottomBanner().then( - (value) { - bannerBottomModel.value = value; - }, - ); + await FireStoreUtils.getHomeBottomBanner().then((value) { + bannerBottomModel.value = value; + }); if (Constant.userModel != null) { - await FireStoreUtils.getFavouriteRestaurant().then( - (value) { - favouriteList.value = value; - }, - ); + await FireStoreUtils.getFavouriteRestaurant().then((value) { + favouriteList.value = value; + }); } } @@ -85,7 +91,13 @@ class DineInController extends GetxController { await FireStoreUtils.getZone().then((value) { if (value != null) { for (int i = 0; i < value.length; i++) { - if (Constant.isPointInPolygon(LatLng(Constant.selectedLocation.location!.latitude ?? 0.0, Constant.selectedLocation.location!.longitude ?? 0.0), value[i].area!)) { + if (Constant.isPointInPolygon( + LatLng( + Constant.selectedLocation.location!.latitude ?? 0.0, + Constant.selectedLocation.location!.longitude ?? 0.0, + ), + value[i].area!, + )) { Constant.selectedZone = value[i]; Constant.isZoneAvailable = true; break; @@ -96,5 +108,4 @@ class DineInController extends GetxController { } }); } - } diff --git a/lib/controllers/dine_in_restaurant_details_controller.dart b/lib/controllers/dine_in_restaurant_details_controller.dart index 478b3f8..34b3715 100644 --- a/lib/controllers/dine_in_restaurant_details_controller.dart +++ b/lib/controllers/dine_in_restaurant_details_controller.dart @@ -1,9 +1,11 @@ import 'dart:async'; import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:customer/constant/const_texts.dart'; import 'package:customer/constant/constant.dart'; import 'package:customer/models/dine_in_booking_model.dart'; import 'package:customer/models/favourite_model.dart'; import 'package:customer/models/vendor_model.dart'; + import '../screen_ui/multi_vendor_service/dine_in_booking/dine_in_booking_screen.dart'; import '../service/fire_store_utils.dart'; import 'package:flutter/material.dart'; @@ -14,9 +16,11 @@ import '../service/send_notification.dart'; import '../themes/show_toast_dialog.dart'; class DineInRestaurantDetailsController extends GetxController { - Rx searchEditingController = TextEditingController().obs; + Rx searchEditingController = + TextEditingController().obs; - Rx additionRequestController = TextEditingController().obs; + Rx additionRequestController = + TextEditingController().obs; RxBool isLoading = true.obs; RxBool firstVisit = false.obs; @@ -41,6 +45,7 @@ class DineInRestaurantDetailsController extends GetxController { return key; } } + RxString selectedOccasion = "".obs; RxList dateList = [].obs; @@ -61,33 +66,56 @@ class DineInRestaurantDetailsController extends GetxController { } Future orderBook() async { - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); DateTime dt = selectedDate.value.toDate(); - String hour = DateFormat("kk:mm").format(DateFormat('hh:mm a').parse((Intl.getCurrentLocale() == "en_US") ? selectedTimeSlot.value : selectedTimeSlot.value.toLowerCase())); - dt = DateTime(dt.year, dt.month, dt.day, int.parse(hour.split(":")[0]), int.parse(hour.split(":")[1]), dt.second, dt.millisecond, dt.microsecond); + String hour = DateFormat("kk:mm").format( + DateFormat('hh:mm a').parse( + (Intl.getCurrentLocale() == "en_US") + ? selectedTimeSlot.value + : selectedTimeSlot.value.toLowerCase(), + ), + ); + dt = DateTime( + dt.year, + dt.month, + dt.day, + int.parse(hour.split(":")[0]), + int.parse(hour.split(":")[1]), + dt.second, + dt.millisecond, + dt.microsecond, + ); selectedDate.value = Timestamp.fromDate(dt); DineInBookingModel dineInBookingModel = DineInBookingModel( - id: Constant.getUuid(), - author: Constant.userModel, - authorID: FireStoreUtils.getCurrentUid(), - createdAt: Timestamp.now(), - date: selectedDate.value, - status: Constant.orderPlaced, - vendor: vendorModel.value, - specialRequest: additionRequestController.value.text.isEmpty ? "" : additionRequestController.value.text, - vendorID: vendorModel.value.id, - guestEmail: Constant.userModel!.email, - guestFirstName: Constant.userModel!.firstName, - guestLastName: Constant.userModel!.lastName, - guestPhone: Constant.userModel!.phoneNumber, - occasion: selectedOccasion.value, - discount: selectedTimeDiscount.value, - discountType: selectedTimeDiscountType.value, - totalGuest: noOfQuantity.value.toString(), - firstVisit: firstVisit.value); + id: Constant.getUuid(), + author: Constant.userModel, + authorID: FireStoreUtils.getCurrentUid(), + createdAt: Timestamp.now(), + date: selectedDate.value, + status: Constant.orderPlaced, + vendor: vendorModel.value, + specialRequest: + additionRequestController.value.text.isEmpty + ? "" + : additionRequestController.value.text, + vendorID: vendorModel.value.id, + guestEmail: Constant.userModel!.email, + guestFirstName: Constant.userModel!.firstName, + guestLastName: Constant.userModel!.lastName, + guestPhone: Constant.userModel!.phoneNumber, + occasion: selectedOccasion.value, + discount: selectedTimeDiscount.value, + discountType: selectedTimeDiscountType.value, + totalGuest: noOfQuantity.value.toString(), + firstVisit: firstVisit.value, + ); await FireStoreUtils.setBookedOrder(dineInBookingModel); - await SendNotification.sendFcmMessage(Constant.dineInPlaced, vendorModel.value.fcmToken.toString(), {}); + await SendNotification.sendFcmMessage( + Constant.dineInPlaced, + vendorModel.value.fcmToken.toString(), + {}, + ); ShowToastDialog.closeLoader(); Get.back(); Get.to(const DineInBookingScreen()); @@ -98,27 +126,46 @@ class DineInRestaurantDetailsController extends GetxController { for (int i = 0; i < 7; i++) { final now = DateTime.now().add(Duration(days: i)); var day = DateFormat('EEEE').format(now); - if (vendorModel.value.specialDiscount?.isNotEmpty == true && vendorModel.value.specialDiscountEnable == true) { + if (vendorModel.value.specialDiscount?.isNotEmpty == true && + vendorModel.value.specialDiscountEnable == true) { for (var element in vendorModel.value.specialDiscount!) { if (day == element.day.toString()) { if (element.timeslot!.isNotEmpty) { - SpecialDiscountTimeslot employeeWithMaxSalary = - element.timeslot!.reduce((item1, item2) => double.parse(item1.discount.toString()) > double.parse(item2.discount.toString()) ? item1 : item2); + SpecialDiscountTimeslot employeeWithMaxSalary = element.timeslot! + .reduce( + (item1, item2) => + double.parse(item1.discount.toString()) > + double.parse(item2.discount.toString()) + ? item1 + : item2, + ); if (employeeWithMaxSalary.discountType == "dinein") { - DateModel model = DateModel(date: Timestamp.fromDate(now), discountPer: employeeWithMaxSalary.discount.toString()); + DateModel model = DateModel( + date: Timestamp.fromDate(now), + discountPer: employeeWithMaxSalary.discount.toString(), + ); dateList.add(model); } else { - DateModel model = DateModel(date: Timestamp.fromDate(now), discountPer: "0"); + DateModel model = DateModel( + date: Timestamp.fromDate(now), + discountPer: "0", + ); dateList.add(model); } } else { - DateModel model = DateModel(date: Timestamp.fromDate(now), discountPer: "0"); + DateModel model = DateModel( + date: Timestamp.fromDate(now), + discountPer: "0", + ); dateList.add(model); } } } } else { - DateModel model = DateModel(date: Timestamp.fromDate(now), discountPer: "0"); + DateModel model = DateModel( + date: Timestamp.fromDate(now), + discountPer: "0", + ); dateList.add(model); } } @@ -126,70 +173,116 @@ class DineInRestaurantDetailsController extends GetxController { timeSet(selectedDate.value); if (timeSlotList.isNotEmpty) { - selectedTimeSlot.value = DateFormat('hh:mm a').format(timeSlotList[0].time!); + selectedTimeSlot.value = DateFormat( + 'hh:mm a', + ).format(timeSlotList[0].time!); } } void timeSet(Timestamp selectedDate) { timeSlotList.clear(); - for (DateTime time = Constant.stringToDate(vendorModel.value.openDineTime.toString()); - time.isBefore(Constant.stringToDate(vendorModel.value.closeDineTime.toString())); - time = time.add(const Duration(minutes: 30))) { + for ( + DateTime time = Constant.stringToDate( + vendorModel.value.openDineTime.toString(), + ); + time.isBefore( + Constant.stringToDate(vendorModel.value.closeDineTime.toString()), + ); + time = time.add(const Duration(minutes: 30)) + ) { final now = DateTime.parse(selectedDate.toDate().toString()); var day = DateFormat('EEEE').format(now); var date = DateFormat('dd-MM-yyyy').format(now); - if (vendorModel.value.specialDiscount?.isNotEmpty == true && vendorModel.value.specialDiscountEnable == true) { + if (vendorModel.value.specialDiscount?.isNotEmpty == true && + vendorModel.value.specialDiscountEnable == true) { for (var element in vendorModel.value.specialDiscount!) { if (day == element.day.toString()) { if (element.timeslot!.isNotEmpty) { for (var element in element.timeslot!) { if (element.discountType == "dinein") { - var start = DateFormat("dd-MM-yyyy HH:mm").parse("$date ${element.from}"); - var end = DateFormat("dd-MM-yyyy HH:mm").parse("$date ${element.to}"); - var selected = DateFormat("dd-MM-yyyy HH:mm").parse("$date ${DateFormat.Hm().format(time)}"); + var start = DateFormat( + "dd-MM-yyyy HH:mm", + ).parse("$date ${element.from}"); + var end = DateFormat( + "dd-MM-yyyy HH:mm", + ).parse("$date ${element.to}"); + var selected = DateFormat( + "dd-MM-yyyy HH:mm", + ).parse("$date ${DateFormat.Hm().format(time)}"); if (isCurrentDateInRangeDineIn(start, end, selected)) { - var contains = timeSlotList.where((element) => element.time == time); + var contains = timeSlotList.where( + (element) => element.time == time, + ); if (contains.isNotEmpty) { - var index = timeSlotList.indexWhere((element) => element.time == time); + var index = timeSlotList.indexWhere( + (element) => element.time == time, + ); if (timeSlotList[index].discountPer == "0") { timeSlotList.removeAt(index); - TimeModel model = TimeModel(time: time, discountPer: element.discount, discountType: element.type); + TimeModel model = TimeModel( + time: time, + discountPer: element.discount, + discountType: element.type, + ); timeSlotList.insert(index == 0 ? 0 : index, model); } } else { - TimeModel model = TimeModel(time: time, discountPer: element.discount, discountType: element.type); + TimeModel model = TimeModel( + time: time, + discountPer: element.discount, + discountType: element.type, + ); timeSlotList.add(model); } } else { - var contains = timeSlotList.where((element) => element.time == time); + var contains = timeSlotList.where( + (element) => element.time == time, + ); if (contains.isEmpty) { - TimeModel model = TimeModel(time: time, discountPer: "0", discountType: "amount"); + TimeModel model = TimeModel( + time: time, + discountPer: "0", + discountType: "amount", + ); timeSlotList.add(model); } } } else { - TimeModel model = TimeModel(time: time, discountPer: "0", discountType: "amount"); + TimeModel model = TimeModel( + time: time, + discountPer: "0", + discountType: "amount", + ); timeSlotList.add(model); } } } else { - TimeModel model = TimeModel(time: time, discountPer: "0", discountType: "amount"); + TimeModel model = TimeModel( + time: time, + discountPer: "0", + discountType: "amount", + ); timeSlotList.add(model); } } } } else { - TimeModel model = TimeModel(time: time, discountPer: "0", discountType: "amount"); + TimeModel model = TimeModel( + time: time, + discountPer: "0", + discountType: "amount", + ); timeSlotList.add(model); } } } void animateSlider() { - if (vendorModel.value.photos != null && vendorModel.value.photos!.isNotEmpty) { + if (vendorModel.value.photos != null && + vendorModel.value.photos!.isNotEmpty) { Timer.periodic(const Duration(seconds: 2), (Timer timer) { if (currentPage < vendorModel.value.photos!.length) { currentPage++; @@ -225,18 +318,16 @@ class DineInRestaurantDetailsController extends GetxController { Future getFavouriteList() async { if (Constant.userModel != null) { - await FireStoreUtils.getFavouriteRestaurant().then( - (value) { - favouriteList.value = value; - }, - ); + await FireStoreUtils.getFavouriteRestaurant().then((value) { + favouriteList.value = value; + }); } - await FireStoreUtils.getVendorCuisines(vendorModel.value.id.toString()).then( - (value) { - tags.value = value; - }, - ); + await FireStoreUtils.getVendorCuisines( + vendorModel.value.id.toString(), + ).then((value) { + tags.value = value; + }); update(); } @@ -250,8 +341,12 @@ class DineInRestaurantDetailsController extends GetxController { if (day == element.day.toString()) { if (element.timeslot!.isNotEmpty) { for (var element in element.timeslot!) { - var start = DateFormat("dd-MM-yyyy HH:mm").parse("$date ${element.from}"); - var end = DateFormat("dd-MM-yyyy HH:mm").parse("$date ${element.to}"); + var start = DateFormat( + "dd-MM-yyyy HH:mm", + ).parse("$date ${element.from}"); + var end = DateFormat( + "dd-MM-yyyy HH:mm", + ).parse("$date ${element.to}"); if (isCurrentDateInRange(start, end)) { isOpen.value = true; } @@ -261,8 +356,14 @@ class DineInRestaurantDetailsController extends GetxController { } } - bool isCurrentDateInRangeDineIn(DateTime startDate, DateTime endDate, DateTime selected) { - return selected.isAtSameMomentAs(startDate) || selected.isAtSameMomentAs(endDate) || selected.isAfter(startDate) && selected.isBefore(endDate); + bool isCurrentDateInRangeDineIn( + DateTime startDate, + DateTime endDate, + DateTime selected, + ) { + return selected.isAtSameMomentAs(startDate) || + selected.isAtSameMomentAs(endDate) || + selected.isAfter(startDate) && selected.isBefore(endDate); } bool isCurrentDateInRange(DateTime startDate, DateTime endDate) { @@ -283,5 +384,9 @@ class TimeModel { String? discountPer; String? discountType; - TimeModel({required this.time, required this.discountPer, required this.discountType}); + TimeModel({ + required this.time, + required this.discountPer, + required this.discountType, + }); } diff --git a/lib/controllers/edit_profile_controller.dart b/lib/controllers/edit_profile_controller.dart index 1208699..38f94db 100644 --- a/lib/controllers/edit_profile_controller.dart +++ b/lib/controllers/edit_profile_controller.dart @@ -1,6 +1,8 @@ import 'dart:io'; +import 'package:customer/constant/const_texts.dart'; import 'package:customer/constant/constant.dart'; import 'package:customer/models/user_model.dart'; + import '../service/fire_store_utils.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -17,7 +19,8 @@ class EditProfileController extends GetxController { Rx lastNameController = TextEditingController().obs; Rx emailController = TextEditingController().obs; Rx phoneNumberController = TextEditingController().obs; - Rx countryCodeController = TextEditingController(text: "+91").obs; + Rx countryCodeController = + TextEditingController(text: "+91").obs; @override void onInit() { @@ -26,14 +29,18 @@ class EditProfileController extends GetxController { } Future getData() async { - await FireStoreUtils.getUserProfile(FireStoreUtils.getCurrentUid()).then((value) { + await FireStoreUtils.getUserProfile(FireStoreUtils.getCurrentUid()).then(( + value, + ) { if (value != null) { userModel.value = value; firstNameController.value.text = userModel.value.firstName.toString(); lastNameController.value.text = userModel.value.lastName.toString(); emailController.value.text = userModel.value.email.toString(); - phoneNumberController.value.text = userModel.value.phoneNumber.toString(); - countryCodeController.value.text = userModel.value.countryCode.toString(); + phoneNumberController.value.text = + userModel.value.phoneNumber.toString(); + countryCodeController.value.text = + userModel.value.countryCode.toString(); profileImage.value = userModel.value.profilePictureURL ?? ""; } }); @@ -42,8 +49,9 @@ class EditProfileController extends GetxController { } Future saveData() async { - ShowToastDialog.showLoader("Please wait...".tr); - if (Constant().hasValidUrl(profileImage.value) == false && profileImage.value.isNotEmpty) { + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); + if (Constant().hasValidUrl(profileImage.value) == false && + profileImage.value.isNotEmpty) { profileImage.value = await Constant.uploadUserImageToFireStorage( File(profileImage.value), "profileImage/${FireStoreUtils.getCurrentUid()}", diff --git a/lib/controllers/enter_manually_location_controller.dart b/lib/controllers/enter_manually_location_controller.dart index 281b2e2..8711cc5 100644 --- a/lib/controllers/enter_manually_location_controller.dart +++ b/lib/controllers/enter_manually_location_controller.dart @@ -1,7 +1,7 @@ import 'package:customer/service/fire_store_utils.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; - import '../models/user_model.dart'; class EnterManuallyLocationController extends GetxController { @@ -12,9 +12,12 @@ class EnterManuallyLocationController extends GetxController { List saveAsList = ['Home', 'Work', 'Hotel', 'other'].obs; RxString selectedSaveAs = "Home".obs; - Rx houseBuildingTextEditingController = TextEditingController().obs; - Rx localityEditingController = TextEditingController().obs; - Rx landmarkEditingController = TextEditingController().obs; + Rx houseBuildingTextEditingController = + TextEditingController().obs; + Rx localityEditingController = + TextEditingController().obs; + Rx landmarkEditingController = + TextEditingController().obs; Rx location = UserLocation().obs; Rx shippingModel = ShippingAddress().obs; RxBool isLoading = false.obs; @@ -35,7 +38,8 @@ class EnterManuallyLocationController extends GetxController { mode.value = argumentData['mode'] ?? "Add"; //check address - if (argumentData['address'] != null && argumentData['address'] is ShippingAddress) { + if (argumentData['address'] != null && + argumentData['address'] is ShippingAddress) { shippingModel.value = argumentData['address']; setData(shippingModel.value); } @@ -48,7 +52,8 @@ class EnterManuallyLocationController extends GetxController { void setData(ShippingAddress shippingAddress) { shippingModel.value = shippingAddress; - houseBuildingTextEditingController.value.text = shippingAddress.address.toString(); + houseBuildingTextEditingController.value.text = + shippingAddress.address.toString(); localityEditingController.value.text = shippingAddress.locality.toString(); landmarkEditingController.value.text = shippingAddress.landmark.toString(); selectedSaveAs.value = shippingAddress.addressAs.toString(); @@ -56,7 +61,9 @@ class EnterManuallyLocationController extends GetxController { } Future getUser() async { - await FireStoreUtils.getUserProfile(FireStoreUtils.getCurrentUid()).then((value) { + await FireStoreUtils.getUserProfile(FireStoreUtils.getCurrentUid()).then(( + value, + ) { if (value != null) { userModel.value = value; if (userModel.value.shippingAddress != null) { diff --git a/lib/controllers/favourite_controller.dart b/lib/controllers/favourite_controller.dart index 149265e..e2c3b8c 100644 --- a/lib/controllers/favourite_controller.dart +++ b/lib/controllers/favourite_controller.dart @@ -35,14 +35,22 @@ class FavouriteController extends GetxController { }); for (var element in favouriteList) { - await FireStoreUtils.getVendorById(element.restaurantId.toString()).then((value) async { + await FireStoreUtils.getVendorById( + element.restaurantId.toString(), + ).then((value) async { if (value != null) { - if ((Constant.isSubscriptionModelApplied == true || value.adminCommission?.isEnabled == true) && value.subscriptionPlan != null) { + if ((Constant.isSubscriptionModelApplied == true || + value.adminCommission?.isEnabled == true) && + value.subscriptionPlan != null) { if (value.subscriptionTotalOrders == "-1") { favouriteVendorList.add(value); } else { print("Restaurant :: ${value.title.toString()}"); - if ((value.subscriptionExpiryDate != null && value.subscriptionExpiryDate!.toDate().isBefore(DateTime.now()) == false) || + if ((value.subscriptionExpiryDate != null && + value.subscriptionExpiryDate!.toDate().isBefore( + DateTime.now(), + ) == + false) || value.subscriptionPlan?.expiryDay == '-1') { if (value.subscriptionTotalOrders != '0') { favouriteVendorList.add(value); @@ -57,32 +65,45 @@ class FavouriteController extends GetxController { } for (var element in favouriteItemList) { - await FireStoreUtils.getProductById(element.productId.toString()).then((value) async { + await FireStoreUtils.getProductById(element.productId.toString()).then(( + value, + ) async { if (value != null) { - await FireStoreUtils.fireStore.collection(CollectionName.vendors).doc(value.vendorID.toString()).get().then((value1) async { - if (value1.exists) { - VendorModel vendorModel = VendorModel.fromJson(value1.data()!); - if(value.publish == true){ - if (Constant.isSubscriptionModelApplied == true || vendorModel.adminCommission?.isEnabled == true) { - if (vendorModel.subscriptionPlan != null) { - if (vendorModel.subscriptionTotalOrders == "-1") { - favouriteFoodList.add(value); - } else { - if ((vendorModel.subscriptionExpiryDate != null && vendorModel.subscriptionExpiryDate!.toDate().isBefore(DateTime.now()) == false) || - vendorModel.subscriptionPlan?.expiryDay == "-1") { - if (vendorModel.subscriptionTotalOrders != '0') { + await FireStoreUtils.fireStore + .collection(CollectionName.vendors) + .doc(value.vendorID.toString()) + .get() + .then((value1) async { + if (value1.exists) { + VendorModel vendorModel = VendorModel.fromJson( + value1.data()!, + ); + if (value.publish == true) { + if (Constant.isSubscriptionModelApplied == true || + vendorModel.adminCommission?.isEnabled == true) { + if (vendorModel.subscriptionPlan != null) { + if (vendorModel.subscriptionTotalOrders == "-1") { favouriteFoodList.add(value); + } else { + if ((vendorModel.subscriptionExpiryDate != null && + vendorModel.subscriptionExpiryDate! + .toDate() + .isBefore(DateTime.now()) == + false) || + vendorModel.subscriptionPlan?.expiryDay == + "-1") { + if (vendorModel.subscriptionTotalOrders != '0') { + favouriteFoodList.add(value); + } + } } } + } else { + favouriteFoodList.add(value); } } - } else { - favouriteFoodList.add(value); } - } - - } - }); + }); } }); } diff --git a/lib/controllers/favourite_ondemmand_controller.dart b/lib/controllers/favourite_ondemmand_controller.dart index 0ed8f26..5210822 100644 --- a/lib/controllers/favourite_ondemmand_controller.dart +++ b/lib/controllers/favourite_ondemmand_controller.dart @@ -10,7 +10,8 @@ class FavouriteOndemmandController extends GetxController { // Add your controller logic here Rx isLoading = false.obs; - RxList lstFav = [].obs; + RxList lstFav = + [].obs; RxList categories = [].obs; @override @@ -25,7 +26,9 @@ class FavouriteOndemmandController extends GetxController { await FireStoreUtils.getOnDemandCategory().then((catValue) { categories.value = catValue; }); - await FireStoreUtils.getFavouritesServiceList(FireStoreUtils.getCurrentUid()).then((favList) { + await FireStoreUtils.getFavouritesServiceList( + FireStoreUtils.getCurrentUid(), + ).then((favList) { lstFav.value = favList; }); isLoading.value = false; @@ -35,23 +38,27 @@ class FavouriteOndemmandController extends GetxController { if (Constant.userModel == null) { Get.to(LoginScreen()); } else { - var contain = lstFav.where((element) => element.service_id == provider.id); + var contain = lstFav.where( + (element) => element.service_id == provider.id, + ); if (contain.isNotEmpty) { - FavouriteOndemandServiceModel favouriteModel = FavouriteOndemandServiceModel( - section_id: provider.sectionId, - service_id: provider.id, - user_id: FireStoreUtils.getCurrentUid(), - serviceAuthorId: provider.author, - ); + FavouriteOndemandServiceModel favouriteModel = + FavouriteOndemandServiceModel( + section_id: provider.sectionId, + service_id: provider.id, + user_id: FireStoreUtils.getCurrentUid(), + serviceAuthorId: provider.author, + ); FireStoreUtils.removeFavouriteOndemandService(favouriteModel); lstFav.removeWhere((item) => item.service_id == provider.id); } else { - FavouriteOndemandServiceModel favouriteModel = FavouriteOndemandServiceModel( - section_id: provider.sectionId, - service_id: provider.id, - user_id: FireStoreUtils.getCurrentUid(), - serviceAuthorId: provider.author, - ); + FavouriteOndemandServiceModel favouriteModel = + FavouriteOndemandServiceModel( + section_id: provider.sectionId, + service_id: provider.id, + user_id: FireStoreUtils.getCurrentUid(), + serviceAuthorId: provider.author, + ); FireStoreUtils.setFavouriteOndemandSection(favouriteModel); lstFav.add(favouriteModel); } @@ -63,7 +70,9 @@ class FavouriteOndemmandController extends GetxController { if (categoryId == null || categoryId.isEmpty) return null; // Try to find category from cached list - CategoryModel? cat = categories.firstWhereOrNull((element) => element.id == categoryId); + CategoryModel? cat = categories.firstWhereOrNull( + (element) => element.id == categoryId, + ); // If not found, fetch from Firestore cat ??= await FireStoreUtils.getCategoryById(categoryId); diff --git a/lib/controllers/food_home_controller.dart b/lib/controllers/food_home_controller.dart index 74f4b97..095a6e5 100644 --- a/lib/controllers/food_home_controller.dart +++ b/lib/controllers/food_home_controller.dart @@ -9,6 +9,7 @@ import 'package:customer/models/favourite_model.dart'; import 'package:customer/models/vendor_category_model.dart'; import 'package:customer/models/vendor_model.dart'; import 'package:customer/utils/preferences.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; @@ -34,8 +35,10 @@ class FoodHomeController extends GetxController { RxBool isPopular = true.obs; RxString selectedOrderTypeValue = "Delivery".tr.obs; - Rx pageController = PageController(viewportFraction: 0.877).obs; - Rx pageBottomController = PageController(viewportFraction: 0.877).obs; + Rx pageController = + PageController(viewportFraction: 0.877).obs; + Rx pageBottomController = + PageController(viewportFraction: 0.877).obs; RxInt currentPage = 0.obs; RxInt currentBottomPage = 0.obs; @@ -65,7 +68,10 @@ class FoodHomeController extends GetxController { Future getData() async { isLoading.value = true; getCartData(); - selectedOrderTypeValue.value = Preferences.getString(Preferences.foodDeliveryType, defaultValue: "Delivery"); + selectedOrderTypeValue.value = Preferences.getString( + Preferences.foodDeliveryType, + defaultValue: "Delivery", + ); await getZone(); FireStoreUtils.getAllNearestRestaurant().listen((event) async { popularRestaurantList.clear(); @@ -81,17 +87,27 @@ class FoodHomeController extends GetxController { (a, b) => Constant.calculateReview( reviewCount: b.reviewsCount.toString(), reviewSum: b.reviewsSum.toString(), - ).compareTo(Constant.calculateReview(reviewCount: a.reviewsCount.toString(), reviewSum: a.reviewsSum.toString())), + ).compareTo( + Constant.calculateReview( + reviewCount: a.reviewsCount.toString(), + reviewSum: a.reviewsSum.toString(), + ), + ), ); - newArrivalRestaurantList.sort((a, b) => (b.createdAt ?? Timestamp.now()).toDate().compareTo((a.createdAt ?? Timestamp.now()).toDate())); + newArrivalRestaurantList.sort( + (a, b) => (b.createdAt ?? Timestamp.now()).toDate().compareTo( + (a.createdAt ?? Timestamp.now()).toDate(), + ), + ); await getVendorCategory(); await FireStoreUtils.getHomeCoupon().then((value) { couponRestaurantList.clear(); couponList.clear(); for (var element1 in value) { for (var element in allNearestRestaurant) { - if (element1.vendorID == element.id && element1.expiresAt!.toDate().isAfter(DateTime.now())) { + if (element1.vendorID == element.id && + element1.expiresAt!.toDate().isAfter(DateTime.now())) { couponList.add(element1); couponRestaurantList.add(element); } @@ -109,7 +125,7 @@ class FoodHomeController extends GetxController { print("nearestIds: $nearestIds"); // Filter stories whose vendorID exists in nearestIds storyList.addAll( - stories.where((story) => nearestIds.contains(story.vendorID)) + stories.where((story) => nearestIds.contains(story.vendorID)), ); print("Filtered storyList length: ${storyList.length}"); }); @@ -147,8 +163,16 @@ class FoodHomeController extends GetxController { await FireStoreUtils.getHomeVendorCategory().then((value) { vendorCategoryModel.value = value; if (Constant.restaurantList != null) { - List usedCategoryIds = Constant.restaurantList!.expand((vendor) => vendor.categoryID ?? []).whereType().toSet().toList(); - vendorCategoryModel.value = vendorCategoryModel.where((category) => usedCategoryIds.contains(category.id)).toList(); + List usedCategoryIds = + Constant.restaurantList! + .expand((vendor) => vendor.categoryID ?? []) + .whereType() + .toSet() + .toList(); + vendorCategoryModel.value = + vendorCategoryModel + .where((category) => usedCategoryIds.contains(category.id)) + .toList(); } }); @@ -176,7 +200,13 @@ class FoodHomeController extends GetxController { await FireStoreUtils.getZone().then((value) { if (value != null) { for (int i = 0; i < value.length; i++) { - if (Constant.isPointInPolygon(LatLng(Constant.selectedLocation.location?.latitude ?? 0.0, Constant.selectedLocation.location?.longitude ?? 0.0), value[i].area!)) { + if (Constant.isPointInPolygon( + LatLng( + Constant.selectedLocation.location?.latitude ?? 0.0, + Constant.selectedLocation.location?.longitude ?? 0.0, + ), + value[i].area!, + )) { Constant.selectedZone = value[i]; Constant.isZoneAvailable = true; break; diff --git a/lib/controllers/forgot_password_controller.dart b/lib/controllers/forgot_password_controller.dart index 3936731..c64621a 100644 --- a/lib/controllers/forgot_password_controller.dart +++ b/lib/controllers/forgot_password_controller.dart @@ -1,3 +1,4 @@ +import 'package:customer/constant/const_texts.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -21,7 +22,7 @@ class ForgotPasswordController extends GetxController { } try { - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); await FirebaseAuth.instance.sendPasswordResetEmail(email: email); ShowToastDialog.closeLoader(); ShowToastDialog.showToast( diff --git a/lib/controllers/gift_card_controller.dart b/lib/controllers/gift_card_controller.dart index 3dd7565..1c98016 100644 --- a/lib/controllers/gift_card_controller.dart +++ b/lib/controllers/gift_card_controller.dart @@ -3,9 +3,11 @@ import 'dart:io'; import 'dart:math' as maths; import 'dart:math'; import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:customer/constant/const_texts.dart'; import 'package:customer/constant/constant.dart'; import 'package:customer/models/gift_cards_model.dart'; import 'package:customer/themes/app_them_data.dart'; + import 'package:flutter_paypal/flutter_paypal.dart'; import 'package:flutter_stripe/flutter_stripe.dart'; import 'package:razorpay_flutter/razorpay_flutter.dart'; @@ -75,27 +77,31 @@ class GiftCardController extends GetxController { giftCardList = value; if (giftCardList.isNotEmpty) { selectedGiftCard.value = giftCardList.first; - messageController.value.text = selectedGiftCard.value.message.toString(); + messageController.value.text = + selectedGiftCard.value.message.toString(); } }); isLoading.value = false; - await FireStoreUtils.getUserProfile(FireStoreUtils.getCurrentUid()).then( - (value) { - if (value != null) { - userModel.value = value; - } - }, - ); + await FireStoreUtils.getUserProfile(FireStoreUtils.getCurrentUid()).then(( + value, + ) { + if (value != null) { + userModel.value = value; + } + }); await getPaymentSettings(); } Future placeOrder() async { if (selectedPaymentMethod.value == PaymentGateway.wallet.name) { - if (double.parse(userModel.value.walletAmount.toString()) >= double.parse(amountController.value.text)) { + if (double.parse(userModel.value.walletAmount.toString()) >= + double.parse(amountController.value.text)) { setOrder(); } else { - ShowToastDialog.showToast("You don't have sufficient wallet balance to purchase gift card".tr); + ShowToastDialog.showToast( + "You don't have sufficient wallet balance to purchase gift card".tr, + ); } } else { setOrder(); @@ -103,7 +109,7 @@ class GiftCardController extends GetxController { } Future setOrder() async { - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); GiftCardsOrderModel giftCardsOrderModel = GiftCardsOrderModel(); giftCardsOrderModel.id = const Uuid().v4(); giftCardsOrderModel.giftId = selectedGiftCard.value.id.toString(); @@ -115,26 +121,34 @@ class GiftCardController extends GetxController { giftCardsOrderModel.giftCode = generateGiftCode(); giftCardsOrderModel.paymentType = selectedPaymentMethod.value; giftCardsOrderModel.createdDate = Timestamp.now(); - DateTime dateTime = DateTime.now().add(Duration(days: int.parse(selectedGiftCard.value.expiryDay ?? "2"))); + DateTime dateTime = DateTime.now().add( + Duration(days: int.parse(selectedGiftCard.value.expiryDay ?? "2")), + ); giftCardsOrderModel.expireDate = Timestamp.fromDate(dateTime); giftCardsOrderModel.userid = FireStoreUtils.getCurrentUid(); if (selectedPaymentMethod.value == PaymentGateway.wallet.name) { WalletTransactionModel transactionModel = WalletTransactionModel( - id: Constant.getUuid(), - amount: double.parse(amountController.value.text), - date: Timestamp.now(), - paymentMethod: PaymentGateway.wallet.name, - transactionUser: "user", - userId: FireStoreUtils.getCurrentUid(), - isTopup: false, - orderId: giftCardsOrderModel.id, - note: "Gift card purchase amount debited".tr, - paymentStatus: "success".tr); + id: Constant.getUuid(), + amount: double.parse(amountController.value.text), + date: Timestamp.now(), + paymentMethod: PaymentGateway.wallet.name, + transactionUser: "user", + userId: FireStoreUtils.getCurrentUid(), + isTopup: false, + orderId: giftCardsOrderModel.id, + note: "Gift card purchase amount debited".tr, + paymentStatus: "success".tr, + ); - await FireStoreUtils.setWalletTransaction(transactionModel).then((value) async { + await FireStoreUtils.setWalletTransaction(transactionModel).then(( + value, + ) async { if (value == true) { - await FireStoreUtils.updateUserWallet(amount: "-${amountController.value.text.toString()}", userId: FireStoreUtils.getCurrentUid()).then((value) {}); + await FireStoreUtils.updateUserWallet( + amount: "-${amountController.value.text.toString()}", + userId: FireStoreUtils.getCurrentUid(), + ).then((value) {}); } }); } @@ -178,54 +192,78 @@ class GiftCardController extends GetxController { Rx xenditModel = Xendit().obs; Future getPaymentSettings() async { - await FireStoreUtils.getPaymentSettingsData().then( - (value) { - payFastModel.value = PayFastModel.fromJson(jsonDecode(Preferences.getString(Preferences.payFastSettings))); - mercadoPagoModel.value = MercadoPagoModel.fromJson(jsonDecode(Preferences.getString(Preferences.mercadoPago))); - payPalModel.value = PayPalModel.fromJson(jsonDecode(Preferences.getString(Preferences.paypalSettings))); - stripeModel.value = StripeModel.fromJson(jsonDecode(Preferences.getString(Preferences.stripeSettings))); - flutterWaveModel.value = FlutterWaveModel.fromJson(jsonDecode(Preferences.getString(Preferences.flutterWave))); - payStackModel.value = PayStackModel.fromJson(jsonDecode(Preferences.getString(Preferences.payStack))); - paytmModel.value = PaytmModel.fromJson(jsonDecode(Preferences.getString(Preferences.paytmSettings))); - razorPayModel.value = RazorPayModel.fromJson(jsonDecode(Preferences.getString(Preferences.razorpaySettings))); - cashOnDeliverySettingModel.value = CodSettingModel.fromJson(jsonDecode(Preferences.getString(Preferences.codSettings))); - midTransModel.value = MidTrans.fromJson(jsonDecode(Preferences.getString(Preferences.midTransSettings))); - orangeMoneyModel.value = OrangeMoney.fromJson(jsonDecode(Preferences.getString(Preferences.orangeMoneySettings))); - xenditModel.value = Xendit.fromJson(jsonDecode(Preferences.getString(Preferences.xenditSettings))); - walletSettingModel.value = WalletSettingModel.fromJson(jsonDecode(Preferences.getString(Preferences.walletSettings))); - if (walletSettingModel.value.isEnabled == true) { - selectedPaymentMethod.value = PaymentGateway.wallet.name; - } else if (stripeModel.value.isEnabled == true) { - selectedPaymentMethod.value = PaymentGateway.stripe.name; - } else if (payPalModel.value.isEnabled == true) { - selectedPaymentMethod.value = PaymentGateway.paypal.name; - } else if (payStackModel.value.isEnable == true) { - selectedPaymentMethod.value = PaymentGateway.payStack.name; - } else if (mercadoPagoModel.value.isEnabled == true) { - selectedPaymentMethod.value = PaymentGateway.mercadoPago.name; - } else if (flutterWaveModel.value.isEnable == true) { - selectedPaymentMethod.value = PaymentGateway.flutterWave.name; - }else if (payFastModel.value.isEnable == true) { - selectedPaymentMethod.value = PaymentGateway.payFast.name; - } else if (razorPayModel.value.isEnabled == true) { - selectedPaymentMethod.value = PaymentGateway.razorpay.name; - } else if (midTransModel.value.enable == true) { - selectedPaymentMethod.value = PaymentGateway.midTrans.name; - } else if (orangeMoneyModel.value.enable == true) { - selectedPaymentMethod.value = PaymentGateway.orangeMoney.name; - } else if (xenditModel.value.enable == true) { - selectedPaymentMethod.value = PaymentGateway.xendit.name; - } - Stripe.publishableKey = stripeModel.value.clientpublishableKey.toString(); - Stripe.merchantIdentifier = 'GoRide'; - Stripe.instance.applySettings(); - setRef(); + await FireStoreUtils.getPaymentSettingsData().then((value) { + payFastModel.value = PayFastModel.fromJson( + jsonDecode(Preferences.getString(Preferences.payFastSettings)), + ); + mercadoPagoModel.value = MercadoPagoModel.fromJson( + jsonDecode(Preferences.getString(Preferences.mercadoPago)), + ); + payPalModel.value = PayPalModel.fromJson( + jsonDecode(Preferences.getString(Preferences.paypalSettings)), + ); + stripeModel.value = StripeModel.fromJson( + jsonDecode(Preferences.getString(Preferences.stripeSettings)), + ); + flutterWaveModel.value = FlutterWaveModel.fromJson( + jsonDecode(Preferences.getString(Preferences.flutterWave)), + ); + payStackModel.value = PayStackModel.fromJson( + jsonDecode(Preferences.getString(Preferences.payStack)), + ); + paytmModel.value = PaytmModel.fromJson( + jsonDecode(Preferences.getString(Preferences.paytmSettings)), + ); + razorPayModel.value = RazorPayModel.fromJson( + jsonDecode(Preferences.getString(Preferences.razorpaySettings)), + ); + cashOnDeliverySettingModel.value = CodSettingModel.fromJson( + jsonDecode(Preferences.getString(Preferences.codSettings)), + ); + midTransModel.value = MidTrans.fromJson( + jsonDecode(Preferences.getString(Preferences.midTransSettings)), + ); + orangeMoneyModel.value = OrangeMoney.fromJson( + jsonDecode(Preferences.getString(Preferences.orangeMoneySettings)), + ); + xenditModel.value = Xendit.fromJson( + jsonDecode(Preferences.getString(Preferences.xenditSettings)), + ); + walletSettingModel.value = WalletSettingModel.fromJson( + jsonDecode(Preferences.getString(Preferences.walletSettings)), + ); + if (walletSettingModel.value.isEnabled == true) { + selectedPaymentMethod.value = PaymentGateway.wallet.name; + } else if (stripeModel.value.isEnabled == true) { + selectedPaymentMethod.value = PaymentGateway.stripe.name; + } else if (payPalModel.value.isEnabled == true) { + selectedPaymentMethod.value = PaymentGateway.paypal.name; + } else if (payStackModel.value.isEnable == true) { + selectedPaymentMethod.value = PaymentGateway.payStack.name; + } else if (mercadoPagoModel.value.isEnabled == true) { + selectedPaymentMethod.value = PaymentGateway.mercadoPago.name; + } else if (flutterWaveModel.value.isEnable == true) { + selectedPaymentMethod.value = PaymentGateway.flutterWave.name; + } else if (payFastModel.value.isEnable == true) { + selectedPaymentMethod.value = PaymentGateway.payFast.name; + } else if (razorPayModel.value.isEnabled == true) { + selectedPaymentMethod.value = PaymentGateway.razorpay.name; + } else if (midTransModel.value.enable == true) { + selectedPaymentMethod.value = PaymentGateway.midTrans.name; + } else if (orangeMoneyModel.value.enable == true) { + selectedPaymentMethod.value = PaymentGateway.orangeMoney.name; + } else if (xenditModel.value.enable == true) { + selectedPaymentMethod.value = PaymentGateway.xendit.name; + } + Stripe.publishableKey = stripeModel.value.clientpublishableKey.toString(); + Stripe.merchantIdentifier = 'GoRide'; + Stripe.instance.applySettings(); + setRef(); - razorPay.on(Razorpay.EVENT_PAYMENT_SUCCESS, handlePaymentSuccess); - razorPay.on(Razorpay.EVENT_EXTERNAL_WALLET, handleExternalWaller); - razorPay.on(Razorpay.EVENT_PAYMENT_ERROR, handlePaymentError); - }, - ); + razorPay.on(Razorpay.EVENT_PAYMENT_SUCCESS, handlePaymentSuccess); + razorPay.on(Razorpay.EVENT_EXTERNAL_WALLET, handleExternalWaller); + razorPay.on(Razorpay.EVENT_PAYMENT_ERROR, handlePaymentError); + }); } // final _flutterPaypalNativePlugin = FlutterPaypalNative.instance; @@ -296,28 +334,34 @@ class GiftCardController extends GetxController { // Strip Future stripeMakePayment({required String amount}) async { try { - Map? paymentIntentData = await createStripeIntent(amount: amount); + Map? paymentIntentData = await createStripeIntent( + amount: amount, + ); if (paymentIntentData!.containsKey("error")) { Get.back(); - ShowToastDialog.showToast("Something went wrong, please contact admin."); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.", + ); } else { await Stripe.instance.initPaymentSheet( - paymentSheetParameters: SetupPaymentSheetParameters( - paymentIntentClientSecret: paymentIntentData['client_secret'], - allowsDelayedPaymentMethods: false, - googlePay: const PaymentSheetGooglePay( - merchantCountryCode: 'US', - testEnv: true, - currencyCode: "USD", - ), - customFlow: true, - style: ThemeMode.system, - appearance: PaymentSheetAppearance( - colors: PaymentSheetAppearanceColors( - primary: AppThemeData.primary300, - ), - ), - merchantDisplayName: 'GoRide')); + paymentSheetParameters: SetupPaymentSheetParameters( + paymentIntentClientSecret: paymentIntentData['client_secret'], + allowsDelayedPaymentMethods: false, + googlePay: const PaymentSheetGooglePay( + merchantCountryCode: 'US', + testEnv: true, + currencyCode: "USD", + ), + customFlow: true, + style: ThemeMode.system, + appearance: PaymentSheetAppearance( + colors: PaymentSheetAppearanceColors( + primary: AppThemeData.primary300, + ), + ), + merchantDisplayName: 'GoRide', + ), + ); displayStripePaymentSheet(amount: amount); } } catch (e, s) { @@ -356,8 +400,14 @@ class GiftCardController extends GetxController { "shipping[address][country]": "US", }; var stripeSecret = stripeModel.value.stripeSecret; - var response = await http.post(Uri.parse('https://api.stripe.com/v1/payment_intents'), - body: body, headers: {'Authorization': 'Bearer $stripeSecret', 'Content-Type': 'application/x-www-form-urlencoded'}); + var response = await http.post( + Uri.parse('https://api.stripe.com/v1/payment_intents'), + body: body, + headers: { + 'Authorization': 'Bearer $stripeSecret', + 'Content-Type': 'application/x-www-form-urlencoded', + }, + ); return jsonDecode(response.body); } catch (e) { @@ -366,7 +416,10 @@ class GiftCardController extends GetxController { } //mercadoo - Future mercadoPagoMakePayment({required BuildContext context, required String amount}) async { + Future mercadoPagoMakePayment({ + required BuildContext context, + required String amount, + }) async { final headers = { 'Authorization': 'Bearer ${mercadoPagoModel.value.accessToken}', 'Content-Type': 'application/json', @@ -380,7 +433,7 @@ class GiftCardController extends GetxController { "quantity": 1, "currency_id": "BRL", // or your preferred currency "unit_price": double.parse(amount), - } + }, ], "payer": {"email": userModel.value.email}, "back_urls": { @@ -388,7 +441,8 @@ class GiftCardController extends GetxController { "pending": "${Constant.globalUrl}payment/pending", "success": "${Constant.globalUrl}payment/success", }, - "auto_return": "approved" // Automatically return after payment is approved + "auto_return": + "approved", // Automatically return after payment is approved }); final response = await http.post( @@ -416,18 +470,22 @@ class GiftCardController extends GetxController { ///PayStack Payment Method Future payStackPayment(String totalAmount) async { await PayStackURLGen.payStackURLGen( - amount: (double.parse(totalAmount) * 100).toString(), currency: "ZAR", secretKey: payStackModel.value.secretKey.toString(), userModel: userModel.value) - .then((value) async { + amount: (double.parse(totalAmount) * 100).toString(), + currency: "ZAR", + secretKey: payStackModel.value.secretKey.toString(), + userModel: userModel.value, + ).then((value) async { if (value != null) { PayStackUrlModel payStackModel0 = value; - Get.to(PayStackScreen( - secretKey: payStackModel.value.secretKey.toString(), - callBackUrl: payStackModel.value.callbackURL.toString(), - initialURl: payStackModel0.data.authorizationUrl, - amount: totalAmount, - reference: payStackModel0.data.reference, - ))! - .then((value) { + Get.to( + PayStackScreen( + secretKey: payStackModel.value.secretKey.toString(), + callBackUrl: payStackModel.value.callbackURL.toString(), + initialURl: payStackModel0.data.authorizationUrl, + amount: totalAmount, + reference: payStackModel0.data.reference, + ), + )!.then((value) { if (value) { ShowToastDialog.showToast("Payment Successful!!".tr); placeOrder(); @@ -436,13 +494,18 @@ class GiftCardController extends GetxController { } }); } else { - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); } }); } //flutter wave Payment Method - Future flutterWaveInitiatePayment({required BuildContext context, required String amount}) async { + Future flutterWaveInitiatePayment({ + required BuildContext context, + required String amount, + }) async { final url = Uri.parse('https://api.flutterwave.com/v3/payments'); final headers = { 'Authorization': 'Bearer ${flutterWaveModel.value.secretKey}', @@ -463,14 +526,16 @@ class GiftCardController extends GetxController { "customizations": { "title": "Payment for Services", "description": "Payment for XYZ services", - } + }, }); final response = await http.post(url, headers: headers, body: body); if (response.statusCode == 200) { final data = jsonDecode(response.body); - Get.to(MercadoPagoScreen(initialURl: data['data']['link']))!.then((value) { + Get.to(MercadoPagoScreen(initialURl: data['data']['link']))!.then(( + value, + ) { if (value) { ShowToastDialog.showToast("Payment Successful!!".tr); placeOrder(); @@ -499,8 +564,14 @@ class GiftCardController extends GetxController { // payFast void payFastPayment({required BuildContext context, required String amount}) { - PayStackURLGen.getPayHTML(payFastSettingData: payFastModel.value, amount: amount.toString(), userModel: userModel.value).then((String? value) async { - bool isDone = await Get.to(PayFastScreen(htmlData: value!, payFastSettingData: payFastModel.value)); + PayStackURLGen.getPayHTML( + payFastSettingData: payFastModel.value, + amount: amount.toString(), + userModel: userModel.value, + ).then((String? value) async { + bool isDone = await Get.to( + PayFastScreen(htmlData: value!, payFastSettingData: payFastModel.value), + ); if (isDone) { Get.back(); ShowToastDialog.showToast("Payment successfully".tr); @@ -512,38 +583,40 @@ class GiftCardController extends GetxController { }); } -//PayPal + //PayPal void paypalPaymentSheet(String amount, context) { Navigator.of(context).push( MaterialPageRoute( - builder: (BuildContext context) => UsePaypal( - sandboxMode: payPalModel.value.isLive == true ? false : true, - clientId: payPalModel.value.paypalClient ?? '', - secretKey: payPalModel.value.paypalSecret ?? '', - returnURL: "com.parkme://paypalpay", - cancelURL: "com.parkme://paypalpay", - transactions: [ - { - "amount": { - "total": amount, - "currency": "USD", - "details": {"subtotal": amount} + builder: + (BuildContext context) => UsePaypal( + sandboxMode: payPalModel.value.isLive == true ? false : true, + clientId: payPalModel.value.paypalClient ?? '', + secretKey: payPalModel.value.paypalSecret ?? '', + returnURL: "com.parkme://paypalpay", + cancelURL: "com.parkme://paypalpay", + transactions: [ + { + "amount": { + "total": amount, + "currency": "USD", + "details": {"subtotal": amount}, + }, }, - } - ], - note: "Contact us for any questions on your order.", - onSuccess: (Map params) async { - placeOrder(); - ShowToastDialog.showToast("Payment Successful!!".tr); - }, - onError: (error) { - Get.back(); - ShowToastDialog.showToast("Payment UnSuccessful!!".tr); - }, - onCancel: (params) { - Get.back(); - ShowToastDialog.showToast("Payment UnSuccessful!!".tr); - }), + ], + note: "Contact us for any questions on your order.", + onSuccess: (Map params) async { + placeOrder(); + ShowToastDialog.showToast("Payment Successful!!".tr); + }, + onError: (error) { + Get.back(); + ShowToastDialog.showToast("Payment UnSuccessful!!".tr); + }, + onCancel: (params) { + Get.back(); + ShowToastDialog.showToast("Payment UnSuccessful!!".tr); + }, + ), ), ); } @@ -554,33 +627,52 @@ class GiftCardController extends GetxController { String getChecksum = "${Constant.globalUrl}payments/getpaytmchecksum"; final response = await http.post( - Uri.parse( - getChecksum, - ), - headers: {}, - body: { - "mid": paytmModel.value.paytmMID.toString(), - "order_id": orderId, - "key_secret": paytmModel.value.pAYTMMERCHANTKEY.toString(), - }); + Uri.parse(getChecksum), + headers: {}, + body: { + "mid": paytmModel.value.paytmMID.toString(), + "order_id": orderId, + "key_secret": paytmModel.value.pAYTMMERCHANTKEY.toString(), + }, + ); final data = jsonDecode(response.body); - await verifyCheckSum(checkSum: data["code"], amount: amount, orderId: orderId).then((value) { + await verifyCheckSum( + checkSum: data["code"], + amount: amount, + orderId: orderId, + ).then((value) { initiatePayment(amount: amount, orderId: orderId).then((value) { String callback = ""; if (paytmModel.value.isSandboxEnabled == true) { - callback = "${callback}https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; + callback = + "${callback}https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; } else { - callback = "${callback}https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; + callback = + "${callback}https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; } GetPaymentTxtTokenModel result = value; - startTransaction(context, txnTokenBy: result.body.txnToken ?? '', orderId: orderId, amount: amount, callBackURL: callback, isStaging: paytmModel.value.isSandboxEnabled); + startTransaction( + context, + txnTokenBy: result.body.txnToken ?? '', + orderId: orderId, + amount: amount, + callBackURL: callback, + isStaging: paytmModel.value.isSandboxEnabled, + ); }); }); } - Future startTransaction(context, {required String txnTokenBy, required orderId, required double amount, required callBackURL, required isStaging}) async { + Future startTransaction( + context, { + required String txnTokenBy, + required orderId, + required double amount, + required callBackURL, + required isStaging, + }) async { // try { // var response = AllInOneSdk.startTransaction( // paytmModel.value.paytmMID.toString(), @@ -615,46 +707,61 @@ class GiftCardController extends GetxController { // } } - Future verifyCheckSum({required String checkSum, required double amount, required orderId}) async { + Future verifyCheckSum({ + required String checkSum, + required double amount, + required orderId, + }) async { String getChecksum = "${Constant.globalUrl}payments/validatechecksum"; final response = await http.post( - Uri.parse( - getChecksum, - ), - headers: {}, - body: { - "mid": paytmModel.value.paytmMID.toString(), - "order_id": orderId, - "key_secret": paytmModel.value.pAYTMMERCHANTKEY.toString(), - "checksum_value": checkSum, - }); + Uri.parse(getChecksum), + headers: {}, + body: { + "mid": paytmModel.value.paytmMID.toString(), + "order_id": orderId, + "key_secret": paytmModel.value.pAYTMMERCHANTKEY.toString(), + "checksum_value": checkSum, + }, + ); final data = jsonDecode(response.body); return data['status']; } - Future initiatePayment({required double amount, required orderId}) async { + Future initiatePayment({ + required double amount, + required orderId, + }) async { String initiateURL = "${Constant.globalUrl}payments/initiatepaytmpayment"; String callback = ""; if (paytmModel.value.isSandboxEnabled == true) { - callback = "${callback}https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; + callback = + "${callback}https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; } else { - callback = "${callback}https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; + callback = + "${callback}https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; } - final response = await http.post(Uri.parse(initiateURL), headers: {}, body: { - "mid": paytmModel.value.paytmMID, - "order_id": orderId, - "key_secret": paytmModel.value.pAYTMMERCHANTKEY, - "amount": amount.toString(), - "currency": "INR", - "callback_url": callback, - "custId": FireStoreUtils.getCurrentUid(), - "issandbox": paytmModel.value.isSandboxEnabled == true ? "1" : "2", - }); + final response = await http.post( + Uri.parse(initiateURL), + headers: {}, + body: { + "mid": paytmModel.value.paytmMID, + "order_id": orderId, + "key_secret": paytmModel.value.pAYTMMERCHANTKEY, + "amount": amount.toString(), + "currency": "INR", + "callback_url": callback, + "custId": FireStoreUtils.getCurrentUid(), + "issandbox": paytmModel.value.isSandboxEnabled == true ? "1" : "2", + }, + ); print(response.body); final data = jsonDecode(response.body); - if (data["body"]["txnToken"] == null || data["body"]["txnToken"].toString().isEmpty) { + if (data["body"]["txnToken"] == null || + data["body"]["txnToken"].toString().isEmpty) { Get.back(); - ShowToastDialog.showToast("something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "something went wrong, please contact admin.".tr, + ); } return GetPaymentTxtTokenModel.fromJson(data); } @@ -677,8 +784,8 @@ class GiftCardController extends GetxController { 'email': userModel.value.email, }, 'external': { - 'wallets': ['paytm'] - } + 'wallets': ['paytm'], + }, }; try { @@ -705,14 +812,14 @@ class GiftCardController extends GetxController { } //Midtrans payment - Future midtransMakePayment({required String amount, required BuildContext context}) async { + Future midtransMakePayment({ + required String amount, + required BuildContext context, + }) async { await createPaymentLink(amount: amount).then((url) { ShowToastDialog.closeLoader(); if (url != '') { - Get.to(() => MidtransScreen( - initialURl: url, - ))! - .then((value) { + Get.to(() => MidtransScreen(initialURl: url))!.then((value) { if (value == true) { ShowToastDialog.showToast("Payment Successful!!".tr); placeOrder(); @@ -726,14 +833,20 @@ class GiftCardController extends GetxController { Future createPaymentLink({required var amount}) async { var ordersId = const Uuid().v1(); - final url = Uri.parse(midTransModel.value.isSandbox! ? 'https://api.sandbox.midtrans.com/v1/payment-links' : 'https://api.midtrans.com/v1/payment-links'); + final url = Uri.parse( + midTransModel.value.isSandbox! + ? 'https://api.sandbox.midtrans.com/v1/payment-links' + : 'https://api.midtrans.com/v1/payment-links', + ); final response = await http.post( url, headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', - 'Authorization': generateBasicAuthHeader(midTransModel.value.serverKey!), + 'Authorization': generateBasicAuthHeader( + midTransModel.value.serverKey!, + ), }, body: jsonEncode({ 'transaction_details': { @@ -741,7 +854,9 @@ class GiftCardController extends GetxController { 'gross_amount': double.parse(amount.toString()).toInt(), }, 'usage_limit': 2, - "callbacks": {"finish": "https://www.google.com?merchant_order_id=$ordersId"}, + "callbacks": { + "finish": "https://www.google.com?merchant_order_id=$ordersId", + }, }), ); @@ -749,7 +864,9 @@ class GiftCardController extends GetxController { final responseData = jsonDecode(response.body); return responseData['payment_url']; } else { - ShowToastDialog.showToast("something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "something went wrong, please contact admin.".tr, + ); return ''; } } @@ -766,21 +883,30 @@ class GiftCardController extends GetxController { static String orderId = ''; static String amount = ''; - Future orangeMakePayment({required String amount, required BuildContext context}) async { + Future orangeMakePayment({ + required String amount, + required BuildContext context, + }) async { reset(); var id = const Uuid().v4(); - var paymentURL = await fetchToken(context: context, orderId: id, amount: amount, currency: 'USD'); + var paymentURL = await fetchToken( + context: context, + orderId: id, + amount: amount, + currency: 'USD', + ); ShowToastDialog.closeLoader(); if (paymentURL.toString() != '') { - Get.to(() => OrangeMoneyScreen( - initialURl: paymentURL, - accessToken: accessToken, - amount: amount, - orangePay: orangeMoneyModel.value, - orderId: orderId, - payToken: payToken, - ))! - .then((value) { + Get.to( + () => OrangeMoneyScreen( + initialURl: paymentURL, + accessToken: accessToken, + amount: amount, + orangePay: orangeMoneyModel.value, + orderId: orderId, + payToken: payToken, + ), + )!.then((value) { if (value == true) { ShowToastDialog.showToast("Payment Successful!!".tr); placeOrder(); @@ -792,19 +918,24 @@ class GiftCardController extends GetxController { } } - Future fetchToken({required String orderId, required String currency, required BuildContext context, required String amount}) async { + Future fetchToken({ + required String orderId, + required String currency, + required BuildContext context, + required String amount, + }) async { String apiUrl = 'https://api.orange.com/oauth/v3/token'; - Map requestBody = { - 'grant_type': 'client_credentials', - }; + Map requestBody = {'grant_type': 'client_credentials'}; - var response = await http.post(Uri.parse(apiUrl), - headers: { - 'Authorization': "Basic ${orangeMoneyModel.value.auth!}", - 'Content-Type': 'application/x-www-form-urlencoded', - 'Accept': 'application/json', - }, - body: requestBody); + var response = await http.post( + Uri.parse(apiUrl), + headers: { + 'Authorization': "Basic ${orangeMoneyModel.value.auth!}", + 'Content-Type': 'application/x-www-form-urlencoded', + 'Accept': 'application/json', + }, + body: requestBody, + ); // Handle the response @@ -813,18 +944,32 @@ class GiftCardController extends GetxController { accessToken = responseData['access_token']; // ignore: use_build_context_synchronously - return await webpayment(context: context, amountData: amount, currency: currency, orderIdData: orderId); + return await webpayment( + context: context, + amountData: amount, + currency: currency, + orderIdData: orderId, + ); } else { - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); return ''; } } - Future webpayment({required String orderIdData, required BuildContext context, required String currency, required String amountData}) async { + Future webpayment({ + required String orderIdData, + required BuildContext context, + required String currency, + required String amountData, + }) async { orderId = orderIdData; amount = amountData; String apiUrl = - orangeMoneyModel.value.isSandbox! == true ? 'https://api.orange.com/orange-money-webpay/dev/v1/webpayment' : 'https://api.orange.com/orange-money-webpay/cm/v1/webpayment'; + orangeMoneyModel.value.isSandbox! == true + ? 'https://api.orange.com/orange-money-webpay/dev/v1/webpayment' + : 'https://api.orange.com/orange-money-webpay/cm/v1/webpayment'; Map requestBody = { "merchant_key": orangeMoneyModel.value.merchantKey ?? '', "currency": orangeMoneyModel.value.isSandbox == true ? "OUV" : currency, @@ -839,7 +984,11 @@ class GiftCardController extends GetxController { var response = await http.post( Uri.parse(apiUrl), - headers: {'Authorization': 'Bearer $accessToken', 'Content-Type': 'application/json', 'Accept': 'application/json'}, + headers: { + 'Authorization': 'Bearer $accessToken', + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, body: json.encode(requestBody), ); @@ -853,7 +1002,9 @@ class GiftCardController extends GetxController { return ''; } } else { - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); return ''; } } @@ -870,12 +1021,13 @@ class GiftCardController extends GetxController { await createXenditInvoice(amount: amount).then((model) { ShowToastDialog.closeLoader(); if (model.id != null) { - Get.to(() => XenditScreen( - initialURl: model.invoiceUrl ?? '', - transId: model.id ?? '', - apiKey: xenditModel.value.apiKey!.toString(), - ))! - .then((value) { + Get.to( + () => XenditScreen( + initialURl: model.invoiceUrl ?? '', + transId: model.id ?? '', + apiKey: xenditModel.value.apiKey!.toString(), + ), + )!.then((value) { if (value == true) { ShowToastDialog.showToast("Payment Successful!!".tr); placeOrder(); @@ -892,7 +1044,9 @@ class GiftCardController extends GetxController { const url = 'https://api.xendit.co/v2/invoices'; var headers = { 'Content-Type': 'application/json', - 'Authorization': generateBasicAuthHeader(xenditModel.value.apiKey!.toString()), + 'Authorization': generateBasicAuthHeader( + xenditModel.value.apiKey!.toString(), + ), // 'Cookie': '__cf_bm=yERkrx3xDITyFGiou0bbKY1bi7xEwovHNwxV1vCNbVc-1724155511-1.0.1.1-jekyYQmPCwY6vIJ524K0V6_CEw6O.dAwOmQnHtwmaXO_MfTrdnmZMka0KZvjukQgXu5B.K_6FJm47SGOPeWviQ', }; @@ -905,7 +1059,11 @@ class GiftCardController extends GetxController { }); try { - final response = await http.post(Uri.parse(url), headers: headers, body: body); + final response = await http.post( + Uri.parse(url), + headers: headers, + body: body, + ); if (response.statusCode == 200 || response.statusCode == 201) { XenditModel model = XenditModel.fromJson(jsonDecode(response.body)); diff --git a/lib/controllers/global_setting_controller.dart b/lib/controllers/global_setting_controller.dart index 1bcf70e..1efe160 100644 --- a/lib/controllers/global_setting_controller.dart +++ b/lib/controllers/global_setting_controller.dart @@ -18,13 +18,27 @@ class GlobalSettingController extends GetxController { } Future getCurrentCurrency() async { - FireStoreUtils.fireStore.collection(CollectionName.currencies).where("isActive", isEqualTo: true).snapshots().listen((event) { - if (event.docs.isNotEmpty) { - Constant.currencyModel = CurrencyModel.fromJson(event.docs.first.data()); - } else { - Constant.currencyModel = CurrencyModel(id: "", code: "USD", decimal: 2, isactive: true, name: "US Dollar", symbol: "\$", symbolatright: false); - } - }); + FireStoreUtils.fireStore + .collection(CollectionName.currencies) + .where("isActive", isEqualTo: true) + .snapshots() + .listen((event) { + if (event.docs.isNotEmpty) { + Constant.currencyModel = CurrencyModel.fromJson( + event.docs.first.data(), + ); + } else { + Constant.currencyModel = CurrencyModel( + id: "", + code: "USD", + decimal: 2, + isactive: true, + name: "US Dollar", + symbol: "\$", + symbolatright: false, + ); + } + }); await FireStoreUtils.getSettings(); } @@ -35,7 +49,9 @@ class GlobalSettingController extends GetxController { String token = await NotificationService.getToken(); log(":::::::TOKEN:::::: $token"); if (FirebaseAuth.instance.currentUser != null) { - await FireStoreUtils.getUserProfile(FireStoreUtils.getCurrentUid()).then((value) { + await FireStoreUtils.getUserProfile( + FireStoreUtils.getCurrentUid(), + ).then((value) { if (value != null) { UserModel driverUserModel = value; driverUserModel.fcmToken = token; diff --git a/lib/controllers/history_gift_card_controller.dart b/lib/controllers/history_gift_card_controller.dart index aae9f46..14d749c 100644 --- a/lib/controllers/history_gift_card_controller.dart +++ b/lib/controllers/history_gift_card_controller.dart @@ -1,6 +1,7 @@ import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:customer/constant/constant.dart'; import 'package:customer/models/gift_cards_order_model.dart'; + import 'package:share_plus/share_plus.dart'; import '../service/fire_store_utils.dart'; import 'package:get/get.dart'; @@ -24,13 +25,20 @@ class HistoryGiftCardController extends GetxController { void updateList(int index) { GiftCardsOrderModel giftCardsOrderModel = giftCardsOrderList[index]; - giftCardsOrderModel.isPasswordShow = giftCardsOrderModel.isPasswordShow == true ? false : true; + giftCardsOrderModel.isPasswordShow = + giftCardsOrderModel.isPasswordShow == true ? false : true; giftCardsOrderList.removeAt(index); giftCardsOrderList.insert(index, giftCardsOrderModel); } - Future share(String giftCode, String giftPin, String msg, String amount, Timestamp date) async { + Future share( + String giftCode, + String giftPin, + String msg, + String amount, + Timestamp date, + ) async { await Share.share( "${'Gift Code :'.tr} $giftCode\n${'Gift Pin :'.tr} $giftPin\n${'Price :'.tr} ${Constant.amountShow(amount: amount)}\n${'Expire Date :'.tr} ${date.toDate()}\n\n${'Message'.tr} : $msg", ); diff --git a/lib/controllers/home_e_commerce_controller.dart b/lib/controllers/home_e_commerce_controller.dart index d92daa0..7571744 100644 --- a/lib/controllers/home_e_commerce_controller.dart +++ b/lib/controllers/home_e_commerce_controller.dart @@ -9,7 +9,6 @@ import 'package:customer/service/cart_provider.dart'; import 'package:customer/service/fire_store_utils.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; - import '../constant/constant.dart'; class HomeECommerceController extends GetxController { @@ -27,8 +26,10 @@ class HomeECommerceController extends GetxController { RxBool isListView = true.obs; RxBool isPopular = true.obs; - Rx pageController = PageController(viewportFraction: 0.877).obs; - Rx pageBottomController = PageController(viewportFraction: 0.877).obs; + Rx pageController = + PageController(viewportFraction: 0.877).obs; + Rx pageBottomController = + PageController(viewportFraction: 0.877).obs; RxInt currentPage = 0.obs; RxInt currentBottomPage = 0.obs; @@ -41,7 +42,8 @@ class HomeECommerceController extends GetxController { } RxList vendorCategoryModel = [].obs; - RxList categoryWiseProductList = [].obs; + RxList categoryWiseProductList = + [].obs; RxList allNearestRestaurant = [].obs; RxList newArrivalRestaurantList = [].obs; @@ -64,10 +66,22 @@ class HomeECommerceController extends GetxController { allNearestRestaurant.addAll(event); newArrivalRestaurantList.addAll(event); Constant.restaurantList = allNearestRestaurant; - List usedCategoryIds = allNearestRestaurant.expand((vendor) => vendor.categoryID ?? []).whereType().toSet().toList(); - vendorCategoryModel.value = vendorCategoryModel.where((category) => usedCategoryIds.contains(category.id)).toList(); + List usedCategoryIds = + allNearestRestaurant + .expand((vendor) => vendor.categoryID ?? []) + .whereType() + .toSet() + .toList(); + vendorCategoryModel.value = + vendorCategoryModel + .where((category) => usedCategoryIds.contains(category.id)) + .toList(); - newArrivalRestaurantList.sort((a, b) => (b.createdAt ?? Timestamp.now()).toDate().compareTo((a.createdAt ?? Timestamp.now()).toDate())); + newArrivalRestaurantList.sort( + (a, b) => (b.createdAt ?? Timestamp.now()).toDate().compareTo( + (a.createdAt ?? Timestamp.now()).toDate(), + ), + ); if (Constant.isEnableAdsFeature == true) { await FireStoreUtils.getAllAdvertisement().then((value) { diff --git a/lib/controllers/live_tracking_controller.dart b/lib/controllers/live_tracking_controller.dart index dbc245c..c347535 100644 --- a/lib/controllers/live_tracking_controller.dart +++ b/lib/controllers/live_tracking_controller.dart @@ -59,37 +59,58 @@ class LiveTrackingController extends GetxController { orderModel.value = args['orderModel']; - orderSub = FireStoreUtils.fireStore.collection(CollectionName.vendorOrders).doc(orderModel.value.id).snapshots().listen((orderSnap) { - if (orderSnap.data() == null) return; - orderModel.value = OrderModel.fromJson(orderSnap.data()!); + orderSub = FireStoreUtils.fireStore + .collection(CollectionName.vendorOrders) + .doc(orderModel.value.id) + .snapshots() + .listen((orderSnap) { + if (orderSnap.data() == null) return; + orderModel.value = OrderModel.fromJson(orderSnap.data()!); - if (orderModel.value.driverID != null) { - driverSub?.cancel(); - driverSub = FireStoreUtils.fireStore.collection(CollectionName.users).doc(orderModel.value.driverID).snapshots().listen((driverSnap) async { - if (driverSnap.data() == null) return; - driverUserModel.value = UserModel.fromJson(driverSnap.data()!); - await updateLiveTracking(); + if (orderModel.value.driverID != null) { + driverSub?.cancel(); + driverSub = FireStoreUtils.fireStore + .collection(CollectionName.users) + .doc(orderModel.value.driverID) + .snapshots() + .listen((driverSnap) async { + if (driverSnap.data() == null) return; + driverUserModel.value = UserModel.fromJson( + driverSnap.data()!, + ); + await updateLiveTracking(); + }); + } + + if (orderModel.value.status == Constant.orderCompleted) { + Get.back(); + } }); - } - - if (orderModel.value.status == Constant.orderCompleted) { - Get.back(); - } - }); isLoading.value = false; } Future updateLiveTracking() async { - driverCurrent.value = location.LatLng(driverUserModel.value.location?.latitude ?? 0.0, driverUserModel.value.location?.longitude ?? 0.0); + driverCurrent.value = location.LatLng( + driverUserModel.value.location?.latitude ?? 0.0, + driverUserModel.value.location?.longitude ?? 0.0, + ); - source.value = location.LatLng(orderModel.value.vendor?.latitude ?? 0.0, orderModel.value.vendor?.longitude ?? 0.0); + source.value = location.LatLng( + orderModel.value.vendor?.latitude ?? 0.0, + orderModel.value.vendor?.longitude ?? 0.0, + ); - destination.value = location.LatLng(orderModel.value.address?.location?.latitude ?? 0.0, orderModel.value.address?.location?.longitude ?? 0.0); + destination.value = location.LatLng( + orderModel.value.address?.location?.latitude ?? 0.0, + orderModel.value.address?.location?.longitude ?? 0.0, + ); - if (orderModel.value.status == Constant.orderPlaced || orderModel.value.status == Constant.orderAccepted) { + if (orderModel.value.status == Constant.orderPlaced || + orderModel.value.status == Constant.orderAccepted) { await showDriverToRestaurantRoute(); - } else if (orderModel.value.status == Constant.orderShipped || orderModel.value.status == Constant.orderInTransit) { + } else if (orderModel.value.status == Constant.orderShipped || + orderModel.value.status == Constant.orderInTransit) { await showDriverToCustomerRoute(); } } @@ -136,7 +157,10 @@ class LiveTrackingController extends GetxController { routePoints.clear(); } - Future fetchRoute(location.LatLng source, location.LatLng destination) async { + Future fetchRoute( + location.LatLng source, + location.LatLng destination, + ) async { final url = Uri.parse( 'https://router.project-osrm.org/route/v1/driving/${source.longitude},${source.latitude};${destination.longitude},${destination.latitude}?overview=full&geometries=geojson', ); @@ -144,7 +168,12 @@ class LiveTrackingController extends GetxController { if (response.statusCode == 200) { final data = json.decode(response.body); final coords = data['routes'][0]['geometry']['coordinates']; - routePoints.value = coords.map((c) => location.LatLng(c[1].toDouble(), c[0].toDouble())).toList(); + routePoints.value = + coords + .map( + (c) => location.LatLng(c[1].toDouble(), c[0].toDouble()), + ) + .toList(); } } @@ -155,15 +184,34 @@ class LiveTrackingController extends GetxController { void addOsmMarkers({bool showPickup = false, bool showDrop = false}) { final List tempMarkers = [ // Driver Marker - flutterMap.Marker(point: driverCurrent.value, width: 40, height: 40, child: Image.asset('assets/images/food_delivery.png')), + flutterMap.Marker( + point: driverCurrent.value, + width: 40, + height: 40, + child: Image.asset('assets/images/food_delivery.png'), + ), ]; if (showPickup) { - tempMarkers.add(flutterMap.Marker(point: source.value, width: 40, height: 40, child: Image.asset('assets/images/pickup.png'))); + tempMarkers.add( + flutterMap.Marker( + point: source.value, + width: 40, + height: 40, + child: Image.asset('assets/images/pickup.png'), + ), + ); } if (showDrop) { - tempMarkers.add(flutterMap.Marker(point: destination.value, width: 40, height: 40, child: Image.asset('assets/images/dropoff.png'))); + tempMarkers.add( + flutterMap.Marker( + point: destination.value, + width: 40, + height: 40, + child: Image.asset('assets/images/dropoff.png'), + ), + ); } osmMarkers.value = tempMarkers; @@ -180,11 +228,16 @@ class LiveTrackingController extends GetxController { List polylineCoordinates = []; PolylineResult result = await polylinePoints.getRouteBetweenCoordinates( - request: PolylineRequest(origin: PointLatLng(sourceLatitude, sourceLongitude), destination: PointLatLng(destinationLatitude, destinationLongitude), mode: TravelMode.driving), + request: PolylineRequest( + origin: PointLatLng(sourceLatitude, sourceLongitude), + destination: PointLatLng(destinationLatitude, destinationLongitude), + mode: TravelMode.driving, + ), ); if (result.points.isNotEmpty) { - polylineCoordinates = result.points.map((e) => LatLng(e.latitude, e.longitude)).toList(); + polylineCoordinates = + result.points.map((e) => LatLng(e.latitude, e.longitude)).toList(); } addGoogleMarkers(showPickup: showPickup, showDrop: showDrop); @@ -205,9 +258,19 @@ class LiveTrackingController extends GetxController { ); } - if (showPickup && orderModel.value.vendor?.latitude != null && pickupIcon != null) { - addMarker(id: "Pickup", latitude: orderModel.value.vendor!.latitude ?? 0.0, longitude: orderModel.value.vendor!.longitude ?? 0.0, descriptor: pickupIcon!, rotation: 0.0); - } else if (showDrop && orderModel.value.address?.location?.latitude != null && dropoffIcon != null) { + if (showPickup && + orderModel.value.vendor?.latitude != null && + pickupIcon != null) { + addMarker( + id: "Pickup", + latitude: orderModel.value.vendor!.latitude ?? 0.0, + longitude: orderModel.value.vendor!.longitude ?? 0.0, + descriptor: pickupIcon!, + rotation: 0.0, + ); + } else if (showDrop && + orderModel.value.address?.location?.latitude != null && + dropoffIcon != null) { addMarker( id: "Drop", latitude: orderModel.value.address!.location!.latitude ?? 0.0, @@ -218,24 +281,50 @@ class LiveTrackingController extends GetxController { } } - void addMarker({required String id, required double latitude, required double longitude, required BitmapDescriptor descriptor, required double rotation}) { + void addMarker({ + required String id, + required double latitude, + required double longitude, + required BitmapDescriptor descriptor, + required double rotation, + }) { MarkerId markerId = MarkerId(id); - markers[markerId] = Marker(markerId: markerId, icon: descriptor, position: LatLng(latitude, longitude), rotation: rotation, anchor: const Offset(0.5, 0.5)); + markers[markerId] = Marker( + markerId: markerId, + icon: descriptor, + position: LatLng(latitude, longitude), + rotation: rotation, + anchor: const Offset(0.5, 0.5), + ); } Future addMarkerIcons() async { if (Constant.selectedMapType == 'osm') return; - pickupIcon = BitmapDescriptor.fromBytes(await Constant().getBytesFromAsset('assets/images/pickup.png', 100)); - dropoffIcon = BitmapDescriptor.fromBytes(await Constant().getBytesFromAsset('assets/images/dropoff.png', 100)); - driverIcon = BitmapDescriptor.fromBytes(await Constant().getBytesFromAsset('assets/images/food_delivery.png', 100)); + pickupIcon = BitmapDescriptor.fromBytes( + await Constant().getBytesFromAsset('assets/images/pickup.png', 100), + ); + dropoffIcon = BitmapDescriptor.fromBytes( + await Constant().getBytesFromAsset('assets/images/dropoff.png', 100), + ); + driverIcon = BitmapDescriptor.fromBytes( + await Constant().getBytesFromAsset( + 'assets/images/food_delivery.png', + 100, + ), + ); } Future _addPolyLine(List polylineCoordinates) async { if (polylineCoordinates.isEmpty) return; PolylineId id = const PolylineId("poly"); - Polyline polyline = Polyline(polylineId: id, color: Colors.blue, width: 5, points: polylineCoordinates); + Polyline polyline = Polyline( + polylineId: id, + color: Colors.blue, + width: 5, + points: polylineCoordinates, + ); polyLines[id] = polyline; await updateCameraBounds(polylineCoordinates); @@ -244,13 +333,26 @@ class LiveTrackingController extends GetxController { Future updateCameraBounds(List points) async { if (mapController == null || points.isEmpty) return; - double minLat = points.map((e) => e.latitude).reduce((a, b) => a < b ? a : b); - double maxLat = points.map((e) => e.latitude).reduce((a, b) => a > b ? a : b); - double minLng = points.map((e) => e.longitude).reduce((a, b) => a < b ? a : b); - double maxLng = points.map((e) => e.longitude).reduce((a, b) => a > b ? a : b); + double minLat = points + .map((e) => e.latitude) + .reduce((a, b) => a < b ? a : b); + double maxLat = points + .map((e) => e.latitude) + .reduce((a, b) => a > b ? a : b); + double minLng = points + .map((e) => e.longitude) + .reduce((a, b) => a < b ? a : b); + double maxLng = points + .map((e) => e.longitude) + .reduce((a, b) => a > b ? a : b); - LatLngBounds bounds = LatLngBounds(southwest: LatLng(minLat, minLng), northeast: LatLng(maxLat, maxLng)); + LatLngBounds bounds = LatLngBounds( + southwest: LatLng(minLat, minLng), + northeast: LatLng(maxLat, maxLng), + ); - await mapController!.animateCamera(CameraUpdate.newLatLngBounds(bounds, 80)); + await mapController!.animateCamera( + CameraUpdate.newLatLngBounds(bounds, 80), + ); } } diff --git a/lib/controllers/login_controller.dart b/lib/controllers/login_controller.dart index fd729ad..52dbfad 100644 --- a/lib/controllers/login_controller.dart +++ b/lib/controllers/login_controller.dart @@ -1,5 +1,7 @@ import 'dart:convert'; import 'package:customer/screen_ui/location_enable_screens/location_permission_screen.dart'; +import 'package:customer/utils/app_router.dart'; + import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -45,16 +47,22 @@ class LoginController extends GetxController { isLoading.value = true; ShowToastDialog.showLoader("Logging in...".tr); - final credential = await FirebaseAuth.instance.signInWithEmailAndPassword(email: email, password: password); + final credential = await FirebaseAuth.instance.signInWithEmailAndPassword( + email: email, + password: password, + ); - final userModel = await FireStoreUtils.getUserProfile(credential.user!.uid); + final userModel = await FireStoreUtils.getUserProfile( + credential.user!.uid, + ); if (userModel != null && userModel.role == Constant.userRoleCustomer) { if (userModel.active == true) { userModel.fcmToken = await NotificationService.getToken(); await FireStoreUtils.updateUser(userModel); - if (userModel.shippingAddress != null && userModel.shippingAddress!.isNotEmpty) { + if (userModel.shippingAddress != null && + userModel.shippingAddress!.isNotEmpty) { final defaultAddress = userModel.shippingAddress!.firstWhere( (e) => e.isDefault == true, orElse: () => userModel.shippingAddress!.first, @@ -62,19 +70,23 @@ class LoginController extends GetxController { Constant.selectedLocation = defaultAddress; - Get.offAll(() => const ServiceListScreen()); + Get.offAll(ServiceListScreen()); } else { - Get.offAll(() => const LocationPermissionScreen()); + Get.offAll(LocationPermissionScreen()); } } else { await FirebaseAuth.instance.signOut(); - ShowToastDialog.showToast("This user is disabled. Please contact admin.".tr); - Get.offAll(() => const LoginScreen()); + ShowToastDialog.showToast( + "This user is disabled. Please contact admin.".tr, + ); + Get.offAll(LoginScreen()); } } else { await FirebaseAuth.instance.signOut(); - ShowToastDialog.showToast("This user does not exist in the customer app.".tr); - Get.offAll(() => const LoginScreen()); + ShowToastDialog.showToast( + "This user does not exist in the customer app.".tr, + ); + Get.offAll(LoginScreen()); } } on FirebaseAuthException catch (e) { if (e.code == 'user-not-found') { @@ -84,7 +96,9 @@ class LoginController extends GetxController { } else if (e.code == 'invalid-email') { ShowToastDialog.showToast("Invalid email.".tr); } else { - ShowToastDialog.showToast(e.message?.tr ?? "Login failed. Please try again.".tr); + ShowToastDialog.showToast( + e.message?.tr ?? "Login failed. Please try again.".tr, + ); } } finally { isLoading.value = false; @@ -106,38 +120,52 @@ class LoginController extends GetxController { userModel.provider = 'google'; ShowToastDialog.closeLoader(); - Get.off(const SignUpScreen(), arguments: {"userModel": userModel, "type": "google"}); + Get.off( + const SignUpScreen(), + arguments: {"userModel": userModel, "type": "google"}, + ); } else { - await FireStoreUtils.userExistOrNot(value.user!.uid).then((userExit) async { + await FireStoreUtils.userExistOrNot(value.user!.uid).then(( + userExit, + ) async { ShowToastDialog.closeLoader(); if (userExit == true) { - UserModel? userModel = await FireStoreUtils.getUserProfile(value.user!.uid); - if (userModel != null && userModel.role == Constant.userRoleCustomer) { + UserModel? userModel = await FireStoreUtils.getUserProfile( + value.user!.uid, + ); + if (userModel != null && + userModel.role == Constant.userRoleCustomer) { if (userModel.active == true) { userModel.fcmToken = await NotificationService.getToken(); await FireStoreUtils.updateUser(userModel); - if (userModel.shippingAddress != null && userModel.shippingAddress!.isNotEmpty) { - final defaultAddress = userModel.shippingAddress!.firstWhere( - (e) => e.isDefault == true, - orElse: () => userModel.shippingAddress!.first, - ); + if (userModel.shippingAddress != null && + userModel.shippingAddress!.isNotEmpty) { + final defaultAddress = userModel.shippingAddress! + .firstWhere( + (e) => e.isDefault == true, + orElse: () => userModel.shippingAddress!.first, + ); Constant.selectedLocation = defaultAddress; - Get.offAll(() => const ServiceListScreen()); + Get.offAll(ServiceListScreen()); } else { - Get.offAll(() => const LocationPermissionScreen()); + Get.offAll(LocationPermissionScreen()); } } else { await FirebaseAuth.instance.signOut(); - ShowToastDialog.showToast("This user is disabled. Please contact admin.".tr); - Get.offAll(() => const LoginScreen()); + ShowToastDialog.showToast( + "This user is disabled. Please contact admin.".tr, + ); + Get.offAll(LoginScreen()); } } else { await FirebaseAuth.instance.signOut(); - ShowToastDialog.showToast("This user does not exist in the customer app.".tr); - Get.offAll(() => const LoginScreen()); + ShowToastDialog.showToast( + "This user does not exist in the customer app.".tr, + ); + Get.offAll(LoginScreen()); } } else { UserModel userModel = UserModel(); @@ -147,7 +175,10 @@ class LoginController extends GetxController { userModel.lastName = value.user!.displayName?.split(' ').last; userModel.provider = 'google'; - Get.off(const SignUpScreen(), arguments: {"userModel": userModel, "type": "google"}); + Get.off( + const SignUpScreen(), + arguments: {"userModel": userModel, "type": "google"}, + ); } }); } @@ -173,37 +204,51 @@ class LoginController extends GetxController { userModel.lastName = appleCredential.familyName; userModel.provider = 'apple'; - Get.off(const SignUpScreen(), arguments: {"userModel": userModel, "type": "apple"}); + Get.off( + const SignUpScreen(), + arguments: {"userModel": userModel, "type": "apple"}, + ); } else { // Existing user - await FireStoreUtils.userExistOrNot(userCredential.user!.uid).then((userExit) async { + await FireStoreUtils.userExistOrNot(userCredential.user!.uid).then(( + userExit, + ) async { if (userExit == true) { - UserModel? userModel = await FireStoreUtils.getUserProfile(userCredential.user!.uid); - if (userModel != null && userModel.role == Constant.userRoleCustomer) { + UserModel? userModel = await FireStoreUtils.getUserProfile( + userCredential.user!.uid, + ); + if (userModel != null && + userModel.role == Constant.userRoleCustomer) { if (userModel.active == true) { userModel.fcmToken = await NotificationService.getToken(); await FireStoreUtils.updateUser(userModel); - if (userModel.shippingAddress != null && userModel.shippingAddress!.isNotEmpty) { - final defaultAddress = userModel.shippingAddress!.firstWhere( - (e) => e.isDefault == true, - orElse: () => userModel.shippingAddress!.first, - ); + if (userModel.shippingAddress != null && + userModel.shippingAddress!.isNotEmpty) { + final defaultAddress = userModel.shippingAddress! + .firstWhere( + (e) => e.isDefault == true, + orElse: () => userModel.shippingAddress!.first, + ); Constant.selectedLocation = defaultAddress; - Get.offAll(() => const ServiceListScreen()); + Get.offAll(ServiceListScreen()); } else { - Get.offAll(() => const LocationPermissionScreen()); + Get.offAll(LocationPermissionScreen()); } } else { await FirebaseAuth.instance.signOut(); - ShowToastDialog.showToast("This user is disabled. Please contact admin.".tr); - Get.offAll(() => const LoginScreen()); + ShowToastDialog.showToast( + "This user is disabled. Please contact admin.".tr, + ); + Get.offAll(LoginScreen()); } } else { await FirebaseAuth.instance.signOut(); - ShowToastDialog.showToast("This user does not exist in the customer app.".tr); - Get.offAll(() => const LoginScreen()); + ShowToastDialog.showToast( + "This user does not exist in the customer app.".tr, + ); + Get.offAll(LoginScreen()); } } else { // User not in DB → go to signup @@ -214,7 +259,10 @@ class LoginController extends GetxController { userModel.lastName = appleCredential.familyName; userModel.provider = 'apple'; - Get.off(const SignUpScreen(), arguments: {"userModel": userModel, "type": "apple"}); + Get.off( + const SignUpScreen(), + arguments: {"userModel": userModel, "type": "apple"}, + ); } }); } @@ -233,8 +281,12 @@ class LoginController extends GetxController { final GoogleSignInAuthentication googleAuth = googleUser.authentication; - final credential = GoogleAuthProvider.credential(idToken: googleAuth.idToken); - final userCredential = await FirebaseAuth.instance.signInWithCredential(credential); + final credential = GoogleAuthProvider.credential( + idToken: googleAuth.idToken, + ); + final userCredential = await FirebaseAuth.instance.signInWithCredential( + credential, + ); return userCredential; } catch (e) { @@ -254,17 +306,27 @@ class LoginController extends GetxController { final rawNonce = generateNonce(); final nonce = sha256ofString(rawNonce); - AuthorizationCredentialAppleID appleCredential = await SignInWithApple.getAppleIDCredential( - scopes: [AppleIDAuthorizationScopes.email, AppleIDAuthorizationScopes.fullName], - nonce: nonce, + AuthorizationCredentialAppleID appleCredential = + await SignInWithApple.getAppleIDCredential( + scopes: [ + AppleIDAuthorizationScopes.email, + AppleIDAuthorizationScopes.fullName, + ], + nonce: nonce, + ); + + final oauthCredential = OAuthProvider("apple.com").credential( + idToken: appleCredential.identityToken, + rawNonce: rawNonce, + accessToken: appleCredential.authorizationCode, ); - final oauthCredential = OAuthProvider( - "apple.com", - ).credential(idToken: appleCredential.identityToken, rawNonce: rawNonce, accessToken: appleCredential.authorizationCode); - - UserCredential userCredential = await FirebaseAuth.instance.signInWithCredential(oauthCredential); - return {"appleCredential": appleCredential, "userCredential": userCredential}; + UserCredential userCredential = await FirebaseAuth.instance + .signInWithCredential(oauthCredential); + return { + "appleCredential": appleCredential, + "userCredential": userCredential, + }; } catch (e) { debugPrint(e.toString()); } diff --git a/lib/controllers/mobile_login_controller.dart b/lib/controllers/mobile_login_controller.dart index d3fe4d6..5a1a048 100644 --- a/lib/controllers/mobile_login_controller.dart +++ b/lib/controllers/mobile_login_controller.dart @@ -1,14 +1,16 @@ import 'package:customer/themes/show_toast_dialog.dart'; + import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; - import '../constant/constant.dart'; import '../screen_ui/auth_screens/otp_verification_screen.dart'; class MobileLoginController extends GetxController { - final Rx mobileController = TextEditingController().obs; - final Rx countryCodeController = TextEditingController(text: Constant.defaultCountryCode).obs; + final Rx mobileController = + TextEditingController().obs; + final Rx countryCodeController = + TextEditingController(text: Constant.defaultCountryCode).obs; final FirebaseAuth _auth = FirebaseAuth.instance; @@ -18,7 +20,9 @@ class MobileLoginController extends GetxController { final countryCode = countryCodeController.value.text.trim(); if (mobile.isEmpty || mobile.length != 10) { - ShowToastDialog.showToast("Please enter a valid 10-digit mobile number".tr); + ShowToastDialog.showToast( + "Please enter a valid 10-digit mobile number".tr, + ); return; } @@ -35,12 +39,21 @@ class MobileLoginController extends GetxController { if (e.code == 'invalid-phone-number') { ShowToastDialog.showToast("Invalid phone number".tr); } else { - ShowToastDialog.showToast(e.message ?? "OTP verification failed".tr); + ShowToastDialog.showToast( + e.message ?? "OTP verification failed".tr, + ); } }, codeSent: (String verificationId, int? resendToken) { ShowToastDialog.closeLoader(); - Get.to(() => const OtpVerificationScreen(), arguments: {'countryCode': countryCode, 'phoneNumber': mobile, 'verificationId': verificationId}); + Get.to( + () => const OtpVerificationScreen(), + arguments: { + 'countryCode': countryCode, + 'phoneNumber': mobile, + 'verificationId': verificationId, + }, + ); }, codeAutoRetrievalTimeout: (String verificationId) { ShowToastDialog.closeLoader(); diff --git a/lib/controllers/my_booking_on_demand_controller.dart b/lib/controllers/my_booking_on_demand_controller.dart index 150f4d5..20a7be3 100644 --- a/lib/controllers/my_booking_on_demand_controller.dart +++ b/lib/controllers/my_booking_on_demand_controller.dart @@ -18,7 +18,6 @@ class MyBookingOnDemandController extends GetxController { listenOrders(); // Listen for real-time updates } - void selectTab(String tab) { selectedTab.value = tab; } @@ -32,7 +31,9 @@ class MyBookingOnDemandController extends GetxController { // Fetch worker info if not already fetched for (var order in updatedOrders) { - if (order.workerId != null && order.workerId!.isNotEmpty && !workers.containsKey(order.workerId!)) { + if (order.workerId != null && + order.workerId!.isNotEmpty && + !workers.containsKey(order.workerId!)) { FireStoreUtils.getWorker(order.workerId!).then((worker) { if (worker != null) workers[order.workerId!] = worker; }); @@ -48,18 +49,39 @@ class MyBookingOnDemandController extends GetxController { ); } - List get filteredParcelOrders => getOrdersForTab(selectedTab.value); + List get filteredParcelOrders => + getOrdersForTab(selectedTab.value); List getOrdersForTab(String tab) { switch (tab) { case "Placed": - return orders.where((order) => ["Order Placed", "Order Accepted", "Order Assigned", "Order Ongoing", "In Transit"].contains(order.status)).toList(); + return orders + .where( + (order) => [ + "Order Placed", + "Order Accepted", + "Order Assigned", + "Order Ongoing", + "In Transit", + ].contains(order.status), + ) + .toList(); case "Completed": - return orders.where((order) => ["Order Completed"].contains(order.status)).toList(); + return orders + .where((order) => ["Order Completed"].contains(order.status)) + .toList(); case "Cancelled": - return orders.where((order) => ["Order Rejected", "Order Cancelled", "Driver Rejected"].contains(order.status)).toList(); + return orders + .where( + (order) => [ + "Order Rejected", + "Order Cancelled", + "Driver Rejected", + ].contains(order.status), + ) + .toList(); default: return []; diff --git a/lib/controllers/my_cab_booking_controller.dart b/lib/controllers/my_cab_booking_controller.dart index f2d6359..eee4f01 100644 --- a/lib/controllers/my_cab_booking_controller.dart +++ b/lib/controllers/my_cab_booking_controller.dart @@ -34,6 +34,7 @@ import 'package:customer/payment/xenditScreen.dart'; import 'package:customer/service/fire_store_utils.dart'; import 'package:customer/themes/show_toast_dialog.dart'; import 'package:customer/utils/preferences.dart'; + import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:flutter_paypal/flutter_paypal.dart'; @@ -71,7 +72,9 @@ class MyCabBookingController extends GetxController { isLoading.value = true; if (FirebaseAuth.instance.currentUser != null) { - await FireStoreUtils.getUserProfile(FireStoreUtils.getCurrentUid()).then((user) { + await FireStoreUtils.getUserProfile(FireStoreUtils.getCurrentUid()).then(( + user, + ) { if (user != null) { userModel.value = user; } @@ -87,21 +90,45 @@ class MyCabBookingController extends GetxController { isLoading.value = false; } - List get filteredParcelOrders => getOrdersForTab(selectedTab.value); + List get filteredParcelOrders => + getOrdersForTab(selectedTab.value); List getOrdersForTab(String tab) { switch (tab) { case "New": - return cabOrder.where((order) => ["Order Placed", "Driver Pending"].contains(order.status)).toList(); + return cabOrder + .where( + (order) => + ["Order Placed", "Driver Pending"].contains(order.status), + ) + .toList(); case "On Going": - return cabOrder.where((order) => ["Driver Accepted", "Order Shipped", "In Transit"].contains(order.status)).toList(); + return cabOrder + .where( + (order) => [ + "Driver Accepted", + "Order Shipped", + "In Transit", + ].contains(order.status), + ) + .toList(); case "Completed": - return cabOrder.where((order) => ["Order Completed"].contains(order.status)).toList(); + return cabOrder + .where((order) => ["Order Completed"].contains(order.status)) + .toList(); case "Cancelled": - return cabOrder.where((order) => ["Order Rejected", "Order Cancelled", "Driver Rejected"].contains(order.status)).toList(); + return cabOrder + .where( + (order) => [ + "Order Rejected", + "Order Cancelled", + "Driver Rejected", + ].contains(order.status), + ) + .toList(); default: return []; @@ -163,15 +190,22 @@ class MyCabBookingController extends GetxController { selectedOrder.value = order; try { - subTotal.value = double.tryParse(selectedOrder.value.subTotal?.toString() ?? "0") ?? 0.0; - discount.value = double.tryParse(selectedOrder.value.discount?.toString() ?? "0") ?? 0.0; + subTotal.value = + double.tryParse(selectedOrder.value.subTotal?.toString() ?? "0") ?? + 0.0; + discount.value = + double.tryParse(selectedOrder.value.discount?.toString() ?? "0") ?? + 0.0; taxAmount.value = 0.0; subTotal.value = subTotal.value; if (selectedOrder.value.taxSetting != null) { for (var element in selectedOrder.value.taxSetting!) { - taxAmount.value += Constant.calculateTax(amount: (subTotal.value - discount.value).toString(), taxModel: element); + taxAmount.value += Constant.calculateTax( + amount: (subTotal.value - discount.value).toString(), + taxModel: element, + ); } } @@ -208,8 +242,13 @@ class MyCabBookingController extends GetxController { serviceType: Constant.parcelServiceType, ); - await FireStoreUtils.setWalletTransaction(transactionModel).then((value) async { - await FireStoreUtils.updateUserWallet(amount: "-${totalAmount.value.toString()}", userId: FireStoreUtils.getCurrentUid()); + await FireStoreUtils.setWalletTransaction(transactionModel).then(( + value, + ) async { + await FireStoreUtils.updateUserWallet( + amount: "-${totalAmount.value.toString()}", + userId: FireStoreUtils.getCurrentUid(), + ); }); } selectedOrder.value.paymentStatus = true; @@ -222,19 +261,45 @@ class MyCabBookingController extends GetxController { Future getPaymentSettings() async { await FireStoreUtils.getPaymentSettingsData().then((value) { - stripeModel.value = StripeModel.fromJson(jsonDecode(Preferences.getString(Preferences.stripeSettings))); - payPalModel.value = PayPalModel.fromJson(jsonDecode(Preferences.getString(Preferences.paypalSettings))); - payStackModel.value = PayStackModel.fromJson(jsonDecode(Preferences.getString(Preferences.payStack))); - mercadoPagoModel.value = MercadoPagoModel.fromJson(jsonDecode(Preferences.getString(Preferences.mercadoPago))); - flutterWaveModel.value = FlutterWaveModel.fromJson(jsonDecode(Preferences.getString(Preferences.flutterWave))); - paytmModel.value = PaytmModel.fromJson(jsonDecode(Preferences.getString(Preferences.paytmSettings))); - payFastModel.value = PayFastModel.fromJson(jsonDecode(Preferences.getString(Preferences.payFastSettings))); - razorPayModel.value = RazorPayModel.fromJson(jsonDecode(Preferences.getString(Preferences.razorpaySettings))); - midTransModel.value = MidTrans.fromJson(jsonDecode(Preferences.getString(Preferences.midTransSettings))); - orangeMoneyModel.value = OrangeMoney.fromJson(jsonDecode(Preferences.getString(Preferences.orangeMoneySettings))); - xenditModel.value = Xendit.fromJson(jsonDecode(Preferences.getString(Preferences.xenditSettings))); - walletSettingModel.value = WalletSettingModel.fromJson(jsonDecode(Preferences.getString(Preferences.walletSettings))); - cashOnDeliverySettingModel.value = CodSettingModel.fromJson(jsonDecode(Preferences.getString(Preferences.codSettings))); + stripeModel.value = StripeModel.fromJson( + jsonDecode(Preferences.getString(Preferences.stripeSettings)), + ); + payPalModel.value = PayPalModel.fromJson( + jsonDecode(Preferences.getString(Preferences.paypalSettings)), + ); + payStackModel.value = PayStackModel.fromJson( + jsonDecode(Preferences.getString(Preferences.payStack)), + ); + mercadoPagoModel.value = MercadoPagoModel.fromJson( + jsonDecode(Preferences.getString(Preferences.mercadoPago)), + ); + flutterWaveModel.value = FlutterWaveModel.fromJson( + jsonDecode(Preferences.getString(Preferences.flutterWave)), + ); + paytmModel.value = PaytmModel.fromJson( + jsonDecode(Preferences.getString(Preferences.paytmSettings)), + ); + payFastModel.value = PayFastModel.fromJson( + jsonDecode(Preferences.getString(Preferences.payFastSettings)), + ); + razorPayModel.value = RazorPayModel.fromJson( + jsonDecode(Preferences.getString(Preferences.razorpaySettings)), + ); + midTransModel.value = MidTrans.fromJson( + jsonDecode(Preferences.getString(Preferences.midTransSettings)), + ); + orangeMoneyModel.value = OrangeMoney.fromJson( + jsonDecode(Preferences.getString(Preferences.orangeMoneySettings)), + ); + xenditModel.value = Xendit.fromJson( + jsonDecode(Preferences.getString(Preferences.xenditSettings)), + ); + walletSettingModel.value = WalletSettingModel.fromJson( + jsonDecode(Preferences.getString(Preferences.walletSettings)), + ); + cashOnDeliverySettingModel.value = CodSettingModel.fromJson( + jsonDecode(Preferences.getString(Preferences.codSettings)), + ); if (walletSettingModel.value.isEnabled == true) { selectedPaymentMethod.value = PaymentGateway.wallet.name; @@ -276,20 +341,32 @@ class MyCabBookingController extends GetxController { Future stripeMakePayment({required String amount}) async { log(double.parse(amount).toStringAsFixed(0)); try { - Map? paymentIntentData = await createStripeIntent(amount: amount); + Map? paymentIntentData = await createStripeIntent( + amount: amount, + ); log("stripe Responce====>$paymentIntentData"); if (paymentIntentData!.containsKey("error")) { Get.back(); - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); } else { await Stripe.instance.initPaymentSheet( paymentSheetParameters: SetupPaymentSheetParameters( paymentIntentClientSecret: paymentIntentData['client_secret'], allowsDelayedPaymentMethods: false, - googlePay: const PaymentSheetGooglePay(merchantCountryCode: 'US', testEnv: true, currencyCode: "USD"), + googlePay: const PaymentSheetGooglePay( + merchantCountryCode: 'US', + testEnv: true, + currencyCode: "USD", + ), customFlow: true, style: ThemeMode.system, - appearance: PaymentSheetAppearance(colors: PaymentSheetAppearanceColors(primary: AppThemeData.primary300)), + appearance: PaymentSheetAppearance( + colors: PaymentSheetAppearanceColors( + primary: AppThemeData.primary300, + ), + ), merchantDisplayName: 'GoRide', ), ); @@ -335,7 +412,10 @@ class MyCabBookingController extends GetxController { var response = await http.post( Uri.parse('https://api.stripe.com/v1/payment_intents'), body: body, - headers: {'Authorization': 'Bearer $stripeSecret', 'Content-Type': 'application/x-www-form-urlencoded'}, + headers: { + 'Authorization': 'Bearer $stripeSecret', + 'Content-Type': 'application/x-www-form-urlencoded', + }, ); return jsonDecode(response.body); @@ -345,8 +425,14 @@ class MyCabBookingController extends GetxController { } //mercadoo - Future mercadoPagoMakePayment({required BuildContext context, required String amount}) async { - final headers = {'Authorization': 'Bearer ${mercadoPagoModel.value.accessToken}', 'Content-Type': 'application/json'}; + Future mercadoPagoMakePayment({ + required BuildContext context, + required String amount, + }) async { + final headers = { + 'Authorization': 'Bearer ${mercadoPagoModel.value.accessToken}', + 'Content-Type': 'application/json', + }; final body = jsonEncode({ "items": [ @@ -368,7 +454,11 @@ class MyCabBookingController extends GetxController { // Automatically return after payment is approved }); - final response = await http.post(Uri.parse("https://api.mercadopago.com/checkout/preferences"), headers: headers, body: body); + final response = await http.post( + Uri.parse("https://api.mercadopago.com/checkout/preferences"), + headers: headers, + body: body, + ); if (response.statusCode == 200 || response.statusCode == 201) { final data = jsonDecode(response.body); @@ -451,15 +541,23 @@ class MyCabBookingController extends GetxController { } }); } else { - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); } }); } //flutter wave Payment Method - Future flutterWaveInitiatePayment({required BuildContext context, required String amount}) async { + Future flutterWaveInitiatePayment({ + required BuildContext context, + required String amount, + }) async { final url = Uri.parse('https://api.flutterwave.com/v3/payments'); - final headers = {'Authorization': 'Bearer ${flutterWaveModel.value.secretKey}', 'Content-Type': 'application/json'}; + final headers = { + 'Authorization': 'Bearer ${flutterWaveModel.value.secretKey}', + 'Content-Type': 'application/json', + }; final body = jsonEncode({ "tx_ref": _ref, @@ -469,17 +567,23 @@ class MyCabBookingController extends GetxController { "payment_options": "ussd, card, barter, payattitude", "customer": { "email": Constant.userModel!.email.toString(), - "phonenumber": Constant.userModel!.phoneNumber, // Add a real phone number + "phonenumber": + Constant.userModel!.phoneNumber, // Add a real phone number "name": Constant.userModel!.fullName(), // Add a real customer name }, - "customizations": {"title": "Payment for Services", "description": "Payment for XYZ services"}, + "customizations": { + "title": "Payment for Services", + "description": "Payment for XYZ services", + }, }); final response = await http.post(url, headers: headers, body: body); if (response.statusCode == 200) { final data = jsonDecode(response.body); - Get.to(MercadoPagoScreen(initialURl: data['data']['link']))!.then((value) { + Get.to(MercadoPagoScreen(initialURl: data['data']['link']))!.then(( + value, + ) { if (value) { ShowToastDialog.showToast("Payment Successful!!".tr); completeOrder(); @@ -508,10 +612,14 @@ class MyCabBookingController extends GetxController { // payFast void payFastPayment({required BuildContext context, required String amount}) { - PayStackURLGen.getPayHTML(payFastSettingData: payFastModel.value, amount: amount.toString(), userModel: Constant.userModel!).then(( - String? value, - ) async { - bool isDone = await Get.to(PayFastScreen(htmlData: value!, payFastSettingData: payFastModel.value)); + PayStackURLGen.getPayHTML( + payFastSettingData: payFastModel.value, + amount: amount.toString(), + userModel: Constant.userModel!, + ).then((String? value) async { + bool isDone = await Get.to( + PayFastScreen(htmlData: value!, payFastSettingData: payFastModel.value), + ); if (isDone) { Get.back(); ShowToastDialog.showToast("Payment successfully".tr); @@ -593,7 +701,11 @@ class MyCabBookingController extends GetxController { // } } - Future verifyCheckSum({required String checkSum, required double amount, required orderId}) async { + Future verifyCheckSum({ + required String checkSum, + required double amount, + required orderId, + }) async { String getChecksum = "${Constant.globalUrl}payments/validatechecksum"; final response = await http.post( Uri.parse(getChecksum), @@ -609,13 +721,18 @@ class MyCabBookingController extends GetxController { return data['status']; } - Future initiatePayment({required double amount, required orderId}) async { + Future initiatePayment({ + required double amount, + required orderId, + }) async { String initiateURL = "${Constant.globalUrl}payments/initiatepaytmpayment"; String callback = ""; if (paytmModel.value.isSandboxEnabled == true) { - callback = "${callback}https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; + callback = + "${callback}https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; } else { - callback = "${callback}https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; + callback = + "${callback}https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; } final response = await http.post( Uri.parse(initiateURL), @@ -633,9 +750,12 @@ class MyCabBookingController extends GetxController { ); log(response.body); final data = jsonDecode(response.body); - if (data["body"]["txnToken"] == null || data["body"]["txnToken"].toString().isEmpty) { + if (data["body"]["txnToken"] == null || + data["body"]["txnToken"].toString().isEmpty) { Get.back(); - ShowToastDialog.showToast("something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "something went wrong, please contact admin.".tr, + ); } return GetPaymentTxtTokenModel.fromJson(data); } @@ -653,7 +773,10 @@ class MyCabBookingController extends GetxController { 'description': 'wallet Topup', 'retry': {'enabled': true, 'max_count': 1}, 'send_sms_hash': true, - 'prefill': {'contact': Constant.userModel!.phoneNumber, 'email': Constant.userModel!.email}, + 'prefill': { + 'contact': Constant.userModel!.phoneNumber, + 'email': Constant.userModel!.email, + }, 'external': { 'wallets': ['paytm'], }, @@ -688,7 +811,10 @@ class MyCabBookingController extends GetxController { } //Midtrans payment - Future midtransMakePayment({required String amount, required BuildContext context}) async { + Future midtransMakePayment({ + required String amount, + required BuildContext context, + }) async { await createPaymentLink(amount: amount).then((url) { ShowToastDialog.closeLoader(); if (url != '') { @@ -707,7 +833,9 @@ class MyCabBookingController extends GetxController { Future createPaymentLink({required var amount}) async { var ordersId = const Uuid().v1(); final url = Uri.parse( - midTransModel.value.isSandbox! ? 'https://api.sandbox.midtrans.com/v1/payment-links' : 'https://api.midtrans.com/v1/payment-links', + midTransModel.value.isSandbox! + ? 'https://api.sandbox.midtrans.com/v1/payment-links' + : 'https://api.midtrans.com/v1/payment-links', ); final response = await http.post( @@ -715,12 +843,19 @@ class MyCabBookingController extends GetxController { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', - 'Authorization': generateBasicAuthHeader(midTransModel.value.serverKey!), + 'Authorization': generateBasicAuthHeader( + midTransModel.value.serverKey!, + ), }, body: jsonEncode({ - 'transaction_details': {'order_id': ordersId, 'gross_amount': double.parse(amount.toString()).toInt()}, + 'transaction_details': { + 'order_id': ordersId, + 'gross_amount': double.parse(amount.toString()).toInt(), + }, 'usage_limit': 2, - "callbacks": {"finish": "https://www.google.com?merchant_order_id=$ordersId"}, + "callbacks": { + "finish": "https://www.google.com?merchant_order_id=$ordersId", + }, }), ); @@ -728,7 +863,9 @@ class MyCabBookingController extends GetxController { final responseData = jsonDecode(response.body); return responseData['payment_url']; } else { - ShowToastDialog.showToast("something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "something went wrong, please contact admin.".tr, + ); return ''; } } @@ -745,10 +882,18 @@ class MyCabBookingController extends GetxController { static String orderId = ''; static String amount = ''; - Future orangeMakePayment({required String amount, required BuildContext context}) async { + Future orangeMakePayment({ + required String amount, + required BuildContext context, + }) async { reset(); var id = const Uuid().v4(); - var paymentURL = await fetchToken(context: context, orderId: id, amount: amount, currency: 'USD'); + var paymentURL = await fetchToken( + context: context, + orderId: id, + amount: amount, + currency: 'USD', + ); ShowToastDialog.closeLoader(); if (paymentURL.toString() != '') { Get.to( @@ -772,7 +917,12 @@ class MyCabBookingController extends GetxController { } } - Future fetchToken({required String orderId, required String currency, required BuildContext context, required String amount}) async { + Future fetchToken({ + required String orderId, + required String currency, + required BuildContext context, + required String amount, + }) async { String apiUrl = 'https://api.orange.com/oauth/v3/token'; Map requestBody = {'grant_type': 'client_credentials'}; @@ -793,9 +943,16 @@ class MyCabBookingController extends GetxController { accessToken = responseData['access_token']; // ignore: use_build_context_synchronously - return await webpayment(context: context, amountData: amount, currency: currency, orderIdData: orderId); + return await webpayment( + context: context, + amountData: amount, + currency: currency, + orderIdData: orderId, + ); } else { - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); return ''; } } @@ -826,7 +983,11 @@ class MyCabBookingController extends GetxController { var response = await http.post( Uri.parse(apiUrl), - headers: {'Authorization': 'Bearer $accessToken', 'Content-Type': 'application/json', 'Accept': 'application/json'}, + headers: { + 'Authorization': 'Bearer $accessToken', + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, body: json.encode(requestBody), ); @@ -840,7 +1001,9 @@ class MyCabBookingController extends GetxController { return ''; } } else { - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); return ''; } } @@ -858,7 +1021,11 @@ class MyCabBookingController extends GetxController { ShowToastDialog.closeLoader(); if (model.id != null) { Get.to( - () => XenditScreen(initialURl: model.invoiceUrl ?? '', transId: model.id ?? '', apiKey: xenditModel.value.apiKey!.toString()), + () => XenditScreen( + initialURl: model.invoiceUrl ?? '', + transId: model.id ?? '', + apiKey: xenditModel.value.apiKey!.toString(), + ), )!.then((value) { if (value == true) { ShowToastDialog.showToast("Payment Successful!!".tr); @@ -876,7 +1043,9 @@ class MyCabBookingController extends GetxController { const url = 'https://api.xendit.co/v2/invoices'; var headers = { 'Content-Type': 'application/json', - 'Authorization': generateBasicAuthHeader(xenditModel.value.apiKey!.toString()), + 'Authorization': generateBasicAuthHeader( + xenditModel.value.apiKey!.toString(), + ), // 'Cookie': '__cf_bm=yERkrx3xDITyFGiou0bbKY1bi7xEwovHNwxV1vCNbVc-1724155511-1.0.1.1-jekyYQmPCwY6vIJ524K0V6_CEw6O.dAwOmQnHtwmaXO_MfTrdnmZMka0KZvjukQgXu5B.K_6FJm47SGOPeWviQ', }; @@ -889,7 +1058,11 @@ class MyCabBookingController extends GetxController { }); try { - final response = await http.post(Uri.parse(url), headers: headers, body: body); + final response = await http.post( + Uri.parse(url), + headers: headers, + body: body, + ); if (response.statusCode == 200 || response.statusCode == 201) { XenditModel model = XenditModel.fromJson(jsonDecode(response.body)); diff --git a/lib/controllers/my_profile_controller.dart b/lib/controllers/my_profile_controller.dart index 566b012..4546340 100644 --- a/lib/controllers/my_profile_controller.dart +++ b/lib/controllers/my_profile_controller.dart @@ -41,7 +41,10 @@ class MyProfileController extends GetxController { Future deleteUserFromServer() async { var url = '${Constant.websiteUrl}/api/delete-user'; try { - var response = await http.post(Uri.parse(url), body: {'uuid': FireStoreUtils.getCurrentUid()}); + var response = await http.post( + Uri.parse(url), + body: {'uuid': FireStoreUtils.getCurrentUid()}, + ); log("deleteUserFromServer :: ${response.body}"); return response.statusCode == 200; } catch (e) { diff --git a/lib/controllers/my_rental_booking_controller.dart b/lib/controllers/my_rental_booking_controller.dart index 1876d9b..35be194 100644 --- a/lib/controllers/my_rental_booking_controller.dart +++ b/lib/controllers/my_rental_booking_controller.dart @@ -4,6 +4,7 @@ import 'package:customer/constant/constant.dart'; import 'package:customer/models/wallet_transaction_model.dart'; import 'package:customer/screen_ui/multi_vendor_service/wallet_screen/wallet_screen.dart'; import 'package:customer/themes/show_toast_dialog.dart'; + import 'package:get/get.dart'; import '../models/rental_order_model.dart'; import '../models/tax_model.dart'; @@ -45,7 +46,6 @@ class MyRentalBookingController extends GetxController { ); } isLoading.value = false; - } Rx selectedOrder = RentalOrderModel().obs; @@ -66,38 +66,84 @@ class MyRentalBookingController extends GetxController { selectedOrder.value = order; try { - subTotal.value = double.tryParse(selectedOrder.value.subTotal?.toString() ?? "0") ?? 0.0; - discount.value = double.tryParse(selectedOrder.value.discount?.toString() ?? "0") ?? 0.0; + subTotal.value = + double.tryParse(selectedOrder.value.subTotal?.toString() ?? "0") ?? + 0.0; + discount.value = + double.tryParse(selectedOrder.value.discount?.toString() ?? "0") ?? + 0.0; taxAmount.value = 0.0; if (selectedOrder.value.endTime != null) { DateTime start = selectedOrder.value.startTime!.toDate(); DateTime end = selectedOrder.value.endTime!.toDate(); int hours = end.difference(start).inHours; - if (hours >= int.parse(selectedOrder.value.rentalPackageModel!.includedHours.toString())) { - hours = hours - int.parse(selectedOrder.value.rentalPackageModel!.includedHours.toString()); - double hourlyRate = double.tryParse(selectedOrder.value.rentalPackageModel?.extraMinuteFare?.toString() ?? "0") ?? 0.0; + if (hours >= + int.parse( + selectedOrder.value.rentalPackageModel!.includedHours.toString(), + )) { + hours = + hours - + int.parse( + selectedOrder.value.rentalPackageModel!.includedHours + .toString(), + ); + double hourlyRate = + double.tryParse( + selectedOrder.value.rentalPackageModel?.extraMinuteFare + ?.toString() ?? + "0", + ) ?? + 0.0; extraMinutesCharge.value = (hours * 60) * hourlyRate; } } - if (selectedOrder.value.startKitoMetersReading != null && selectedOrder.value.endKitoMetersReading != null) { - double startKm = double.tryParse(selectedOrder.value.startKitoMetersReading?.toString() ?? "0") ?? 0.0; - double endKm = double.tryParse(selectedOrder.value.endKitoMetersReading?.toString() ?? "0") ?? 0.0; + if (selectedOrder.value.startKitoMetersReading != null && + selectedOrder.value.endKitoMetersReading != null) { + double startKm = + double.tryParse( + selectedOrder.value.startKitoMetersReading?.toString() ?? "0", + ) ?? + 0.0; + double endKm = + double.tryParse( + selectedOrder.value.endKitoMetersReading?.toString() ?? "0", + ) ?? + 0.0; if (endKm > startKm) { double totalKm = endKm - startKm; - if (totalKm > double.parse(selectedOrder.value.rentalPackageModel!.includedDistance!)) { - totalKm = totalKm - double.parse(selectedOrder.value.rentalPackageModel!.includedDistance!); - double extraKmRate = double.tryParse(selectedOrder.value.rentalPackageModel?.extraKmFare?.toString() ?? "0") ?? 0.0; + if (totalKm > + double.parse( + selectedOrder.value.rentalPackageModel!.includedDistance!, + )) { + totalKm = + totalKm - + double.parse( + selectedOrder.value.rentalPackageModel!.includedDistance!, + ); + double extraKmRate = + double.tryParse( + selectedOrder.value.rentalPackageModel?.extraKmFare + ?.toString() ?? + "0", + ) ?? + 0.0; extraKilometerCharge.value = totalKm * extraKmRate; } } } - subTotal.value = subTotal.value + extraKilometerCharge.value + extraMinutesCharge.value; + subTotal.value = + subTotal.value + + extraKilometerCharge.value + + extraMinutesCharge.value; if (selectedOrder.value.taxSetting != null) { for (var element in selectedOrder.value.taxSetting!) { - taxAmount.value += Constant.calculateTax(amount: (subTotal.value - discount.value).toString(), taxModel: element); + taxAmount.value += Constant.calculateTax( + amount: (subTotal.value - discount.value).toString(), + taxModel: element, + ); } } @@ -133,9 +179,14 @@ class MyRentalBookingController extends GetxController { serviceType: Constant.parcelServiceType, ); - await FireStoreUtils.setWalletTransaction(transactionModel).then((value) async { + await FireStoreUtils.setWalletTransaction(transactionModel).then(( + value, + ) async { if (value == true) { - await FireStoreUtils.updateUserWallet(amount: "-${totalAmount.value.toString()}", userId: FireStoreUtils.getCurrentUid()); + await FireStoreUtils.updateUserWallet( + amount: "-${totalAmount.value.toString()}", + userId: FireStoreUtils.getCurrentUid(), + ); } }); } @@ -152,16 +203,42 @@ class MyRentalBookingController extends GetxController { List getOrdersForTab(String tab) { switch (tab) { case "New": - return rentalOrders.where((order) => ["Order Placed", "Order Accepted", "Driver Pending"].contains(order.status)).toList(); + return rentalOrders + .where( + (order) => [ + "Order Placed", + "Order Accepted", + "Driver Pending", + ].contains(order.status), + ) + .toList(); case "On Going": - return rentalOrders.where((order) => ["Driver Accepted", "Order Shipped", "In Transit"].contains(order.status)).toList(); + return rentalOrders + .where( + (order) => [ + "Driver Accepted", + "Order Shipped", + "In Transit", + ].contains(order.status), + ) + .toList(); case "Completed": - return rentalOrders.where((order) => ["Order Completed"].contains(order.status)).toList(); + return rentalOrders + .where((order) => ["Order Completed"].contains(order.status)) + .toList(); case "Cancelled": - return rentalOrders.where((order) => ["Order Rejected", "Order Cancelled", "Driver Rejected"].contains(order.status)).toList(); + return rentalOrders + .where( + (order) => [ + "Order Rejected", + "Order Cancelled", + "Driver Rejected", + ].contains(order.status), + ) + .toList(); default: return []; @@ -169,9 +246,13 @@ class MyRentalBookingController extends GetxController { } /// Old helper (optional) - List get filteredRentalOrders => getOrdersForTab(selectedTab.value); + List get filteredRentalOrders => + getOrdersForTab(selectedTab.value); - Future cancelRentalRequest(RentalOrderModel order, {List? taxList}) async { + Future cancelRentalRequest( + RentalOrderModel order, { + List? taxList, + }) async { try { isLoading.value = true; order.status = Constant.orderCancelled; @@ -185,13 +266,18 @@ class MyRentalBookingController extends GetxController { if (taxList != null) { for (var element in taxList) { totalTax += Constant.calculateTax( - amount: (double.parse(order.subTotal.toString()) - double.parse(order.discount.toString())).toString(), + amount: + (double.parse(order.subTotal.toString()) - + double.parse(order.discount.toString())) + .toString(), taxModel: element, ); } } - double subTotal = double.parse(order.subTotal.toString()) - double.parse(order.discount.toString()); + double subTotal = + double.parse(order.subTotal.toString()) - + double.parse(order.discount.toString()); double refundAmount = subTotal + totalTax; WalletTransactionModel walletTransaction = WalletTransactionModel( @@ -210,7 +296,10 @@ class MyRentalBookingController extends GetxController { ); await FireStoreUtils.setWalletTransaction(walletTransaction); - await FireStoreUtils.updateUserWallet(amount: refundAmount.toString(), userId: FireStoreUtils.getCurrentUid()); + await FireStoreUtils.updateUserWallet( + amount: refundAmount.toString(), + userId: FireStoreUtils.getCurrentUid(), + ); } ShowToastDialog.showToast("Booking cancelled successfully".tr); } catch (e) { diff --git a/lib/controllers/on_demand_booking_controller.dart b/lib/controllers/on_demand_booking_controller.dart index ab33fbd..91978f1 100644 --- a/lib/controllers/on_demand_booking_controller.dart +++ b/lib/controllers/on_demand_booking_controller.dart @@ -1,7 +1,10 @@ import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:customer/constant/const_texts.dart'; import 'package:customer/constant/constant.dart'; import 'package:customer/models/coupon_model.dart'; import 'package:customer/models/user_model.dart'; +import 'package:customer/utils/app_router.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:intl/intl.dart'; @@ -54,8 +57,12 @@ class OnDemandBookingController extends GetxController { void fetchCoupons() { if (provider.value?.author != null && provider.value!.author!.isNotEmpty) { - FireStoreUtils.getProviderCoupon(provider.value!.author!).then((activeCoupons) => couponList.assignAll(activeCoupons)); - FireStoreUtils.getProviderCouponAfterExpire(provider.value!.author!).then((expiredCoupons) => couponList.addAll(expiredCoupons)); + FireStoreUtils.getProviderCoupon( + provider.value!.author!, + ).then((activeCoupons) => couponList.assignAll(activeCoupons)); + FireStoreUtils.getProviderCouponAfterExpire( + provider.value!.author!, + ).then((expiredCoupons) => couponList.addAll(expiredCoupons)); } } @@ -79,8 +86,12 @@ class OnDemandBookingController extends GetxController { void applyCoupon(CouponModel coupon) { double discount = 0.0; - if (coupon.discountType == "Percentage" || coupon.discountType == "Percent") { - discount = price.value * (double.tryParse(coupon.discount.toString()) ?? 0) / 100; + if (coupon.discountType == "Percentage" || + coupon.discountType == "Percent") { + discount = + price.value * + (double.tryParse(coupon.discount.toString()) ?? 0) / + 100; } else { discount = double.tryParse(coupon.discount.toString()) ?? 0; } @@ -114,9 +125,14 @@ class OnDemandBookingController extends GetxController { // discount if (discountType.value == "Percentage" || discountType.value == "Percent") { - discountAmount.value = price.value * (double.tryParse(discountLabel.value) ?? 0) / 100; + discountAmount.value = + price.value * (double.tryParse(discountLabel.value) ?? 0) / 100; } else { - discountAmount.value = double.tryParse(discountLabel.value.isEmpty ? '0' : discountLabel.value) ?? 0; + discountAmount.value = + double.tryParse( + discountLabel.value.isEmpty ? '0' : discountLabel.value, + ) ?? + 0; } subTotal.value = price.value - discountAmount.value; @@ -124,7 +140,10 @@ class OnDemandBookingController extends GetxController { // tax calculation double total = subTotal.value; for (var element in Constant.taxList) { - total += Constant.getTaxValue(amount: subTotal.value.toString(), taxModel: element); + total += Constant.getTaxValue( + amount: subTotal.value.toString(), + taxModel: element, + ); } totalAmount.value = total; @@ -136,7 +155,9 @@ class OnDemandBookingController extends GetxController { } else if (dateTimeController.value.text.isEmpty) { ShowToastDialog.showToast("Please select time slot.".tr); } else { - UserModel? providerUser = await FireStoreUtils.getUserProfile(provider.value!.author!); + UserModel? providerUser = await FireStoreUtils.getUserProfile( + provider.value!.author!, + ); if (provider.value?.priceUnit == "Fixed") { OnProviderOrderModel onDemandOrderModel = OnProviderOrderModel( @@ -160,16 +181,29 @@ class OnDemandBookingController extends GetxController { adminCommissionType: Constant.sectionConstantModel?.adminCommision?.isEnabled == false ? 'fixed' - : providerUser?.adminCommissionModel?.commissionType ?? Constant.sectionConstantModel?.adminCommision?.commissionType, + : providerUser?.adminCommissionModel?.commissionType ?? + Constant + .sectionConstantModel + ?.adminCommision + ?.commissionType, otp: Constant.getReferralCode(), couponCode: offerCode.toString(), ); - print('totalAmount ::::::: ${double.tryParse(Constant.amountShow(amount: totalAmount.value.toString())) ?? 0.0}'); + print( + 'totalAmount ::::::: ${double.tryParse(Constant.amountShow(amount: totalAmount.value.toString())) ?? 0.0}', + ); print('totalAmount value ::::::: ${totalAmount.value}'); - Get.to(() => OnDemandPaymentScreen(), arguments: {'onDemandOrderModel': Rxn(onDemandOrderModel), 'totalAmount': totalAmount.value, 'isExtra': false}); + Get.to( + () => OnDemandPaymentScreen(), + arguments: { + 'onDemandOrderModel': Rxn(onDemandOrderModel), + 'totalAmount': totalAmount.value, + 'isExtra': false, + }, + ); } else { - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); OnProviderOrderModel onDemandOrder = OnProviderOrderModel( otp: Constant.getReferralCode(), authorID: FireStoreUtils.getCurrentUid(), @@ -191,21 +225,36 @@ class OnDemandBookingController extends GetxController { adminCommissionType: Constant.sectionConstantModel?.adminCommision?.isEnabled == false ? 'fixed' - : providerUser?.adminCommissionModel?.commissionType ?? Constant.sectionConstantModel?.adminCommision?.commissionType, + : providerUser?.adminCommissionModel?.commissionType ?? + Constant + .sectionConstantModel + ?.adminCommision + ?.commissionType, paymentStatus: true, ); await FireStoreUtils.onDemandOrderPlace(onDemandOrder, 0.0); - await FireStoreUtils.sendOrderOnDemandServiceEmail(orderModel: onDemandOrder); + await FireStoreUtils.sendOrderOnDemandServiceEmail( + orderModel: onDemandOrder, + ); if (providerUser != null) { - Map payLoad = {"type": 'provider_order', "orderId": onDemandOrder.id}; - await SendNotification.sendFcmMessage(Constant.bookingPlaced, providerUser.fcmToken.toString(), payLoad); + Map payLoad = { + "type": 'provider_order', + "orderId": onDemandOrder.id, + }; + await SendNotification.sendFcmMessage( + Constant.bookingPlaced, + providerUser.fcmToken.toString(), + payLoad, + ); } ShowToastDialog.closeLoader(); Get.offAll(const OnDemandDashboardScreen()); - OnDemandDashboardController controller = Get.put(OnDemandDashboardController()); + OnDemandDashboardController controller = Get.put( + OnDemandDashboardController(), + ); controller.selectedIndex.value = 2; ShowToastDialog.showToast("OnDemand Service successfully booked".tr); } diff --git a/lib/controllers/on_demand_category_controller.dart b/lib/controllers/on_demand_category_controller.dart index 31e6da0..8b573c4 100644 --- a/lib/controllers/on_demand_category_controller.dart +++ b/lib/controllers/on_demand_category_controller.dart @@ -1,5 +1,4 @@ import 'package:get/get.dart'; - import '../models/category_model.dart'; import '../service/fire_store_utils.dart'; diff --git a/lib/controllers/on_demand_dashboard_controller.dart b/lib/controllers/on_demand_dashboard_controller.dart index 33b395c..d7cf110 100644 --- a/lib/controllers/on_demand_dashboard_controller.dart +++ b/lib/controllers/on_demand_dashboard_controller.dart @@ -4,7 +4,6 @@ import 'package:customer/screen_ui/multi_vendor_service/wallet_screen/wallet_scr import 'package:customer/screen_ui/on_demand_service/favourite_ondemand_screen.dart'; import 'package:customer/service/fire_store_utils.dart'; import 'package:get/get.dart'; - import '../screen_ui/on_demand_service/my_booking_on_demand_screen.dart'; import '../screen_ui/on_demand_service/on_demand_home_screen.dart'; @@ -17,7 +16,12 @@ class OnDemandDashboardController extends GetxController { void onInit() { getTaxList(); if (Constant.walletSetting == false) { - pageList.value = [OnDemandHomeScreen(), FavouriteOndemandScreen(), const MyBookingOnDemandScreen(), const ProfileScreen()]; + pageList.value = [ + OnDemandHomeScreen(), + FavouriteOndemandScreen(), + const MyBookingOnDemandScreen(), + const ProfileScreen(), + ]; } else { pageList.value = [ OnDemandHomeScreen(), @@ -31,7 +35,9 @@ class OnDemandDashboardController extends GetxController { } Future getTaxList() async { - await FireStoreUtils.getTaxList(Constant.sectionConstantModel!.id).then((value) { + await FireStoreUtils.getTaxList(Constant.sectionConstantModel!.id).then(( + value, + ) { if (value != null) { Constant.taxList = value; } diff --git a/lib/controllers/on_demand_details_controller.dart b/lib/controllers/on_demand_details_controller.dart index 8f7ea01..3064071 100644 --- a/lib/controllers/on_demand_details_controller.dart +++ b/lib/controllers/on_demand_details_controller.dart @@ -14,7 +14,8 @@ class OnDemandDetailsController extends GetxController { final RxString subCategoryTitle = ''.obs; final RxString categoryTitle = ''.obs; final RxList ratingService = [].obs; - final RxList lstFav = [].obs; + final RxList lstFav = + [].obs; final RxBool isLoading = true.obs; final RxBool isOpen = false.obs; final RxString tabString = "About".obs; @@ -27,35 +28,44 @@ class OnDemandDetailsController extends GetxController { getData(); } - Future getData() async { await getReviewList(); await getAuthor(); //fetch and set provider author here if (Constant.userModel != null) { - lstFav.value = await FireStoreUtils.getFavouritesServiceList(FireStoreUtils.getCurrentUid()); + lstFav.value = await FireStoreUtils.getFavouritesServiceList( + FireStoreUtils.getCurrentUid(), + ); } isLoading.value = false; } Future getReviewList() async { - await FireStoreUtils.getCategoryById(provider.categoryId.toString()).then((value) { + await FireStoreUtils.getCategoryById(provider.categoryId.toString()).then(( + value, + ) { if (value != null) { categoryTitle.value = value.title.toString(); } }); - await FireStoreUtils.getSubCategoryById(provider.subCategoryId.toString()).then((value) { + await FireStoreUtils.getSubCategoryById( + provider.subCategoryId.toString(), + ).then((value) { if (value != null) { subCategoryTitle.value = value.title.toString(); } }); - await FireStoreUtils.getReviewByProviderServiceId(provider.id.toString()).then((value) { + await FireStoreUtils.getReviewByProviderServiceId( + provider.id.toString(), + ).then((value) { ratingService.value = value; }); if (Constant.userModel != null) { - await FireStoreUtils.getFavouritesServiceList(FireStoreUtils.getCurrentUid()).then((value) { + await FireStoreUtils.getFavouritesServiceList( + FireStoreUtils.getCurrentUid(), + ).then((value) { lstFav.value = value; }); } @@ -78,8 +88,12 @@ class OnDemandDetailsController extends GetxController { for (var element in provider.days) { if (day == element.toString()) { - final start = DateFormat("dd-MM-yyyy HH:mm").parse("$date ${provider.startTime}"); - final end = DateFormat("dd-MM-yyyy HH:mm").parse("$date ${provider.endTime}"); + final start = DateFormat( + "dd-MM-yyyy HH:mm", + ).parse("$date ${provider.startTime}"); + final end = DateFormat( + "dd-MM-yyyy HH:mm", + ).parse("$date ${provider.endTime}"); if (isCurrentDateInRange(start, end)) { isOpen.value = true; } @@ -96,5 +110,3 @@ class OnDemandDetailsController extends GetxController { tabString.value = tab; } } - - diff --git a/lib/controllers/on_demand_home_controller.dart b/lib/controllers/on_demand_home_controller.dart index 16f4aac..fc8764c 100644 --- a/lib/controllers/on_demand_home_controller.dart +++ b/lib/controllers/on_demand_home_controller.dart @@ -40,24 +40,31 @@ class OnDemandHomeController extends GetxController { // Fetch provider services FireStoreUtils.getProviderFuture() .then((providerServiceList) { - Set uniqueAuthorIds = providerServiceList.map((service) => service.author).toSet(); + Set uniqueAuthorIds = + providerServiceList.map((service) => service.author).toSet(); List listOfUniqueProviders = uniqueAuthorIds.toList(); List filteredProviders = []; for (var provider in listOfUniqueProviders) { - List filteredList = providerServiceList.where((service) => service.author == provider).toList(); + List filteredList = + providerServiceList + .where((service) => service.author == provider) + .toList(); filteredList.sort((a, b) => a.createdAt!.compareTo(b.createdAt!)); for (int index = 0; index < filteredList.length; index++) { final service = filteredList[index]; - if (Constant.isSubscriptionModelApplied == true || Constant.sectionConstantModel?.adminCommision?.isEnabled == true) { + if (Constant.isSubscriptionModelApplied == true || + Constant.sectionConstantModel?.adminCommision?.isEnabled == + true) { if (service.subscriptionPlan?.itemLimit == "-1") { filteredProviders.add(service); } else { - if (index < int.parse(service.subscriptionPlan?.itemLimit ?? '0')) { + if (index < + int.parse(service.subscriptionPlan?.itemLimit ?? '0')) { filteredProviders.add(service); } } @@ -75,7 +82,9 @@ class OnDemandHomeController extends GetxController { isLoading.value = false; }); - FireStoreUtils.getFavouritesServiceList(FireStoreUtils.getCurrentUid()).then((favList) { + FireStoreUtils.getFavouritesServiceList( + FireStoreUtils.getCurrentUid(), + ).then((favList) { lstFav.value = favList; }); } @@ -85,7 +94,9 @@ class OnDemandHomeController extends GetxController { if (categoryId == null || categoryId.isEmpty) return null; // Try to find category from cached list - CategoryModel? cat = categories.firstWhereOrNull((element) => element.id == categoryId); + CategoryModel? cat = categories.firstWhereOrNull( + (element) => element.id == categoryId, + ); // If not found, fetch from Firestore cat ??= await FireStoreUtils.getCategoryById(categoryId); @@ -94,29 +105,34 @@ class OnDemandHomeController extends GetxController { return cat; } - RxList lstFav = [].obs; + RxList lstFav = + [].obs; void toggleFavourite(ProviderServiceModel provider) { if (Constant.userModel == null) { Get.to(LoginScreen()); } else { - var contain = lstFav.where((element) => element.service_id == provider.id); + var contain = lstFav.where( + (element) => element.service_id == provider.id, + ); if (contain.isNotEmpty) { - FavouriteOndemandServiceModel favouriteModel = FavouriteOndemandServiceModel( - section_id: provider.sectionId, - service_id: provider.id, - user_id: FireStoreUtils.getCurrentUid(), - serviceAuthorId: provider.author, - ); + FavouriteOndemandServiceModel favouriteModel = + FavouriteOndemandServiceModel( + section_id: provider.sectionId, + service_id: provider.id, + user_id: FireStoreUtils.getCurrentUid(), + serviceAuthorId: provider.author, + ); FireStoreUtils.removeFavouriteOndemandService(favouriteModel); lstFav.removeWhere((item) => item.service_id == provider.id); } else { - FavouriteOndemandServiceModel favouriteModel = FavouriteOndemandServiceModel( - section_id: provider.sectionId, - service_id: provider.id, - user_id: FireStoreUtils.getCurrentUid(), - serviceAuthorId: provider.author, - ); + FavouriteOndemandServiceModel favouriteModel = + FavouriteOndemandServiceModel( + section_id: provider.sectionId, + service_id: provider.id, + user_id: FireStoreUtils.getCurrentUid(), + serviceAuthorId: provider.author, + ); FireStoreUtils.setFavouriteOndemandSection(favouriteModel); lstFav.add(favouriteModel); } @@ -127,7 +143,13 @@ class OnDemandHomeController extends GetxController { await FireStoreUtils.getZone().then((value) { if (value != null) { for (int i = 0; i < value.length; i++) { - if (Constant.isPointInPolygon(LatLng(Constant.selectedLocation.location?.latitude ?? 0.0, Constant.selectedLocation.location?.longitude ?? 0.0), value[i].area!)) { + if (Constant.isPointInPolygon( + LatLng( + Constant.selectedLocation.location?.latitude ?? 0.0, + Constant.selectedLocation.location?.longitude ?? 0.0, + ), + value[i].area!, + )) { Constant.selectedZone = value[i]; Constant.isZoneAvailable = true; break; diff --git a/lib/controllers/on_demand_order_details_controller.dart b/lib/controllers/on_demand_order_details_controller.dart index 2fb2d76..c351b6c 100644 --- a/lib/controllers/on_demand_order_details_controller.dart +++ b/lib/controllers/on_demand_order_details_controller.dart @@ -1,7 +1,9 @@ import 'dart:developer'; import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:customer/constant/const_texts.dart'; import 'package:customer/models/coupon_model.dart'; import 'package:customer/models/user_model.dart'; + import 'package:flutter/cupertino.dart'; import 'package:get/get.dart'; import '../constant/constant.dart'; @@ -18,7 +20,8 @@ class OnDemandOrderDetailsController extends GetxController { Rxn worker = Rxn(); Rx couponTextController = TextEditingController().obs; - Rx cancelBookingController = TextEditingController().obs; + Rx cancelBookingController = + TextEditingController().obs; RxDouble subTotal = 0.0.obs; RxDouble price = 0.0.obs; @@ -47,17 +50,22 @@ class OnDemandOrderDetailsController extends GetxController { Future getData() async { try { - final order = await FireStoreUtils.getProviderOrderById(onProviderOrder.value!.id); + final order = await FireStoreUtils.getProviderOrderById( + onProviderOrder.value!.id, + ); if (order != null) { onProviderOrder.value = order; discountType.value = order.discountType ?? ""; discountLabel.value = order.discountLabel ?? ""; - discountAmount.value = double.tryParse(order.discount.toString()) ?? 0.0; + discountAmount.value = + double.tryParse(order.discount.toString()) ?? 0.0; offerCode.value = order.couponCode ?? ""; // Fetch provider - providerUser.value = await FireStoreUtils.getUserProfile(order.provider.author.toString()); + providerUser.value = await FireStoreUtils.getUserProfile( + order.provider.author.toString(), + ); // Fetch worker (if exists) if (order.workerId != null && order.workerId!.isNotEmpty) { @@ -69,7 +77,9 @@ class OnDemandOrderDetailsController extends GetxController { calculatePrice(); // Load available coupons - FireStoreUtils.getProviderCouponAfterExpire(order.provider.author.toString()).then((expiredCoupons) { + FireStoreUtils.getProviderCouponAfterExpire( + order.provider.author.toString(), + ).then((expiredCoupons) { couponList.assignAll(expiredCoupons); }); } else { @@ -89,8 +99,12 @@ class OnDemandOrderDetailsController extends GetxController { void applyCoupon(CouponModel coupon) { double discount = 0.0; - if (coupon.discountType == "Percentage" || coupon.discountType == "Percent") { - discount = price.value * (double.tryParse(coupon.discount.toString()) ?? 0) / 100; + if (coupon.discountType == "Percentage" || + coupon.discountType == "Percent") { + discount = + price.value * + (double.tryParse(coupon.discount.toString()) ?? 0) / + 100; } else { discount = double.tryParse(coupon.discount.toString()) ?? 0; } @@ -107,17 +121,29 @@ class OnDemandOrderDetailsController extends GetxController { void calculatePrice() { double basePrice = - (onProviderOrder.value?.provider.disPrice == "" || onProviderOrder.value?.provider.disPrice == "0") - ? double.tryParse(onProviderOrder.value?.provider.price.toString() ?? "0") ?? 0 - : double.tryParse(onProviderOrder.value?.provider.disPrice.toString() ?? "0") ?? 0; + (onProviderOrder.value?.provider.disPrice == "" || + onProviderOrder.value?.provider.disPrice == "0") + ? double.tryParse( + onProviderOrder.value?.provider.price.toString() ?? "0", + ) ?? + 0 + : double.tryParse( + onProviderOrder.value?.provider.disPrice.toString() ?? "0", + ) ?? + 0; price.value = basePrice * (onProviderOrder.value?.quantity ?? 0.0); // discount if (discountType.value == "Percentage" || discountType.value == "Percent") { - discountAmount.value = price.value * (double.tryParse(discountLabel.value) ?? 0) / 100; + discountAmount.value = + price.value * (double.tryParse(discountLabel.value) ?? 0) / 100; } else { - discountAmount.value = double.tryParse(discountLabel.value.isEmpty ? '0' : discountLabel.value) ?? 0; + discountAmount.value = + double.tryParse( + discountLabel.value.isEmpty ? '0' : discountLabel.value, + ) ?? + 0; } subTotal.value = price.value - discountAmount.value; @@ -125,7 +151,10 @@ class OnDemandOrderDetailsController extends GetxController { // tax calculation double total = subTotal.value; for (var element in Constant.taxList) { - total += Constant.getTaxValue(amount: subTotal.value.toString(), taxModel: element); + total += Constant.getTaxValue( + amount: subTotal.value.toString(), + taxModel: element, + ); } totalAmount.value = total; @@ -144,29 +173,37 @@ class OnDemandOrderDetailsController extends GetxController { final order = onProviderOrder.value; if (order == null) return; - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); try { double total = 0.0; // Calculate total final pricePerUnit = - (order.provider.disPrice == "" || order.provider.disPrice == "0") ? double.tryParse(order.provider.price.toString()) ?? 0 : double.tryParse(order.provider.disPrice.toString()) ?? 0; + (order.provider.disPrice == "" || order.provider.disPrice == "0") + ? double.tryParse(order.provider.price.toString()) ?? 0 + : double.tryParse(order.provider.disPrice.toString()) ?? 0; total = pricePerUnit * (order.quantity); // Add tax if (Constant.taxList.isNotEmpty) { for (var tax in Constant.taxList) { - total += Constant.getTaxValue(amount: total.toString(), taxModel: tax); + total += Constant.getTaxValue( + amount: total.toString(), + taxModel: tax, + ); } } // Admin commission double adminComm = 0.0; - if ((order.adminCommission ?? '0') != '0' && (order.adminCommissionType ?? '').isNotEmpty) { - if (order.adminCommissionType!.toLowerCase() == 'percentage' || order.adminCommissionType!.toLowerCase() == 'percent') { - adminComm = (total * (double.tryParse(order.adminCommission!) ?? 0)) / 100; + if ((order.adminCommission ?? '0') != '0' && + (order.adminCommissionType ?? '').isNotEmpty) { + if (order.adminCommissionType!.toLowerCase() == 'percentage' || + order.adminCommissionType!.toLowerCase() == 'percent') { + adminComm = + (total * (double.tryParse(order.adminCommission!) ?? 0)) / 100; } else { adminComm = double.tryParse(order.adminCommission!) ?? 0; } @@ -236,10 +273,19 @@ class OnDemandOrderDetailsController extends GetxController { await FireStoreUtils.updateOnDemandOrder(order); // Ensure this completes // Notify provider - final provider = await FireStoreUtils.getUserProfile(order.provider.author ?? ''); + final provider = await FireStoreUtils.getUserProfile( + order.provider.author ?? '', + ); if (provider != null) { - Map payload = {"type": 'provider_order', "orderId": order.id}; - await SendNotification.sendFcmMessage(Constant.bookingPlaced, provider.fcmToken ?? '', payload); + Map payload = { + "type": 'provider_order', + "orderId": order.id, + }; + await SendNotification.sendFcmMessage( + Constant.bookingPlaced, + provider.fcmToken ?? '', + payload, + ); } ShowToastDialog.closeLoader(); diff --git a/lib/controllers/on_demand_review_controller.dart b/lib/controllers/on_demand_review_controller.dart index 4ccccd2..9208286 100644 --- a/lib/controllers/on_demand_review_controller.dart +++ b/lib/controllers/on_demand_review_controller.dart @@ -1,4 +1,5 @@ import 'package:cloud_firestore/cloud_firestore.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../constant/collection_name.dart'; @@ -19,7 +20,8 @@ class OnDemandReviewController extends GetxController { final TextEditingController comment = TextEditingController(); final Rxn provider = Rxn(); - final Rxn providerServiceModel = Rxn(); + final Rxn providerServiceModel = + Rxn(); final Rxn workerModel = Rxn(); final RxInt providerReviewCount = 0.obs; @@ -45,14 +47,20 @@ class OnDemandReviewController extends GetxController { void getReview() async { // Get existing rating if (reviewFor.value == "Provider") { - RatingModel? value = await FireStoreUtils.getReviewsByProviderID(order.value!.id, order.value!.provider.author.toString()); + RatingModel? value = await FireStoreUtils.getReviewsByProviderID( + order.value!.id, + order.value!.provider.author.toString(), + ); if (value != null) { ratingModel.value = value; ratings.value = value.rating ?? 0.0; comment.text = value.comment ?? ''; } } else { - RatingModel? value = await FireStoreUtils.getReviewsByWorkerID(order.value!.id, order.value!.workerId.toString()); + RatingModel? value = await FireStoreUtils.getReviewsByWorkerID( + order.value!.id, + order.value!.workerId.toString(), + ); if (value != null) { ratingModel.value = value; ratings.value = value.rating ?? 0.0; @@ -62,7 +70,9 @@ class OnDemandReviewController extends GetxController { // Worker review logic if (reviewFor.value == "Worker") { - WorkerModel? value = await FireStoreUtils.getWorker(order.value!.workerId.toString()); + WorkerModel? value = await FireStoreUtils.getWorker( + order.value!.workerId.toString(), + ); if (value != null) { workerModel.value = value; @@ -70,25 +80,35 @@ class OnDemandReviewController extends GetxController { final double existingSum = (value.reviewsSum ?? 0.0).toDouble(); final double oldRating = ratingModel.value?.rating ?? 0.0; - workerReviewCount.value = ratingModel.value != null ? (existingCount - 1) : existingCount; - workerReviewSum.value = ratingModel.value != null ? (existingSum - oldRating) : existingSum; + workerReviewCount.value = + ratingModel.value != null ? (existingCount - 1) : existingCount; + workerReviewSum.value = + ratingModel.value != null ? (existingSum - oldRating) : existingSum; } } // Provider & service review logic else { - UserModel? user = await FireStoreUtils.getUserProfile(order.value!.provider.author.toString()); + UserModel? user = await FireStoreUtils.getUserProfile( + order.value!.provider.author.toString(), + ); if (user != null) { provider.value = user; - final int existingCount = int.tryParse(user.reviewsCount?.toString() ?? '0') ?? 0; - final double existingSum = double.tryParse(user.reviewsSum?.toString() ?? '0.0') ?? 0.0; + final int existingCount = + int.tryParse(user.reviewsCount?.toString() ?? '0') ?? 0; + final double existingSum = + double.tryParse(user.reviewsSum?.toString() ?? '0.0') ?? 0.0; final double oldRating = ratingModel.value?.rating ?? 0.0; - providerReviewCount.value = ratingModel.value != null ? (existingCount - 1) : existingCount; - providerReviewSum.value = ratingModel.value != null ? (existingSum - oldRating) : existingSum; + providerReviewCount.value = + ratingModel.value != null ? (existingCount - 1) : existingCount; + providerReviewSum.value = + ratingModel.value != null ? (existingSum - oldRating) : existingSum; } - ProviderServiceModel? service = await FireStoreUtils.getCurrentProvider(order.value!.provider.id.toString()); + ProviderServiceModel? service = await FireStoreUtils.getCurrentProvider( + order.value!.provider.id.toString(), + ); if (service != null) { providerServiceModel.value = service; @@ -96,8 +116,10 @@ class OnDemandReviewController extends GetxController { final double existingSum = (service.reviewsSum ?? 0.0).toDouble(); final double oldRating = ratingModel.value?.rating ?? 0.0; - serviceReviewCount.value = ratingModel.value != null ? (existingCount - 1) : existingCount; - serviceReviewSum.value = ratingModel.value != null ? (existingSum - oldRating) : existingSum; + serviceReviewCount.value = + ratingModel.value != null ? (existingCount - 1) : existingCount; + serviceReviewSum.value = + ratingModel.value != null ? (existingSum - oldRating) : existingSum; } } } @@ -113,22 +135,29 @@ class OnDemandReviewController extends GetxController { Future _providerReviewSubmit() async { ShowToastDialog.showLoader("Submit in...".tr); providerServiceModel.value!.reviewsCount = serviceReviewCount.value + 1; - providerServiceModel.value!.reviewsSum = serviceReviewSum.value + ratings.value; + providerServiceModel.value!.reviewsSum = + serviceReviewSum.value + ratings.value; // Convert to string only if your model field is String provider.value!.reviewsCount = (providerReviewCount.value + 1).toString(); - provider.value!.reviewsSum = (providerReviewSum.value + ratings.value).toString(); + provider.value!.reviewsSum = + (providerReviewSum.value + ratings.value).toString(); RatingModel rate = RatingModel( - id: ratingModel.value?.id ?? firestore.collection(CollectionName.itemsReview).doc().id, + id: + ratingModel.value?.id ?? + firestore.collection(CollectionName.itemsReview).doc().id, productId: ratingModel.value?.productId ?? order.value!.provider.id, comment: comment.text, photos: ratingModel.value?.photos ?? [], rating: ratings.value, orderId: ratingModel.value?.orderId ?? order.value!.id, - vendorId: ratingModel.value?.vendorId ?? order.value!.provider.author.toString(), + vendorId: + ratingModel.value?.vendorId ?? + order.value!.provider.author.toString(), customerId: Constant.userModel?.id, - uname: '${Constant.userModel?.firstName ?? ''} ${Constant.userModel?.lastName ?? ''}', + uname: + '${Constant.userModel?.firstName ?? ''} ${Constant.userModel?.lastName ?? ''}', profile: Constant.userModel?.profilePictureURL, createdAt: Timestamp.now(), ); @@ -147,7 +176,9 @@ class OnDemandReviewController extends GetxController { workerModel.value!.reviewsSum = workerReviewSum.value + ratings.value; RatingModel rate = RatingModel( - id: ratingModel.value?.id ?? firestore.collection(CollectionName.itemsReview).doc().id, + id: + ratingModel.value?.id ?? + firestore.collection(CollectionName.itemsReview).doc().id, productId: ratingModel.value?.productId ?? order.value!.provider.id, comment: comment.text, photos: ratingModel.value?.photos ?? [], @@ -155,7 +186,8 @@ class OnDemandReviewController extends GetxController { orderId: ratingModel.value?.orderId ?? order.value!.id, driverId: ratingModel.value?.driverId ?? order.value!.workerId.toString(), customerId: Constant.userModel?.id, - uname: '${Constant.userModel?.firstName ?? ''} ${Constant.userModel?.lastName ?? ''}', + uname: + '${Constant.userModel?.firstName ?? ''} ${Constant.userModel?.lastName ?? ''}', profile: Constant.userModel?.profilePictureURL, createdAt: Timestamp.now(), ); diff --git a/lib/controllers/order_controller.dart b/lib/controllers/order_controller.dart index c6b606b..aa16c62 100644 --- a/lib/controllers/order_controller.dart +++ b/lib/controllers/order_controller.dart @@ -26,16 +26,27 @@ class OrderController extends GetxController { await FireStoreUtils.getAllOrder().then((value) { allList.value = value; - rejectedList.value = allList.where((p0) => p0.status == Constant.orderRejected).toList(); + rejectedList.value = + allList.where((p0) => p0.status == Constant.orderRejected).toList(); inProgressList.value = allList .where( - (p0) => p0.status == Constant.orderAccepted || p0.status == Constant.driverPending || p0.status == Constant.orderShipped || p0.status == Constant.orderInTransit, + (p0) => + p0.status == Constant.orderAccepted || + p0.status == Constant.driverPending || + p0.status == Constant.orderShipped || + p0.status == Constant.orderInTransit, ) .toList(); - deliveredList.value = allList.where((p0) => p0.status == Constant.orderCompleted).toList(); - cancelledList.value = allList.where((p0) => p0.status == Constant.orderCancelled).toList(); + deliveredList.value = + allList + .where((p0) => p0.status == Constant.orderCompleted) + .toList(); + cancelledList.value = + allList + .where((p0) => p0.status == Constant.orderCancelled) + .toList(); }); } @@ -45,7 +56,11 @@ class OrderController extends GetxController { final CartProvider cartProvider = CartProvider(); void addToCart({required CartProductModel cartProductModel}) { - cartProvider.addToCart(Get.context!, cartProductModel, cartProductModel.quantity!); + cartProvider.addToCart( + Get.context!, + cartProductModel, + cartProductModel.quantity!, + ); update(); } } diff --git a/lib/controllers/order_details_controller.dart b/lib/controllers/order_details_controller.dart index 44c2898..adf1e24 100644 --- a/lib/controllers/order_details_controller.dart +++ b/lib/controllers/order_details_controller.dart @@ -2,7 +2,6 @@ import 'package:customer/constant/constant.dart'; import 'package:customer/models/cart_product_model.dart'; import 'package:customer/models/order_model.dart'; import 'package:get/get.dart'; - import '../service/cart_provider.dart'; class OrderDetailsController extends GetxController { @@ -39,28 +38,48 @@ class OrderDetailsController extends GetxController { for (var element in orderModel.value.products!) { if (double.parse(element.discountPrice.toString()) <= 0) { - subTotal.value = subTotal.value + - double.parse(element.price.toString()) * double.parse(element.quantity.toString()) + - (double.parse(element.extrasPrice.toString()) * double.parse(element.quantity.toString())); + subTotal.value = + subTotal.value + + double.parse(element.price.toString()) * + double.parse(element.quantity.toString()) + + (double.parse(element.extrasPrice.toString()) * + double.parse(element.quantity.toString())); } else { - subTotal.value = subTotal.value + - double.parse(element.discountPrice.toString()) * double.parse(element.quantity.toString()) + - (double.parse(element.extrasPrice.toString()) * double.parse(element.quantity.toString())); + subTotal.value = + subTotal.value + + double.parse(element.discountPrice.toString()) * + double.parse(element.quantity.toString()) + + (double.parse(element.extrasPrice.toString()) * + double.parse(element.quantity.toString())); } } - if (orderModel.value.specialDiscount != null && orderModel.value.specialDiscount!['special_discount'] != null) { - specialDiscountAmount.value = double.parse(orderModel.value.specialDiscount!['special_discount'].toString()); + if (orderModel.value.specialDiscount != null && + orderModel.value.specialDiscount!['special_discount'] != null) { + specialDiscountAmount.value = double.parse( + orderModel.value.specialDiscount!['special_discount'].toString(), + ); } if (orderModel.value.taxSetting != null) { for (var element in orderModel.value.taxSetting!) { - taxAmount.value = taxAmount.value + - Constant.calculateTax(amount: (subTotal.value - double.parse(orderModel.value.discount.toString()) - specialDiscountAmount.value).toString(), taxModel: element); + taxAmount.value = + taxAmount.value + + Constant.calculateTax( + amount: + (subTotal.value - + double.parse(orderModel.value.discount.toString()) - + specialDiscountAmount.value) + .toString(), + taxModel: element, + ); } } - totalAmount.value = (subTotal.value - double.parse(orderModel.value.discount.toString()) - specialDiscountAmount.value) + + totalAmount.value = + (subTotal.value - + double.parse(orderModel.value.discount.toString()) - + specialDiscountAmount.value) + taxAmount.value + double.parse(orderModel.value.deliveryCharge.toString()) + double.parse(orderModel.value.tipAmount.toString()); @@ -71,7 +90,11 @@ class OrderDetailsController extends GetxController { final CartProvider cartProvider = CartProvider(); void addToCart({required CartProductModel cartProductModel}) { - cartProvider.addToCart(Get.context!, cartProductModel, cartProductModel.quantity!); + cartProvider.addToCart( + Get.context!, + cartProductModel, + cartProductModel.quantity!, + ); update(); } } diff --git a/lib/controllers/osm_search_place_controller.dart b/lib/controllers/osm_search_place_controller.dart index 7cdf1e2..8902871 100644 --- a/lib/controllers/osm_search_place_controller.dart +++ b/lib/controllers/osm_search_place_controller.dart @@ -25,7 +25,8 @@ class OsmSearchPlaceController extends GetxController { try { String locale = 'en'; SharedPreferences sp = await SharedPreferences.getInstance(); - if (sp.getString("languageCode") != null || sp.getString("languageCode")?.isNotEmpty == true) { + if (sp.getString("languageCode") != null || + sp.getString("languageCode")?.isNotEmpty == true) { locale = sp.getString("languageCode") ?? "en"; } suggestionsList.value = await addressSuggestion(text, locale: locale); diff --git a/lib/controllers/otp_verification_controller.dart b/lib/controllers/otp_verification_controller.dart index d9309f5..7c6712a 100644 --- a/lib/controllers/otp_verification_controller.dart +++ b/lib/controllers/otp_verification_controller.dart @@ -1,5 +1,7 @@ import 'package:customer/screen_ui/location_enable_screens/location_permission_screen.dart'; import 'package:customer/themes/show_toast_dialog.dart'; +import 'package:customer/utils/app_router.dart'; + import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -62,15 +64,27 @@ class OtpVerifyController extends GetxController { try { ShowToastDialog.showLoader("Verifying OTP...".tr); - final credential = PhoneAuthProvider.credential(verificationId: verificationId.value, smsCode: otpController.value.text.trim()); + final credential = PhoneAuthProvider.credential( + verificationId: verificationId.value, + smsCode: otpController.value.text.trim(), + ); final fcmToken = await NotificationService.getToken(); final result = await _auth.signInWithCredential(credential); if (result.additionalUserInfo?.isNewUser == true) { - final userModel = UserModel(id: result.user!.uid, countryCode: countryCode.value, phoneNumber: phoneNumber.value, fcmToken: fcmToken, active: true); + final userModel = UserModel( + id: result.user!.uid, + countryCode: countryCode.value, + phoneNumber: phoneNumber.value, + fcmToken: fcmToken, + active: true, + ); ShowToastDialog.closeLoader(); - Get.to(() => const SignUpScreen(), arguments: {'type': 'mobileNumber', 'userModel': userModel}); + Get.to( + () => const SignUpScreen(), + arguments: {'type': 'mobileNumber', 'userModel': userModel}, + ); return; } @@ -78,22 +92,30 @@ class OtpVerifyController extends GetxController { ShowToastDialog.closeLoader(); if (!exists) { - final userModel = UserModel(id: result.user!.uid, countryCode: countryCode.value, phoneNumber: phoneNumber.value, fcmToken: fcmToken); - Get.off(() => const SignUpScreen(), arguments: {'type': 'mobileNumber', 'userModel': userModel}); + final userModel = UserModel( + id: result.user!.uid, + countryCode: countryCode.value, + phoneNumber: phoneNumber.value, + fcmToken: fcmToken, + ); + Get.off( + () => const SignUpScreen(), + arguments: {'type': 'mobileNumber', 'userModel': userModel}, + ); return; } final userModel = await FireStoreUtils.getUserProfile(result.user!.uid); if (userModel == null || userModel.role != 'customer') { await _auth.signOut(); - Get.offAll(() => const LoginScreen()); + Get.offAll(LoginScreen()); return; } if (userModel.active == false) { ShowToastDialog.showToast("This user is disabled".tr); await _auth.signOut(); - Get.offAll(() => const LoginScreen()); + Get.offAll(LoginScreen()); return; } @@ -101,12 +123,15 @@ class OtpVerifyController extends GetxController { await FireStoreUtils.updateUser(userModel); if (userModel.shippingAddress?.isNotEmpty ?? false) { - final defaultAddress = userModel.shippingAddress!.firstWhere((e) => e.isDefault == true, orElse: () => userModel.shippingAddress!.first); + final defaultAddress = userModel.shippingAddress!.firstWhere( + (e) => e.isDefault == true, + orElse: () => userModel.shippingAddress!.first, + ); Constant.selectedLocation = defaultAddress; - Get.offAll(() => const ServiceListScreen()); + Get.offAll(ServiceListScreen()); } else { - Get.offAll(() => const LocationPermissionScreen()); + Get.offAll(LocationPermissionScreen()); } } catch (e) { ShowToastDialog.closeLoader(); diff --git a/lib/controllers/parcel_coupon_controller.dart b/lib/controllers/parcel_coupon_controller.dart index 89da091..f01f03f 100644 --- a/lib/controllers/parcel_coupon_controller.dart +++ b/lib/controllers/parcel_coupon_controller.dart @@ -2,8 +2,7 @@ import 'package:customer/models/coupon_model.dart'; import 'package:customer/service/fire_store_utils.dart'; import 'package:get/get.dart'; -class ParcelCouponController extends GetxController{ - +class ParcelCouponController extends GetxController { @override void onInit() { // TODO: implement onInit @@ -11,10 +10,10 @@ class ParcelCouponController extends GetxController{ super.onInit(); } - - void getData(){ + void getData() { getCouponCode(); } + RxBool isLoading = true.obs; RxList cabCouponList = [].obs; @@ -26,4 +25,4 @@ class ParcelCouponController extends GetxController{ print("cabCouponList ${cabCouponList.length}"); isLoading.value = false; } -} \ No newline at end of file +} diff --git a/lib/controllers/parcel_dashboard_controller.dart b/lib/controllers/parcel_dashboard_controller.dart index bc9b6a5..bf7b2ce 100644 --- a/lib/controllers/parcel_dashboard_controller.dart +++ b/lib/controllers/parcel_dashboard_controller.dart @@ -15,15 +15,26 @@ class ParcelDashboardController extends GetxController { void onInit() { getTaxList(); if (Constant.walletSetting == false) { - pageList.value = [const HomeParcelScreen(), const MyBookingScreen(), const ProfileScreen()]; + pageList.value = [ + const HomeParcelScreen(), + const MyBookingScreen(), + const ProfileScreen(), + ]; } else { - pageList.value = [const HomeParcelScreen(), const MyBookingScreen(), const WalletScreen(), const ProfileScreen()]; + pageList.value = [ + const HomeParcelScreen(), + const MyBookingScreen(), + const WalletScreen(), + const ProfileScreen(), + ]; } super.onInit(); } Future getTaxList() async { - await FireStoreUtils.getTaxList(Constant.sectionConstantModel!.id).then((value) { + await FireStoreUtils.getTaxList(Constant.sectionConstantModel!.id).then(( + value, + ) { if (value != null) { Constant.taxList = value; } diff --git a/lib/controllers/parcel_my_booking_controller.dart b/lib/controllers/parcel_my_booking_controller.dart index 3e2addd..90c541e 100644 --- a/lib/controllers/parcel_my_booking_controller.dart +++ b/lib/controllers/parcel_my_booking_controller.dart @@ -1,5 +1,6 @@ import 'dart:async'; import 'package:cloud_firestore/cloud_firestore.dart'; + import 'package:get/get.dart'; import 'package:intl/intl.dart'; import '../constant/constant.dart'; @@ -14,7 +15,8 @@ class ParcelMyBookingController extends GetxController { RxList parcelOrder = [].obs; RxString selectedTab = "New".obs; - RxList tabTitles = ["New", "In Transit", "Delivered", "Cancelled"].obs; + RxList tabTitles = + ["New", "In Transit", "Delivered", "Cancelled"].obs; StreamSubscription>? _parcelSubscription; @@ -52,16 +54,38 @@ class ParcelMyBookingController extends GetxController { List getOrdersForTab(String tab) { switch (tab) { case "New": - return parcelOrder.where((order) => ["Order Placed"].contains(order.status)).toList(); + return parcelOrder + .where((order) => ["Order Placed"].contains(order.status)) + .toList(); case "In Transit": - return parcelOrder.where((order) => ["Order Accepted", "Driver Accepted", "Driver Pending", "Order Shipped", "In Transit"].contains(order.status)).toList(); + return parcelOrder + .where( + (order) => [ + "Order Accepted", + "Driver Accepted", + "Driver Pending", + "Order Shipped", + "In Transit", + ].contains(order.status), + ) + .toList(); case "Delivered": - return parcelOrder.where((order) => ["Order Completed"].contains(order.status)).toList(); + return parcelOrder + .where((order) => ["Order Completed"].contains(order.status)) + .toList(); case "Cancelled": - return parcelOrder.where((order) => ["Order Rejected", "Order Cancelled", "Driver Rejected"].contains(order.status)).toList(); + return parcelOrder + .where( + (order) => [ + "Order Rejected", + "Order Cancelled", + "Driver Rejected", + ].contains(order.status), + ) + .toList(); default: return []; @@ -69,7 +93,8 @@ class ParcelMyBookingController extends GetxController { } /// Old helper (optional) - List get filteredParcelOrders => getOrdersForTab(selectedTab.value); + List get filteredParcelOrders => + getOrdersForTab(selectedTab.value); String formatDate(Timestamp timestamp) { final dateTime = timestamp.toDate(); @@ -96,10 +121,18 @@ class ParcelMyBookingController extends GetxController { final taxSettings = order.taxSetting ?? []; for (var element in taxSettings) { - totalTax += Constant.calculateTax(amount: (double.parse(order.subTotal.toString()) - double.parse(order.discount.toString())).toString(), taxModel: element); + totalTax += Constant.calculateTax( + amount: + (double.parse(order.subTotal.toString()) - + double.parse(order.discount.toString())) + .toString(), + taxModel: element, + ); } - double subTotal = double.parse(order.subTotal.toString()) - double.parse(order.discount.toString()); + double subTotal = + double.parse(order.subTotal.toString()) - + double.parse(order.discount.toString()); double refundAmount = subTotal + totalTax; WalletTransactionModel walletTransaction = WalletTransactionModel( @@ -121,7 +154,10 @@ class ParcelMyBookingController extends GetxController { await FireStoreUtils.setWalletTransaction(walletTransaction); // Update wallet balance - await FireStoreUtils.updateUserWallet(amount: refundAmount.toString(), userId: FireStoreUtils.getCurrentUid()); + await FireStoreUtils.updateUserWallet( + amount: refundAmount.toString(), + userId: FireStoreUtils.getCurrentUid(), + ); } ShowToastDialog.showToast("Order cancelled successfully".tr); diff --git a/lib/controllers/parcel_order_confirmation_controller.dart b/lib/controllers/parcel_order_confirmation_controller.dart index 7c61e0b..d3d1cc1 100644 --- a/lib/controllers/parcel_order_confirmation_controller.dart +++ b/lib/controllers/parcel_order_confirmation_controller.dart @@ -3,8 +3,10 @@ import 'dart:developer'; import 'dart:io'; import 'dart:math' as maths; import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:customer/constant/const_texts.dart'; import 'package:customer/models/coupon_model.dart'; import 'package:customer/models/wallet_transaction_model.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_paypal/flutter_paypal.dart'; import 'package:flutter_stripe/flutter_stripe.dart'; @@ -96,11 +98,19 @@ class ParcelOrderConfirmationController extends GetxController { subTotal.value = double.tryParse(parcelOrder.value.subTotal ?? '0') ?? 0.0; if (selectedCouponModel.value.id != null) { - discount.value = Constant.calculateDiscount(amount: subTotal.value.toString(), offerModel: selectedCouponModel.value); + discount.value = Constant.calculateDiscount( + amount: subTotal.value.toString(), + offerModel: selectedCouponModel.value, + ); } for (var element in Constant.taxList) { - taxAmount.value = (taxAmount.value + Constant.calculateTax(amount: (subTotal.value - discount.value).toString(), taxModel: element)); + taxAmount.value = + (taxAmount.value + + Constant.calculateTax( + amount: (subTotal.value - discount.value).toString(), + taxModel: element, + )); } print("Tax: ${taxAmount.value}"); @@ -127,31 +137,46 @@ class ParcelOrderConfirmationController extends GetxController { } Future placeOrder() async { - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); try { List parcelImages = []; if (images.isNotEmpty) { for (var image in images) { - final upload = await FireStoreUtils.uploadChatImageToFireStorage(File(image.path), Get.context!); + final upload = await FireStoreUtils.uploadChatImageToFireStorage( + File(image.path), + Get.context!, + ); parcelImages.add(upload.url); } } parcelOrder.value.parcelImages = parcelImages; parcelOrder.value.discount = discount.value.toString(); - parcelOrder.value.discountType = selectedCouponModel.value.discountType.toString(); - parcelOrder.value.discountLabel = selectedCouponModel.value.code.toString(); - parcelOrder.value.adminCommission = Constant.sectionConstantModel?.adminCommision?.amount?.toString(); - parcelOrder.value.adminCommissionType = Constant.sectionConstantModel?.adminCommision?.commissionType; + parcelOrder.value.discountType = + selectedCouponModel.value.discountType.toString(); + parcelOrder.value.discountLabel = + selectedCouponModel.value.code.toString(); + parcelOrder.value.adminCommission = + Constant.sectionConstantModel?.adminCommision?.amount?.toString(); + parcelOrder.value.adminCommissionType = + Constant.sectionConstantModel?.adminCommision?.commissionType; parcelOrder.value.status = Constant.orderPlaced; parcelOrder.value.createdAt = Timestamp.now(); parcelOrder.value.author = userModel.value; parcelOrder.value.authorID = FireStoreUtils.getCurrentUid(); - parcelOrder.value.paymentMethod = paymentBy.value == "Receiver" ? "cod" : selectedPaymentMethod.value; - parcelOrder.value.paymentCollectByReceiver = paymentBy.value == "Receiver"; - parcelOrder.value.senderZoneId = Constant.getZoneId(parcelOrder.value.senderLatLong!.latitude ?? 0.0, parcelOrder.value.senderLatLong!.longitude ?? 0.0); - parcelOrder.value.receiverZoneId = Constant.getZoneId(parcelOrder.value.receiverLatLong!.latitude ?? 0.0, parcelOrder.value.receiverLatLong!.longitude ?? 0.0); + parcelOrder.value.paymentMethod = + paymentBy.value == "Receiver" ? "cod" : selectedPaymentMethod.value; + parcelOrder.value.paymentCollectByReceiver = + paymentBy.value == "Receiver"; + parcelOrder.value.senderZoneId = Constant.getZoneId( + parcelOrder.value.senderLatLong!.latitude ?? 0.0, + parcelOrder.value.senderLatLong!.longitude ?? 0.0, + ); + parcelOrder.value.receiverZoneId = Constant.getZoneId( + parcelOrder.value.receiverLatLong!.latitude ?? 0.0, + parcelOrder.value.receiverLatLong!.longitude ?? 0.0, + ); if (selectedPaymentMethod.value == PaymentGateway.wallet.name) { WalletTransactionModel transactionModel = WalletTransactionModel( @@ -168,16 +193,26 @@ class ParcelOrderConfirmationController extends GetxController { serviceType: Constant.parcelServiceType, ); - await FireStoreUtils.setWalletTransaction(transactionModel).then((value) async { + await FireStoreUtils.setWalletTransaction(transactionModel).then(( + value, + ) async { if (value == true) { - await FireStoreUtils.updateUserWallet(amount: "-${totalAmount.value.toString()}", userId: FireStoreUtils.getCurrentUid()); + await FireStoreUtils.updateUserWallet( + amount: "-${totalAmount.value.toString()}", + userId: FireStoreUtils.getCurrentUid(), + ); } }); } - await FireStoreUtils.parcelOrderPlace(parcelOrder.value).then((value) async { + await FireStoreUtils.parcelOrderPlace(parcelOrder.value).then(( + value, + ) async { ShowToastDialog.closeLoader(); ShowToastDialog.showToast("Order placed successfully".tr); - Get.offAll(() => OrderSuccessfullyPlaced(), arguments: {'parcelOrder': parcelOrder.value}); + Get.offAll( + () => OrderSuccessfullyPlaced(), + arguments: {'parcelOrder': parcelOrder.value}, + ); await FireStoreUtils.sendParcelBookEmail(orderModel: parcelOrder.value); }); } catch (e) { @@ -203,19 +238,45 @@ class ParcelOrderConfirmationController extends GetxController { Future getPaymentSettings() async { await FireStoreUtils.getPaymentSettingsData().then((value) { - stripeModel.value = StripeModel.fromJson(jsonDecode(Preferences.getString(Preferences.stripeSettings))); - payPalModel.value = PayPalModel.fromJson(jsonDecode(Preferences.getString(Preferences.paypalSettings))); - payStackModel.value = PayStackModel.fromJson(jsonDecode(Preferences.getString(Preferences.payStack))); - mercadoPagoModel.value = MercadoPagoModel.fromJson(jsonDecode(Preferences.getString(Preferences.mercadoPago))); - flutterWaveModel.value = FlutterWaveModel.fromJson(jsonDecode(Preferences.getString(Preferences.flutterWave))); - paytmModel.value = PaytmModel.fromJson(jsonDecode(Preferences.getString(Preferences.paytmSettings))); - payFastModel.value = PayFastModel.fromJson(jsonDecode(Preferences.getString(Preferences.payFastSettings))); - razorPayModel.value = RazorPayModel.fromJson(jsonDecode(Preferences.getString(Preferences.razorpaySettings))); - midTransModel.value = MidTrans.fromJson(jsonDecode(Preferences.getString(Preferences.midTransSettings))); - orangeMoneyModel.value = OrangeMoney.fromJson(jsonDecode(Preferences.getString(Preferences.orangeMoneySettings))); - xenditModel.value = Xendit.fromJson(jsonDecode(Preferences.getString(Preferences.xenditSettings))); - walletSettingModel.value = WalletSettingModel.fromJson(jsonDecode(Preferences.getString(Preferences.walletSettings))); - cashOnDeliverySettingModel.value = CodSettingModel.fromJson(jsonDecode(Preferences.getString(Preferences.codSettings))); + stripeModel.value = StripeModel.fromJson( + jsonDecode(Preferences.getString(Preferences.stripeSettings)), + ); + payPalModel.value = PayPalModel.fromJson( + jsonDecode(Preferences.getString(Preferences.paypalSettings)), + ); + payStackModel.value = PayStackModel.fromJson( + jsonDecode(Preferences.getString(Preferences.payStack)), + ); + mercadoPagoModel.value = MercadoPagoModel.fromJson( + jsonDecode(Preferences.getString(Preferences.mercadoPago)), + ); + flutterWaveModel.value = FlutterWaveModel.fromJson( + jsonDecode(Preferences.getString(Preferences.flutterWave)), + ); + paytmModel.value = PaytmModel.fromJson( + jsonDecode(Preferences.getString(Preferences.paytmSettings)), + ); + payFastModel.value = PayFastModel.fromJson( + jsonDecode(Preferences.getString(Preferences.payFastSettings)), + ); + razorPayModel.value = RazorPayModel.fromJson( + jsonDecode(Preferences.getString(Preferences.razorpaySettings)), + ); + midTransModel.value = MidTrans.fromJson( + jsonDecode(Preferences.getString(Preferences.midTransSettings)), + ); + orangeMoneyModel.value = OrangeMoney.fromJson( + jsonDecode(Preferences.getString(Preferences.orangeMoneySettings)), + ); + xenditModel.value = Xendit.fromJson( + jsonDecode(Preferences.getString(Preferences.xenditSettings)), + ); + walletSettingModel.value = WalletSettingModel.fromJson( + jsonDecode(Preferences.getString(Preferences.walletSettings)), + ); + cashOnDeliverySettingModel.value = CodSettingModel.fromJson( + jsonDecode(Preferences.getString(Preferences.codSettings)), + ); if (walletSettingModel.value.isEnabled == true) { selectedPaymentMethod.value = PaymentGateway.wallet.name; @@ -257,20 +318,32 @@ class ParcelOrderConfirmationController extends GetxController { Future stripeMakePayment({required String amount}) async { log(double.parse(amount).toStringAsFixed(0)); try { - Map? paymentIntentData = await createStripeIntent(amount: amount); + Map? paymentIntentData = await createStripeIntent( + amount: amount, + ); log("stripe Responce====>$paymentIntentData"); if (paymentIntentData!.containsKey("error")) { Get.back(); - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); } else { await Stripe.instance.initPaymentSheet( paymentSheetParameters: SetupPaymentSheetParameters( paymentIntentClientSecret: paymentIntentData['client_secret'], allowsDelayedPaymentMethods: false, - googlePay: const PaymentSheetGooglePay(merchantCountryCode: 'US', testEnv: true, currencyCode: "USD"), + googlePay: const PaymentSheetGooglePay( + merchantCountryCode: 'US', + testEnv: true, + currencyCode: "USD", + ), customFlow: true, style: ThemeMode.system, - appearance: PaymentSheetAppearance(colors: PaymentSheetAppearanceColors(primary: AppThemeData.primary300)), + appearance: PaymentSheetAppearance( + colors: PaymentSheetAppearanceColors( + primary: AppThemeData.primary300, + ), + ), merchantDisplayName: 'GoRide', ), ); @@ -316,7 +389,10 @@ class ParcelOrderConfirmationController extends GetxController { var response = await http.post( Uri.parse('https://api.stripe.com/v1/payment_intents'), body: body, - headers: {'Authorization': 'Bearer $stripeSecret', 'Content-Type': 'application/x-www-form-urlencoded'}, + headers: { + 'Authorization': 'Bearer $stripeSecret', + 'Content-Type': 'application/x-www-form-urlencoded', + }, ); return jsonDecode(response.body); @@ -326,8 +402,14 @@ class ParcelOrderConfirmationController extends GetxController { } //mercadoo - Future mercadoPagoMakePayment({required BuildContext context, required String amount}) async { - final headers = {'Authorization': 'Bearer ${mercadoPagoModel.value.accessToken}', 'Content-Type': 'application/json'}; + Future mercadoPagoMakePayment({ + required BuildContext context, + required String amount, + }) async { + final headers = { + 'Authorization': 'Bearer ${mercadoPagoModel.value.accessToken}', + 'Content-Type': 'application/json', + }; final body = jsonEncode({ "items": [ @@ -340,12 +422,20 @@ class ParcelOrderConfirmationController extends GetxController { }, ], "payer": {"email": Constant.userModel?.email}, - "back_urls": {"failure": "${Constant.globalUrl}payment/failure", "pending": "${Constant.globalUrl}payment/pending", "success": "${Constant.globalUrl}payment/success"}, + "back_urls": { + "failure": "${Constant.globalUrl}payment/failure", + "pending": "${Constant.globalUrl}payment/pending", + "success": "${Constant.globalUrl}payment/success", + }, "auto_return": "approved", // Automatically return after payment is approved }); - final response = await http.post(Uri.parse("https://api.mercadopago.com/checkout/preferences"), headers: headers, body: body); + final response = await http.post( + Uri.parse("https://api.mercadopago.com/checkout/preferences"), + headers: headers, + body: body, + ); if (response.statusCode == 200 || response.statusCode == 201) { final data = jsonDecode(response.body); @@ -375,8 +465,8 @@ class ParcelOrderConfirmationController extends GetxController { sandboxMode: payPalModel.value.isLive == true ? false : true, clientId: payPalModel.value.paypalClient ?? '', secretKey: payPalModel.value.paypalSecret ?? '', - returnURL: "com.emart.customer://paypalpay", - cancelURL: "com.emart.customer://paypalcancel", + returnURL: "felix.fondex.uz://paypalpay", + cancelURL: "felix.fondex.uz://paypalcancel", transactions: [ { @@ -418,8 +508,8 @@ class ParcelOrderConfirmationController extends GetxController { // secretKey: payPalModel.value.paypalSecret ?? '', // returnURL: "https://success.emart.com/return", // cancelURL: "https://cancel.emart.com/cancel", - // // returnURL: "com.emart.customer://paypalpay", - // // cancelURL: "com.emart.customer://paypalpay", + // // returnURL: "felix.fondex.uz://paypalpay", + // // cancelURL: "felix.fondex.uz://paypalpay", // transactions: [ // { // "amount": { @@ -477,17 +567,25 @@ class ParcelOrderConfirmationController extends GetxController { } }); } else { - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); } }); } ///flutter wave Payment Method - Future flutterWaveInitiatePayment({required BuildContext context, required String amount}) async { + Future flutterWaveInitiatePayment({ + required BuildContext context, + required String amount, + }) async { setRef(); // make sure you generate reference final url = Uri.parse('https://api.flutterwave.com/v3/payments'); - final headers = {'Authorization': 'Bearer ${flutterWaveModel.value.secretKey}', 'Content-Type': 'application/json'}; + final headers = { + 'Authorization': 'Bearer ${flutterWaveModel.value.secretKey}', + 'Content-Type': 'application/json', + }; final body = jsonEncode({ "tx_ref": _ref, @@ -495,8 +593,15 @@ class ParcelOrderConfirmationController extends GetxController { "currency": "NGN", "redirect_url": "${Constant.globalUrl}payment/success", "payment_options": "ussd, card, barter, payattitude", - "customer": {"email": Constant.userModel?.email.toString(), "phonenumber": Constant.userModel?.phoneNumber, "name": Constant.userModel?.fullName()}, - "customizations": {"title": "Payment for Services", "description": "Payment for XYZ services"}, + "customer": { + "email": Constant.userModel?.email.toString(), + "phonenumber": Constant.userModel?.phoneNumber, + "name": Constant.userModel?.fullName(), + }, + "customizations": { + "title": "Payment for Services", + "description": "Payment for XYZ services", + }, }); final response = await http.post(url, headers: headers, body: body); @@ -504,7 +609,9 @@ class ParcelOrderConfirmationController extends GetxController { if (response.statusCode == 200) { final data = jsonDecode(response.body); - Get.to(MercadoPagoScreen(initialURl: data['data']['link']))!.then((value) async { + Get.to(MercadoPagoScreen(initialURl: data['data']['link']))!.then(( + value, + ) async { bool isVerified = await verifyFlutterWavePayment(_ref!); if (isVerified) { @@ -522,13 +629,19 @@ class ParcelOrderConfirmationController extends GetxController { Future verifyFlutterWavePayment(String txRef) async { try { - final url = Uri.parse("https://api.flutterwave.com/v3/transactions/verify_by_reference?tx_ref=$txRef"); - final headers = {'Authorization': 'Bearer ${flutterWaveModel.value.secretKey}', 'Content-Type': 'application/json'}; + final url = Uri.parse( + "https://api.flutterwave.com/v3/transactions/verify_by_reference?tx_ref=$txRef", + ); + final headers = { + 'Authorization': 'Bearer ${flutterWaveModel.value.secretKey}', + 'Content-Type': 'application/json', + }; final response = await http.get(url, headers: headers); if (response.statusCode == 200) { final data = jsonDecode(response.body); - if (data['status'] == 'success' && data['data']['status'] == 'successful') { + if (data['status'] == 'success' && + data['data']['status'] == 'successful') { return true; // ✅ Payment confirmed } } @@ -554,8 +667,14 @@ class ParcelOrderConfirmationController extends GetxController { // payFast void payFastPayment({required BuildContext context, required String amount}) { - PayStackURLGen.getPayHTML(payFastSettingData: payFastModel.value, amount: amount.toString(), userModel: Constant.userModel!).then((String? value) async { - bool isDone = await Get.to(PayFastScreen(htmlData: value!, payFastSettingData: payFastModel.value)); + PayStackURLGen.getPayHTML( + payFastSettingData: payFastModel.value, + amount: amount.toString(), + userModel: Constant.userModel!, + ).then((String? value) async { + bool isDone = await Get.to( + PayFastScreen(htmlData: value!, payFastSettingData: payFastModel.value), + ); if (isDone) { Get.back(); ShowToastDialog.showToast("Payment successfully".tr); @@ -576,26 +695,50 @@ class ParcelOrderConfirmationController extends GetxController { final response = await http.post( Uri.parse(getChecksum), headers: {}, - body: {"mid": paytmModel.value.paytmMID.toString(), "order_id": orderId, "key_secret": paytmModel.value.pAYTMMERCHANTKEY.toString()}, + body: { + "mid": paytmModel.value.paytmMID.toString(), + "order_id": orderId, + "key_secret": paytmModel.value.pAYTMMERCHANTKEY.toString(), + }, ); final data = jsonDecode(response.body); - await verifyCheckSum(checkSum: data["code"], amount: amount, orderId: orderId).then((value) { + await verifyCheckSum( + checkSum: data["code"], + amount: amount, + orderId: orderId, + ).then((value) { initiatePayment(amount: amount, orderId: orderId).then((value) { String callback = ""; if (paytmModel.value.isSandboxEnabled == true) { - callback = "${callback}https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; + callback = + "${callback}https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; } else { - callback = "${callback}https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; + callback = + "${callback}https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; } GetPaymentTxtTokenModel result = value; - startTransaction(context, txnTokenBy: result.body.txnToken ?? '', orderId: orderId, amount: amount, callBackURL: callback, isStaging: paytmModel.value.isSandboxEnabled); + startTransaction( + context, + txnTokenBy: result.body.txnToken ?? '', + orderId: orderId, + amount: amount, + callBackURL: callback, + isStaging: paytmModel.value.isSandboxEnabled, + ); }); }); } - Future startTransaction(context, {required String txnTokenBy, required orderId, required double amount, required callBackURL, required isStaging}) async { + Future startTransaction( + context, { + required String txnTokenBy, + required orderId, + required double amount, + required callBackURL, + required isStaging, + }) async { // try { // var response = AllInOneSdk.startTransaction( // paytmModel.value.paytmMID.toString(), @@ -631,28 +774,44 @@ class ParcelOrderConfirmationController extends GetxController { // } } - Future verifyCheckSum({required String checkSum, required double amount, required orderId}) async { + Future verifyCheckSum({ + required String checkSum, + required double amount, + required orderId, + }) async { String getChecksum = "${Constant.globalUrl}payments/validatechecksum"; final response = await http.post( Uri.parse(getChecksum), headers: {}, - body: {"mid": paytmModel.value.paytmMID.toString(), "order_id": orderId, "key_secret": paytmModel.value.pAYTMMERCHANTKEY.toString(), "checksum_value": checkSum}, + body: { + "mid": paytmModel.value.paytmMID.toString(), + "order_id": orderId, + "key_secret": paytmModel.value.pAYTMMERCHANTKEY.toString(), + "checksum_value": checkSum, + }, ); final data = jsonDecode(response.body); return data['status']; } - Future initiatePayment({required double amount, required String orderId}) async { + Future initiatePayment({ + required double amount, + required String orderId, + }) async { String initiateURL = "${Constant.globalUrl}payments/initiatepaytmpayment"; String callback = - (paytmModel.value.isSandboxEnabled ?? false) ? "https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=$orderId" : "https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; + (paytmModel.value.isSandboxEnabled ?? false) + ? "https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=$orderId" + : "https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; print("INITIATE PAYMENT CALL:"); print("MID: ${paytmModel.value.paytmMID}"); print("OrderId: $orderId"); print("Amount: $amount"); - print("Env: ${(paytmModel.value.isSandboxEnabled ?? false) ? "STAGING" : "LIVE"}"); + print( + "Env: ${(paytmModel.value.isSandboxEnabled ?? false) ? "STAGING" : "LIVE"}", + ); final response = await http.post( Uri.parse(initiateURL), @@ -671,9 +830,12 @@ class ParcelOrderConfirmationController extends GetxController { log("Paytm Initiate Response: ${response.body}"); final data = jsonDecode(response.body); - if (data["body"]["txnToken"] == null || data["body"]["txnToken"].toString().isEmpty) { + if (data["body"]["txnToken"] == null || + data["body"]["txnToken"].toString().isEmpty) { Get.back(); - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); } return GetPaymentTxtTokenModel.fromJson(data); @@ -723,7 +885,10 @@ class ParcelOrderConfirmationController extends GetxController { 'description': 'wallet Topup', 'retry': {'enabled': true, 'max_count': 1}, 'send_sms_hash': true, - 'prefill': {'contact': Constant.userModel?.phoneNumber, 'email': Constant.userModel?.email}, + 'prefill': { + 'contact': Constant.userModel?.phoneNumber, + 'email': Constant.userModel?.email, + }, 'external': { 'wallets': ['paytm'], }, @@ -758,7 +923,10 @@ class ParcelOrderConfirmationController extends GetxController { } //Midtrans payment - Future midtransMakePayment({required String amount, required BuildContext context}) async { + Future midtransMakePayment({ + required String amount, + required BuildContext context, + }) async { await createPaymentLink(amount: amount).then((url) { ShowToastDialog.closeLoader(); if (url != '') { @@ -776,15 +944,30 @@ class ParcelOrderConfirmationController extends GetxController { Future createPaymentLink({required var amount}) async { var ordersId = const Uuid().v1(); - final url = Uri.parse(midTransModel.value.isSandbox! ? 'https://api.sandbox.midtrans.com/v1/payment-links' : 'https://api.midtrans.com/v1/payment-links'); + final url = Uri.parse( + midTransModel.value.isSandbox! + ? 'https://api.sandbox.midtrans.com/v1/payment-links' + : 'https://api.midtrans.com/v1/payment-links', + ); final response = await http.post( url, - headers: {'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': generateBasicAuthHeader(midTransModel.value.serverKey!)}, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': generateBasicAuthHeader( + midTransModel.value.serverKey!, + ), + }, body: jsonEncode({ - 'transaction_details': {'order_id': ordersId, 'gross_amount': double.parse(amount.toString()).toInt()}, + 'transaction_details': { + 'order_id': ordersId, + 'gross_amount': double.parse(amount.toString()).toInt(), + }, 'usage_limit': 2, - "callbacks": {"finish": "https://www.google.com?merchant_order_id=$ordersId"}, + "callbacks": { + "finish": "https://www.google.com?merchant_order_id=$ordersId", + }, }), ); @@ -792,7 +975,9 @@ class ParcelOrderConfirmationController extends GetxController { final responseData = jsonDecode(response.body); return responseData['payment_url']; } else { - ShowToastDialog.showToast("something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "something went wrong, please contact admin.".tr, + ); return ''; } } @@ -809,7 +994,10 @@ class ParcelOrderConfirmationController extends GetxController { static String orderId = ''; static String amount = ''; - Future orangeMakePayment({required String amount, required BuildContext context}) async { + Future orangeMakePayment({ + required String amount, + required BuildContext context, + }) async { reset(); var id = const Uuid().v4(); debugPrint('🟩 Starting OrangePay Payment...'); @@ -817,14 +1005,28 @@ class ParcelOrderConfirmationController extends GetxController { ShowToastDialog.showLoader("Initializing payment...".tr); - var paymentURL = await fetchToken(context: context, orderId: id, amount: amount, currency: 'USD'); + var paymentURL = await fetchToken( + context: context, + orderId: id, + amount: amount, + currency: 'USD', + ); ShowToastDialog.closeLoader(); if (paymentURL.toString().isNotEmpty) { debugPrint('✅ Payment URL fetched successfully: $paymentURL'); - Get.to(() => OrangeMoneyScreen(initialURl: paymentURL, accessToken: accessToken, amount: amount, orangePay: orangeMoneyModel.value, orderId: orderId, payToken: payToken))?.then((value) async { + Get.to( + () => OrangeMoneyScreen( + initialURl: paymentURL, + accessToken: accessToken, + amount: amount, + orangePay: orangeMoneyModel.value, + orderId: orderId, + payToken: payToken, + ), + )?.then((value) async { if (value == true) { ShowToastDialog.showToast("Payment Successful!!".tr); debugPrint('🎉 Payment Successful for Order ID: $orderId'); @@ -844,16 +1046,27 @@ class ParcelOrderConfirmationController extends GetxController { } } - Future fetchToken({required String orderId, required String currency, required BuildContext context, required String amount}) async { + Future fetchToken({ + required String orderId, + required String currency, + required BuildContext context, + required String amount, + }) async { const String apiUrl = 'https://api.orange.com/oauth/v3/token'; - final Map requestBody = {'grant_type': 'client_credentials'}; + final Map requestBody = { + 'grant_type': 'client_credentials', + }; debugPrint('🔐 Fetching access token from Orange API...'); debugPrint('📡 POST $apiUrl'); final response = await http.post( Uri.parse(apiUrl), - headers: {'Authorization': "Basic ${orangeMoneyModel.value.auth!}", 'Content-Type': 'application/x-www-form-urlencoded', 'Accept': 'application/json'}, + headers: { + 'Authorization': "Basic ${orangeMoneyModel.value.auth!}", + 'Content-Type': 'application/x-www-form-urlencoded', + 'Accept': 'application/json', + }, body: requestBody, ); @@ -865,19 +1078,34 @@ class ParcelOrderConfirmationController extends GetxController { accessToken = responseData['access_token']; debugPrint('✅ Access Token Received: $accessToken'); - return await webpayment(context: context, amountData: amount, currency: currency, orderIdData: orderId); + return await webpayment( + context: context, + amountData: amount, + currency: currency, + orderIdData: orderId, + ); } else { debugPrint('❌ Failed to fetch access token.'); - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); return ''; } } - Future webpayment({required String orderIdData, required BuildContext context, required String currency, required String amountData}) async { + Future webpayment({ + required String orderIdData, + required BuildContext context, + required String currency, + required String amountData, + }) async { orderId = orderIdData; amount = amountData; - String apiUrl = orangeMoneyModel.value.isSandbox == true ? 'https://api.orange.com/orange-money-webpay/dev/v1/webpayment' : 'https://api.orange.com/orange-money-webpay/cm/v1/webpayment'; + String apiUrl = + orangeMoneyModel.value.isSandbox == true + ? 'https://api.orange.com/orange-money-webpay/dev/v1/webpayment' + : 'https://api.orange.com/orange-money-webpay/cm/v1/webpayment'; // ✅ Ensure amount formatted correctly String formattedAmount = double.parse(amountData).toStringAsFixed(2); @@ -900,7 +1128,11 @@ class ParcelOrderConfirmationController extends GetxController { final response = await http.post( Uri.parse(apiUrl), - headers: {'Authorization': 'Bearer $accessToken', 'Content-Type': 'application/json', 'Accept': 'application/json'}, + headers: { + 'Authorization': 'Bearer $accessToken', + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, body: json.encode(requestBody), ); @@ -920,7 +1152,9 @@ class ParcelOrderConfirmationController extends GetxController { } } else { debugPrint('❌ Payment request failed.'); - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); return ''; } } @@ -938,7 +1172,13 @@ class ParcelOrderConfirmationController extends GetxController { await createXenditInvoice(amount: amount).then((model) { ShowToastDialog.closeLoader(); if (model.id != null) { - Get.to(() => XenditScreen(initialURl: model.invoiceUrl ?? '', transId: model.id ?? '', apiKey: xenditModel.value.apiKey!.toString()))!.then((value) { + Get.to( + () => XenditScreen( + initialURl: model.invoiceUrl ?? '', + transId: model.id ?? '', + apiKey: xenditModel.value.apiKey!.toString(), + ), + )!.then((value) { if (value == true) { ShowToastDialog.showToast("Payment Successful!!".tr); placeOrder(); @@ -955,7 +1195,9 @@ class ParcelOrderConfirmationController extends GetxController { const url = 'https://api.xendit.co/v2/invoices'; var headers = { 'Content-Type': 'application/json', - 'Authorization': generateBasicAuthHeader(xenditModel.value.apiKey!.toString()), + 'Authorization': generateBasicAuthHeader( + xenditModel.value.apiKey!.toString(), + ), // 'Cookie': '__cf_bm=yERkrx3xDITyFGiou0bbKY1bi7xEwovHNwxV1vCNbVc-1724155511-1.0.1.1-jekyYQmPCwY6vIJ524K0V6_CEw6O.dAwOmQnHtwmaXO_MfTrdnmZMka0KZvjukQgXu5B.K_6FJm47SGOPeWviQ', }; @@ -968,7 +1210,11 @@ class ParcelOrderConfirmationController extends GetxController { }); try { - final response = await http.post(Uri.parse(url), headers: headers, body: body); + final response = await http.post( + Uri.parse(url), + headers: headers, + body: body, + ); if (response.statusCode == 200 || response.statusCode == 201) { XenditModel model = XenditModel.fromJson(jsonDecode(response.body)); diff --git a/lib/controllers/parcel_order_details_controller.dart b/lib/controllers/parcel_order_details_controller.dart index e82d9b8..3d0b30e 100644 --- a/lib/controllers/parcel_order_details_controller.dart +++ b/lib/controllers/parcel_order_details_controller.dart @@ -3,6 +3,7 @@ import 'package:customer/models/rating_model.dart'; import 'package:customer/models/wallet_transaction_model.dart'; import 'package:customer/screen_ui/multi_vendor_service/wallet_screen/wallet_screen.dart'; import 'package:customer/themes/show_toast_dialog.dart'; + import 'package:get/get.dart'; import 'package:intl/intl.dart'; import '../constant/constant.dart'; @@ -44,7 +45,12 @@ class ParcelOrderDetailsController extends GetxController { discount.value = double.parse(parcelOrder.value.discount ?? '0.0'); for (var element in parcelOrder.value.taxSetting!) { - taxAmount.value = (taxAmount.value + Constant.calculateTax(amount: (subTotal.value - discount.value).toString(), taxModel: element)); + taxAmount.value = + (taxAmount.value + + Constant.calculateTax( + amount: (subTotal.value - discount.value).toString(), + taxModel: element, + )); } totalAmount.value = (subTotal.value - discount.value) + taxAmount.value; @@ -53,22 +59,32 @@ class ParcelOrderDetailsController extends GetxController { Future fetchDriverDetails() async { if (parcelOrder.value.driverId != null) { - await FireStoreUtils.getUserProfile(parcelOrder.value.driverId ?? '').then((value) { + await FireStoreUtils.getUserProfile( + parcelOrder.value.driverId ?? '', + ).then((value) { if (value != null) { driverUser.value = value; } }); - await FireStoreUtils.getReviewsbyID(parcelOrder.value.id.toString()).then((value) { - if (value != null) { - ratingModel.value = value; - } - }); + await FireStoreUtils.getReviewsbyID(parcelOrder.value.id.toString()).then( + (value) { + if (value != null) { + ratingModel.value = value; + } + }, + ); } } void setStatusHistoryFromString(ParcelOrderModel order) { - final steps = ["Order Placed", "Driver Accepted", "Pickup Done", "In Transit", "Delivered"]; + final steps = [ + "Order Placed", + "Driver Accepted", + "Pickup Done", + "In Transit", + "Delivered", + ]; final history = []; @@ -78,7 +94,12 @@ class ParcelOrderDetailsController extends GetxController { for (int i = 0; i < steps.length; i++) { final step = steps[i]; - history.add(ParcelStatus(status: step, time: baseTime.add(Duration(minutes: i * minutesGap)))); + history.add( + ParcelStatus( + status: step, + time: baseTime.add(Duration(minutes: i * minutesGap)), + ), + ); if (step == order.status) break; } @@ -108,7 +129,10 @@ class ParcelOrderDetailsController extends GetxController { await FireStoreUtils.setWalletTransaction(walletTransaction); // Update wallet balance - await FireStoreUtils.updateUserWallet(amount: totalAmount.value.toString(), userId: FireStoreUtils.getCurrentUid()); + await FireStoreUtils.updateUserWallet( + amount: totalAmount.value.toString(), + userId: FireStoreUtils.getCurrentUid(), + ); } await FireStoreUtils.parcelOrderPlace(parcelOrder.value); @@ -131,7 +155,12 @@ class ParcelOrderDetailsController extends GetxController { ParcelCategory? getSelectedCategory() { try { - return parcelCategory.firstWhere((cat) => cat.title?.toLowerCase().trim() == parcelOrder.value.parcelType?.toLowerCase().trim(), orElse: () => ParcelCategory()); + return parcelCategory.firstWhere( + (cat) => + cat.title?.toLowerCase().trim() == + parcelOrder.value.parcelType?.toLowerCase().trim(), + orElse: () => ParcelCategory(), + ); } catch (e) { return null; } diff --git a/lib/controllers/parcel_review_controller.dart b/lib/controllers/parcel_review_controller.dart index becae1f..cf445c1 100644 --- a/lib/controllers/parcel_review_controller.dart +++ b/lib/controllers/parcel_review_controller.dart @@ -1,5 +1,6 @@ import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:customer/models/parcel_order_model.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../models/rating_model.dart'; @@ -46,12 +47,17 @@ class ParcelReviewController extends GetxController { } }); - await FireStoreUtils.getUserProfile(order.value?.driverId ?? '').then((value) { + await FireStoreUtils.getUserProfile(order.value?.driverId ?? '').then(( + value, + ) { if (value != null) { driverUser.value = value; - final int userReviewsCount = int.tryParse(driverUser.value!.reviewsCount?.toString() ?? "0") ?? 0; - final int userReviewsSum = int.tryParse(driverUser.value!.reviewsSum?.toString() ?? "0") ?? 0; + final int userReviewsCount = + int.tryParse(driverUser.value!.reviewsCount?.toString() ?? "0") ?? + 0; + final int userReviewsSum = + int.tryParse(driverUser.value!.reviewsSum?.toString() ?? "0") ?? 0; if (ratingModel.value != null) { final int oldRating = ratingModel.value?.rating?.toInt() ?? 0; @@ -76,7 +82,9 @@ class ParcelReviewController extends GetxController { ShowToastDialog.showLoader("Submit in...".tr); - final user = await FireStoreUtils.getUserProfile(order.value?.driverId ?? ''); + final user = await FireStoreUtils.getUserProfile( + order.value?.driverId ?? '', + ); if (user != null) { user.reviewsCount = (futureCount.value + 1).toString(); @@ -93,7 +101,8 @@ class ParcelReviewController extends GetxController { driverId: ratingModel.value!.driverId, customerId: ratingModel.value!.customerId, vendorId: ratingModel.value?.vendorId, - uname: "${Constant.userModel?.firstName ?? ''} ${Constant.userModel?.lastName ?? ''}", + uname: + "${Constant.userModel?.firstName ?? ''} ${Constant.userModel?.lastName ?? ''}", profile: Constant.userModel?.profilePictureURL, createdAt: Timestamp.now(), ); @@ -112,7 +121,8 @@ class ParcelReviewController extends GetxController { orderId: order.value?.id, driverId: order.value?.driverId.toString(), customerId: Constant.userModel?.id, - uname: "${Constant.userModel?.firstName ?? ''} ${Constant.userModel?.lastName ?? ''}", + uname: + "${Constant.userModel?.firstName ?? ''} ${Constant.userModel?.lastName ?? ''}", profile: Constant.userModel?.profilePictureURL, createdAt: Timestamp.now(), ); diff --git a/lib/controllers/provider_controller.dart b/lib/controllers/provider_controller.dart index b10e21d..2cde1b4 100644 --- a/lib/controllers/provider_controller.dart +++ b/lib/controllers/provider_controller.dart @@ -10,7 +10,8 @@ class ProviderController extends GetxController { RxBool isLoading = true.obs; late final String providerId; - Rx onDemandHomeController = Get.put(OnDemandHomeController()).obs; + Rx onDemandHomeController = + Get.put(OnDemandHomeController()).obs; @override void onInit() { @@ -24,7 +25,9 @@ class ProviderController extends GetxController { } void getProvider() async { - FireStoreUtils.getProviderServiceByProviderId(providerId: providerId).then((catValue) { + FireStoreUtils.getProviderServiceByProviderId(providerId: providerId).then(( + catValue, + ) { providerList.value = catValue; }); diff --git a/lib/controllers/rate_product_controller.dart b/lib/controllers/rate_product_controller.dart index a31cbc6..be7d7ce 100644 --- a/lib/controllers/rate_product_controller.dart +++ b/lib/controllers/rate_product_controller.dart @@ -1,11 +1,13 @@ import 'dart:developer'; import 'dart:io'; import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:customer/constant/const_texts.dart'; import 'package:customer/constant/constant.dart'; import 'package:customer/models/order_model.dart'; import 'package:customer/models/product_model.dart'; import 'package:customer/models/vendor_category_model.dart'; import 'package:customer/models/vendor_model.dart'; + import '../models/rating_model.dart'; import '../models/review_attribute_model.dart'; import '../service/fire_store_utils.dart'; @@ -34,7 +36,8 @@ class RateProductController extends GetxController { Rx vendorModel = VendorModel().obs; Rx vendorCategoryModel = VendorCategoryModel().obs; - RxList reviewAttributeList = [].obs; + RxList reviewAttributeList = + [].obs; RxDouble ratings = 0.0.obs; @@ -53,7 +56,10 @@ class RateProductController extends GetxController { orderModel.value = argumentData['orderModel']; productId.value = argumentData['productId']; - await FireStoreUtils.getOrderReviewsByID(orderModel.value.id.toString(), productId.value).then((value) { + await FireStoreUtils.getOrderReviewsByID( + orderModel.value.id.toString(), + productId.value, + ).then((value) { if (value != null) { ratingModel.value = value; ratings.value = value.rating ?? 0.0; @@ -63,23 +69,33 @@ class RateProductController extends GetxController { } }); - await FireStoreUtils.getProductById(productId.value.split('~').first).then((value) { + await FireStoreUtils.getProductById( + productId.value.split('~').first, + ).then((value) { if (value != null) { productModel.value = value; - if (ratingModel.value.id != null && ratingModel.value.id!.isNotEmpty) { + if (ratingModel.value.id != null && + ratingModel.value.id!.isNotEmpty) { productReviewCount.value = value.reviewsCount! - 1; productReviewSum.value = value.reviewsSum! - ratings.value; if (value.reviewAttributes != null) { value.reviewAttributes!.forEach((key, value) { - ReviewsAttribute reviewsAttributeModel = ReviewsAttribute.fromJson(value); - reviewsAttributeModel.reviewsCount = reviewsAttributeModel.reviewsCount! - 1; - reviewsAttributeModel.reviewsSum = reviewsAttributeModel.reviewsSum! - reviewAttribute[key]; - reviewProductAttributes.addEntries([MapEntry(key, reviewsAttributeModel.toJson())]); + ReviewsAttribute reviewsAttributeModel = + ReviewsAttribute.fromJson(value); + reviewsAttributeModel.reviewsCount = + reviewsAttributeModel.reviewsCount! - 1; + reviewsAttributeModel.reviewsSum = + reviewsAttributeModel.reviewsSum! - reviewAttribute[key]; + reviewProductAttributes.addEntries([ + MapEntry(key, reviewsAttributeModel.toJson()), + ]); }); } } else { - productReviewCount.value = double.parse(value.reviewsCount.toString()); + productReviewCount.value = double.parse( + value.reviewsCount.toString(), + ); productReviewSum.value = double.parse(value.reviewsSum.toString()); if (value.reviewAttributes != null) { reviewProductAttributes.value = value.reviewAttributes!; @@ -88,24 +104,33 @@ class RateProductController extends GetxController { } }); - await FireStoreUtils.getVendorById(productModel.value.vendorID.toString()).then((value) { + await FireStoreUtils.getVendorById( + productModel.value.vendorID.toString(), + ).then((value) { if (value != null) { vendorModel.value = value; - if (ratingModel.value.id != null && ratingModel.value.id!.isNotEmpty) { + if (ratingModel.value.id != null && + ratingModel.value.id!.isNotEmpty) { vendorReviewCount.value = value.reviewsCount! - 1; vendorReviewSum.value = value.reviewsSum! - ratings.value; } else { - vendorReviewCount.value = double.parse(value.reviewsCount.toString()); + vendorReviewCount.value = double.parse( + value.reviewsCount.toString(), + ); vendorReviewSum.value = double.parse(value.reviewsSum.toString()); } } }); - await FireStoreUtils.getVendorCategoryByCategoryId(productModel.value.categoryID.toString()).then((value) async { + await FireStoreUtils.getVendorCategoryByCategoryId( + productModel.value.categoryID.toString(), + ).then((value) async { if (value != null) { vendorCategoryModel.value = value; for (var element in vendorCategoryModel.value.reviewAttributes!) { - await FireStoreUtils.getVendorReviewAttribute(element).then((value) { + await FireStoreUtils.getVendorReviewAttribute(element).then(( + value, + ) { reviewAttributeList.add(value!); }); } @@ -118,7 +143,7 @@ class RateProductController extends GetxController { Future saveRating() async { if (ratings.value != 0.0) { - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); productModel.value.reviewsCount = productReviewCount.value + 1; productModel.value.reviewsSum = productReviewSum.value + ratings.value; productModel.value.reviewAttributes = reviewProductAttributes; @@ -128,21 +153,36 @@ class RateProductController extends GetxController { if (reviewProductAttributes.isEmpty) { reviewAttribute.forEach((key, value) { - ReviewsAttribute reviewsAttributeModel = ReviewsAttribute(reviewsCount: 1, reviewsSum: value); - reviewProductAttributes.addEntries([MapEntry(key, reviewsAttributeModel.toJson())]); + ReviewsAttribute reviewsAttributeModel = ReviewsAttribute( + reviewsCount: 1, + reviewsSum: value, + ); + reviewProductAttributes.addEntries([ + MapEntry(key, reviewsAttributeModel.toJson()), + ]); }); } else { reviewProductAttributes.forEach((key, value) { - ReviewsAttribute reviewsAttributeModel = ReviewsAttribute.fromJson(value); - reviewsAttributeModel.reviewsCount = reviewsAttributeModel.reviewsCount! + 1; - reviewsAttributeModel.reviewsSum = reviewsAttributeModel.reviewsSum! + reviewAttribute[key]; - reviewProductAttributes.addEntries([MapEntry(key, reviewsAttributeModel.toJson())]); + ReviewsAttribute reviewsAttributeModel = ReviewsAttribute.fromJson( + value, + ); + reviewsAttributeModel.reviewsCount = + reviewsAttributeModel.reviewsCount! + 1; + reviewsAttributeModel.reviewsSum = + reviewsAttributeModel.reviewsSum! + reviewAttribute[key]; + reviewProductAttributes.addEntries([ + MapEntry(key, reviewsAttributeModel.toJson()), + ]); }); } for (int i = 0; i < images.length; i++) { if (images[i].runtimeType == XFile) { - String url = await Constant.uploadUserImageToFireStorage(File(images[i].path), "profileImage/${FireStoreUtils.getCurrentUid()}", File(images[i].path).path.split('/').last); + String url = await Constant.uploadUserImageToFireStorage( + File(images[i].path), + "profileImage/${FireStoreUtils.getCurrentUid()}", + File(images[i].path).path.split('/').last, + ); images.removeAt(i); images.insert(i, url); } @@ -154,7 +194,10 @@ class RateProductController extends GetxController { photos: images, rating: ratings.value, customerId: FireStoreUtils.getCurrentUid(), - id: ratingModel.value.id != null && ratingModel.value.id!.isNotEmpty ? ratingModel.value.id : Constant.getUuid(), + id: + ratingModel.value.id != null && ratingModel.value.id!.isNotEmpty + ? ratingModel.value.id + : Constant.getUuid(), orderId: orderModel.value.id, vendorId: productModel.value.vendorID, createdAt: Timestamp.now(), diff --git a/lib/controllers/rental_conformation_controller.dart b/lib/controllers/rental_conformation_controller.dart index a272942..0c4c3e1 100644 --- a/lib/controllers/rental_conformation_controller.dart +++ b/lib/controllers/rental_conformation_controller.dart @@ -5,9 +5,10 @@ import 'package:customer/models/coupon_model.dart'; import 'package:customer/models/rental_order_model.dart'; import 'package:customer/service/fire_store_utils.dart'; import 'package:customer/themes/show_toast_dialog.dart'; +import 'package:customer/utils/app_router.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; - import '../screen_ui/rental_service/rental_dashboard_screen.dart'; import 'cab_rental_dashboard_controllers.dart'; @@ -26,7 +27,8 @@ class RentalConformationController extends GetxController { void getArguments() { final args = Get.arguments; - if (args.containsKey('rentalOrderModel') && args['rentalOrderModel'] is RentalOrderModel) { + if (args.containsKey('rentalOrderModel') && + args['rentalOrderModel'] is RentalOrderModel) { rentalOrderModel.value = args['rentalOrderModel'] as RentalOrderModel; calculateAmount(); } else { @@ -47,12 +49,21 @@ class RentalConformationController extends GetxController { taxAmount.value = 0.0; totalAmount.value = 0.0; - subTotal.value = double.tryParse(rentalOrderModel.value.subTotal ?? '0') ?? 0.0; + subTotal.value = + double.tryParse(rentalOrderModel.value.subTotal ?? '0') ?? 0.0; if (selectedCouponModel.value.id != null) { - discount.value = Constant.calculateDiscount(amount: subTotal.value.toString(), offerModel: selectedCouponModel.value); + discount.value = Constant.calculateDiscount( + amount: subTotal.value.toString(), + offerModel: selectedCouponModel.value, + ); } for (var element in rentalOrderModel.value.taxSetting ?? []) { - taxAmount.value = (taxAmount.value + Constant.calculateTax(amount: (subTotal.value - discount.value).toString(), taxModel: element)); + taxAmount.value = + (taxAmount.value + + Constant.calculateTax( + amount: (subTotal.value - discount.value).toString(), + taxModel: element, + )); } totalAmount.value = subTotal.value - discount.value + taxAmount.value; @@ -76,12 +87,17 @@ class RentalConformationController extends GetxController { rentalOrderModel.value.couponCode = selectedCouponModel.value.code; rentalOrderModel.value.couponId = selectedCouponModel.value.id; rentalOrderModel.value.subTotal = subTotal.value.toString(); - rentalOrderModel.value.otpCode = (maths.Random().nextInt(9000) + 1000).toString(); - await FireStoreUtils.rentalOrderPlace(rentalOrderModel.value).then((value) async { + rentalOrderModel.value.otpCode = + (maths.Random().nextInt(9000) + 1000).toString(); + await FireStoreUtils.rentalOrderPlace(rentalOrderModel.value).then(( + value, + ) async { ShowToastDialog.closeLoader(); ShowToastDialog.showToast("Order placed successfully".tr); - Get.offAll(const RentalDashboardScreen()); - CabRentalDashboardControllers controller = Get.put(CabRentalDashboardControllers()); + Get.offAll(RentalDashboardScreen()); + CabRentalDashboardControllers controller = Get.put( + CabRentalDashboardControllers(), + ); controller.selectedIndex.value = 1; // Get.back(); }); diff --git a/lib/controllers/rental_coupon_controller.dart b/lib/controllers/rental_coupon_controller.dart index 9f4b303..e5ded68 100644 --- a/lib/controllers/rental_coupon_controller.dart +++ b/lib/controllers/rental_coupon_controller.dart @@ -2,8 +2,7 @@ import 'package:customer/models/coupon_model.dart'; import 'package:customer/service/fire_store_utils.dart'; import 'package:get/get.dart'; -class RentalCouponController extends GetxController{ - +class RentalCouponController extends GetxController { @override void onInit() { // TODO: implement onInit @@ -11,10 +10,10 @@ class RentalCouponController extends GetxController{ super.onInit(); } - - void getData(){ + void getData() { getCouponCode(); } + RxBool isLoading = true.obs; RxList cabCouponList = [].obs; @@ -25,4 +24,4 @@ class RentalCouponController extends GetxController{ print("cabCouponList ${cabCouponList.length}"); isLoading.value = false; } -} \ No newline at end of file +} diff --git a/lib/controllers/rental_home_controller.dart b/lib/controllers/rental_home_controller.dart index 779eea6..621993b 100644 --- a/lib/controllers/rental_home_controller.dart +++ b/lib/controllers/rental_home_controller.dart @@ -7,6 +7,7 @@ import 'package:customer/models/user_model.dart'; import 'package:customer/models/vendor_model.dart'; import 'package:customer/screen_ui/rental_service/rental_conformation_screen.dart'; import 'package:customer/widget/geoflutterfire/src/geoflutterfire.dart'; + import 'package:flutter/material.dart'; import 'package:geolocator/geolocator.dart'; import 'package:get/get.dart'; @@ -37,7 +38,8 @@ class RentalHomeController extends GetxController { RxBool isLoading = false.obs; // Location input - final Rx sourceTextEditController = TextEditingController().obs; + final Rx sourceTextEditController = + TextEditingController().obs; // Selected date Rx selectedDate = DateTime.now().obs; @@ -73,11 +75,20 @@ class RentalHomeController extends GetxController { Constant.currentLocation = position; // Set default coordinates for Google or OSM - departureLatLong.value = gmaps.LatLng(position.latitude, position.longitude); - departureLatLongOsm.value = latlong.LatLng(position.latitude, position.longitude); + departureLatLong.value = gmaps.LatLng( + position.latitude, + position.longitude, + ); + departureLatLongOsm.value = latlong.LatLng( + position.latitude, + position.longitude, + ); // Get readable address - String address = await Utils.getAddressFromCoordinates(position.latitude, position.longitude); + String address = await Utils.getAddressFromCoordinates( + position.latitude, + position.longitude, + ); sourceTextEditController.value.text = address; } } catch (e) { @@ -101,7 +112,12 @@ class RentalHomeController extends GetxController { /// Date Picker Future pickDate(BuildContext context) async { - final DateTime? picked = await showDatePicker(context: context, initialDate: selectedDate.value, firstDate: DateTime.now(), lastDate: DateTime(2100)); + final DateTime? picked = await showDatePicker( + context: context, + initialDate: selectedDate.value, + firstDate: DateTime.now(), + lastDate: DateTime(2100), + ); if (picked != null) { selectedDate.value = picked; @@ -109,7 +125,9 @@ class RentalHomeController extends GetxController { } Future getRentalPackage() async { - await FireStoreUtils.getRentalPackage(selectedVehicleType.value!.id.toString()).then((value) { + await FireStoreUtils.getRentalPackage( + selectedVehicleType.value!.id.toString(), + ).then((value) { rentalPackages.value = value; if (rentalPackages.isNotEmpty) { selectedPackage.value = rentalPackages[0]; @@ -119,8 +137,14 @@ class RentalHomeController extends GetxController { void completeOrder() { DestinationLocation sourceLocation = DestinationLocation( - latitude: Constant.selectedMapType == 'osm' ? departureLatLongOsm.value.latitude : departureLatLong.value.latitude, - longitude: Constant.selectedMapType == 'osm' ? departureLatLongOsm.value.longitude : departureLatLong.value.longitude, + latitude: + Constant.selectedMapType == 'osm' + ? departureLatLongOsm.value.latitude + : departureLatLong.value.latitude, + longitude: + Constant.selectedMapType == 'osm' + ? departureLatLongOsm.value.longitude + : departureLatLong.value.longitude, ); print("=====>"); @@ -143,18 +167,35 @@ class RentalHomeController extends GetxController { rentalOrderModel.taxSetting = Constant.taxList; rentalOrderModel.createdAt = Timestamp.now(); rentalOrderModel.sourceLocation = sourceLocation; - rentalOrderModel.adminCommission = Constant.sectionConstantModel!.adminCommision!.amount; - rentalOrderModel.adminCommissionType = Constant.sectionConstantModel!.adminCommision!.commissionType; + rentalOrderModel.adminCommission = + Constant.sectionConstantModel!.adminCommision!.amount; + rentalOrderModel.adminCommissionType = + Constant.sectionConstantModel!.adminCommision!.commissionType; rentalOrderModel.sourcePoint = G( - geopoint: GeoPoint(sourceLocation.latitude ?? 0.0, sourceLocation.longitude ?? 0.0), - geohash: Geoflutterfire().point(latitude: sourceLocation.latitude ?? 0.0, longitude: sourceLocation.longitude ?? 0.0).hash, + geopoint: GeoPoint( + sourceLocation.latitude ?? 0.0, + sourceLocation.longitude ?? 0.0, + ), + geohash: + Geoflutterfire() + .point( + latitude: sourceLocation.latitude ?? 0.0, + longitude: sourceLocation.longitude ?? 0.0, + ) + .hash, + ); + rentalOrderModel.zoneId = Constant.getZoneId( + sourceLocation.latitude ?? 0.0, + sourceLocation.longitude ?? 0.0, ); - rentalOrderModel.zoneId = Constant.getZoneId(sourceLocation.latitude ?? 0.0, sourceLocation.longitude ?? 0.0); log(rentalOrderModel.toJson().toString()); Get.back(); Get.back(); - Get.to(() => RentalConformationScreen(), arguments: {"rentalOrderModel": rentalOrderModel}); + Get.to( + () => RentalConformationScreen(), + arguments: {"rentalOrderModel": rentalOrderModel}, + ); } void setDepartureMarker(double lat, double lng) { @@ -193,19 +234,45 @@ class RentalHomeController extends GetxController { Future getPaymentSettings() async { await FireStoreUtils.getPaymentSettingsData().then((value) { - stripeModel.value = StripeModel.fromJson(jsonDecode(Preferences.getString(Preferences.stripeSettings))); - payPalModel.value = PayPalModel.fromJson(jsonDecode(Preferences.getString(Preferences.paypalSettings))); - payStackModel.value = PayStackModel.fromJson(jsonDecode(Preferences.getString(Preferences.payStack))); - mercadoPagoModel.value = MercadoPagoModel.fromJson(jsonDecode(Preferences.getString(Preferences.mercadoPago))); - flutterWaveModel.value = FlutterWaveModel.fromJson(jsonDecode(Preferences.getString(Preferences.flutterWave))); - paytmModel.value = PaytmModel.fromJson(jsonDecode(Preferences.getString(Preferences.paytmSettings))); - payFastModel.value = PayFastModel.fromJson(jsonDecode(Preferences.getString(Preferences.payFastSettings))); - razorPayModel.value = RazorPayModel.fromJson(jsonDecode(Preferences.getString(Preferences.razorpaySettings))); - midTransModel.value = MidTrans.fromJson(jsonDecode(Preferences.getString(Preferences.midTransSettings))); - orangeMoneyModel.value = OrangeMoney.fromJson(jsonDecode(Preferences.getString(Preferences.orangeMoneySettings))); - xenditModel.value = Xendit.fromJson(jsonDecode(Preferences.getString(Preferences.xenditSettings))); - walletSettingModel.value = WalletSettingModel.fromJson(jsonDecode(Preferences.getString(Preferences.walletSettings))); - cashOnDeliverySettingModel.value = CodSettingModel.fromJson(jsonDecode(Preferences.getString(Preferences.codSettings))); + stripeModel.value = StripeModel.fromJson( + jsonDecode(Preferences.getString(Preferences.stripeSettings)), + ); + payPalModel.value = PayPalModel.fromJson( + jsonDecode(Preferences.getString(Preferences.paypalSettings)), + ); + payStackModel.value = PayStackModel.fromJson( + jsonDecode(Preferences.getString(Preferences.payStack)), + ); + mercadoPagoModel.value = MercadoPagoModel.fromJson( + jsonDecode(Preferences.getString(Preferences.mercadoPago)), + ); + flutterWaveModel.value = FlutterWaveModel.fromJson( + jsonDecode(Preferences.getString(Preferences.flutterWave)), + ); + paytmModel.value = PaytmModel.fromJson( + jsonDecode(Preferences.getString(Preferences.paytmSettings)), + ); + payFastModel.value = PayFastModel.fromJson( + jsonDecode(Preferences.getString(Preferences.payFastSettings)), + ); + razorPayModel.value = RazorPayModel.fromJson( + jsonDecode(Preferences.getString(Preferences.razorpaySettings)), + ); + midTransModel.value = MidTrans.fromJson( + jsonDecode(Preferences.getString(Preferences.midTransSettings)), + ); + orangeMoneyModel.value = OrangeMoney.fromJson( + jsonDecode(Preferences.getString(Preferences.orangeMoneySettings)), + ); + xenditModel.value = Xendit.fromJson( + jsonDecode(Preferences.getString(Preferences.xenditSettings)), + ); + walletSettingModel.value = WalletSettingModel.fromJson( + jsonDecode(Preferences.getString(Preferences.walletSettings)), + ); + cashOnDeliverySettingModel.value = CodSettingModel.fromJson( + jsonDecode(Preferences.getString(Preferences.codSettings)), + ); if (walletSettingModel.value.isEnabled == true) { selectedPaymentMethod.value = PaymentGateway.wallet.name; diff --git a/lib/controllers/rental_order_details_controller.dart b/lib/controllers/rental_order_details_controller.dart index 59bd3e6..76f634b 100644 --- a/lib/controllers/rental_order_details_controller.dart +++ b/lib/controllers/rental_order_details_controller.dart @@ -35,6 +35,7 @@ import 'package:customer/screen_ui/multi_vendor_service/wallet_screen/wallet_scr import 'package:customer/themes/app_them_data.dart'; import 'package:customer/themes/show_toast_dialog.dart'; import 'package:customer/utils/preferences.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_paypal/flutter_paypal.dart'; import 'package:flutter_stripe/flutter_stripe.dart'; @@ -83,13 +84,17 @@ class RentalOrderDetailsController extends GetxController { Future fetchDriverDetails() async { if (order.value.driverId != null) { - await FireStoreUtils.getUserProfile(order.value.driverId ?? '').then((value) { + await FireStoreUtils.getUserProfile(order.value.driverId ?? '').then(( + value, + ) { if (value != null) { driverUser.value = value; } }); - await FireStoreUtils.getReviewsbyID(order.value.id.toString()).then((value) { + await FireStoreUtils.getReviewsbyID(order.value.id.toString()).then(( + value, + ) { if (value != null) { ratingModel.value = value; } @@ -99,9 +104,15 @@ class RentalOrderDetailsController extends GetxController { String getExtraKm() { try { - final double start = double.tryParse(order.value.startKitoMetersReading ?? '0') ?? 0.0; - final double end = double.tryParse(order.value.endKitoMetersReading ?? '0') ?? 0.0; - final double included = double.tryParse(order.value.rentalPackageModel?.includedDistance?.toString() ?? '0') ?? 0.0; + final double start = + double.tryParse(order.value.startKitoMetersReading ?? '0') ?? 0.0; + final double end = + double.tryParse(order.value.endKitoMetersReading ?? '0') ?? 0.0; + final double included = + double.tryParse( + order.value.rentalPackageModel?.includedDistance?.toString() ?? '0', + ) ?? + 0.0; // Calculate extra km safely final double extra = (end - start - included); @@ -116,8 +127,10 @@ class RentalOrderDetailsController extends GetxController { ///Safe calculation after order is loaded void calculateTotalAmount() { try { - subTotal.value = double.tryParse(order.value.subTotal?.toString() ?? "0") ?? 0.0; - discount.value = double.tryParse(order.value.discount?.toString() ?? "0") ?? 0.0; + subTotal.value = + double.tryParse(order.value.subTotal?.toString() ?? "0") ?? 0.0; + discount.value = + double.tryParse(order.value.discount?.toString() ?? "0") ?? 0.0; taxAmount.value = 0.0; if (order.value.endTime != null) { @@ -127,12 +140,23 @@ class RentalOrderDetailsController extends GetxController { // Total rented minutes int totalMinutes = end.difference(start).inMinutes; - int includedMinutes = (int.tryParse(order.value.rentalPackageModel?.includedHours.toString() ?? "0") ?? 0) * 60; + int includedMinutes = + (int.tryParse( + order.value.rentalPackageModel?.includedHours.toString() ?? + "0", + ) ?? + 0) * + 60; if (totalMinutes > includedMinutes) { int extraMinutes = totalMinutes - includedMinutes; - double minuteFare = double.tryParse(order.value.rentalPackageModel?.extraMinuteFare?.toString() ?? "0") ?? 0.0; + double minuteFare = + double.tryParse( + order.value.rentalPackageModel?.extraMinuteFare?.toString() ?? + "0", + ) ?? + 0.0; extraMinutesCharge.value = extraMinutes * minuteFare; } else { @@ -140,24 +164,47 @@ class RentalOrderDetailsController extends GetxController { } } - if (order.value.startKitoMetersReading != null && order.value.endKitoMetersReading != null) { - double startKm = double.tryParse(order.value.startKitoMetersReading?.toString() ?? "0") ?? 0.0; - double endKm = double.tryParse(order.value.endKitoMetersReading?.toString() ?? "0") ?? 0.0; + if (order.value.startKitoMetersReading != null && + order.value.endKitoMetersReading != null) { + double startKm = + double.tryParse( + order.value.startKitoMetersReading?.toString() ?? "0", + ) ?? + 0.0; + double endKm = + double.tryParse( + order.value.endKitoMetersReading?.toString() ?? "0", + ) ?? + 0.0; if (endKm > startKm) { double totalKm = endKm - startKm; - if (totalKm > double.parse(order.value.rentalPackageModel!.includedDistance!)) { - totalKm = totalKm - double.parse(order.value.rentalPackageModel!.includedDistance!); - double extraKmRate = double.tryParse(order.value.rentalPackageModel?.extraKmFare?.toString() ?? "0") ?? 0.0; + if (totalKm > + double.parse(order.value.rentalPackageModel!.includedDistance!)) { + totalKm = + totalKm - + double.parse(order.value.rentalPackageModel!.includedDistance!); + double extraKmRate = + double.tryParse( + order.value.rentalPackageModel?.extraKmFare?.toString() ?? + "0", + ) ?? + 0.0; extraKilometerCharge.value = totalKm * extraKmRate; } } } - subTotal.value = subTotal.value + extraKilometerCharge.value + extraMinutesCharge.value; + subTotal.value = + subTotal.value + + extraKilometerCharge.value + + extraMinutesCharge.value; if (order.value.taxSetting != null) { for (var element in order.value.taxSetting!) { - taxAmount.value += Constant.calculateTax(amount: (subTotal.value - discount.value).toString(), taxModel: element); + taxAmount.value += Constant.calculateTax( + amount: (subTotal.value - discount.value).toString(), + taxModel: element, + ); } } @@ -193,9 +240,14 @@ class RentalOrderDetailsController extends GetxController { serviceType: Constant.parcelServiceType, ); - await FireStoreUtils.setWalletTransaction(transactionModel).then((value) async { + await FireStoreUtils.setWalletTransaction(transactionModel).then(( + value, + ) async { if (value == true) { - await FireStoreUtils.updateUserWallet(amount: "-${totalAmount.toString()}", userId: FireStoreUtils.getCurrentUid()); + await FireStoreUtils.updateUserWallet( + amount: "-${totalAmount.toString()}", + userId: FireStoreUtils.getCurrentUid(), + ); } }); } @@ -208,7 +260,10 @@ class RentalOrderDetailsController extends GetxController { } } - Future cancelRentalRequest(RentalOrderModel order, {List? taxList}) async { + Future cancelRentalRequest( + RentalOrderModel order, { + List? taxList, + }) async { try { isLoading.value = true; @@ -220,11 +275,19 @@ class RentalOrderDetailsController extends GetxController { if (taxList != null) { for (var element in taxList) { - totalTax += Constant.calculateTax(amount: (double.parse(order.subTotal.toString()) - double.parse(order.discount.toString())).toString(), taxModel: element); + totalTax += Constant.calculateTax( + amount: + (double.parse(order.subTotal.toString()) - + double.parse(order.discount.toString())) + .toString(), + taxModel: element, + ); } } - double subTotal = double.parse(order.subTotal.toString()) - double.parse(order.discount.toString()); + double subTotal = + double.parse(order.subTotal.toString()) - + double.parse(order.discount.toString()); double refundAmount = subTotal + totalTax; WalletTransactionModel walletTransaction = WalletTransactionModel( @@ -243,7 +306,10 @@ class RentalOrderDetailsController extends GetxController { ); await FireStoreUtils.setWalletTransaction(walletTransaction); - await FireStoreUtils.updateUserWallet(amount: refundAmount.toString(), userId: FireStoreUtils.getCurrentUid()); + await FireStoreUtils.updateUserWallet( + amount: refundAmount.toString(), + userId: FireStoreUtils.getCurrentUid(), + ); } ShowToastDialog.showToast("Booking cancelled successfully".tr); Get.back(); @@ -271,19 +337,45 @@ class RentalOrderDetailsController extends GetxController { Future getPaymentSettings() async { await FireStoreUtils.getPaymentSettingsData().then((value) { - stripeModel.value = StripeModel.fromJson(jsonDecode(Preferences.getString(Preferences.stripeSettings))); - payPalModel.value = PayPalModel.fromJson(jsonDecode(Preferences.getString(Preferences.paypalSettings))); - payStackModel.value = PayStackModel.fromJson(jsonDecode(Preferences.getString(Preferences.payStack))); - mercadoPagoModel.value = MercadoPagoModel.fromJson(jsonDecode(Preferences.getString(Preferences.mercadoPago))); - flutterWaveModel.value = FlutterWaveModel.fromJson(jsonDecode(Preferences.getString(Preferences.flutterWave))); - paytmModel.value = PaytmModel.fromJson(jsonDecode(Preferences.getString(Preferences.paytmSettings))); - payFastModel.value = PayFastModel.fromJson(jsonDecode(Preferences.getString(Preferences.payFastSettings))); - razorPayModel.value = RazorPayModel.fromJson(jsonDecode(Preferences.getString(Preferences.razorpaySettings))); - midTransModel.value = MidTrans.fromJson(jsonDecode(Preferences.getString(Preferences.midTransSettings))); - orangeMoneyModel.value = OrangeMoney.fromJson(jsonDecode(Preferences.getString(Preferences.orangeMoneySettings))); - xenditModel.value = Xendit.fromJson(jsonDecode(Preferences.getString(Preferences.xenditSettings))); - walletSettingModel.value = WalletSettingModel.fromJson(jsonDecode(Preferences.getString(Preferences.walletSettings))); - cashOnDeliverySettingModel.value = CodSettingModel.fromJson(jsonDecode(Preferences.getString(Preferences.codSettings))); + stripeModel.value = StripeModel.fromJson( + jsonDecode(Preferences.getString(Preferences.stripeSettings)), + ); + payPalModel.value = PayPalModel.fromJson( + jsonDecode(Preferences.getString(Preferences.paypalSettings)), + ); + payStackModel.value = PayStackModel.fromJson( + jsonDecode(Preferences.getString(Preferences.payStack)), + ); + mercadoPagoModel.value = MercadoPagoModel.fromJson( + jsonDecode(Preferences.getString(Preferences.mercadoPago)), + ); + flutterWaveModel.value = FlutterWaveModel.fromJson( + jsonDecode(Preferences.getString(Preferences.flutterWave)), + ); + paytmModel.value = PaytmModel.fromJson( + jsonDecode(Preferences.getString(Preferences.paytmSettings)), + ); + payFastModel.value = PayFastModel.fromJson( + jsonDecode(Preferences.getString(Preferences.payFastSettings)), + ); + razorPayModel.value = RazorPayModel.fromJson( + jsonDecode(Preferences.getString(Preferences.razorpaySettings)), + ); + midTransModel.value = MidTrans.fromJson( + jsonDecode(Preferences.getString(Preferences.midTransSettings)), + ); + orangeMoneyModel.value = OrangeMoney.fromJson( + jsonDecode(Preferences.getString(Preferences.orangeMoneySettings)), + ); + xenditModel.value = Xendit.fromJson( + jsonDecode(Preferences.getString(Preferences.xenditSettings)), + ); + walletSettingModel.value = WalletSettingModel.fromJson( + jsonDecode(Preferences.getString(Preferences.walletSettings)), + ); + cashOnDeliverySettingModel.value = CodSettingModel.fromJson( + jsonDecode(Preferences.getString(Preferences.codSettings)), + ); if (walletSettingModel.value.isEnabled == true) { selectedPaymentMethod.value = PaymentGateway.wallet.name; @@ -325,20 +417,32 @@ class RentalOrderDetailsController extends GetxController { Future stripeMakePayment({required String amount}) async { log(double.parse(amount).toStringAsFixed(0)); try { - Map? paymentIntentData = await createStripeIntent(amount: amount); + Map? paymentIntentData = await createStripeIntent( + amount: amount, + ); log("stripe Responce====>$paymentIntentData"); if (paymentIntentData!.containsKey("error")) { Get.back(); - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); } else { await Stripe.instance.initPaymentSheet( paymentSheetParameters: SetupPaymentSheetParameters( paymentIntentClientSecret: paymentIntentData['client_secret'], allowsDelayedPaymentMethods: false, - googlePay: const PaymentSheetGooglePay(merchantCountryCode: 'US', testEnv: true, currencyCode: "USD"), + googlePay: const PaymentSheetGooglePay( + merchantCountryCode: 'US', + testEnv: true, + currencyCode: "USD", + ), customFlow: true, style: ThemeMode.system, - appearance: PaymentSheetAppearance(colors: PaymentSheetAppearanceColors(primary: AppThemeData.primary300)), + appearance: PaymentSheetAppearance( + colors: PaymentSheetAppearanceColors( + primary: AppThemeData.primary300, + ), + ), merchantDisplayName: 'GoRide', ), ); @@ -384,7 +488,10 @@ class RentalOrderDetailsController extends GetxController { var response = await http.post( Uri.parse('https://api.stripe.com/v1/payment_intents'), body: body, - headers: {'Authorization': 'Bearer $stripeSecret', 'Content-Type': 'application/x-www-form-urlencoded'}, + headers: { + 'Authorization': 'Bearer $stripeSecret', + 'Content-Type': 'application/x-www-form-urlencoded', + }, ); return jsonDecode(response.body); @@ -394,8 +501,14 @@ class RentalOrderDetailsController extends GetxController { } //mercadoo - Future mercadoPagoMakePayment({required BuildContext context, required String amount}) async { - final headers = {'Authorization': 'Bearer ${mercadoPagoModel.value.accessToken}', 'Content-Type': 'application/json'}; + Future mercadoPagoMakePayment({ + required BuildContext context, + required String amount, + }) async { + final headers = { + 'Authorization': 'Bearer ${mercadoPagoModel.value.accessToken}', + 'Content-Type': 'application/json', + }; final body = jsonEncode({ "items": [ @@ -408,12 +521,20 @@ class RentalOrderDetailsController extends GetxController { }, ], "payer": {"email": Constant.userModel!.email}, - "back_urls": {"failure": "${Constant.globalUrl}payment/failure", "pending": "${Constant.globalUrl}payment/pending", "success": "${Constant.globalUrl}payment/success"}, + "back_urls": { + "failure": "${Constant.globalUrl}payment/failure", + "pending": "${Constant.globalUrl}payment/pending", + "success": "${Constant.globalUrl}payment/success", + }, "auto_return": "approved", // Automatically return after payment is approved }); - final response = await http.post(Uri.parse("https://api.mercadopago.com/checkout/preferences"), headers: headers, body: body); + final response = await http.post( + Uri.parse("https://api.mercadopago.com/checkout/preferences"), + headers: headers, + body: body, + ); if (response.statusCode == 200 || response.statusCode == 201) { final data = jsonDecode(response.body); @@ -496,15 +617,23 @@ class RentalOrderDetailsController extends GetxController { } }); } else { - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); } }); } //flutter wave Payment Method - Future flutterWaveInitiatePayment({required BuildContext context, required String amount}) async { + Future flutterWaveInitiatePayment({ + required BuildContext context, + required String amount, + }) async { final url = Uri.parse('https://api.flutterwave.com/v3/payments'); - final headers = {'Authorization': 'Bearer ${flutterWaveModel.value.secretKey}', 'Content-Type': 'application/json'}; + final headers = { + 'Authorization': 'Bearer ${flutterWaveModel.value.secretKey}', + 'Content-Type': 'application/json', + }; final body = jsonEncode({ "tx_ref": _ref, @@ -514,17 +643,23 @@ class RentalOrderDetailsController extends GetxController { "payment_options": "ussd, card, barter, payattitude", "customer": { "email": Constant.userModel!.email.toString(), - "phonenumber": Constant.userModel!.phoneNumber, // Add a real phone number + "phonenumber": + Constant.userModel!.phoneNumber, // Add a real phone number "name": Constant.userModel!.fullName(), // Add a real customer name }, - "customizations": {"title": "Payment for Services", "description": "Payment for XYZ services"}, + "customizations": { + "title": "Payment for Services", + "description": "Payment for XYZ services", + }, }); final response = await http.post(url, headers: headers, body: body); if (response.statusCode == 200) { final data = jsonDecode(response.body); - Get.to(MercadoPagoScreen(initialURl: data['data']['link']))!.then((value) { + Get.to(MercadoPagoScreen(initialURl: data['data']['link']))!.then(( + value, + ) { if (value) { ShowToastDialog.showToast("Payment Successful!!".tr); completeOrder(); @@ -553,8 +688,14 @@ class RentalOrderDetailsController extends GetxController { // payFast void payFastPayment({required BuildContext context, required String amount}) { - PayStackURLGen.getPayHTML(payFastSettingData: payFastModel.value, amount: amount.toString(), userModel: Constant.userModel!).then((String? value) async { - bool isDone = await Get.to(PayFastScreen(htmlData: value!, payFastSettingData: payFastModel.value)); + PayStackURLGen.getPayHTML( + payFastSettingData: payFastModel.value, + amount: amount.toString(), + userModel: Constant.userModel!, + ).then((String? value) async { + bool isDone = await Get.to( + PayFastScreen(htmlData: value!, payFastSettingData: payFastModel.value), + ); if (isDone) { Get.back(); ShowToastDialog.showToast("Payment successfully".tr); @@ -593,7 +734,14 @@ class RentalOrderDetailsController extends GetxController { // }); } - Future startTransaction(context, {required String txnTokenBy, required orderId, required double amount, required callBackURL, required isStaging}) async { + Future startTransaction( + context, { + required String txnTokenBy, + required orderId, + required double amount, + required callBackURL, + required isStaging, + }) async { // try { // var response = AllInOneSdk.startTransaction( // paytmModel.value.paytmMID.toString(), @@ -629,24 +777,38 @@ class RentalOrderDetailsController extends GetxController { // } } - Future verifyCheckSum({required String checkSum, required double amount, required orderId}) async { + Future verifyCheckSum({ + required String checkSum, + required double amount, + required orderId, + }) async { String getChecksum = "${Constant.globalUrl}payments/validatechecksum"; final response = await http.post( Uri.parse(getChecksum), headers: {}, - body: {"mid": paytmModel.value.paytmMID.toString(), "order_id": orderId, "key_secret": paytmModel.value.pAYTMMERCHANTKEY.toString(), "checksum_value": checkSum}, + body: { + "mid": paytmModel.value.paytmMID.toString(), + "order_id": orderId, + "key_secret": paytmModel.value.pAYTMMERCHANTKEY.toString(), + "checksum_value": checkSum, + }, ); final data = jsonDecode(response.body); return data['status']; } - Future initiatePayment({required double amount, required orderId}) async { + Future initiatePayment({ + required double amount, + required orderId, + }) async { String initiateURL = "${Constant.globalUrl}payments/initiatepaytmpayment"; String callback = ""; if (paytmModel.value.isSandboxEnabled == true) { - callback = "${callback}https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; + callback = + "${callback}https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; } else { - callback = "${callback}https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; + callback = + "${callback}https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=$orderId"; } final response = await http.post( Uri.parse(initiateURL), @@ -664,9 +826,12 @@ class RentalOrderDetailsController extends GetxController { ); log(response.body); final data = jsonDecode(response.body); - if (data["body"]["txnToken"] == null || data["body"]["txnToken"].toString().isEmpty) { + if (data["body"]["txnToken"] == null || + data["body"]["txnToken"].toString().isEmpty) { Get.back(); - ShowToastDialog.showToast("something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "something went wrong, please contact admin.".tr, + ); } return GetPaymentTxtTokenModel.fromJson(data); } @@ -684,7 +849,10 @@ class RentalOrderDetailsController extends GetxController { 'description': 'wallet Topup', 'retry': {'enabled': true, 'max_count': 1}, 'send_sms_hash': true, - 'prefill': {'contact': Constant.userModel!.phoneNumber, 'email': Constant.userModel!.email}, + 'prefill': { + 'contact': Constant.userModel!.phoneNumber, + 'email': Constant.userModel!.email, + }, 'external': { 'wallets': ['paytm'], }, @@ -719,7 +887,10 @@ class RentalOrderDetailsController extends GetxController { } //Midtrans payment - Future midtransMakePayment({required String amount, required BuildContext context}) async { + Future midtransMakePayment({ + required String amount, + required BuildContext context, + }) async { await createPaymentLink(amount: amount).then((url) { ShowToastDialog.closeLoader(); if (url != '') { @@ -737,15 +908,30 @@ class RentalOrderDetailsController extends GetxController { Future createPaymentLink({required var amount}) async { var ordersId = const Uuid().v1(); - final url = Uri.parse(midTransModel.value.isSandbox! ? 'https://api.sandbox.midtrans.com/v1/payment-links' : 'https://api.midtrans.com/v1/payment-links'); + final url = Uri.parse( + midTransModel.value.isSandbox! + ? 'https://api.sandbox.midtrans.com/v1/payment-links' + : 'https://api.midtrans.com/v1/payment-links', + ); final response = await http.post( url, - headers: {'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': generateBasicAuthHeader(midTransModel.value.serverKey!)}, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': generateBasicAuthHeader( + midTransModel.value.serverKey!, + ), + }, body: jsonEncode({ - 'transaction_details': {'order_id': ordersId, 'gross_amount': double.parse(amount.toString()).toInt()}, + 'transaction_details': { + 'order_id': ordersId, + 'gross_amount': double.parse(amount.toString()).toInt(), + }, 'usage_limit': 2, - "callbacks": {"finish": "https://www.google.com?merchant_order_id=$ordersId"}, + "callbacks": { + "finish": "https://www.google.com?merchant_order_id=$ordersId", + }, }), ); @@ -753,7 +939,9 @@ class RentalOrderDetailsController extends GetxController { final responseData = jsonDecode(response.body); return responseData['payment_url']; } else { - ShowToastDialog.showToast("something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "something went wrong, please contact admin.".tr, + ); return ''; } } @@ -770,13 +958,30 @@ class RentalOrderDetailsController extends GetxController { static String orderId = ''; static String amount = ''; - Future orangeMakePayment({required String amount, required BuildContext context}) async { + Future orangeMakePayment({ + required String amount, + required BuildContext context, + }) async { reset(); var id = const Uuid().v4(); - var paymentURL = await fetchToken(context: context, orderId: id, amount: amount, currency: 'USD'); + var paymentURL = await fetchToken( + context: context, + orderId: id, + amount: amount, + currency: 'USD', + ); ShowToastDialog.closeLoader(); if (paymentURL.toString() != '') { - Get.to(() => OrangeMoneyScreen(initialURl: paymentURL, accessToken: accessToken, amount: amount, orangePay: orangeMoneyModel.value, orderId: orderId, payToken: payToken))!.then((value) { + Get.to( + () => OrangeMoneyScreen( + initialURl: paymentURL, + accessToken: accessToken, + amount: amount, + orangePay: orangeMoneyModel.value, + orderId: orderId, + payToken: payToken, + ), + )!.then((value) { if (value == true) { ShowToastDialog.showToast("Payment Successful!!".tr); completeOrder(); @@ -788,13 +993,22 @@ class RentalOrderDetailsController extends GetxController { } } - Future fetchToken({required String orderId, required String currency, required BuildContext context, required String amount}) async { + Future fetchToken({ + required String orderId, + required String currency, + required BuildContext context, + required String amount, + }) async { String apiUrl = 'https://api.orange.com/oauth/v3/token'; Map requestBody = {'grant_type': 'client_credentials'}; var response = await http.post( Uri.parse(apiUrl), - headers: {'Authorization': "Basic ${orangeMoneyModel.value.auth!}", 'Content-Type': 'application/x-www-form-urlencoded', 'Accept': 'application/json'}, + headers: { + 'Authorization': "Basic ${orangeMoneyModel.value.auth!}", + 'Content-Type': 'application/x-www-form-urlencoded', + 'Accept': 'application/json', + }, body: requestBody, ); @@ -805,17 +1019,32 @@ class RentalOrderDetailsController extends GetxController { accessToken = responseData['access_token']; // ignore: use_build_context_synchronously - return await webpayment(context: context, amountData: amount, currency: currency, orderIdData: orderId); + return await webpayment( + context: context, + amountData: amount, + currency: currency, + orderIdData: orderId, + ); } else { - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); return ''; } } - Future webpayment({required String orderIdData, required BuildContext context, required String currency, required String amountData}) async { + Future webpayment({ + required String orderIdData, + required BuildContext context, + required String currency, + required String amountData, + }) async { orderId = orderIdData; amount = amountData; - String apiUrl = orangeMoneyModel.value.isSandbox! == true ? 'https://api.orange.com/orange-money-webpay/dev/v1/webpayment' : 'https://api.orange.com/orange-money-webpay/cm/v1/webpayment'; + String apiUrl = + orangeMoneyModel.value.isSandbox! == true + ? 'https://api.orange.com/orange-money-webpay/dev/v1/webpayment' + : 'https://api.orange.com/orange-money-webpay/cm/v1/webpayment'; Map requestBody = { "merchant_key": orangeMoneyModel.value.merchantKey ?? '', "currency": orangeMoneyModel.value.isSandbox == true ? "OUV" : currency, @@ -830,7 +1059,11 @@ class RentalOrderDetailsController extends GetxController { var response = await http.post( Uri.parse(apiUrl), - headers: {'Authorization': 'Bearer $accessToken', 'Content-Type': 'application/json', 'Accept': 'application/json'}, + headers: { + 'Authorization': 'Bearer $accessToken', + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, body: json.encode(requestBody), ); @@ -844,7 +1077,9 @@ class RentalOrderDetailsController extends GetxController { return ''; } } else { - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); return ''; } } @@ -860,7 +1095,13 @@ class RentalOrderDetailsController extends GetxController { await createXenditInvoice(amount: amount).then((model) { ShowToastDialog.closeLoader(); if (model.id != null) { - Get.to(() => XenditScreen(initialURl: model.invoiceUrl ?? '', transId: model.id ?? '', apiKey: xenditModel.value.apiKey!.toString()))!.then((value) { + Get.to( + () => XenditScreen( + initialURl: model.invoiceUrl ?? '', + transId: model.id ?? '', + apiKey: xenditModel.value.apiKey!.toString(), + ), + )!.then((value) { if (value == true) { ShowToastDialog.showToast("Payment Successful!!".tr); completeOrder(); @@ -876,7 +1117,9 @@ class RentalOrderDetailsController extends GetxController { const url = 'https://api.xendit.co/v2/invoices'; var headers = { 'Content-Type': 'application/json', - 'Authorization': generateBasicAuthHeader(xenditModel.value.apiKey!.toString()), + 'Authorization': generateBasicAuthHeader( + xenditModel.value.apiKey!.toString(), + ), // 'Cookie': '__cf_bm=yERkrx3xDITyFGiou0bbKY1bi7xEwovHNwxV1vCNbVc-1724155511-1.0.1.1-jekyYQmPCwY6vIJ524K0V6_CEw6O.dAwOmQnHtwmaXO_MfTrdnmZMka0KZvjukQgXu5B.K_6FJm47SGOPeWviQ', }; @@ -889,7 +1132,11 @@ class RentalOrderDetailsController extends GetxController { }); try { - final response = await http.post(Uri.parse(url), headers: headers, body: body); + final response = await http.post( + Uri.parse(url), + headers: headers, + body: body, + ); if (response.statusCode == 200 || response.statusCode == 201) { XenditModel model = XenditModel.fromJson(jsonDecode(response.body)); diff --git a/lib/controllers/rental_review_controller.dart b/lib/controllers/rental_review_controller.dart index cc40f11..58283ca 100644 --- a/lib/controllers/rental_review_controller.dart +++ b/lib/controllers/rental_review_controller.dart @@ -1,4 +1,5 @@ import 'package:cloud_firestore/cloud_firestore.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../constant/collection_name.dart'; @@ -47,12 +48,17 @@ class RentalReviewController extends GetxController { } }); - await FireStoreUtils.getUserProfile(order.value?.driverId ?? '').then((value) { + await FireStoreUtils.getUserProfile(order.value?.driverId ?? '').then(( + value, + ) { if (value != null) { driverUser.value = value; - final int userReviewsCount = int.tryParse(driverUser.value!.reviewsCount?.toString() ?? "0") ?? 0; - final int userReviewsSum = int.tryParse(driverUser.value!.reviewsSum?.toString() ?? "0") ?? 0; + final int userReviewsCount = + int.tryParse(driverUser.value!.reviewsCount?.toString() ?? "0") ?? + 0; + final int userReviewsSum = + int.tryParse(driverUser.value!.reviewsSum?.toString() ?? "0") ?? 0; if (ratingModel.value != null) { final int oldRating = ratingModel.value?.rating?.toInt() ?? 0; @@ -77,7 +83,9 @@ class RentalReviewController extends GetxController { ShowToastDialog.showLoader("Submit in...".tr); - final user = await FireStoreUtils.getUserProfile(order.value?.driverId ?? ''); + final user = await FireStoreUtils.getUserProfile( + order.value?.driverId ?? '', + ); if (user != null) { user.reviewsCount = (futureCount.value + 1).toString(); @@ -94,7 +102,8 @@ class RentalReviewController extends GetxController { driverId: ratingModel.value!.driverId, customerId: ratingModel.value!.customerId, vendorId: ratingModel.value?.vendorId, - uname: "${Constant.userModel?.firstName ?? ''} ${Constant.userModel?.lastName ?? ''}", + uname: + "${Constant.userModel?.firstName ?? ''} ${Constant.userModel?.lastName ?? ''}", profile: Constant.userModel?.profilePictureURL, createdAt: Timestamp.now(), ); @@ -105,7 +114,8 @@ class RentalReviewController extends GetxController { } } else { /// New review - final docRef = FireStoreUtils.fireStore.collection(CollectionName.itemsReview).doc(); + final docRef = + FireStoreUtils.fireStore.collection(CollectionName.itemsReview).doc(); final newRating = RatingModel( id: docRef.id, comment: comment.value.text, @@ -114,7 +124,8 @@ class RentalReviewController extends GetxController { orderId: order.value?.id, driverId: order.value?.driverId.toString(), customerId: Constant.userModel?.id, - uname: "${Constant.userModel?.firstName ?? ''} ${Constant.userModel?.lastName ?? ''}", + uname: + "${Constant.userModel?.firstName ?? ''} ${Constant.userModel?.lastName ?? ''}", profile: Constant.userModel?.profilePictureURL, createdAt: Timestamp.now(), ); diff --git a/lib/controllers/restaurant_details_controller.dart b/lib/controllers/restaurant_details_controller.dart index 7901954..6c7f50c 100644 --- a/lib/controllers/restaurant_details_controller.dart +++ b/lib/controllers/restaurant_details_controller.dart @@ -17,7 +17,8 @@ import 'package:get/get.dart'; import 'package:intl/intl.dart'; class RestaurantDetailsController extends GetxController { - Rx searchEditingController = TextEditingController().obs; + Rx searchEditingController = + TextEditingController().obs; RxBool isLoading = true.obs; Rx pageController = PageController().obs; @@ -44,7 +45,8 @@ class RestaurantDetailsController extends GetxController { } void animateSlider() { - if (vendorModel.value.photos != null && vendorModel.value.photos!.isNotEmpty) { + if (vendorModel.value.photos != null && + vendorModel.value.photos!.isNotEmpty) { Timer.periodic(const Duration(seconds: 2), (Timer timer) { if (currentPage < vendorModel.value.photos!.length - 1) { currentPage++; @@ -53,7 +55,11 @@ class RestaurantDetailsController extends GetxController { } if (pageController.value.hasClients) { - pageController.value.animateToPage(currentPage.value, duration: const Duration(milliseconds: 300), curve: Curves.easeIn); + pageController.value.animateToPage( + currentPage.value, + duration: const Duration(milliseconds: 300), + curve: Curves.easeIn, + ); } }); } @@ -86,14 +92,25 @@ class RestaurantDetailsController extends GetxController { RxList brandList = [].obs; Future getProduct() async { - await FireStoreUtils.getProductByVendorId(vendorModel.value.id.toString()).then((value) { - if ((Constant.isSubscriptionModelApplied == true || vendorModel.value.adminCommission?.isEnabled == true) && vendorModel.value.subscriptionPlan != null) { + await FireStoreUtils.getProductByVendorId( + vendorModel.value.id.toString(), + ).then((value) { + if ((Constant.isSubscriptionModelApplied == true || + vendorModel.value.adminCommission?.isEnabled == true) && + vendorModel.value.subscriptionPlan != null) { if (vendorModel.value.subscriptionPlan?.itemLimit == '-1') { allProductList.value = value; productList.value = value; } else { int selectedProduct = - value.length < int.parse(vendorModel.value.subscriptionPlan?.itemLimit ?? '0') ? (value.isEmpty ? 0 : (value.length)) : int.parse(vendorModel.value.subscriptionPlan?.itemLimit ?? '0'); + value.length < + int.parse( + vendorModel.value.subscriptionPlan?.itemLimit ?? '0', + ) + ? (value.isEmpty ? 0 : (value.length)) + : int.parse( + vendorModel.value.subscriptionPlan?.itemLimit ?? '0', + ); allProductList.value = value.sublist(0, selectedProduct); productList.value = value.sublist(0, selectedProduct); } @@ -104,7 +121,9 @@ class RestaurantDetailsController extends GetxController { }); for (var element in productList) { - await FireStoreUtils.getVendorCategoryById(element.categoryID.toString()).then((value) { + await FireStoreUtils.getVendorCategoryById( + element.categoryID.toString(), + ).then((value) { if (value != null) { vendorCategoryList.add(value); } @@ -116,7 +135,10 @@ class RestaurantDetailsController extends GetxController { }); var seen = {}; - vendorCategoryList.value = vendorCategoryList.where((element) => seen.add(element.id.toString())).toList(); + vendorCategoryList.value = + vendorCategoryList + .where((element) => seen.add(element.id.toString())) + .toList(); } void searchProduct(String name) { @@ -126,25 +148,42 @@ class RestaurantDetailsController extends GetxController { } else { isVag.value = false; isNonVag.value = false; - productList.value = allProductList.where((p0) => p0.name!.toLowerCase().contains(name.toLowerCase())).toList(); + productList.value = + allProductList + .where( + (p0) => p0.name!.toLowerCase().contains(name.toLowerCase()), + ) + .toList(); } update(); } void filterRecord() { if (isVag.value == true && isNonVag.value == true) { - productList.value = allProductList.where((p0) => p0.nonveg == true || p0.nonveg == false).toList(); + productList.value = + allProductList + .where((p0) => p0.nonveg == true || p0.nonveg == false) + .toList(); } else if (isVag.value == true && isNonVag.value == false) { - productList.value = allProductList.where((p0) => p0.nonveg == false).toList(); + productList.value = + allProductList.where((p0) => p0.nonveg == false).toList(); } else if (isVag.value == false && isNonVag.value == true) { - productList.value = allProductList.where((p0) => p0.nonveg == true).toList(); + productList.value = + allProductList.where((p0) => p0.nonveg == true).toList(); } else if (isVag.value == false && isNonVag.value == false) { - productList.value = allProductList.where((p0) => p0.nonveg == true || p0.nonveg == false).toList(); + productList.value = + allProductList + .where((p0) => p0.nonveg == true || p0.nonveg == false) + .toList(); } } - Future> getProductByCategory(VendorCategoryModel vendorCategoryModel) async { - return productList.where((p0) => p0.categoryID == vendorCategoryModel.id).toList(); + Future> getProductByCategory( + VendorCategoryModel vendorCategoryModel, + ) async { + return productList + .where((p0) => p0.categoryID == vendorCategoryModel.id) + .toList(); } Future getFavouriteList() async { @@ -157,7 +196,9 @@ class RestaurantDetailsController extends GetxController { favouriteItemList.value = value; }); - await FireStoreUtils.getOfferByVendorId(vendorModel.value.id.toString()).then((value) { + await FireStoreUtils.getOfferByVendorId( + vendorModel.value.id.toString(), + ).then((value) { couponList.value = value; }); } @@ -175,8 +216,12 @@ class RestaurantDetailsController extends GetxController { if (day == element.day.toString()) { if (element.timeslot!.isNotEmpty) { for (var element in element.timeslot!) { - var start = DateFormat("dd-MM-yyyy HH:mm").parse("$date ${element.from}"); - var end = DateFormat("dd-MM-yyyy HH:mm").parse("$date ${element.to}"); + var start = DateFormat( + "dd-MM-yyyy HH:mm", + ).parse("$date ${element.from}"); + var end = DateFormat( + "dd-MM-yyyy HH:mm", + ).parse("$date ${element.to}"); if (isCurrentDateInRange(start, end)) { isOpen.value = true; } @@ -219,15 +264,33 @@ class RestaurantDetailsController extends GetxController { String adOnsPrice = "0"; if (productModel.itemAttribute != null) { - if (productModel.itemAttribute!.variants!.where((element) => element.variantSku == selectedVariants.join('-')).isNotEmpty) { + if (productModel.itemAttribute!.variants! + .where((element) => element.variantSku == selectedVariants.join('-')) + .isNotEmpty) { variantPrice = Constant.productCommissionPrice( vendorModel.value, - productModel.itemAttribute!.variants!.where((element) => element.variantSku == selectedVariants.join('-')).first.variantPrice ?? '0', + productModel.itemAttribute!.variants! + .where( + (element) => + element.variantSku == selectedVariants.join('-'), + ) + .first + .variantPrice ?? + '0', ); } } else { - String price = Constant.productCommissionPrice(vendorModel.value, productModel.price.toString()); - String disPrice = double.parse(productModel.disPrice.toString()) <= 0 ? "0" : Constant.productCommissionPrice(vendorModel.value, productModel.disPrice.toString()); + String price = Constant.productCommissionPrice( + vendorModel.value, + productModel.price.toString(), + ); + String disPrice = + double.parse(productModel.disPrice.toString()) <= 0 + ? "0" + : Constant.productCommissionPrice( + vendorModel.value, + productModel.disPrice.toString(), + ); if (double.parse(disPrice) <= 0) { variantPrice = price; } else { @@ -237,11 +300,23 @@ class RestaurantDetailsController extends GetxController { for (int i = 0; i < productModel.addOnsPrice!.length; i++) { if (selectedAddOns.contains(productModel.addOnsTitle![i]) == true) { - adOnsPrice = (double.parse(adOnsPrice.toString()) + double.parse(Constant.productCommissionPrice(vendorModel.value, productModel.addOnsPrice![i].toString()))).toString(); + adOnsPrice = + (double.parse(adOnsPrice.toString()) + + double.parse( + Constant.productCommissionPrice( + vendorModel.value, + productModel.addOnsPrice![i].toString(), + ), + )) + .toString(); } } adOnsPrice = (quantity.value * double.parse(adOnsPrice)).toString(); - mainPrice = ((double.parse(variantPrice.toString()) * double.parse(quantity.value.toString())) + double.parse(adOnsPrice.toString())).toString(); + mainPrice = + ((double.parse(variantPrice.toString()) * + double.parse(quantity.value.toString())) + + double.parse(adOnsPrice.toString())) + .toString(); return mainPrice; } @@ -253,18 +328,35 @@ class RestaurantDetailsController extends GetxController { }); } - Future addToCart({required ProductModel productModel, required String price, required String discountPrice, required bool isIncrement, required int quantity, VariantInfo? variantInfo}) async { + Future addToCart({ + required ProductModel productModel, + required String price, + required String discountPrice, + required bool isIncrement, + required int quantity, + VariantInfo? variantInfo, + }) async { CartProductModel cartProductModel = CartProductModel(); String adOnsPrice = "0"; for (int i = 0; i < productModel.addOnsPrice!.length; i++) { - if (selectedAddOns.contains(productModel.addOnsTitle![i]) == true && productModel.addOnsPrice![i] != '0') { - adOnsPrice = (double.parse(adOnsPrice.toString()) + double.parse(Constant.productCommissionPrice(vendorModel.value, productModel.addOnsPrice![i].toString()))).toString(); + if (selectedAddOns.contains(productModel.addOnsTitle![i]) == true && + productModel.addOnsPrice![i] != '0') { + adOnsPrice = + (double.parse(adOnsPrice.toString()) + + double.parse( + Constant.productCommissionPrice( + vendorModel.value, + productModel.addOnsPrice![i].toString(), + ), + )) + .toString(); } } if (variantInfo != null) { - cartProductModel.id = "${productModel.id!}~${variantInfo.variantId.toString()}"; + cartProductModel.id = + "${productModel.id!}~${variantInfo.variantId.toString()}"; cartProductModel.name = productModel.name!; cartProductModel.photo = productModel.photo!; cartProductModel.categoryId = productModel.categoryID!; diff --git a/lib/controllers/search_controller.dart b/lib/controllers/search_controller.dart index bf20ea6..278c9da 100644 --- a/lib/controllers/search_controller.dart +++ b/lib/controllers/search_controller.dart @@ -28,13 +28,20 @@ class SearchScreenController extends GetxController { isLoading.value = false; for (var element in vendorList) { - await FireStoreUtils.getProductByVendorId(element.id.toString()).then((value) { - if ((Constant.isSubscriptionModelApplied == true || element.adminCommission?.isEnabled == true) && element.subscriptionPlan != null) { + await FireStoreUtils.getProductByVendorId(element.id.toString()).then(( + value, + ) { + if ((Constant.isSubscriptionModelApplied == true || + element.adminCommission?.isEnabled == true) && + element.subscriptionPlan != null) { if (element.subscriptionPlan?.itemLimit == '-1') { productList.addAll(value); } else { int selectedProduct = - value.length < int.parse(element.subscriptionPlan?.itemLimit ?? '0') ? (value.isEmpty ? 0 : (value.length)) : int.parse(element.subscriptionPlan?.itemLimit ?? '0'); + value.length < + int.parse(element.subscriptionPlan?.itemLimit ?? '0') + ? (value.isEmpty ? 0 : (value.length)) + : int.parse(element.subscriptionPlan?.itemLimit ?? '0'); productList.addAll(value.sublist(0, selectedProduct)); } } else { diff --git a/lib/controllers/service_list_controller.dart b/lib/controllers/service_list_controller.dart index 52cf118..19d08ed 100644 --- a/lib/controllers/service_list_controller.dart +++ b/lib/controllers/service_list_controller.dart @@ -1,3 +1,4 @@ +import 'package:customer/constant/const_texts.dart'; import 'package:customer/models/section_model.dart'; import 'package:customer/screen_ui/cab_service_screens/cab_dashboard_screen.dart'; import 'package:customer/screen_ui/ecommarce/dash_board_e_commerce_screen.dart'; @@ -12,8 +13,11 @@ import 'package:customer/models/currency_model.dart'; import 'package:customer/themes/app_them_data.dart'; import 'package:customer/themes/round_button_fill.dart'; import 'package:customer/themes/show_toast_dialog.dart'; +import 'package:customer/utils/app_router.dart'; + import 'package:firebase_auth/firebase_auth.dart' as auth; import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import '../screen_ui/auth_screens/login_screen.dart'; import '../screen_ui/multi_vendor_service/dash_board_screens/dash_board_screen.dart'; @@ -38,7 +42,17 @@ class ServiceListController extends GetxController { // fetch currency CurrencyModel? currency = await FireStoreUtils.getCurrency(); - currencyData.value = currency ?? CurrencyModel(id: "", code: "USD", decimal: 2, isactive: true, name: "US Dollar", symbol: "\$", symbolatright: false); + currencyData.value = + currency ?? + CurrencyModel( + id: "", + code: "USD", + decimal: 2, + isactive: true, + name: "US Dollar", + symbol: "\$", + symbolatright: false, + ); // Load sections List sections = await FireStoreUtils.getSections(); @@ -59,11 +73,17 @@ class ServiceListController extends GetxController { }); } - Future onServiceTap(BuildContext context, SectionModel sectionModel) async { + Future onServiceTap( + BuildContext context, + SectionModel sectionModel, + ) async { try { - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); Constant.sectionConstantModel = sectionModel; - AppThemeData.primary300 = Color(int.tryParse(sectionModel.color?.replaceFirst("#", "0xff") ?? '') ?? 0xff2196F3); + AppThemeData.primary300 = Color( + int.tryParse(sectionModel.color?.replaceFirst("#", "0xff") ?? '') ?? + 0xff2196F3, + ); if (auth.FirebaseAuth.instance.currentUser != null) { String uid = auth.FirebaseAuth.instance.currentUser!.uid; UserModel? user = await FireStoreUtils.getUserProfile(uid); @@ -74,7 +94,7 @@ class ServiceListController extends GetxController { await _navigate(sectionModel); } else { ShowToastDialog.closeLoader(); - Get.offAll(() => const LoginScreen()); + Get.offAll(LoginScreen()); } } else { ShowToastDialog.closeLoader(); @@ -93,7 +113,8 @@ class ServiceListController extends GetxController { } }); - if (sectionModel.serviceTypeFlag == "ecommerce-service" || sectionModel.serviceTypeFlag == "delivery-service") { + if (sectionModel.serviceTypeFlag == "ecommerce-service" || + sectionModel.serviceTypeFlag == "delivery-service") { if (cartItem.isNotEmpty) { showAlertDialog(Get.context!, UserModel(), sectionModel); } else { @@ -130,18 +151,27 @@ class ServiceListController extends GetxController { final CartProvider cartProvider = CartProvider(); - void showAlertDialog(BuildContext context, UserModel user, SectionModel sectionModel) { + void showAlertDialog( + BuildContext context, + UserModel user, + SectionModel sectionModel, + ) { Get.defaultDialog( title: "Alert!", content: Column( mainAxisSize: MainAxisSize.min, children: [ - Text("If you select this Section/Service, your previously added items will be removed from the cart.".tr, textAlign: TextAlign.center), + Text( + "If you select this Section/Service, your previously added items will be removed from the cart." + .tr, + textAlign: TextAlign.center, + ), const SizedBox(height: 20), Row( children: [ Expanded( child: RoundedButtonFill( + borderRadius: 10.r, height: 5.5, title: "Cancel".tr, onPress: () { @@ -154,6 +184,7 @@ class ServiceListController extends GetxController { const SizedBox(width: 12), Expanded( child: RoundedButtonFill( + borderRadius: 10.r, title: "OK".tr, height: 5.5, onPress: () async { diff --git a/lib/controllers/sign_up_controller.dart b/lib/controllers/sign_up_controller.dart index 5817e97..8760fcd 100644 --- a/lib/controllers/sign_up_controller.dart +++ b/lib/controllers/sign_up_controller.dart @@ -1,6 +1,8 @@ import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:customer/models/user_model.dart'; import 'package:customer/screen_ui/location_enable_screens/location_permission_screen.dart'; +import 'package:customer/utils/app_router.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:firebase_auth/firebase_auth.dart' as auth; @@ -16,9 +18,11 @@ class SignUpController extends GetxController { Rx lastNameController = TextEditingController().obs; Rx emailController = TextEditingController().obs; Rx mobileController = TextEditingController().obs; - Rx countryCodeController = TextEditingController(text: Constant.defaultCountryCode).obs; + Rx countryCodeController = + TextEditingController(text: Constant.defaultCountryCode).obs; Rx passwordController = TextEditingController().obs; - Rx confirmPasswordController = TextEditingController().obs; + Rx confirmPasswordController = + TextEditingController().obs; Rx referralController = TextEditingController().obs; final FocusNode emailFocusNode = FocusNode(); @@ -89,7 +93,8 @@ class SignUpController extends GetxController { } else if (lastNameController.value.text.isEmpty) { ShowToastDialog.showToast("Please enter last name".tr); return false; - } else if (emailController.value.text.isEmpty || !emailController.value.text.isEmail) { + } else if (emailController.value.text.isEmpty || + !emailController.value.text.isEmail) { ShowToastDialog.showToast("Please enter a valid email address".tr); return false; } else if (mobileController.value.text.isEmpty) { @@ -98,8 +103,11 @@ class SignUpController extends GetxController { } else if (passwordController.value.text.length < 6) { ShowToastDialog.showToast("Password must be at least 6 characters".tr); return false; - } else if (passwordController.value.text != confirmPasswordController.value.text) { - ShowToastDialog.showToast("Password and Confirm password do not match".tr); + } else if (passwordController.value.text != + confirmPasswordController.value.text) { + ShowToastDialog.showToast( + "Password and Confirm password do not match".tr, + ); return false; } return true; @@ -108,7 +116,10 @@ class SignUpController extends GetxController { /// Email Sign-up Flow Future _signUpWithEmail() async { try { - final credential = await _firebaseAuth.createUserWithEmailAndPassword(email: emailController.value.text.trim(), password: passwordController.value.text.trim()); + final credential = await _firebaseAuth.createUserWithEmailAndPassword( + email: emailController.value.text.trim(), + password: passwordController.value.text.trim(), + ); if (credential.user != null) { final newUser = await _buildUserModel(credential.user?.uid ?? ''); @@ -118,7 +129,9 @@ class SignUpController extends GetxController { _navigateBasedOnAddress(newUser); } } on auth.FirebaseAuthException catch (e) { - debugPrint("FirebaseAuthException caught: code=${e.code}, message=${e.message}"); + debugPrint( + "FirebaseAuthException caught: code=${e.code}, message=${e.message}", + ); if (e.code == 'email-already-in-use') { ShowToastDialog.showToast("Email already in use".tr); } else if (e.code == 'weak-password') { @@ -130,7 +143,9 @@ class SignUpController extends GetxController { } } catch (e) { debugPrint("Something went wrong: ${e.toString()}"); - ShowToastDialog.showToast("${'something_went_wrong'.tr}: ${e.toString()}"); + ShowToastDialog.showToast( + "${'something_went_wrong'.tr}: ${e.toString()}", + ); } } @@ -172,9 +187,17 @@ class SignUpController extends GetxController { /// Handle Referral Logic Future _handleReferral(String userId) async { final referralCode = referralController.value.text.trim(); - final referralBy = referralCode.isNotEmpty ? (await FireStoreUtils.getReferralUserByCode(referralCode))?.id ?? '' : ''; + final referralBy = + referralCode.isNotEmpty + ? (await FireStoreUtils.getReferralUserByCode(referralCode))?.id ?? + '' + : ''; - final referral = ReferralModel(id: userId, referralBy: referralBy, referralCode: Constant.getReferralCode()); + final referral = ReferralModel( + id: userId, + referralBy: referralBy, + referralCode: Constant.getReferralCode(), + ); await FireStoreUtils.referralAdd(referral); } @@ -182,14 +205,17 @@ class SignUpController extends GetxController { /// Navigate Based on Shipping Address void _navigateBasedOnAddress(UserModel user) { if (user.shippingAddress?.isNotEmpty == true) { - final defaultAddress = user.shippingAddress!.firstWhere((e) => e.isDefault == true, orElse: () => user.shippingAddress!.first); + final defaultAddress = user.shippingAddress!.firstWhere( + (e) => e.isDefault == true, + orElse: () => user.shippingAddress!.first, + ); /// Save the default address to global constant Constant.selectedLocation = defaultAddress; - Get.offAll(() => const ServiceListScreen()); + Get.offAll(ServiceListScreen()); } else { - Get.offAll(() => const LocationPermissionScreen()); + Get.offAll(LocationPermissionScreen()); } } } diff --git a/lib/controllers/splash_controller.dart b/lib/controllers/splash_controller.dart index 3042224..2052507 100644 --- a/lib/controllers/splash_controller.dart +++ b/lib/controllers/splash_controller.dart @@ -4,9 +4,11 @@ import 'package:customer/constant/constant.dart'; import 'package:customer/models/user_model.dart'; import 'package:customer/screen_ui/maintenance_mode_screen/maintenance_mode_screen.dart'; import 'package:customer/screen_ui/service_home_screen/service_list_screen.dart'; +import 'package:customer/utils/app_router.dart'; import 'package:customer/utils/notification_service.dart'; import 'package:customer/utils/preferences.dart'; import 'package:firebase_auth/firebase_auth.dart'; +import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../screen_ui/auth_screens/login_screen.dart'; import '../screen_ui/location_enable_screens/location_permission_screen.dart'; @@ -14,9 +16,13 @@ import '../screen_ui/on_boarding_screen/on_boarding_screen.dart'; import '../service/fire_store_utils.dart'; class SplashController extends GetxController { + final BuildContext context; + + SplashController({required this.context}); + @override void onInit() { - Timer(const Duration(seconds: 3), () => redirectScreen()); + Timer(const Duration(seconds: 2), () => redirectScreen()); super.onInit(); } @@ -30,7 +36,9 @@ class SplashController extends GetxController { } else { bool isLogin = await FireStoreUtils.isLogin(); if (isLogin == true) { - await FireStoreUtils.getUserProfile(FireStoreUtils.getCurrentUid()).then((value) async { + await FireStoreUtils.getUserProfile( + FireStoreUtils.getCurrentUid(), + ).then((value) async { if (value != null) { UserModel userModel = value; log(userModel.toJson().toString()); @@ -38,11 +46,18 @@ class SplashController extends GetxController { if (userModel.active == true) { userModel.fcmToken = await NotificationService.getToken(); await FireStoreUtils.updateUser(userModel); - if (userModel.shippingAddress != null && userModel.shippingAddress!.isNotEmpty) { - if (userModel.shippingAddress!.where((element) => element.isDefault == true).isNotEmpty) { - Constant.selectedLocation = userModel.shippingAddress!.where((element) => element.isDefault == true).single; + if (userModel.shippingAddress != null && + userModel.shippingAddress!.isNotEmpty) { + if (userModel.shippingAddress! + .where((element) => element.isDefault == true) + .isNotEmpty) { + Constant.selectedLocation = + userModel.shippingAddress! + .where((element) => element.isDefault == true) + .single; } else { - Constant.selectedLocation = userModel.shippingAddress!.first; + Constant.selectedLocation = + userModel.shippingAddress!.first; } Get.offAll(const ServiceListScreen()); } else { @@ -64,4 +79,11 @@ class SplashController extends GetxController { } } } + + void _navigateAndRemoveAll(Widget screen) { + Navigator.of(context).pushAndRemoveUntil( + MaterialPageRoute(builder: (_) => screen), + (route) => false, + ); + } } diff --git a/lib/controllers/theme_controller.dart b/lib/controllers/theme_controller.dart index 64b05d6..50efcc6 100644 --- a/lib/controllers/theme_controller.dart +++ b/lib/controllers/theme_controller.dart @@ -23,5 +23,3 @@ class ThemeController extends GetxController { ThemeMode get themeMode => isDark.value ? ThemeMode.dark : ThemeMode.light; } - - diff --git a/lib/controllers/view_all_category_controller.dart b/lib/controllers/view_all_category_controller.dart index 1612e88..49a61e5 100644 --- a/lib/controllers/view_all_category_controller.dart +++ b/lib/controllers/view_all_category_controller.dart @@ -18,12 +18,19 @@ class ViewAllCategoryController extends GetxController { Future getCategoryData() async { await FireStoreUtils.getVendorCategory().then((value) { vendorCategoryModel.value = value; - }); if (Constant.restaurantList != null) { - List usedCategoryIds = Constant.restaurantList!.expand((vendor) => vendor.categoryID ?? []).whereType().toSet().toList(); - vendorCategoryModel.value = vendorCategoryModel.where((category) => usedCategoryIds.contains(category.id)).toList(); + List usedCategoryIds = + Constant.restaurantList! + .expand((vendor) => vendor.categoryID ?? []) + .whereType() + .toSet() + .toList(); + vendorCategoryModel.value = + vendorCategoryModel + .where((category) => usedCategoryIds.contains(category.id)) + .toList(); } isLoading.value = false; diff --git a/lib/controllers/view_all_popular_service_controller.dart b/lib/controllers/view_all_popular_service_controller.dart index 24da089..5f2d604 100644 --- a/lib/controllers/view_all_popular_service_controller.dart +++ b/lib/controllers/view_all_popular_service_controller.dart @@ -10,13 +10,17 @@ class ViewAllPopularServiceController extends GetxController { RxList providerList = [].obs; RxList allProviderList = [].obs; RxBool isLoading = true.obs; - Rx onDemandHomeController = Get.find().obs; + Rx onDemandHomeController = + Get.find().obs; - final OnDemandHomeController onDemandController = Get.find(); + final OnDemandHomeController onDemandController = + Get.find(); - Rx searchTextFiledController = TextEditingController().obs; + Rx searchTextFiledController = + TextEditingController().obs; - RxList lstFav = [].obs; + RxList lstFav = + [].obs; @override void onInit() { @@ -29,24 +33,31 @@ class ViewAllPopularServiceController extends GetxController { await FireStoreUtils.getProviderFuture() .then((providerServiceList) { - Set uniqueAuthorIds = providerServiceList.map((service) => service.author).toSet(); + Set uniqueAuthorIds = + providerServiceList.map((service) => service.author).toSet(); List listOfUniqueProviders = uniqueAuthorIds.toList(); List filteredProviders = []; for (var provider in listOfUniqueProviders) { - List filteredList = providerServiceList.where((service) => service.author == provider).toList(); + List filteredList = + providerServiceList + .where((service) => service.author == provider) + .toList(); filteredList.sort((a, b) => a.createdAt!.compareTo(b.createdAt!)); for (int index = 0; index < filteredList.length; index++) { final service = filteredList[index]; - if (Constant.isSubscriptionModelApplied == true || Constant.sectionConstantModel?.adminCommision?.isEnabled == true) { + if (Constant.isSubscriptionModelApplied == true || + Constant.sectionConstantModel?.adminCommision?.isEnabled == + true) { if (service.subscriptionPlan?.itemLimit == "-1") { filteredProviders.add(service); } else { - if (index < int.parse(service.subscriptionPlan?.itemLimit ?? '0')) { + if (index < + int.parse(service.subscriptionPlan?.itemLimit ?? '0')) { filteredProviders.add(service); } } @@ -66,7 +77,9 @@ class ViewAllPopularServiceController extends GetxController { }); if (Constant.userModel != null) { - await FireStoreUtils.getFavouritesServiceList(FireStoreUtils.getCurrentUid()).then((value) { + await FireStoreUtils.getFavouritesServiceList( + FireStoreUtils.getCurrentUid(), + ).then((value) { lstFav.value = value; }); } @@ -75,7 +88,14 @@ class ViewAllPopularServiceController extends GetxController { void getFilterData(String value) { if (value.isNotEmpty) { - providerList.value = allProviderList.where((e) => e.title!.toLowerCase().contains(value.toLowerCase()) || e.title!.startsWith(value)).toList(); + providerList.value = + allProviderList + .where( + (e) => + e.title!.toLowerCase().contains(value.toLowerCase()) || + e.title!.startsWith(value), + ) + .toList(); } else { providerList.assignAll(allProviderList); } diff --git a/lib/controllers/view_category_service_controller.dart b/lib/controllers/view_category_service_controller.dart index 58cdaf6..776ab42 100644 --- a/lib/controllers/view_category_service_controller.dart +++ b/lib/controllers/view_category_service_controller.dart @@ -9,7 +9,8 @@ class ViewCategoryServiceController extends GetxController { RxList providerList = [].obs; RxString categoryId = "".obs, categoryTitle = "".obs; - Rx onDemandHomeController = Get.find().obs; + Rx onDemandHomeController = + Get.find().obs; @override void onInit() { @@ -26,21 +27,32 @@ class ViewCategoryServiceController extends GetxController { providerList.clear(); isLoading.value = true; - List providerServiceList = await FireStoreUtils.getProviderFuture(categoryId: categoryId.value); + List providerServiceList = + await FireStoreUtils.getProviderFuture(categoryId: categoryId.value); - List uniqueAuthId = providerServiceList.map((service) => service.author).toList(); - List uniqueServiceId = providerServiceList.map((service) => service.id).toList(); + List uniqueAuthId = + providerServiceList.map((service) => service.author).toList(); + List uniqueServiceId = + providerServiceList.map((service) => service.id).toList(); List filterByItemLimit = []; List uniqueId = []; - if ((Constant.isSubscriptionModelApplied == true || Constant.sectionConstantModel!.adminCommision?.isEnabled == true)) { + if ((Constant.isSubscriptionModelApplied == true || + Constant.sectionConstantModel!.adminCommision?.isEnabled == true)) { for (var authUser in uniqueAuthId) { - List listofAllServiceByAuth = await FireStoreUtils.getAllProviderServiceByAuthorId(authUser!); + List listofAllServiceByAuth = + await FireStoreUtils.getAllProviderServiceByAuthorId(authUser!); for (int i = 0; i < listofAllServiceByAuth.length; i++) { if (listofAllServiceByAuth[i].subscriptionPlan?.itemLimit != null && - (i < int.parse(listofAllServiceByAuth[i].subscriptionPlan?.itemLimit ?? '0') || listofAllServiceByAuth[i].subscriptionPlan?.itemLimit == '-1')) { + (i < + int.parse( + listofAllServiceByAuth[i].subscriptionPlan?.itemLimit ?? + '0', + ) || + listofAllServiceByAuth[i].subscriptionPlan?.itemLimit == + '-1')) { if (uniqueServiceId.contains(listofAllServiceByAuth[i].id)) { filterByItemLimit.add(listofAllServiceByAuth[i]); } @@ -49,7 +61,9 @@ class ViewCategoryServiceController extends GetxController { for (var service in filterByItemLimit) { for (var unique in uniqueServiceId) { - if (service.id == unique && !uniqueId.contains(service.id) && service.subscriptionTotalOrders != '0') { + if (service.id == unique && + !uniqueId.contains(service.id) && + service.subscriptionTotalOrders != '0') { uniqueId.add(service.id); providerList.add(service); } diff --git a/lib/controllers/wallet_controller.dart b/lib/controllers/wallet_controller.dart index a955701..afa1f11 100644 --- a/lib/controllers/wallet_controller.dart +++ b/lib/controllers/wallet_controller.dart @@ -17,6 +17,7 @@ import 'package:customer/models/payment_model/xendit.dart'; import 'package:customer/models/user_model.dart'; import 'package:customer/models/wallet_transaction_model.dart'; import 'package:customer/themes/app_them_data.dart'; + import 'package:flutter_paypal/flutter_paypal.dart'; import 'package:flutter_stripe/flutter_stripe.dart'; import 'package:razorpay_flutter/razorpay_flutter.dart'; @@ -44,7 +45,8 @@ class WalletController extends GetxController { Rx topUpAmountController = TextEditingController().obs; - RxList walletTransactionList = [].obs; + RxList walletTransactionList = + [].obs; Rx userModel = UserModel().obs; RxString selectedPaymentMethod = "".obs; @@ -70,17 +72,37 @@ class WalletController extends GetxController { Future getPaymentSettings() async { await FireStoreUtils.getPaymentSettingsData().then((value) { - payFastModel.value = PayFastModel.fromJson(jsonDecode(Preferences.getString(Preferences.payFastSettings))); - mercadoPagoModel.value = MercadoPagoModel.fromJson(jsonDecode(Preferences.getString(Preferences.mercadoPago))); - payPalModel.value = PayPalModel.fromJson(jsonDecode(Preferences.getString(Preferences.paypalSettings))); - stripeModel.value = StripeModel.fromJson(jsonDecode(Preferences.getString(Preferences.stripeSettings))); - flutterWaveModel.value = FlutterWaveModel.fromJson(jsonDecode(Preferences.getString(Preferences.flutterWave))); - payStackModel.value = PayStackModel.fromJson(jsonDecode(Preferences.getString(Preferences.payStack))); - razorPayModel.value = RazorPayModel.fromJson(jsonDecode(Preferences.getString(Preferences.razorpaySettings))); + payFastModel.value = PayFastModel.fromJson( + jsonDecode(Preferences.getString(Preferences.payFastSettings)), + ); + mercadoPagoModel.value = MercadoPagoModel.fromJson( + jsonDecode(Preferences.getString(Preferences.mercadoPago)), + ); + payPalModel.value = PayPalModel.fromJson( + jsonDecode(Preferences.getString(Preferences.paypalSettings)), + ); + stripeModel.value = StripeModel.fromJson( + jsonDecode(Preferences.getString(Preferences.stripeSettings)), + ); + flutterWaveModel.value = FlutterWaveModel.fromJson( + jsonDecode(Preferences.getString(Preferences.flutterWave)), + ); + payStackModel.value = PayStackModel.fromJson( + jsonDecode(Preferences.getString(Preferences.payStack)), + ); + razorPayModel.value = RazorPayModel.fromJson( + jsonDecode(Preferences.getString(Preferences.razorpaySettings)), + ); - midTransModel.value = MidTrans.fromJson(jsonDecode(Preferences.getString(Preferences.midTransSettings))); - orangeMoneyModel.value = OrangeMoney.fromJson(json.decode(Preferences.getString(Preferences.orangeMoneySettings))); - xenditModel.value = Xendit.fromJson(jsonDecode(Preferences.getString(Preferences.xenditSettings))); + midTransModel.value = MidTrans.fromJson( + jsonDecode(Preferences.getString(Preferences.midTransSettings)), + ); + orangeMoneyModel.value = OrangeMoney.fromJson( + json.decode(Preferences.getString(Preferences.orangeMoneySettings)), + ); + xenditModel.value = Xendit.fromJson( + jsonDecode(Preferences.getString(Preferences.xenditSettings)), + ); Stripe.publishableKey = stripeModel.value.clientpublishableKey.toString(); Stripe.merchantIdentifier = 'GoRide'; @@ -100,7 +122,9 @@ class WalletController extends GetxController { walletTransactionList.value = value; } }); - await FireStoreUtils.getUserProfile(FireStoreUtils.getCurrentUid()).then((value) { + await FireStoreUtils.getUserProfile(FireStoreUtils.getCurrentUid()).then(( + value, + ) { if (value != null) { userModel.value = value; } @@ -122,9 +146,14 @@ class WalletController extends GetxController { paymentStatus: "success", ); - await FireStoreUtils.setWalletTransaction(transactionModel).then((value) async { + await FireStoreUtils.setWalletTransaction(transactionModel).then(( + value, + ) async { if (value == true) { - await FireStoreUtils.updateUserWallet(amount: topUpAmountController.value.text, userId: FireStoreUtils.getCurrentUid()).then((value) { + await FireStoreUtils.updateUserWallet( + amount: topUpAmountController.value.text, + userId: FireStoreUtils.getCurrentUid(), + ).then((value) { getWalletTransaction(); Get.back(); }); @@ -138,20 +167,32 @@ class WalletController extends GetxController { Future stripeMakePayment({required String amount}) async { log(double.parse(amount).toStringAsFixed(0)); try { - Map? paymentIntentData = await createStripeIntent(amount: amount); + Map? paymentIntentData = await createStripeIntent( + amount: amount, + ); log("stripe Responce====>$paymentIntentData"); if (paymentIntentData!.containsKey("error")) { Get.back(); - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); } else { await Stripe.instance.initPaymentSheet( paymentSheetParameters: SetupPaymentSheetParameters( paymentIntentClientSecret: paymentIntentData['client_secret'], allowsDelayedPaymentMethods: false, - googlePay: const PaymentSheetGooglePay(merchantCountryCode: 'US', testEnv: true, currencyCode: "USD"), + googlePay: const PaymentSheetGooglePay( + merchantCountryCode: 'US', + testEnv: true, + currencyCode: "USD", + ), customFlow: true, style: ThemeMode.system, - appearance: PaymentSheetAppearance(colors: PaymentSheetAppearanceColors(primary: AppThemeData.primary300)), + appearance: PaymentSheetAppearance( + colors: PaymentSheetAppearanceColors( + primary: AppThemeData.primary300, + ), + ), merchantDisplayName: 'GoRide', ), ); @@ -197,7 +238,10 @@ class WalletController extends GetxController { var response = await http.post( Uri.parse('https://api.stripe.com/v1/payment_intents'), body: body, - headers: {'Authorization': 'Bearer $stripeSecret', 'Content-Type': 'application/x-www-form-urlencoded'}, + headers: { + 'Authorization': 'Bearer $stripeSecret', + 'Content-Type': 'application/x-www-form-urlencoded', + }, ); return jsonDecode(response.body); @@ -207,8 +251,14 @@ class WalletController extends GetxController { } //mercadoo - Future mercadoPagoMakePayment({required BuildContext context, required String amount}) async { - final headers = {'Authorization': 'Bearer ${mercadoPagoModel.value.accessToken}', 'Content-Type': 'application/json'}; + Future mercadoPagoMakePayment({ + required BuildContext context, + required String amount, + }) async { + final headers = { + 'Authorization': 'Bearer ${mercadoPagoModel.value.accessToken}', + 'Content-Type': 'application/json', + }; final body = jsonEncode({ "items": [ @@ -221,11 +271,20 @@ class WalletController extends GetxController { }, ], "payer": {"email": userModel.value.email}, - "back_urls": {"failure": "${Constant.globalUrl}payment/failure", "pending": "${Constant.globalUrl}payment/pending", "success": "${Constant.globalUrl}payment/success"}, - "auto_return": "approved", // Automatically return after payment is approved + "back_urls": { + "failure": "${Constant.globalUrl}payment/failure", + "pending": "${Constant.globalUrl}payment/pending", + "success": "${Constant.globalUrl}payment/success", + }, + "auto_return": + "approved", // Automatically return after payment is approved }); - final response = await http.post(Uri.parse("https://api.mercadopago.com/checkout/preferences"), headers: headers, body: body); + final response = await http.post( + Uri.parse("https://api.mercadopago.com/checkout/preferences"), + headers: headers, + body: body, + ); if (response.statusCode == 200 || response.statusCode == 201) { final data = jsonDecode(response.body); @@ -238,7 +297,9 @@ class WalletController extends GetxController { } }); } else { - ShowToastDialog.showToast("Something want wrong please contact administrator".tr); + ShowToastDialog.showToast( + "Something want wrong please contact administrator".tr, + ); print('Error creating preference: ${response.body}'); return null; } @@ -283,9 +344,12 @@ class WalletController extends GetxController { ///PayStack Payment Method Future payStackPayment(String totalAmount) async { - await PayStackURLGen.payStackURLGen(amount: (double.parse(totalAmount) * 100).toString(), currency: "ZAR", secretKey: payStackModel.value.secretKey.toString(), userModel: userModel.value).then(( - value, - ) async { + await PayStackURLGen.payStackURLGen( + amount: (double.parse(totalAmount) * 100).toString(), + currency: "ZAR", + secretKey: payStackModel.value.secretKey.toString(), + userModel: userModel.value, + ).then((value) async { if (value != null) { PayStackUrlModel payStackModel0 = value; Get.to( @@ -305,15 +369,23 @@ class WalletController extends GetxController { } }); } else { - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); } }); } //flutter wave Payment Method - Future flutterWaveInitiatePayment({required BuildContext context, required String amount}) async { + Future flutterWaveInitiatePayment({ + required BuildContext context, + required String amount, + }) async { final url = Uri.parse('https://api.flutterwave.com/v3/payments'); - final headers = {'Authorization': 'Bearer ${flutterWaveModel.value.secretKey}', 'Content-Type': 'application/json'}; + final headers = { + 'Authorization': 'Bearer ${flutterWaveModel.value.secretKey}', + 'Content-Type': 'application/json', + }; final body = jsonEncode({ "tx_ref": _ref, @@ -326,14 +398,19 @@ class WalletController extends GetxController { "phonenumber": userModel.value.phoneNumber, // Add a real phone number "name": userModel.value.fullName(), // Add a real customer name }, - "customizations": {"title": "Payment for Services", "description": "Payment for XYZ services"}, + "customizations": { + "title": "Payment for Services", + "description": "Payment for XYZ services", + }, }); final response = await http.post(url, headers: headers, body: body); if (response.statusCode == 200) { final data = jsonDecode(response.body); - Get.to(MercadoPagoScreen(initialURl: data['data']['link']))!.then((value) { + Get.to(MercadoPagoScreen(initialURl: data['data']['link']))!.then(( + value, + ) { if (value) { ShowToastDialog.showToast("Payment Successful!!".tr); walletTopUp(); @@ -362,8 +439,14 @@ class WalletController extends GetxController { // payFast void payFastPayment({required BuildContext context, required String amount}) { - PayStackURLGen.getPayHTML(payFastSettingData: payFastModel.value, amount: amount.toString(), userModel: userModel.value).then((String? value) async { - bool isDone = await Get.to(PayFastScreen(htmlData: value!, payFastSettingData: payFastModel.value)); + PayStackURLGen.getPayHTML( + payFastSettingData: payFastModel.value, + amount: amount.toString(), + userModel: userModel.value, + ).then((String? value) async { + bool isDone = await Get.to( + PayFastScreen(htmlData: value!, payFastSettingData: payFastModel.value), + ); if (isDone) { Get.back(); ShowToastDialog.showToast("Payment successfully".tr); @@ -388,7 +471,10 @@ class WalletController extends GetxController { 'description': 'wallet Topup', 'retry': {'enabled': true, 'max_count': 1}, 'send_sms_hash': true, - 'prefill': {'contact': userModel.value.phoneNumber, 'email': userModel.value.email}, + 'prefill': { + 'contact': userModel.value.phoneNumber, + 'email': userModel.value.email, + }, 'external': { 'wallets': ['paytm'], }, @@ -417,7 +503,10 @@ class WalletController extends GetxController { } //Midtrans payment - Future midtransMakePayment({required String amount, required BuildContext context}) async { + Future midtransMakePayment({ + required String amount, + required BuildContext context, + }) async { await createPaymentLink(amount: amount).then((url) { ShowToastDialog.closeLoader(); if (url != '') { @@ -435,15 +524,30 @@ class WalletController extends GetxController { Future createPaymentLink({required var amount}) async { var ordersId = const Uuid().v1(); - final url = Uri.parse(midTransModel.value.isSandbox! ? 'https://api.sandbox.midtrans.com/v1/payment-links' : 'https://api.midtrans.com/v1/payment-links'); + final url = Uri.parse( + midTransModel.value.isSandbox! + ? 'https://api.sandbox.midtrans.com/v1/payment-links' + : 'https://api.midtrans.com/v1/payment-links', + ); final response = await http.post( url, - headers: {'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': generateBasicAuthHeader(midTransModel.value.serverKey!)}, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': generateBasicAuthHeader( + midTransModel.value.serverKey!, + ), + }, body: jsonEncode({ - 'transaction_details': {'order_id': ordersId, 'gross_amount': double.parse(amount.toString()).toInt()}, + 'transaction_details': { + 'order_id': ordersId, + 'gross_amount': double.parse(amount.toString()).toInt(), + }, 'usage_limit': 2, - "callbacks": {"finish": "https://www.google.com?merchant_order_id=$ordersId"}, + "callbacks": { + "finish": "https://www.google.com?merchant_order_id=$ordersId", + }, }), ); @@ -451,7 +555,9 @@ class WalletController extends GetxController { final responseData = jsonDecode(response.body); return responseData['payment_url']; } else { - ShowToastDialog.showToast("something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "something went wrong, please contact admin.".tr, + ); return ''; } } @@ -468,13 +574,30 @@ class WalletController extends GetxController { static String orderId = ''; static String amount = ''; - Future orangeMakePayment({required String amount, required BuildContext context}) async { + Future orangeMakePayment({ + required String amount, + required BuildContext context, + }) async { reset(); var id = const Uuid().v4(); - var paymentURL = await fetchToken(context: context, orderId: id, amount: amount, currency: 'USD'); + var paymentURL = await fetchToken( + context: context, + orderId: id, + amount: amount, + currency: 'USD', + ); ShowToastDialog.closeLoader(); if (paymentURL.toString() != '') { - Get.to(() => OrangeMoneyScreen(initialURl: paymentURL, accessToken: accessToken, amount: amount, orangePay: orangeMoneyModel.value, orderId: orderId, payToken: payToken))!.then((value) { + Get.to( + () => OrangeMoneyScreen( + initialURl: paymentURL, + accessToken: accessToken, + amount: amount, + orangePay: orangeMoneyModel.value, + orderId: orderId, + payToken: payToken, + ), + )!.then((value) { if (value == true) { ShowToastDialog.showToast("Payment Successful!!".tr); walletTopUp(); @@ -485,13 +608,22 @@ class WalletController extends GetxController { } } - Future fetchToken({required String orderId, required String currency, required BuildContext context, required String amount}) async { + Future fetchToken({ + required String orderId, + required String currency, + required BuildContext context, + required String amount, + }) async { String apiUrl = 'https://api.orange.com/oauth/v3/token'; Map requestBody = {'grant_type': 'client_credentials'}; var response = await http.post( Uri.parse(apiUrl), - headers: {'Authorization': "Basic ${orangeMoneyModel.value.auth!}", 'Content-Type': 'application/x-www-form-urlencoded', 'Accept': 'application/json'}, + headers: { + 'Authorization': "Basic ${orangeMoneyModel.value.auth!}", + 'Content-Type': 'application/x-www-form-urlencoded', + 'Accept': 'application/json', + }, body: requestBody, ); @@ -499,17 +631,32 @@ class WalletController extends GetxController { Map responseData = jsonDecode(response.body); accessToken = responseData['access_token']; - return await webpayment(context: context, amountData: amount, currency: currency, orderIdData: orderId); + return await webpayment( + context: context, + amountData: amount, + currency: currency, + orderIdData: orderId, + ); } else { - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); return ''; } } - Future webpayment({required String orderIdData, required BuildContext context, required String currency, required String amountData}) async { + Future webpayment({ + required String orderIdData, + required BuildContext context, + required String currency, + required String amountData, + }) async { orderId = orderIdData; amount = amountData; - String apiUrl = orangeMoneyModel.value.isSandbox! == true ? 'https://api.orange.com/orange-money-webpay/dev/v1/webpayment' : 'https://api.orange.com/orange-money-webpay/cm/v1/webpayment'; + String apiUrl = + orangeMoneyModel.value.isSandbox! == true + ? 'https://api.orange.com/orange-money-webpay/dev/v1/webpayment' + : 'https://api.orange.com/orange-money-webpay/cm/v1/webpayment'; Map requestBody = { "merchant_key": orangeMoneyModel.value.merchantKey ?? '', "currency": orangeMoneyModel.value.isSandbox == true ? "OUV" : currency, @@ -524,7 +671,11 @@ class WalletController extends GetxController { var response = await http.post( Uri.parse(apiUrl), - headers: {'Authorization': 'Bearer $accessToken', 'Content-Type': 'application/json', 'Accept': 'application/json'}, + headers: { + 'Authorization': 'Bearer $accessToken', + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, body: json.encode(requestBody), ); print(response.statusCode); @@ -540,7 +691,9 @@ class WalletController extends GetxController { return ''; } } else { - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); return ''; } } @@ -557,7 +710,13 @@ class WalletController extends GetxController { await createXenditInvoice(amount: amount).then((model) { ShowToastDialog.closeLoader(); if (model.id != null) { - Get.to(() => XenditScreen(initialURl: model.invoiceUrl ?? '', transId: model.id ?? '', apiKey: xenditModel.value.apiKey!.toString()))!.then((value) { + Get.to( + () => XenditScreen( + initialURl: model.invoiceUrl ?? '', + transId: model.id ?? '', + apiKey: xenditModel.value.apiKey!.toString(), + ), + )!.then((value) { if (value == true) { ShowToastDialog.showToast("Payment Successful!!".tr); walletTopUp(); @@ -573,7 +732,9 @@ class WalletController extends GetxController { const url = 'https://api.xendit.co/v2/invoices'; var headers = { 'Content-Type': 'application/json', - 'Authorization': generateBasicAuthHeader(xenditModel.value.apiKey!.toString()), + 'Authorization': generateBasicAuthHeader( + xenditModel.value.apiKey!.toString(), + ), // 'Cookie': '__cf_bm=yERkrx3xDITyFGiou0bbKY1bi7xEwovHNwxV1vCNbVc-1724155511-1.0.1.1-jekyYQmPCwY6vIJ524K0V6_CEw6O.dAwOmQnHtwmaXO_MfTrdnmZMka0KZvjukQgXu5B.K_6FJm47SGOPeWviQ', }; @@ -586,7 +747,11 @@ class WalletController extends GetxController { }); try { - final response = await http.post(Uri.parse(url), headers: headers, body: body); + final response = await http.post( + Uri.parse(url), + headers: headers, + body: body, + ); if (response.statusCode == 200 || response.statusCode == 201) { XenditModel model = XenditModel.fromJson(jsonDecode(response.body)); diff --git a/lib/firebase_options.dart b/lib/firebase_options.dart index f77a606..cf4dd0d 100644 --- a/lib/firebase_options.dart +++ b/lib/firebase_options.dart @@ -1,7 +1,8 @@ // File generated by FlutterFire CLI. // ignore_for_file: type=lint import 'package:firebase_core/firebase_core.dart' show FirebaseOptions; -import 'package:flutter/foundation.dart' show defaultTargetPlatform, kIsWeb, TargetPlatform; +import 'package:flutter/foundation.dart' + show defaultTargetPlatform, kIsWeb, TargetPlatform; /// Default [FirebaseOptions] for use with your Firebase apps. /// @@ -18,7 +19,7 @@ class DefaultFirebaseOptions { if (kIsWeb) { throw UnsupportedError( 'DefaultFirebaseOptions have not been configured for web - ' - 'you can reconfigure this by running the FlutterFire CLI again.', + 'you can reconfigure this by running the FlutterFire CLI again.', ); } switch (defaultTargetPlatform) { @@ -29,17 +30,17 @@ class DefaultFirebaseOptions { case TargetPlatform.macOS: throw UnsupportedError( 'DefaultFirebaseOptions have not been configured for macos - ' - 'you can reconfigure this by running the FlutterFire CLI again.', + 'you can reconfigure this by running the FlutterFire CLI again.', ); case TargetPlatform.windows: throw UnsupportedError( 'DefaultFirebaseOptions have not been configured for windows - ' - 'you can reconfigure this by running the FlutterFire CLI again.', + 'you can reconfigure this by running the FlutterFire CLI again.', ); case TargetPlatform.linux: throw UnsupportedError( 'DefaultFirebaseOptions have not been configured for linux - ' - 'you can reconfigure this by running the FlutterFire CLI again.', + 'you can reconfigure this by running the FlutterFire CLI again.', ); default: throw UnsupportedError( @@ -50,7 +51,7 @@ class DefaultFirebaseOptions { static const FirebaseOptions android = FirebaseOptions( apiKey: 'AIzaSyALZhdy7Rw3jffipxsDvvz7_C_b4teVg1k', - appId: '1:893074789710:android:05002c15a64cf1e0c4ba1f', + appId: '1:893074789710:android:e932bc88da6665b3c4ba1f', messagingSenderId: '893074789710', projectId: 'fondexuzb', databaseURL: 'https://fondexuzb-default-rtdb.firebaseio.com', @@ -59,13 +60,13 @@ class DefaultFirebaseOptions { static const FirebaseOptions ios = FirebaseOptions( apiKey: 'AIzaSyD6Khoz4y93GCj3mOPi2FoluDipplH1av0', - appId: '1:893074789710:ios:510ebf9e4ebed6a8c4ba1f', + appId: '1:893074789710:ios:7dd456b65070f325c4ba1f', messagingSenderId: '893074789710', projectId: 'fondexuzb', databaseURL: 'https://fondexuzb-default-rtdb.firebaseio.com', storageBucket: 'fondexuzb.firebasestorage.app', - iosClientId: '893074789710-pv12m4nhe82a4ueg9sb2pgt42r0e5da3.apps.googleusercontent.com', - iosBundleId: 'com.emart.customer', + iosClientId: '893074789710-tgc677brhj8902uu2nv6k53otbhbnp1e.apps.googleusercontent.com', + iosBundleId: 'uz.felix.fondex.customer', ); } \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 8e1f5ea..7883818 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,19 +1,28 @@ +// ignore_for_file: depend_on_referenced_packages + +import 'package:firebase_core/firebase_core.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; import 'package:customer/screen_ui/splash_screen/splash_screen.dart'; import 'package:customer/service/localization_service.dart'; import 'package:customer/themes/app_them_data.dart'; import 'package:customer/themes/easy_loading_config.dart'; +import 'package:customer/utils/app_router.dart'; import 'package:customer/utils/preferences.dart'; -import 'package:firebase_core/firebase_core.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_easyloading/flutter_easyloading.dart'; -import 'package:get/get.dart'; import 'controllers/global_setting_controller.dart'; import 'controllers/theme_controller.dart'; import 'firebase_options.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); - await Firebase.initializeApp(name: 'default', options: DefaultFirebaseOptions.currentPlatform); + await LocalizationService.init(); + await Firebase.initializeApp( + name: 'default', + options: DefaultFirebaseOptions.currentPlatform, + ); await Preferences.initPref(); @@ -32,54 +41,88 @@ class MyApp extends StatelessWidget { Widget build(BuildContext context) { Get.put(ThemeController()); return Obx( - () => GetMaterialApp( - debugShowCheckedModeBanner: false, - builder: (context, child) { - return SafeArea(bottom: true, top: false, child: EasyLoading.init()(context, child)); - }, - translations: LocalizationService(), - locale: LocalizationService.locale, - fallbackLocale: LocalizationService.locale, - themeMode: themeController.themeMode, - theme: ThemeData( - scaffoldBackgroundColor: AppThemeData.surface, - textTheme: TextTheme(bodyLarge: TextStyle(color: AppThemeData.grey900)), - appBarTheme: AppBarTheme( - backgroundColor: AppThemeData.surface, - foregroundColor: AppThemeData.grey900, - iconTheme: IconThemeData(color: AppThemeData.grey900), - ), - bottomNavigationBarTheme: BottomNavigationBarThemeData( - backgroundColor: AppThemeData.surface, - selectedItemColor: AppThemeData.primary300, - unselectedItemColor: AppThemeData.grey600, - selectedLabelStyle: TextStyle(fontFamily: AppThemeData.bold, fontSize: 12), - unselectedLabelStyle: TextStyle(fontFamily: AppThemeData.bold, fontSize: 12), - type: BottomNavigationBarType.fixed, - ), - ), - darkTheme: ThemeData( - scaffoldBackgroundColor: AppThemeData.surfaceDark, - textTheme: TextTheme(bodyLarge: TextStyle(color: AppThemeData.greyDark900)), - appBarTheme: AppBarTheme( - backgroundColor: AppThemeData.surfaceDark, - foregroundColor: AppThemeData.greyDark900, - iconTheme: IconThemeData(color: AppThemeData.greyDark900), - ), - bottomNavigationBarTheme: BottomNavigationBarThemeData( - backgroundColor: AppThemeData.grey900, - selectedItemColor: AppThemeData.primary300, - unselectedItemColor: AppThemeData.grey300, - selectedLabelStyle: TextStyle(fontFamily: AppThemeData.bold, fontSize: 12), - unselectedLabelStyle: TextStyle(fontFamily: AppThemeData.bold, fontSize: 12), - type: BottomNavigationBarType.fixed, - ), - ), - home: GetBuilder( - init: GlobalSettingController(), - builder: (context) { - return const SplashScreen(); + () => ScreenUtilInit( + designSize: Size(375, 812), + minTextAdapt: true, + splitScreenMode: true, + child: GetMaterialApp( + translations: LocalizationService(), + locale: const Locale('uz', 'UZ'), // current locale + fallbackLocale: const Locale('en', 'US'), + supportedLocales: LocalizationService.supportedLocales, + localizationsDelegates: const [ + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + GlobalCupertinoLocalizations.delegate, + ], + navigatorKey: AppRouter.navigatorKey, + + debugShowCheckedModeBanner: false, + builder: (context, child) { + return SafeArea( + bottom: true, + top: false, + child: EasyLoading.init()(context, child), + ); }, + // fallbackLocale: LocalizationService.locale, + themeMode: themeController.themeMode, + theme: ThemeData( + scaffoldBackgroundColor: AppThemeData.surface, + textTheme: TextTheme( + bodyLarge: TextStyle(color: AppThemeData.grey900), + ), + appBarTheme: AppBarTheme( + backgroundColor: AppThemeData.surface, + foregroundColor: AppThemeData.grey900, + iconTheme: IconThemeData(color: AppThemeData.grey900), + ), + bottomNavigationBarTheme: BottomNavigationBarThemeData( + backgroundColor: AppThemeData.surface, + selectedItemColor: AppThemeData.primary300, + unselectedItemColor: AppThemeData.grey600, + selectedLabelStyle: TextStyle( + fontFamily: AppThemeData.bold, + fontSize: 12, + ), + unselectedLabelStyle: TextStyle( + fontFamily: AppThemeData.bold, + fontSize: 12, + ), + type: BottomNavigationBarType.fixed, + ), + ), + darkTheme: ThemeData( + scaffoldBackgroundColor: AppThemeData.surfaceDark, + textTheme: TextTheme( + bodyLarge: TextStyle(color: AppThemeData.greyDark900), + ), + appBarTheme: AppBarTheme( + backgroundColor: AppThemeData.surfaceDark, + foregroundColor: AppThemeData.greyDark900, + iconTheme: IconThemeData(color: AppThemeData.greyDark900), + ), + bottomNavigationBarTheme: BottomNavigationBarThemeData( + backgroundColor: AppThemeData.grey900, + selectedItemColor: AppThemeData.primary300, + unselectedItemColor: AppThemeData.grey300, + selectedLabelStyle: TextStyle( + fontFamily: AppThemeData.bold, + fontSize: 12, + ), + unselectedLabelStyle: TextStyle( + fontFamily: AppThemeData.bold, + fontSize: 12, + ), + type: BottomNavigationBarType.fixed, + ), + ), + home: GetBuilder( + init: GlobalSettingController(), + builder: (context) { + return const SplashScreen(); + }, + ), ), ), ); diff --git a/lib/payment/MercadoPagoScreen.dart b/lib/payment/MercadoPagoScreen.dart index ceb4282..c8ff28f 100644 --- a/lib/payment/MercadoPagoScreen.dart +++ b/lib/payment/MercadoPagoScreen.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'package:customer/constant/constant.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:webview_flutter/webview_flutter.dart'; @@ -35,10 +36,17 @@ class _MercadoPagoScreenState extends State { onWebResourceError: (WebResourceError error) {}, onNavigationRequest: (NavigationRequest navigation) async { debugPrint("--->2 ${navigation.url}"); - if (navigation.url.contains("${Constant.globalUrl}payment/success")) { + if (navigation.url.contains( + "${Constant.globalUrl}payment/success", + )) { Get.back(result: true); } - if (navigation.url.contains("${Constant.globalUrl}payment/failure") || navigation.url.contains("${Constant.globalUrl}payment/pending")) { + if (navigation.url.contains( + "${Constant.globalUrl}payment/failure", + ) || + navigation.url.contains( + "${Constant.globalUrl}payment/pending", + )) { Get.back(result: false); } return NavigationDecision.navigate; @@ -81,14 +89,20 @@ class _MercadoPagoScreenState extends State { content: SingleChildScrollView(child: Text("Cancel Payment?".tr)), actions: [ TextButton( - child: Text('Cancel'.tr, style: const TextStyle(color: Colors.red)), + child: Text( + 'Cancel'.tr, + style: const TextStyle(color: Colors.red), + ), onPressed: () { Navigator.of(context).pop(); Get.back(result: false); }, ), TextButton( - child: Text('Continue'.tr, style: const TextStyle(color: Colors.green)), + child: Text( + 'Continue'.tr, + style: const TextStyle(color: Colors.green), + ), onPressed: () { Navigator.of(context).pop(); }, diff --git a/lib/payment/PayFastScreen.dart b/lib/payment/PayFastScreen.dart index e4b570c..d8bc2b5 100644 --- a/lib/payment/PayFastScreen.dart +++ b/lib/payment/PayFastScreen.dart @@ -3,6 +3,7 @@ import 'dart:developer'; import 'package:customer/models/payment_model/pay_fast_model.dart'; + import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -12,7 +13,11 @@ class PayFastScreen extends StatefulWidget { final String htmlData; final PayFastModel payFastSettingData; - const PayFastScreen({super.key, required this.htmlData, required this.payFastSettingData}); + const PayFastScreen({ + super.key, + required this.htmlData, + required this.payFastSettingData, + }); @override State createState() => _PayFastScreenState(); @@ -44,9 +49,11 @@ class _PayFastScreenState extends State { } if (navigation.url == widget.payFastSettingData.returnUrl) { Get.back(result: true); - } else if (navigation.url == widget.payFastSettingData.notifyUrl) { + } else if (navigation.url == + widget.payFastSettingData.notifyUrl) { Get.back(result: false); - } else if (navigation.url == widget.payFastSettingData.cancelUrl) { + } else if (navigation.url == + widget.payFastSettingData.cancelUrl) { _showMyDialog(); } return NavigationDecision.navigate; @@ -94,7 +101,10 @@ class _PayFastScreenState extends State { }, ), TextButton( - child: Text('Continue Payment'.tr, style: TextStyle(color: Colors.green)), + child: Text( + 'Continue Payment'.tr, + style: TextStyle(color: Colors.green), + ), onPressed: () { Get.back(); }, diff --git a/lib/payment/midtrans_screen.dart b/lib/payment/midtrans_screen.dart index 9660953..2ca9411 100644 --- a/lib/payment/midtrans_screen.dart +++ b/lib/payment/midtrans_screen.dart @@ -47,7 +47,10 @@ class _MidtransScreenState extends State { Get.back(result: false); } } else { - String? orderId = Uri.parse(navigation.url).queryParameters['merchant_order_id']; + String? orderId = + Uri.parse( + navigation.url, + ).queryParameters['merchant_order_id']; if (orderId != null) { Get.back(result: true); } else { @@ -80,7 +83,16 @@ class _MidtransScreenState extends State { child: const Icon(Icons.arrow_back, color: Colors.white), ), ), - body: Stack(alignment: Alignment.center, children: [WebViewWidget(controller: controller), Visibility(visible: isLoading, child: const Center(child: CircularProgressIndicator()))]), + body: Stack( + alignment: Alignment.center, + children: [ + WebViewWidget(controller: controller), + Visibility( + visible: isLoading, + child: const Center(child: CircularProgressIndicator()), + ), + ], + ), ), ); } @@ -95,14 +107,20 @@ class _MidtransScreenState extends State { content: SingleChildScrollView(child: Text("Cancel Payment?".tr)), actions: [ TextButton( - child: Text('Cancel'.tr, style: const TextStyle(color: Colors.red)), + child: Text( + 'Cancel'.tr, + style: const TextStyle(color: Colors.red), + ), onPressed: () { Get.back(result: false); Get.back(result: false); }, ), TextButton( - child: Text('Continue'.tr, style: const TextStyle(color: Colors.green)), + child: Text( + 'Continue'.tr, + style: const TextStyle(color: Colors.green), + ), onPressed: () { Get.back(result: false); }, diff --git a/lib/payment/orangePayScreen.dart b/lib/payment/orangePayScreen.dart index d187080..dd71bda 100644 --- a/lib/payment/orangePayScreen.dart +++ b/lib/payment/orangePayScreen.dart @@ -3,6 +3,7 @@ import 'dart:async'; import 'dart:convert'; import 'package:customer/models/payment_model/orange_money.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:http/http.dart' as http; @@ -16,7 +17,15 @@ class OrangeMoneyScreen extends StatefulWidget { String orderId = ''; String amount = ''; - OrangeMoneyScreen({super.key, required this.initialURl, required this.orangePay, required this.accessToken, required this.payToken, required this.orderId, required this.amount}); + OrangeMoneyScreen({ + super.key, + required this.initialURl, + required this.orangePay, + required this.accessToken, + required this.payToken, + required this.orderId, + required this.amount, + }); @override State createState() => _OrangeMoneyScreenState(); @@ -40,7 +49,12 @@ class _OrangeMoneyScreenState extends State { timer = Timer.periodic(const Duration(seconds: 3), (Timer t) async { if (!mounted) return; - String status = await transactionStatus(accessToken: widget.accessToken, amount: widget.amount, orderId: widget.orderId, payToken: widget.payToken); + String status = await transactionStatus( + accessToken: widget.accessToken, + amount: widget.amount, + orderId: widget.orderId, + payToken: widget.payToken, + ); if (status == 'SUCCESS') { timer?.cancel(); @@ -71,15 +85,31 @@ class _OrangeMoneyScreenState extends State { ..loadRequest(Uri.parse(widget.initialURl)); } - Future transactionStatus({required String orderId, required String amount, required String payToken, required String accessToken}) async { - String apiUrl = widget.orangePay.isSandbox == true ? 'https://api.orange.com/orange-money-webpay/dev/v1/transactionstatus' : 'https://api.orange.com/orange-money-webpay/cm/v1/transactionstatus'; + Future transactionStatus({ + required String orderId, + required String amount, + required String payToken, + required String accessToken, + }) async { + String apiUrl = + widget.orangePay.isSandbox == true + ? 'https://api.orange.com/orange-money-webpay/dev/v1/transactionstatus' + : 'https://api.orange.com/orange-money-webpay/cm/v1/transactionstatus'; - Map requestBody = {"order_id": orderId, "amount": amount, "pay_token": payToken}; + Map requestBody = { + "order_id": orderId, + "amount": amount, + "pay_token": payToken, + }; try { var response = await http.post( Uri.parse(apiUrl), - headers: {'Authorization': 'Bearer $accessToken', 'Content-Type': 'application/json', 'Accept': 'application/json'}, + headers: { + 'Authorization': 'Bearer $accessToken', + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, body: json.encode(requestBody), ); @@ -106,10 +136,16 @@ class _OrangeMoneyScreenState extends State { child: Scaffold( appBar: AppBar( backgroundColor: Colors.black, - leading: IconButton(icon: const Icon(Icons.arrow_back, color: Colors.white), onPressed: _showCancelDialog), + leading: IconButton( + icon: const Icon(Icons.arrow_back, color: Colors.white), + onPressed: _showCancelDialog, + ), title: Text('Orange Money Payment'.tr), ), - body: isLoading ? const Center(child: CircularProgressIndicator()) : WebViewWidget(controller: controller), + body: + isLoading + ? const Center(child: CircularProgressIndicator()) + : WebViewWidget(controller: controller), ), ); } @@ -123,9 +159,12 @@ class _OrangeMoneyScreenState extends State { title: Text('Cancel Payment'.tr), content: Text('Are you sure you want to cancel this payment?'.tr), actions: [ - TextButton(child: Text('No', style: TextStyle(color: Colors.green)), onPressed: () => Get.back()), TextButton( - child: Text('Yes'.tr, style: TextStyle(color: Colors.red)), + child: Text('No', style: TextStyle(color: Colors.green)), + onPressed: () => Get.back(), + ), + TextButton( + child: Text('Yes'.tr, style: TextStyle(color: Colors.red)), onPressed: () { timer?.cancel(); Get.back(); // close dialog @@ -151,8 +190,7 @@ class _OrangeMoneyScreenState extends State { // import 'dart:convert'; // import 'package:customer/models/payment_model/orange_money.dart'; // import 'package:flutter/material.dart'; -// import 'package:get/get.dart'; -// import 'package:http/http.dart' as http; +// import 'package:get/get.dart';// import 'package:http/http.dart' as http; // import 'package:webview_flutter/webview_flutter.dart'; // // class OrangeMoneyScreen extends StatefulWidget { diff --git a/lib/payment/paystack/pay_stack_screen.dart b/lib/payment/paystack/pay_stack_screen.dart index 3ade273..07786cc 100644 --- a/lib/payment/paystack/pay_stack_screen.dart +++ b/lib/payment/paystack/pay_stack_screen.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:customer/payment/paystack/paystack_url_genrater.dart'; import 'package:customer/themes/app_them_data.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:webview_flutter/webview_flutter.dart'; @@ -13,7 +14,14 @@ class PayStackScreen extends StatefulWidget { final String secretKey; final String callBackUrl; - const PayStackScreen({super.key, required this.initialURl, required this.reference, required this.amount, required this.secretKey, required this.callBackUrl}); + const PayStackScreen({ + super.key, + required this.initialURl, + required this.reference, + required this.amount, + required this.secretKey, + required this.callBackUrl, + }); @override State createState() => _PayStackScreenState(); @@ -29,37 +37,52 @@ class _PayStackScreenState extends State { } void initController() { - controller = WebViewController() - ..setJavaScriptMode(JavaScriptMode.unrestricted) - ..setBackgroundColor(const Color(0x00000000)) - ..setNavigationDelegate( - NavigationDelegate( - onProgress: (int progress) { - // Update loading bar. - }, - onPageStarted: (String url) {}, - onPageFinished: (String url) {}, - onWebResourceError: (WebResourceError error) {}, - onNavigationRequest: (NavigationRequest navigation) async { - debugPrint("--->2${navigation.url}"); - debugPrint("--->2" "${widget.callBackUrl}?trxref=${widget.reference}&reference=${widget.reference}"); - if (navigation.url == 'https://foodieweb.siswebapp.com/success?trxref=${widget.reference}&reference=${widget.reference}' || - navigation.url == '${widget.callBackUrl}?trxref=${widget.reference}&reference=${widget.reference}') { - final isDone = await PayStackURLGen.verifyTransaction(secretKey: widget.secretKey, reference: widget.reference, amount: widget.amount); - Get.back(result: isDone); - } - if ((navigation.url == '${widget.callBackUrl}?trxref=${widget.reference}&reference=${widget.reference}') || - (navigation.url == "https://hello.pstk.xyz/callback") || - (navigation.url == 'https://standard.paystack.co/close') || - (navigation.url == 'https://talazo.app/login')) { - final isDone = await PayStackURLGen.verifyTransaction(secretKey: widget.secretKey, reference: widget.reference, amount: widget.amount); - Get.back(result: isDone); - } - return NavigationDecision.navigate; - }, - ), - ) - ..loadRequest(Uri.parse(widget.initialURl)); + controller = + WebViewController() + ..setJavaScriptMode(JavaScriptMode.unrestricted) + ..setBackgroundColor(const Color(0x00000000)) + ..setNavigationDelegate( + NavigationDelegate( + onProgress: (int progress) { + // Update loading bar. + }, + onPageStarted: (String url) {}, + onPageFinished: (String url) {}, + onWebResourceError: (WebResourceError error) {}, + onNavigationRequest: (NavigationRequest navigation) async { + debugPrint("--->2${navigation.url}"); + debugPrint( + "--->2" + "${widget.callBackUrl}?trxref=${widget.reference}&reference=${widget.reference}", + ); + if (navigation.url == + 'https://foodieweb.siswebapp.com/success?trxref=${widget.reference}&reference=${widget.reference}' || + navigation.url == + '${widget.callBackUrl}?trxref=${widget.reference}&reference=${widget.reference}') { + final isDone = await PayStackURLGen.verifyTransaction( + secretKey: widget.secretKey, + reference: widget.reference, + amount: widget.amount, + ); + Get.back(result: isDone); + } + if ((navigation.url == + '${widget.callBackUrl}?trxref=${widget.reference}&reference=${widget.reference}') || + (navigation.url == "https://hello.pstk.xyz/callback") || + (navigation.url == 'https://standard.paystack.co/close') || + (navigation.url == 'https://talazo.app/login')) { + final isDone = await PayStackURLGen.verifyTransaction( + secretKey: widget.secretKey, + reference: widget.reference, + amount: widget.amount, + ); + Get.back(result: isDone); + } + return NavigationDecision.navigate; + }, + ), + ) + ..loadRequest(Uri.parse(widget.initialURl)); } @override @@ -71,17 +94,16 @@ class _PayStackScreenState extends State { }, child: Scaffold( appBar: AppBar( - backgroundColor: AppThemeData.grey50, - title: Text("Payment".tr), - centerTitle: false, - leading: GestureDetector( - onTap: () { - _showMyDialog(); - }, - child: const Icon( - Icons.arrow_back, - ), - )), + backgroundColor: AppThemeData.grey50, + title: Text("Payment".tr), + centerTitle: false, + leading: GestureDetector( + onTap: () { + _showMyDialog(); + }, + child: const Icon(Icons.arrow_back), + ), + ), body: WebViewWidget(controller: controller), ), ); @@ -94,15 +116,10 @@ class _PayStackScreenState extends State { builder: (BuildContext context) { return AlertDialog( title: const Text('Cancel Payment'), - content: const SingleChildScrollView( - child: Text("cancelPayment?"), - ), + content: const SingleChildScrollView(child: Text("cancelPayment?")), actions: [ TextButton( - child: const Text( - 'Cancel', - style: TextStyle(color: Colors.red), - ), + child: const Text('Cancel', style: TextStyle(color: Colors.red)), onPressed: () { Navigator.of(context).pop(); Navigator.of(context).pop(false); diff --git a/lib/payment/xenditScreen.dart b/lib/payment/xenditScreen.dart index a494ab7..84b058c 100644 --- a/lib/payment/xenditScreen.dart +++ b/lib/payment/xenditScreen.dart @@ -3,6 +3,7 @@ import 'dart:convert'; import 'dart:developer'; import 'package:customer/payment/xenditModel.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:http/http.dart' as http; @@ -13,7 +14,12 @@ class XenditScreen extends StatefulWidget { final String transId; final String apiKey; - const XenditScreen({super.key, required this.initialURl, required this.transId, required this.apiKey}); + const XenditScreen({ + super.key, + required this.initialURl, + required this.transId, + required this.apiKey, + }); @override State createState() => _XenditScreenState(); @@ -101,7 +107,16 @@ class _XenditScreenState extends State { child: const Icon(Icons.arrow_back, color: Colors.white), ), ), - body: Stack(alignment: Alignment.center, children: [WebViewWidget(controller: controller), Visibility(visible: isLoading, child: const Center(child: CircularProgressIndicator()))]), + body: Stack( + alignment: Alignment.center, + children: [ + WebViewWidget(controller: controller), + Visibility( + visible: isLoading, + child: const Center(child: CircularProgressIndicator()), + ), + ], + ), ), ); } @@ -116,14 +131,20 @@ class _XenditScreenState extends State { content: SingleChildScrollView(child: Text("Cancel Payment?".tr)), actions: [ TextButton( - child: Text('Cancel'.tr, style: const TextStyle(color: Colors.red)), + child: Text( + 'Cancel'.tr, + style: const TextStyle(color: Colors.red), + ), onPressed: () { Navigator.of(context).pop(false); Navigator.of(context).pop(false); }, ), TextButton( - child: Text('Continue'.tr, style: const TextStyle(color: Colors.green)), + child: Text( + 'Continue'.tr, + style: const TextStyle(color: Colors.green), + ), onPressed: () { Navigator.of(context).pop(false); }, @@ -139,7 +160,10 @@ class _XenditScreenState extends State { var url = Uri.parse('https://api.xendit.co/v2/invoices/$paymentId'); // Headers - var headers = {'Content-Type': 'application/json', 'Authorization': generateBasicAuthHeader(widget.apiKey.toString())}; + var headers = { + 'Content-Type': 'application/json', + 'Authorization': generateBasicAuthHeader(widget.apiKey.toString()), + }; // Making the POST request var response = await http.get(url, headers: headers); diff --git a/lib/screen_ui/auth_screens/forgot_password_screen.dart b/lib/screen_ui/auth_screens/forgot_password_screen.dart index dd3e5de..24c08a0 100644 --- a/lib/screen_ui/auth_screens/forgot_password_screen.dart +++ b/lib/screen_ui/auth_screens/forgot_password_screen.dart @@ -1,5 +1,9 @@ +import 'package:customer/constant/const_texts.dart'; +import 'package:customer/utils/app_router.dart'; + import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import '../../controllers/forgot_password_controller.dart'; import '../../controllers/theme_controller.dart'; @@ -26,12 +30,34 @@ class ForgotPasswordScreen extends StatelessWidget { actions: [ TextButton( onPressed: () {}, - style: TextButton.styleFrom(padding: const EdgeInsets.symmetric(horizontal: 12), minimumSize: const Size(0, 40), tapTargetSize: MaterialTapTargetSize.shrinkWrap), + style: TextButton.styleFrom( + padding: const EdgeInsets.symmetric(horizontal: 12), + minimumSize: const Size(0, 40), + tapTargetSize: MaterialTapTargetSize.shrinkWrap, + ), child: Row( mainAxisSize: MainAxisSize.min, children: [ - Text("Skip".tr, style: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500)), - Padding(padding: const EdgeInsets.only(top: 2), child: Icon(Icons.arrow_forward_ios, size: 16, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500)), + Text( + ConstTexts.skip.tr, + style: AppThemeData.mediumTextStyle( + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), + ), + Padding( + padding: const EdgeInsets.only(top: 2), + child: Icon( + Icons.arrow_forward_ios, + size: 16, + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), + ), ], ), ), @@ -49,17 +75,34 @@ class ForgotPasswordScreen extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "Enter your registered email to receive a reset link.".tr, - style: AppThemeData.boldTextStyle(fontSize: 24, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + ConstTexts.enterYourregisteredEmail.tr, + style: AppThemeData.boldTextStyle( + fontSize: 24, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), const SizedBox(height: 24), - TextFieldWidget(title: "Email Address*".tr, hintText: "jerome014@gmail.com", controller: controller.emailEditingController.value), + TextFieldWidget( + title: ConstTexts.emailAddress.tr, + hintText: "abdusalom@gmail.com", + controller: controller.emailEditingController.value, + ), const SizedBox(height: 30), RoundedButtonFill( - title: "Send Link".tr, + borderRadius: 10.r, + title: ConstTexts.sendLink.tr, onPress: controller.forgotPassword, - color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, - textColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + textColor: + isDark + ? AppThemeData.surfaceDark + : AppThemeData.surface, ), ], ), @@ -70,16 +113,25 @@ class ForgotPasswordScreen extends StatelessWidget { child: Center( child: Text.rich( TextSpan( - text: "Remember Password?".tr, - style: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800), + text: ConstTexts.rememberPassword.tr, + style: AppThemeData.mediumTextStyle( + color: + isDark + ? AppThemeData.greyDark800 + : AppThemeData.grey800, + ), children: [ TextSpan( - text: "Log in".tr, - style: AppThemeData.mediumTextStyle(color: AppThemeData.ecommerce300, decoration: TextDecoration.underline, decorationColor: AppThemeData.ecommerce300), + text: ConstTexts.login.tr, + style: AppThemeData.mediumTextStyle( + color: AppThemeData.ecommerce300, + decoration: TextDecoration.underline, + decorationColor: AppThemeData.ecommerce300, + ), recognizer: TapGestureRecognizer() ..onTap = () { - Get.offAll(() => const LoginScreen()); + Get.offAll(LoginScreen()); }, ), ], diff --git a/lib/screen_ui/auth_screens/login_screen.dart b/lib/screen_ui/auth_screens/login_screen.dart index 1b311cc..c20f8b9 100644 --- a/lib/screen_ui/auth_screens/login_screen.dart +++ b/lib/screen_ui/auth_screens/login_screen.dart @@ -1,9 +1,13 @@ import 'dart:io'; +import 'package:customer/constant/const_texts.dart'; import 'package:customer/screen_ui/auth_screens/sign_up_screen.dart'; import 'package:customer/screen_ui/location_enable_screens/location_permission_screen.dart'; +import 'package:customer/utils/app_router.dart'; + import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_svg/svg.dart'; import '../../controllers/login_controller.dart'; import '../../controllers/theme_controller.dart'; @@ -34,8 +38,23 @@ class LoginScreen extends StatelessWidget { }, child: Row( children: [ - Text("Skip".tr, style: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), - Icon(Icons.arrow_forward_ios, size: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + Text( + ConstTexts.skip.tr, + style: AppThemeData.mediumTextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + Icon( + Icons.arrow_forward_ios, + size: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ], ), ), @@ -54,15 +73,26 @@ class LoginScreen extends StatelessWidget { children: [ const SizedBox(height: 20), Text( - "Log in to explore your all in one vendor app favourites and shop effortlessly.".tr, - style: AppThemeData.boldTextStyle(fontSize: 24, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + ConstTexts.loginToExplore.tr, + style: AppThemeData.boldTextStyle( + fontSize: 24, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), const SizedBox(height: 24), - TextFieldWidget(title: "Email Address*".tr, hintText: "jerome014@gmail.com", controller: controller.emailController.value, focusNode: controller.emailFocusNode), + TextFieldWidget( + title: ConstTexts.emailAddress.tr, + hintText: "abdusalom@gmail.com", + controller: controller.emailController.value, + focusNode: controller.emailFocusNode, + ), const SizedBox(height: 15), TextFieldWidget( - title: "Password*".tr, - hintText: "Enter password".tr, + title: ConstTexts.password.tr, + hintText: ConstTexts.enterPassword.tr, controller: controller.passwordController.value, obscureText: controller.passwordVisible.value, focusNode: controller.passwordFocusNode, @@ -70,60 +100,137 @@ class LoginScreen extends StatelessWidget { padding: const EdgeInsets.all(12), child: InkWell( onTap: () { - controller.passwordVisible.value = !controller.passwordVisible.value; + controller.passwordVisible.value = + !controller.passwordVisible.value; }, child: controller.passwordVisible.value - ? SvgPicture.asset("assets/icons/ic_password_show.svg", colorFilter: ColorFilter.mode(isDark ? AppThemeData.grey300 : AppThemeData.grey600, BlendMode.srcIn)) - : SvgPicture.asset("assets/icons/ic_password_close.svg", colorFilter: ColorFilter.mode(isDark ? AppThemeData.grey300 : AppThemeData.grey600, BlendMode.srcIn)), + ? SvgPicture.asset( + "assets/icons/ic_password_show.svg", + colorFilter: ColorFilter.mode( + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + BlendMode.srcIn, + ), + ) + : SvgPicture.asset( + "assets/icons/ic_password_close.svg", + colorFilter: ColorFilter.mode( + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + BlendMode.srcIn, + ), + ), ), ), ), Align( alignment: Alignment.centerRight, child: TextButton( - onPressed: () => Get.to(() => const ForgotPasswordScreen()), - child: Text("Forgot Password".tr, style: AppThemeData.semiBoldTextStyle(color: AppThemeData.info400)), + onPressed: + () => Get.to( + () => const ForgotPasswordScreen(), + ), + child: Text( + ConstTexts.forgotPassword.tr, + style: AppThemeData.semiBoldTextStyle( + color: AppThemeData.info400, + ), + ), ), ), const SizedBox(height: 20), RoundedButtonFill( - title: "Log in".tr, + borderRadius: 10.r, + title: ConstTexts.login.tr, onPress: controller.loginWithEmail, - color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, - textColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + textColor: + isDark + ? AppThemeData.surfaceDark + : AppThemeData.surface, ), const SizedBox(height: 25), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Container(width: 52, height: 1, color: isDark ? AppThemeData.greyDark400 : AppThemeData.grey300), + Container( + width: 52, + height: 1, + color: + isDark + ? AppThemeData.greyDark400 + : AppThemeData.grey300, + ), const SizedBox(width: 15), - Text("or continue with".tr, style: AppThemeData.regularTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900.withOpacity(0.6))), + Text( + ConstTexts.orContinueWith.tr, + style: AppThemeData.regularTextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900.withValues( + alpha: 0.6, + ), + ), + ), const SizedBox(width: 15), - Container(width: 52, height: 1, color: isDark ? AppThemeData.greyDark400 : AppThemeData.grey300), + Container( + width: 52, + height: 1, + color: + isDark + ? AppThemeData.greyDark400 + : AppThemeData.grey300, + ), ], ), const SizedBox(height: 25), RoundedButtonFill( - title: "Mobile number".tr, - onPress: () => Get.to(() => const MobileLoginScreen()), + borderRadius: 10.r, + title: ConstTexts.mobileNumber.tr, + onPress: + () => Get.to(() => const MobileLoginScreen()), isRight: false, isCenter: true, - icon: Icon(Icons.mobile_friendly_outlined, size: 20, color: isDark ? AppThemeData.greyDark900 : null), + icon: Icon( + Icons.mobile_friendly_outlined, + size: 20, + color: isDark ? AppThemeData.greyDark900 : null, + ), //Image.asset(AppAssets.icMessage, width: 20, height: 18, color: isDark ? AppThemeData.greyDark900 : null), - color: isDark ? AppThemeData.greyDark400 : AppThemeData.grey300, - textColor: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + color: + isDark + ? AppThemeData.greyDark400 + : AppThemeData.grey300, + textColor: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, ), const SizedBox(height: 12), Row( children: [ Expanded( child: RoundedButtonFill( - title: "with Google".tr, - textColor: isDark ? AppThemeData.grey100 : AppThemeData.grey900, - color: isDark ? AppThemeData.grey900 : AppThemeData.grey100, - icon: SvgPicture.asset("assets/icons/ic_google.svg"), + borderRadius: 10.r, + title: ConstTexts.withGoogle.tr, + textColor: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey900, + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey100, + icon: SvgPicture.asset( + "assets/icons/ic_google.svg", + ), isRight: false, isCenter: true, onPress: () async { @@ -135,11 +242,20 @@ class LoginScreen extends StatelessWidget { Platform.isIOS ? Expanded( child: RoundedButtonFill( - title: "with Apple".tr, + borderRadius: 10.r, + title: ConstTexts.withApple.tr, isCenter: true, - textColor: isDark ? AppThemeData.grey100 : AppThemeData.grey900, - color: isDark ? AppThemeData.grey900 : AppThemeData.grey100, - icon: SvgPicture.asset("assets/icons/ic_apple.svg"), + textColor: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey900, + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey100, + icon: SvgPicture.asset( + "assets/icons/ic_apple.svg", + ), isRight: false, onPress: () async { controller.loginWithApple(); @@ -158,16 +274,24 @@ class LoginScreen extends StatelessWidget { child: Center( child: Text.rich( TextSpan( - text: "Didn't have an account?".tr, - style: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + text: "${ConstTexts.dontHaveAccount.tr} ", + style: AppThemeData.mediumTextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), children: [ TextSpan( - text: "Sign up".tr, - style: AppThemeData.mediumTextStyle(color: AppThemeData.ecommerce300, decoration: TextDecoration.underline), + text: ConstTexts.signUp.tr, + style: AppThemeData.mediumTextStyle( + color: AppThemeData.ecommerce300, + decoration: TextDecoration.underline, + ), recognizer: TapGestureRecognizer() ..onTap = () { - Get.offAll(() => const SignUpScreen()); + Get.offAll(SignUpScreen()); }, ), ], diff --git a/lib/screen_ui/auth_screens/mobile_login_screen.dart b/lib/screen_ui/auth_screens/mobile_login_screen.dart index d5dd719..bb60041 100644 --- a/lib/screen_ui/auth_screens/mobile_login_screen.dart +++ b/lib/screen_ui/auth_screens/mobile_login_screen.dart @@ -1,9 +1,13 @@ import 'package:country_code_picker/country_code_picker.dart'; +import 'package:customer/constant/const_texts.dart'; import 'package:customer/screen_ui/auth_screens/sign_up_screen.dart'; import 'package:customer/screen_ui/location_enable_screens/location_permission_screen.dart'; +import 'package:customer/utils/app_router.dart'; + import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import '../../constant/assets.dart'; import '../../constant/constant.dart'; @@ -29,7 +33,11 @@ class MobileLoginScreen extends StatelessWidget { elevation: 0, automaticallyImplyLeading: false, leading: IconButton( - icon: Icon(Icons.arrow_back, size: 20, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500), + icon: Icon( + Icons.arrow_back, + size: 20, + color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500, + ), onPressed: () { Get.back(); }, @@ -39,12 +47,34 @@ class MobileLoginScreen extends StatelessWidget { onPressed: () { Get.to(() => LocationPermissionScreen()); }, - style: TextButton.styleFrom(padding: const EdgeInsets.symmetric(horizontal: 12), minimumSize: const Size(0, 40), tapTargetSize: MaterialTapTargetSize.shrinkWrap), + style: TextButton.styleFrom( + padding: const EdgeInsets.symmetric(horizontal: 12), + minimumSize: const Size(0, 40), + tapTargetSize: MaterialTapTargetSize.shrinkWrap, + ), child: Row( mainAxisSize: MainAxisSize.min, children: [ - Text("Skip".tr, style: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500)), - Padding(padding: const EdgeInsets.only(top: 2, left: 4), child: Icon(Icons.arrow_forward_ios, size: 16, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500)), + Text( + ConstTexts.skip.tr, + style: AppThemeData.mediumTextStyle( + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), + ), + Padding( + padding: const EdgeInsets.only(top: 2, left: 4), + child: Icon( + Icons.arrow_forward_ios, + size: 16, + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), + ), ], ), ), @@ -62,67 +92,162 @@ class MobileLoginScreen extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "Use your mobile number to Log in easily and securely.".tr, - style: AppThemeData.boldTextStyle(fontSize: 24, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + ConstTexts.useYourMobileNumber.tr, + style: AppThemeData.boldTextStyle( + fontSize: 24, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), const SizedBox(height: 25), TextFieldWidget( - title: "Mobile Number*".tr, - hintText: "Enter Mobile number".tr, + title: ConstTexts.mobileNumber.tr, + hintText: ConstTexts.enterMobileNumber.tr, controller: controller.mobileController.value, - textInputType: const TextInputType.numberWithOptions(signed: true, decimal: true), + textInputType: + const TextInputType.numberWithOptions( + signed: true, + decimal: true, + ), textInputAction: TextInputAction.done, - inputFormatters: [FilteringTextInputFormatter.allow(RegExp('[0-9]')), LengthLimitingTextInputFormatter(10)], + inputFormatters: [ + FilteringTextInputFormatter.allow( + RegExp('[0-9]'), + ), + LengthLimitingTextInputFormatter(10), + ], prefix: Row( mainAxisSize: MainAxisSize.min, children: [ CountryCodePicker( onChanged: (value) { - controller.countryCodeController.value.text = value.dialCode ?? Constant.defaultCountryCode; + controller + .countryCodeController + .value + .text = value.dialCode ?? + Constant.defaultCountryCode; }, - initialSelection: controller.countryCodeController.value.text.isNotEmpty ? controller.countryCodeController.value.text : Constant.defaultCountryCode, + initialSelection: + controller + .countryCodeController + .value + .text + .isNotEmpty + ? controller + .countryCodeController + .value + .text + : Constant.defaultCountryCode, showCountryOnly: false, showOnlyCountryWhenClosed: false, alignLeft: false, - textStyle: TextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : Colors.black), - dialogTextStyle: TextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), - searchStyle: TextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), - dialogBackgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + textStyle: TextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : Colors.black, + ), + dialogTextStyle: TextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + searchStyle: TextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + dialogBackgroundColor: + isDark + ? AppThemeData.surfaceDark + : AppThemeData.surface, padding: EdgeInsets.zero, ), // const Icon(Icons.keyboard_arrow_down_rounded, size: 24, color: AppThemeData.grey400), - Container(height: 24, width: 1, color: AppThemeData.grey400), + Container( + height: 24, + width: 1, + color: AppThemeData.grey400, + ), const SizedBox(width: 4), ], ), ), const SizedBox(height: 30), RoundedButtonFill( - title: "Send Code".tr, + borderRadius: 10.r, + title: ConstTexts.sendCode.tr, onPress: controller.sendOtp, - color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, - textColor: isDark ? AppThemeData.surfaceDark : Colors.white, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + textColor: + isDark + ? AppThemeData.surfaceDark + : Colors.white, ), const SizedBox(height: 25), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Container(width: 52, height: 1, color: isDark ? AppThemeData.greyDark300 : AppThemeData.grey300), + Container( + width: 52, + height: 1, + color: + isDark + ? AppThemeData.greyDark300 + : AppThemeData.grey300, + ), const SizedBox(width: 15), - Text("or continue with".tr, style: AppThemeData.regularTextStyle(color: isDark ? AppThemeData.greyDark400 : AppThemeData.grey400)), + Text( + ConstTexts.orContinueWith.tr, + style: AppThemeData.regularTextStyle( + color: + isDark + ? AppThemeData.greyDark400 + : AppThemeData.grey400, + ), + ), const SizedBox(width: 15), - Container(width: 52, height: 1, color: isDark ? AppThemeData.greyDark400 : AppThemeData.grey400), + Container( + width: 52, + height: 1, + color: + isDark + ? AppThemeData.greyDark400 + : AppThemeData.grey400, + ), ], ), const SizedBox(height: 25), RoundedButtonFill( - title: "Email address".tr, + borderRadius: 10.r, + title: ConstTexts.emailAddress.tr, onPress: () => Get.to(() => const SignUpScreen()), isRight: false, isCenter: true, - icon: Image.asset(AppAssets.icMessage, width: 20, height: 18, color: isDark ? AppThemeData.greyDark900 : null), - color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200, - textColor: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + icon: Image.asset( + AppAssets.icMessage, + width: 20, + height: 18, + color: isDark ? AppThemeData.greyDark900 : null, + ), + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + textColor: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, ), ], ), @@ -133,11 +258,16 @@ class MobileLoginScreen extends StatelessWidget { child: Center( child: Text.rich( TextSpan( - text: "Didn't have an account?".tr, - style: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800), + text: "${ConstTexts.dontHaveAccount.tr} ", + style: AppThemeData.mediumTextStyle( + color: + isDark + ? AppThemeData.greyDark800 + : AppThemeData.grey800, + ), children: [ TextSpan( - text: "Sign up".tr, + text: ConstTexts.signUp.tr, style: AppThemeData.mediumTextStyle( color: AppThemeData.ecommerce300, decoration: TextDecoration.underline, @@ -147,7 +277,7 @@ class MobileLoginScreen extends StatelessWidget { recognizer: TapGestureRecognizer() ..onTap = () { - Get.offAll(() => const SignUpScreen()); + Get.offAll(SignUpScreen()); }, ), ], diff --git a/lib/screen_ui/auth_screens/otp_verification_screen.dart b/lib/screen_ui/auth_screens/otp_verification_screen.dart index 07857fc..54d4231 100644 --- a/lib/screen_ui/auth_screens/otp_verification_screen.dart +++ b/lib/screen_ui/auth_screens/otp_verification_screen.dart @@ -1,6 +1,10 @@ +import 'package:customer/constant/const_texts.dart'; import 'package:customer/screen_ui/auth_screens/sign_up_screen.dart'; +import 'package:customer/utils/app_router.dart'; + import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:pin_code_fields/pin_code_fields.dart'; import '../../constant/assets.dart'; @@ -25,7 +29,11 @@ class OtpVerificationScreen extends StatelessWidget { elevation: 0, automaticallyImplyLeading: false, leading: IconButton( - icon: Icon(Icons.arrow_back, size: 20, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500), + icon: Icon( + Icons.arrow_back, + size: 20, + color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500, + ), onPressed: () { Get.back(); }, @@ -35,14 +43,33 @@ class OtpVerificationScreen extends StatelessWidget { onPressed: () { // Handle skip action }, - style: TextButton.styleFrom(padding: const EdgeInsets.symmetric(horizontal: 12), minimumSize: const Size(0, 40), tapTargetSize: MaterialTapTargetSize.shrinkWrap), + style: TextButton.styleFrom( + padding: const EdgeInsets.symmetric(horizontal: 12), + minimumSize: const Size(0, 40), + tapTargetSize: MaterialTapTargetSize.shrinkWrap, + ), child: Row( mainAxisSize: MainAxisSize.min, children: [ - Text("Skip".tr, style: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500)), + Text( + ConstTexts.skip.tr, + style: AppThemeData.mediumTextStyle( + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), + ), Padding( padding: const EdgeInsets.only(top: 2, left: 4), - child: Icon(Icons.arrow_forward_ios, size: 16, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500), + child: Icon( + Icons.arrow_forward_ios, + size: 16, + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), ), ], ), @@ -61,8 +88,14 @@ class OtpVerificationScreen extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "${"Enter the OTP sent to your mobile".tr} ${controller.countryCode} ${controller.maskPhoneNumber(controller.phoneNumber.value)}", - style: AppThemeData.boldTextStyle(fontSize: 24, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + "${ConstTexts.enterOtpSent.tr} ${controller.countryCode} ${controller.maskPhoneNumber(controller.phoneNumber.value)}", + style: AppThemeData.boldTextStyle( + fontSize: 24, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), const SizedBox(height: 30), @@ -73,20 +106,41 @@ class OtpVerificationScreen extends StatelessWidget { length: 6, controller: controller.otpController.value, keyboardType: TextInputType.number, - cursorColor: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500, + cursorColor: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, enablePinAutofill: true, hintCharacter: "-", - textStyle: AppThemeData.semiBoldTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800), + textStyle: AppThemeData.semiBoldTextStyle( + fontSize: 18, + color: + isDark + ? AppThemeData.greyDark800 + : AppThemeData.grey800, + ), pinTheme: PinTheme( shape: PinCodeFieldShape.box, borderRadius: BorderRadius.circular(12), fieldHeight: 54, fieldWidth: 51, - inactiveColor: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200, + inactiveColor: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, inactiveFillColor: Colors.transparent, - selectedColor: isDark ? AppThemeData.greyDark400 : AppThemeData.grey400, - selectedFillColor: isDark ? AppThemeData.surfaceDark : AppThemeData.grey50, - activeColor: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200, + selectedColor: + isDark + ? AppThemeData.greyDark400 + : AppThemeData.grey400, + selectedFillColor: + isDark + ? AppThemeData.surfaceDark + : AppThemeData.grey50, + activeColor: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, activeFillColor: Colors.transparent, errorBorderColor: AppThemeData.danger300, disabledColor: Colors.transparent, @@ -101,13 +155,23 @@ class OtpVerificationScreen extends StatelessWidget { Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Image.asset(AppAssets.icArrowsClockwise, height: 20, width: 20), + Image.asset( + AppAssets.icArrowsClockwise, + height: 20, + width: 20, + ), TextButton( onPressed: () { controller.otpController.value.clear(); controller.sendOTP(); }, - child: Text("Resend OTP".tr, style: AppThemeData.semiBoldTextStyle(color: AppThemeData.info400, fontSize: 16)), + child: Text( + ConstTexts.resendOTP.tr, + style: AppThemeData.semiBoldTextStyle( + color: AppThemeData.info400, + fontSize: 16, + ), + ), ), ], ), @@ -116,10 +180,17 @@ class OtpVerificationScreen extends StatelessWidget { /// Verify Button RoundedButtonFill( - title: "Verify".tr, + borderRadius: 10.r, + title: ConstTexts.verify.tr, onPress: controller.verifyOtp, - color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, - textColor: isDark ? AppThemeData.surfaceDark : Colors.white, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + textColor: + isDark + ? AppThemeData.surfaceDark + : Colors.white, ), ], ), @@ -130,13 +201,23 @@ class OtpVerificationScreen extends StatelessWidget { child: Center( child: Text.rich( TextSpan( - text: "Didn't have an account?".tr, - style: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800), + text: "${ConstTexts.dontHaveAccount.tr} ", + style: AppThemeData.mediumTextStyle( + color: + isDark + ? AppThemeData.greyDark800 + : AppThemeData.grey800, + ), children: [ TextSpan( - text: "Sign up".tr, - style: AppThemeData.mediumTextStyle(color: AppThemeData.ecommerce300, decoration: TextDecoration.underline), - recognizer: TapGestureRecognizer()..onTap = () => Get.offAll(() => const SignUpScreen()), + text: ConstTexts.signUp.tr, + style: AppThemeData.mediumTextStyle( + color: AppThemeData.ecommerce300, + decoration: TextDecoration.underline, + ), + recognizer: + TapGestureRecognizer() + ..onTap = () => Get.offAll(SignUpScreen()), ), ], ), diff --git a/lib/screen_ui/auth_screens/sign_up_screen.dart b/lib/screen_ui/auth_screens/sign_up_screen.dart index 69c9645..a46a796 100644 --- a/lib/screen_ui/auth_screens/sign_up_screen.dart +++ b/lib/screen_ui/auth_screens/sign_up_screen.dart @@ -1,8 +1,12 @@ import 'package:country_code_picker/country_code_picker.dart'; +import 'package:customer/constant/const_texts.dart'; import 'package:customer/screen_ui/location_enable_screens/location_permission_screen.dart'; +import 'package:customer/utils/app_router.dart'; + import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_svg/svg.dart'; import '../../constant/constant.dart'; import '../../controllers/sign_up_controller.dart'; @@ -33,14 +37,33 @@ class SignUpScreen extends StatelessWidget { onPressed: () { Get.to(() => LocationPermissionScreen()); }, - style: TextButton.styleFrom(padding: const EdgeInsets.symmetric(horizontal: 12), minimumSize: const Size(0, 40), tapTargetSize: MaterialTapTargetSize.shrinkWrap), + style: TextButton.styleFrom( + padding: const EdgeInsets.symmetric(horizontal: 12), + minimumSize: const Size(0, 40), + tapTargetSize: MaterialTapTargetSize.shrinkWrap, + ), child: Row( mainAxisSize: MainAxisSize.min, children: [ - Text("Skip".tr, style: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500)), + Text( + ConstTexts.skip.tr, + style: AppThemeData.mediumTextStyle( + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), + ), Padding( padding: const EdgeInsets.only(top: 2), - child: Icon(Icons.arrow_forward_ios, size: 16, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500), + child: Icon( + Icons.arrow_forward_ios, + size: 16, + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), ), ], ), @@ -56,62 +79,125 @@ class SignUpScreen extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "Sign up to explore all our services and start shopping, riding, and more.".tr, - style: AppThemeData.boldTextStyle(fontSize: 24, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + ConstTexts.signUpToExplore.tr, + style: AppThemeData.boldTextStyle( + fontSize: 24, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), const SizedBox(height: 24), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Expanded(child: TextFieldWidget(title: "First Name*".tr, hintText: "Jerome".tr, controller: controller.firstNameController.value)), + Expanded( + child: TextFieldWidget( + title: ConstTexts.firstName.tr, + hintText: "Abdusalom", + controller: controller.firstNameController.value, + ), + ), const SizedBox(width: 10), - Expanded(child: TextFieldWidget(title: "Last Name*".tr, hintText: "Bell".tr, controller: controller.lastNameController.value)), + Expanded( + child: TextFieldWidget( + title: ConstTexts.lastName.tr, + hintText: "G'ayratov", + controller: controller.lastNameController.value, + ), + ), ], ), const SizedBox(height: 15), TextFieldWidget( - title: "Email Address*".tr, - hintText: "jerome014@gmail.com", + title: ConstTexts.emailAddress.tr, + hintText: "abdusalom@gmail.com", controller: controller.emailController.value, focusNode: controller.emailFocusNode, ), const SizedBox(height: 15), TextFieldWidget( - title: "Mobile Number*".tr, - hintText: "Enter Mobile number".tr, - enable: controller.type.value == "mobileNumber" ? false : true, + title: ConstTexts.mobileNumber.tr, + hintText: ConstTexts.enterMobileNumber.tr, + enable: + controller.type.value == "mobileNumber" + ? false + : true, controller: controller.mobileController.value, - textInputType: const TextInputType.numberWithOptions(signed: true, decimal: true), + textInputType: const TextInputType.numberWithOptions( + signed: true, + decimal: true, + ), textInputAction: TextInputAction.done, - inputFormatters: [FilteringTextInputFormatter.allow(RegExp('[0-9]')), LengthLimitingTextInputFormatter(10)], + inputFormatters: [ + FilteringTextInputFormatter.allow(RegExp('[0-9]')), + LengthLimitingTextInputFormatter(10), + ], prefix: Row( mainAxisSize: MainAxisSize.min, children: [ CountryCodePicker( onChanged: (value) { - controller.countryCodeController.value.text = value.dialCode ?? Constant.defaultCountryCode; + controller.countryCodeController.value.text = + value.dialCode ?? Constant.defaultCountryCode; }, - initialSelection: controller.countryCodeController.value.text.isNotEmpty ? controller.countryCodeController.value.text : Constant.defaultCountryCode, + initialSelection: + controller + .countryCodeController + .value + .text + .isNotEmpty + ? controller + .countryCodeController + .value + .text + : Constant.defaultCountryCode, showCountryOnly: false, showOnlyCountryWhenClosed: false, alignLeft: false, enabled: controller.type.value != "mobileNumber", - textStyle: TextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : Colors.black), - dialogTextStyle: TextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), - searchStyle: TextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), - dialogBackgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + textStyle: TextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : Colors.black, + ), + dialogTextStyle: TextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + searchStyle: TextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + dialogBackgroundColor: + isDark + ? AppThemeData.surfaceDark + : AppThemeData.surface, padding: EdgeInsets.zero, ), // const Icon(Icons.keyboard_arrow_down_rounded, size: 24, color: AppThemeData.grey400), - Container(height: 24, width: 1, color: AppThemeData.grey400), + Container( + height: 24, + width: 1, + color: AppThemeData.grey400, + ), const SizedBox(width: 4), ], ), ), const SizedBox(height: 15), TextFieldWidget( - title: "Password*".tr, - hintText: "Enter password".tr, + title: ConstTexts.password.tr, + hintText: ConstTexts.enterPassword.tr, controller: controller.passwordController.value, obscureText: controller.passwordVisible.value, focusNode: controller.passwordFocusNode, @@ -119,76 +205,142 @@ class SignUpScreen extends StatelessWidget { padding: const EdgeInsets.all(12), child: InkWell( onTap: () { - controller.passwordVisible.value = !controller.passwordVisible.value; + controller.passwordVisible.value = + !controller.passwordVisible.value; }, child: controller.passwordVisible.value ? SvgPicture.asset( "assets/icons/ic_password_show.svg", - colorFilter: ColorFilter.mode(isDark ? AppThemeData.grey300 : AppThemeData.grey600, BlendMode.srcIn), + colorFilter: ColorFilter.mode( + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + BlendMode.srcIn, + ), ) : SvgPicture.asset( "assets/icons/ic_password_close.svg", - colorFilter: ColorFilter.mode(isDark ? AppThemeData.grey300 : AppThemeData.grey600, BlendMode.srcIn), + colorFilter: ColorFilter.mode( + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + BlendMode.srcIn, + ), ), ), ), ), const SizedBox(height: 15), TextFieldWidget( - title: "Confirm Password*".tr, - hintText: "Enter confirm password".tr, + title: ConstTexts.confirmPassword.tr, + hintText: ConstTexts.enterConfirmPassword.tr, controller: controller.confirmPasswordController.value, obscureText: controller.conformPasswordVisible.value, suffix: Padding( padding: const EdgeInsets.all(12), child: InkWell( onTap: () { - controller.conformPasswordVisible.value = !controller.conformPasswordVisible.value; + controller.conformPasswordVisible.value = + !controller.conformPasswordVisible.value; }, child: controller.conformPasswordVisible.value ? SvgPicture.asset( "assets/icons/ic_password_show.svg", - colorFilter: ColorFilter.mode(isDark ? AppThemeData.grey300 : AppThemeData.grey600, BlendMode.srcIn), + colorFilter: ColorFilter.mode( + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + BlendMode.srcIn, + ), ) : SvgPicture.asset( "assets/icons/ic_password_close.svg", - colorFilter: ColorFilter.mode(isDark ? AppThemeData.grey300 : AppThemeData.grey600, BlendMode.srcIn), + colorFilter: ColorFilter.mode( + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + BlendMode.srcIn, + ), ), ), ), ), const SizedBox(height: 15), - TextFieldWidget(title: "Referral Code".tr, hintText: "Enter referral code".tr, controller: controller.referralController.value), + TextFieldWidget( + title: ConstTexts.referralCode.tr, + hintText: ConstTexts.enterReferralCode.tr, + controller: controller.referralController.value, + ), const SizedBox(height: 40), RoundedButtonFill( - title: "Sign up".tr, + borderRadius: 10.r, + title: ConstTexts.signUp.tr, onPress: () => controller.signUp(), - color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, - textColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + textColor: + isDark + ? AppThemeData.surfaceDark + : AppThemeData.surface, ), const SizedBox(height: 25), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Container(width: 52, height: 1, color: isDark ? AppThemeData.greyDark400 : AppThemeData.grey300), + Container( + width: 52, + height: 1, + color: + isDark + ? AppThemeData.greyDark400 + : AppThemeData.grey300, + ), const SizedBox(width: 15), - Text("or continue with".tr, style: AppThemeData.regularTextStyle(color: isDark ? AppThemeData.greyDark400 : AppThemeData.grey400)), + Text( + ConstTexts.orContinueWith.tr, + style: AppThemeData.regularTextStyle( + color: + isDark + ? AppThemeData.greyDark400 + : AppThemeData.grey400, + ), + ), const SizedBox(width: 15), - Container(width: 52, height: 1, color: isDark ? AppThemeData.greyDark400 : AppThemeData.grey300), + Container( + width: 52, + height: 1, + color: + isDark + ? AppThemeData.greyDark400 + : AppThemeData.grey300, + ), ], ), const SizedBox(height: 25), RoundedButtonFill( - title: "Mobile number".tr, + borderRadius: 10.r, + title: ConstTexts.mobileNumber.tr, onPress: () => Get.to(() => const MobileLoginScreen()), isRight: false, isCenter: true, - icon: Icon(Icons.mobile_friendly_outlined, size: 20, color: isDark ? AppThemeData.greyDark900 : null), + icon: Icon( + Icons.mobile_friendly_outlined, + size: 20, + color: isDark ? AppThemeData.greyDark900 : null, + ), //Image.asset(AppAssets.icMessage, width: 20, height: 18, color: isDark ? AppThemeData.greyDark900 : null), - color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200, - textColor: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + textColor: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, ), const SizedBox(height: 25), Padding( @@ -196,11 +348,16 @@ class SignUpScreen extends StatelessWidget { child: Center( child: Text.rich( TextSpan( - text: "Already have an account?".tr, - style: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800), + text: ConstTexts.alreadyHaveAccount.tr, + style: AppThemeData.mediumTextStyle( + color: + isDark + ? AppThemeData.greyDark800 + : AppThemeData.grey800, + ), children: [ TextSpan( - text: "Log in".tr, + text: ConstTexts.login.tr, style: AppThemeData.mediumTextStyle( color: AppThemeData.ecommerce300, decoration: TextDecoration.underline, @@ -210,7 +367,7 @@ class SignUpScreen extends StatelessWidget { recognizer: TapGestureRecognizer() ..onTap = () { - Get.offAll(() => const LoginScreen()); + Get.offAll(LoginScreen()); }, ), ], diff --git a/lib/screen_ui/cab_service_screens/Intercity_home_screen.dart b/lib/screen_ui/cab_service_screens/Intercity_home_screen.dart index 2095b2f..3cf353d 100644 --- a/lib/screen_ui/cab_service_screens/Intercity_home_screen.dart +++ b/lib/screen_ui/cab_service_screens/Intercity_home_screen.dart @@ -1,6 +1,6 @@ import 'dart:io'; - import 'package:cached_network_image/cached_network_image.dart'; +import 'package:customer/constant/const_texts.dart'; import 'package:customer/controllers/Intercity_home_controller.dart'; import 'package:customer/models/coupon_model.dart'; import 'package:customer/models/tax_model.dart'; @@ -14,7 +14,9 @@ import 'package:customer/themes/round_button_border.dart'; import 'package:customer/utils/network_image_widget.dart'; import 'package:customer/utils/utils.dart'; import 'package:dotted_border/dotted_border.dart'; + import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:geocoding/geocoding.dart' as get_cord_address; import 'package:get/get.dart'; @@ -57,19 +59,57 @@ class IntercityHomeScreen extends StatelessWidget { options: flutterMap.MapOptions( initialCenter: Constant.currentLocation != null - ? latlong.LatLng(Constant.currentLocation!.latitude, Constant.currentLocation!.longitude) + ? latlong.LatLng( + Constant.currentLocation!.latitude, + Constant.currentLocation!.longitude, + ) : controller.currentOrder.value.id != null ? latlong.LatLng( - double.parse(controller.currentOrder.value.sourceLocation!.latitude.toString()), - double.parse(controller.currentOrder.value.sourceLocation!.longitude.toString()), + double.parse( + controller + .currentOrder + .value + .sourceLocation! + .latitude + .toString(), + ), + double.parse( + controller + .currentOrder + .value + .sourceLocation! + .longitude + .toString(), + ), ) - : latlong.LatLng(41.4219057, -102.0840772), + : latlong.LatLng( + 41.4219057, + -102.0840772, + ), initialZoom: 14, ), children: [ - flutterMap.TileLayer(urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', userAgentPackageName: Platform.isAndroid ? "com.emart" : "com.emart.ios"), - flutterMap.MarkerLayer(markers: controller.osmMarker), - if (controller.routePoints.isNotEmpty) flutterMap.PolylineLayer(polylines: [flutterMap.Polyline(points: controller.routePoints, strokeWidth: 5.0, color: Colors.blue)]), + flutterMap.TileLayer( + urlTemplate: + 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', + userAgentPackageName: + Platform.isAndroid + ? "com.emart" + : "com.emart.ios", + ), + flutterMap.MarkerLayer( + markers: controller.osmMarker, + ), + if (controller.routePoints.isNotEmpty) + flutterMap.PolylineLayer( + polylines: [ + flutterMap.Polyline( + points: controller.routePoints, + strokeWidth: 5.0, + color: Colors.blue, + ), + ], + ), ], ) : GoogleMap( @@ -77,16 +117,26 @@ class IntercityHomeScreen extends StatelessWidget { controller.mapController = googleMapController; if (Constant.currentLocation != null) { - controller.setDepartureMarker(Constant.currentLocation!.latitude, Constant.currentLocation!.longitude); + controller.setDepartureMarker( + Constant.currentLocation!.latitude, + Constant.currentLocation!.longitude, + ); controller.searchPlaceNameGoogle(); } }, - initialCameraPosition: CameraPosition(target: controller.currentPosition.value, zoom: 14), + initialCameraPosition: CameraPosition( + target: controller.currentPosition.value, + zoom: 14, + ), myLocationEnabled: true, zoomControlsEnabled: true, zoomGesturesEnabled: true, - polylines: Set.of(controller.polyLines.values), - markers: controller.markers.toSet(), // reactive marker set + polylines: Set.of( + controller.polyLines.values, + ), + markers: + controller.markers + .toSet(), // reactive marker set ), Positioned( top: 50, @@ -94,36 +144,64 @@ class IntercityHomeScreen extends StatelessWidget { right: Constant.isRtl ? 20 : null, child: InkWell( onTap: () { - if (controller.bottomSheetType.value == "vehicleSelection") { + if (controller.bottomSheetType.value == + "vehicleSelection") { controller.bottomSheetType.value = "location"; - } else if (controller.bottomSheetType.value == "payment") { - controller.bottomSheetType.value = "vehicleSelection"; - } else if (controller.bottomSheetType.value == "conformRide") { + } else if (controller.bottomSheetType.value == + "payment") { + controller.bottomSheetType.value = + "vehicleSelection"; + } else if (controller.bottomSheetType.value == + "conformRide") { controller.bottomSheetType.value = "payment"; - } else if (controller.bottomSheetType.value == "waitingDriver" || controller.bottomSheetType.value == "driverDetails") { + } else if (controller.bottomSheetType.value == + "waitingDriver" || + controller.bottomSheetType.value == + "driverDetails") { Get.back(result: true); } else { Get.back(); } }, child: Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, borderRadius: BorderRadius.circular(30)), + decoration: BoxDecoration( + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + borderRadius: BorderRadius.circular(30), + ), child: Padding( padding: const EdgeInsets.all(10), - child: Center(child: Icon(Icons.arrow_back_ios_new, size: 20, color: isDark ? AppThemeData.grey50 : AppThemeData.greyDark50)), + child: Center( + child: Icon( + Icons.arrow_back_ios_new, + size: 20, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.greyDark50, + ), + ), ), ), ), ), controller.bottomSheetType.value == "location" - ? searchLocationBottomSheet(context, controller, isDark) - : controller.bottomSheetType.value == "vehicleSelection" + ? searchLocationBottomSheet( + context, + controller, + isDark, + ) + : controller.bottomSheetType.value == + "vehicleSelection" ? vehicleSelection(context, controller, isDark) : controller.bottomSheetType.value == "payment" ? paymentBottomSheet(context, controller, isDark) : controller.bottomSheetType.value == "conformRide" ? conformBottomSheet(context, isDark) - : controller.bottomSheetType.value == "waitingForDriver" + : controller.bottomSheetType.value == + "waitingForDriver" ? waitingDialog(context, controller, isDark) : controller.bottomSheetType.value == "driverDetails" ? driverDialog(context, controller, isDark) @@ -135,7 +213,11 @@ class IntercityHomeScreen extends StatelessWidget { ); } - Widget searchLocationBottomSheet(BuildContext context, IntercityHomeController controller, bool isDark) { + Widget searchLocationBottomSheet( + BuildContext context, + IntercityHomeController controller, + bool isDark, + ) { return Positioned.fill( child: DraggableScrollableSheet( initialChildSize: 0.48, @@ -145,16 +227,29 @@ class IntercityHomeScreen extends StatelessWidget { builder: (context, scrollController) { return Container( padding: const EdgeInsets.all(16), - decoration: BoxDecoration(color: isDark ? AppThemeData.grey700 : Colors.white, borderRadius: BorderRadius.vertical(top: Radius.circular(35))), + decoration: BoxDecoration( + color: isDark ? AppThemeData.grey700 : Colors.white, + borderRadius: BorderRadius.vertical(top: Radius.circular(35)), + ), child: Column( mainAxisSize: MainAxisSize.min, children: [ - Container(decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), color: AppThemeData.grey400), height: 4, width: 33), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: AppThemeData.grey400, + ), + height: 4, + width: 33, + ), SizedBox(height: 10), Stack( children: [ Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.grey700 : Colors.white, borderRadius: BorderRadius.circular(12)), + decoration: BoxDecoration( + color: isDark ? AppThemeData.grey700 : Colors.white, + borderRadius: BorderRadius.circular(12), + ), child: Column( mainAxisSize: MainAxisSize.min, children: [ @@ -162,40 +257,82 @@ class IntercityHomeScreen extends StatelessWidget { InkWell( onTap: () async { if (Constant.selectedMapType == 'osm') { - final result = await Get.to(() => MapPickerPage()); - controller.sourceTextEditController.value.text = ''; + final result = await Get.to( + () => MapPickerPage(), + ); + controller.sourceTextEditController.value.text = + ''; final firstPlace = result; if (result != null) { - if (Constant.checkZoneCheck(firstPlace.coordinates.latitude, firstPlace.coordinates.longitude) == true) { + if (Constant.checkZoneCheck( + firstPlace.coordinates.latitude, + firstPlace.coordinates.longitude, + ) == + true) { final lat = firstPlace.coordinates.latitude; - final lng = firstPlace.coordinates.longitude; + final lng = + firstPlace.coordinates.longitude; final address = firstPlace.address; - controller.sourceTextEditController.value.text = address.toString(); + controller + .sourceTextEditController + .value + .text = address.toString(); controller.setDepartureMarker(lat, lng); } else { - ShowToastDialog.showToast("Service is unavailable at the selected address.".tr); + ShowToastDialog.showToast( + ConstTexts.serviceIsUnavailable.tr, + ); } } } else { - Get.to(LocationPickerScreen())!.then((value) async { + Get.to(LocationPickerScreen())!.then(( + value, + ) async { if (value != null) { - SelectedLocationModel selectedLocationModel = value; + SelectedLocationModel + selectedLocationModel = value; - if (Constant.checkZoneCheck(selectedLocationModel.latLng!.latitude, selectedLocationModel.latLng!.longitude) == true) { - controller.sourceTextEditController.value.text = Utils.formatAddress(selectedLocation: selectedLocationModel); - controller.setDepartureMarker(selectedLocationModel.latLng!.latitude, selectedLocationModel.latLng!.longitude); + if (Constant.checkZoneCheck( + selectedLocationModel + .latLng! + .latitude, + selectedLocationModel + .latLng! + .longitude, + ) == + true) { + controller + .sourceTextEditController + .value + .text = Utils.formatAddress( + selectedLocation: selectedLocationModel, + ); + controller.setDepartureMarker( + selectedLocationModel.latLng!.latitude, + selectedLocationModel.latLng!.longitude, + ); } else { - ShowToastDialog.showToast("Service is unavailable at the selected address.".tr); + ShowToastDialog.showToast( + ConstTexts.serviceIsUnavailable.tr, + ); } } }); } }, child: TextFieldWidget( - controller: controller.sourceTextEditController.value, - hintText: "Pickup Location".tr, + controller: + controller.sourceTextEditController.value, + hintText: ConstTexts.pickUpLocation.tr, enable: false, - prefix: Padding(padding: EdgeInsets.only(left: 10, right: 10), child: Image.asset("assets/icons/pickup.png", height: 22, width: 22)), + prefix: Padding( + padding: EdgeInsets.only(left: 10, right: 10), + child: Image.asset( + "assets/icons/pickup.png", + height: 22, + width: 22, + ), + ), ), ), const SizedBox(height: 10), @@ -203,34 +340,62 @@ class IntercityHomeScreen extends StatelessWidget { InkWell( onTap: () async { if (Constant.selectedMapType == 'osm') { - final result = await Get.to(() => MapPickerPage()); + final result = await Get.to( + () => MapPickerPage(), + ); if (result != null) { - controller.destinationTextEditController.value.text = ''; + controller + .destinationTextEditController + .value + .text = ''; final firstPlace = result; final lat = firstPlace.coordinates.latitude; final lng = firstPlace.coordinates.longitude; final address = firstPlace.address; - controller.destinationTextEditController.value.text = address.toString(); + controller + .destinationTextEditController + .value + .text = address.toString(); controller.setDestinationMarker(lat, lng); } } else { - Get.to(LocationPickerScreen())!.then((value) async { + Get.to(LocationPickerScreen())!.then(( + value, + ) async { if (value != null) { - SelectedLocationModel selectedLocationModel = value; + SelectedLocationModel + selectedLocationModel = value; - controller.destinationTextEditController.value.text = Utils.formatAddress(selectedLocation: selectedLocationModel); - controller.setDestinationMarker(selectedLocationModel.latLng!.latitude, selectedLocationModel.latLng!.longitude); + controller + .destinationTextEditController + .value + .text = Utils.formatAddress( + selectedLocation: selectedLocationModel, + ); + controller.setDestinationMarker( + selectedLocationModel.latLng!.latitude, + selectedLocationModel.latLng!.longitude, + ); } }); } }, child: TextFieldWidget( - controller: controller.destinationTextEditController.value, + controller: + controller + .destinationTextEditController + .value, // backgroundColor: AppThemeData.grey50, // borderColor: AppThemeData.grey50, - hintText: "Destination Location".tr, + hintText: ConstTexts.destinationLocation.tr, enable: false, - prefix: const Padding(padding: EdgeInsets.only(left: 10, right: 10), child: Icon(Icons.radio_button_checked, color: Colors.red)), + prefix: const Padding( + padding: EdgeInsets.only(left: 10, right: 10), + child: Icon( + Icons.radio_button_checked, + color: Colors.red, + ), + ), ), ), ], @@ -256,7 +421,16 @@ class IntercityHomeScreen extends StatelessWidget { ], ), SizedBox(height: 15), - Align(alignment: Alignment.centerLeft, child: Text("Popular Destinations".tr, style: AppThemeData.boldTextStyle(fontSize: 16, color: AppThemeData.grey900))), + Align( + alignment: Alignment.centerLeft, + child: Text( + ConstTexts.popularDestinations.tr, + style: AppThemeData.boldTextStyle( + fontSize: 16, + color: AppThemeData.grey900, + ), + ), + ), SizedBox( height: 120, child: Padding( @@ -267,22 +441,62 @@ class IntercityHomeScreen extends StatelessWidget { itemBuilder: (context, index) { return InkWell( onTap: () async { - if (controller.popularDestination[index].latitude != null || controller.popularDestination[index].longitude != null) { - List placeMarks = await get_cord_address.placemarkFromCoordinates( - controller.popularDestination[index].latitude ?? 0.0, - controller.popularDestination[index].longitude ?? 0.0, - ); + if (controller.popularDestination[index].latitude != + null || + controller + .popularDestination[index] + .longitude != + null) { + List placeMarks = + await get_cord_address + .placemarkFromCoordinates( + controller + .popularDestination[index] + .latitude ?? + 0.0, + controller + .popularDestination[index] + .longitude ?? + 0.0, + ); final address = - (placeMarks.first.subLocality!.isEmpty ? '' : "${placeMarks.first.subLocality}, ") + - (placeMarks.first.street!.isEmpty ? '' : "${placeMarks.first.street}, ") + - (placeMarks.first.name!.isEmpty ? '' : "${placeMarks.first.name}, ") + - (placeMarks.first.subAdministrativeArea!.isEmpty ? '' : "${placeMarks.first.subAdministrativeArea}, ") + - (placeMarks.first.administrativeArea!.isEmpty ? '' : "${placeMarks.first.administrativeArea}, ") + - (placeMarks.first.country!.isEmpty ? '' : "${placeMarks.first.country}, ") + - (placeMarks.first.postalCode!.isEmpty ? '' : "${placeMarks.first.postalCode}, "); - controller.destinationTextEditController.value.text = address; - controller.setDestinationMarker(controller.popularDestination[index].latitude ?? 0.0, controller.popularDestination[index].longitude ?? 0.0); + (placeMarks.first.subLocality!.isEmpty + ? '' + : "${placeMarks.first.subLocality}, ") + + (placeMarks.first.street!.isEmpty + ? '' + : "${placeMarks.first.street}, ") + + (placeMarks.first.name!.isEmpty + ? '' + : "${placeMarks.first.name}, ") + + (placeMarks + .first + .subAdministrativeArea! + .isEmpty + ? '' + : "${placeMarks.first.subAdministrativeArea}, ") + + (placeMarks.first.administrativeArea!.isEmpty + ? '' + : "${placeMarks.first.administrativeArea}, ") + + (placeMarks.first.country!.isEmpty + ? '' + : "${placeMarks.first.country}, ") + + (placeMarks.first.postalCode!.isEmpty + ? '' + : "${placeMarks.first.postalCode}, "); + controller + .destinationTextEditController + .value + .text = address; + controller.setDestinationMarker( + controller.popularDestination[index].latitude ?? + 0.0, + controller + .popularDestination[index] + .longitude ?? + 0.0, + ); } }, child: Padding( @@ -291,24 +505,65 @@ class IntercityHomeScreen extends StatelessWidget { children: [ CachedNetworkImage( imageUrl: - (controller.popularDestination[index].image != null && controller.popularDestination[index].image!.isNotEmpty) - ? controller.popularDestination[index].image! + (controller + .popularDestination[index] + .image != + null && + controller + .popularDestination[index] + .image! + .isNotEmpty) + ? controller + .popularDestination[index] + .image! : Constant.placeHolderImage, height: 160, width: 120, imageBuilder: - (context, imageProvider) => - Container(decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), image: DecorationImage(image: imageProvider, fit: BoxFit.cover))), - placeholder: (context, url) => Center(child: CircularProgressIndicator.adaptive(valueColor: AlwaysStoppedAnimation(AppThemeData.primary300))), + (context, imageProvider) => Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular( + 10, + ), + image: DecorationImage( + image: imageProvider, + fit: BoxFit.cover, + ), + ), + ), + placeholder: + (context, url) => Center( + child: + CircularProgressIndicator.adaptive( + valueColor: + AlwaysStoppedAnimation( + AppThemeData.primary300, + ), + ), + ), errorWidget: - (context, url, error) => - ClipRRect(borderRadius: BorderRadius.circular(10), child: Image.network(Constant.placeHolderImage, fit: BoxFit.cover, cacheHeight: 80, cacheWidth: 80)), + (context, url, error) => ClipRRect( + borderRadius: BorderRadius.circular(10), + child: Image.network( + Constant.placeHolderImage, + fit: BoxFit.cover, + cacheHeight: 80, + cacheWidth: 80, + ), + ), fit: BoxFit.cover, ), Positioned( left: 5, top: 80, - child: Text(controller.popularDestination[index].title.toString(), style: AppThemeData.boldTextStyle(fontSize: 15, color: AppThemeData.surface)), + child: Text( + controller.popularDestination[index].title + .toString(), + style: AppThemeData.boldTextStyle( + fontSize: 15, + color: AppThemeData.surface, + ), + ), ), ], ), @@ -320,12 +575,25 @@ class IntercityHomeScreen extends StatelessWidget { ), SizedBox(height: 10), RoundedButtonFill( - title: "Continue".tr, + borderRadius: 10.r, + title: ConstTexts.continueT.tr, onPress: () { - if (controller.sourceTextEditController.value.text.isEmpty) { - ShowToastDialog.showToast("Please select source location".tr); - } else if (controller.destinationTextEditController.value.text.isEmpty) { - ShowToastDialog.showToast("Please select destination location".tr); + if (controller + .sourceTextEditController + .value + .text + .isEmpty) { + ShowToastDialog.showToast( + ConstTexts.plsSelectSourceLocation.tr, + ); + } else if (controller + .destinationTextEditController + .value + .text + .isEmpty) { + ShowToastDialog.showToast( + ConstTexts.plsSelectDestinationLocations.tr, + ); } else { controller.bottomSheetType.value = "vehicleSelection"; } @@ -341,7 +609,11 @@ class IntercityHomeScreen extends StatelessWidget { ); } - Widget vehicleSelection(BuildContext context, IntercityHomeController controller, bool isDark) { + Widget vehicleSelection( + BuildContext context, + IntercityHomeController controller, + bool isDark, + ) { return Positioned.fill( child: DraggableScrollableSheet( initialChildSize: 0.40, @@ -350,20 +622,42 @@ class IntercityHomeScreen extends StatelessWidget { expand: false, builder: (context, scrollController) { return Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.grey700 : Colors.white, borderRadius: const BorderRadius.only(topLeft: Radius.circular(24), topRight: Radius.circular(24))), + decoration: BoxDecoration( + color: isDark ? AppThemeData.grey700 : Colors.white, + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(24), + topRight: Radius.circular(24), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 15.0, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 15.0, + vertical: 10, + ), child: Column( mainAxisSize: MainAxisSize.min, children: [ - Container(decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), color: AppThemeData.grey400), height: 4, width: 33), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: AppThemeData.grey400, + ), + height: 4, + width: 33, + ), Align( alignment: Alignment.topLeft, child: Padding( padding: const EdgeInsets.symmetric(vertical: 10), child: Text( - "Select Your Vehicle Type".tr, - style: AppThemeData.boldTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + ConstTexts.selectVehicleType.tr, + style: AppThemeData.boldTextStyle( + fontSize: 18, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), textAlign: TextAlign.start, ), ), @@ -376,11 +670,13 @@ class IntercityHomeScreen extends StatelessWidget { controller: scrollController, scrollDirection: Axis.vertical, itemBuilder: (context, index) { - VehicleType vehicleType = controller.vehicleTypes[index]; + VehicleType vehicleType = + controller.vehicleTypes[index]; return Obx( () => InkWell( onTap: () { - controller.selectedVehicleType.value = controller.vehicleTypes[index]; + controller.selectedVehicleType.value = + controller.vehicleTypes[index]; }, child: Padding( padding: const EdgeInsets.only(bottom: 10), @@ -390,60 +686,130 @@ class IntercityHomeScreen extends StatelessWidget { border: Border.all( color: isDark - ? controller.selectedVehicleType.value.id == vehicleType.id + ? controller + .selectedVehicleType + .value + .id == + vehicleType.id ? Colors.white : AppThemeData.grey500 - : controller.selectedVehicleType.value.id == vehicleType.id + : controller + .selectedVehicleType + .value + .id == + vehicleType.id ? AppThemeData.grey300 : Colors.transparent, width: 1, ), color: - controller.selectedVehicleType.value.id == vehicleType.id + controller.selectedVehicleType.value.id == + vehicleType.id ? AppThemeData.grey50 : isDark ? AppThemeData.grey300 : Colors.white, ), child: Padding( - padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10), + padding: const EdgeInsets.symmetric( + vertical: 10, + horizontal: 10, + ), child: Row( children: [ ClipRRect( //borderRadius: BorderRadius.circular(10), child: CachedNetworkImage( - imageUrl: vehicleType.vehicleIcon.toString(), + imageUrl: + vehicleType.vehicleIcon + .toString(), height: 60, width: 60, imageBuilder: (context, imageProvider) => - Container(decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), image: DecorationImage(image: imageProvider, fit: BoxFit.cover))), - placeholder: (context, url) => Center(child: CircularProgressIndicator.adaptive(valueColor: AlwaysStoppedAnimation(AppThemeData.primary300))), - errorWidget: (context, url, error) => ClipRRect(borderRadius: BorderRadius.circular(20), child: Image.network(Constant.userPlaceHolder, fit: BoxFit.cover)), + Container( + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular( + 10, + ), + image: DecorationImage( + image: imageProvider, + fit: BoxFit.cover, + ), + ), + ), + placeholder: + (context, url) => Center( + child: + CircularProgressIndicator.adaptive( + valueColor: + AlwaysStoppedAnimation( + AppThemeData + .primary300, + ), + ), + ), + errorWidget: + (context, url, error) => + ClipRRect( + borderRadius: + BorderRadius.circular( + 20, + ), + child: Image.network( + Constant.userPlaceHolder, + fit: BoxFit.cover, + ), + ), fit: BoxFit.cover, ), ), Expanded( child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10), + padding: const EdgeInsets.symmetric( + horizontal: 10, + ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( "${vehicleType.name} | ${controller.distance.toStringAsFixed(2)}km", - style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold, letterSpacing: 1), + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + letterSpacing: 1, + ), ), Padding( - padding: const EdgeInsets.only(top: 2.0), - child: Text(controller.duration.value, style: const TextStyle(fontWeight: FontWeight.w400, letterSpacing: 1)), + padding: const EdgeInsets.only( + top: 2.0, + ), + child: Text( + controller.duration.value, + style: const TextStyle( + fontWeight: FontWeight.w400, + letterSpacing: 1, + ), + ), ), ], ), ), ), Text( - Constant.amountShow(amount: controller.getAmount(vehicleType).toString()), - style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold, letterSpacing: 1), + Constant.amountShow( + amount: + controller + .getAmount(vehicleType) + .toString(), + ), + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + letterSpacing: 1, + ), ), ], ), @@ -457,12 +823,17 @@ class IntercityHomeScreen extends StatelessWidget { ), Obx( () => RoundedButtonFill( - title: 'pay_amount'.trParams({ - 'amount': - controller.selectedVehicleType.value.id == null - ? Constant.amountShow(amount: "0.0") - : Constant.amountShow(amount: controller.getAmount(controller.selectedVehicleType.value).toString()), - }), + borderRadius: 10.r, + title: 'pay_amount'.trParams({ + 'amount': controller.selectedVehicleType.value.id == null + ? Constant.amountShow(amount: "0.0") + : Constant.amountShow( + amount: controller + .getAmount(controller.selectedVehicleType.value) + .toString(), + ), +}), + // title: // "Pay ${controller.selectedVehicleType.value.id == null ? Constant.amountShow(amount: "0.0") : Constant.amountShow(amount: controller.getAmount(controller.selectedVehicleType.value).toString())}", onPress: () async { @@ -470,7 +841,9 @@ class IntercityHomeScreen extends StatelessWidget { controller.calculateTotalAmount(); controller.bottomSheetType.value = "payment"; } else { - ShowToastDialog.showToast("Please select a vehicle type first.".tr); + ShowToastDialog.showToast( + ConstTexts.plsSelectVehicleTypeFirst.tr, + ); } }, color: AppThemeData.primary300, @@ -486,7 +859,11 @@ class IntercityHomeScreen extends StatelessWidget { ); } - Widget paymentBottomSheet(BuildContext context, IntercityHomeController controller, bool isDark) { + Widget paymentBottomSheet( + BuildContext context, + IntercityHomeController controller, + bool isDark, + ) { return Positioned.fill( child: DraggableScrollableSheet( initialChildSize: 0.70, @@ -496,19 +873,37 @@ class IntercityHomeScreen extends StatelessWidget { builder: (context, scrollController) { return Container( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20), - decoration: BoxDecoration(color: isDark ? AppThemeData.grey700 : Colors.white, borderRadius: BorderRadius.vertical(top: Radius.circular(24))), + decoration: BoxDecoration( + color: isDark ? AppThemeData.grey700 : Colors.white, + borderRadius: BorderRadius.vertical(top: Radius.circular(24)), + ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text("Select Payment Method".tr, style: AppThemeData.mediumTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + ConstTexts.selectPaymentMethod.tr, + style: AppThemeData.mediumTextStyle( + fontSize: 18, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), GestureDetector( onTap: () { Get.back(); }, - child: Icon(Icons.close, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + child: Icon( + Icons.close, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ], ), @@ -518,40 +913,96 @@ class IntercityHomeScreen extends StatelessWidget { padding: EdgeInsets.zero, controller: scrollController, children: [ - Text("Preferred Payment".tr, textAlign: TextAlign.start, style: AppThemeData.boldTextStyle(fontSize: 15, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500)), + Text( + ConstTexts.prefferedPayment.tr, + textAlign: TextAlign.start, + style: AppThemeData.boldTextStyle( + fontSize: 15, + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), + ), const SizedBox(height: 10), - if (controller.walletSettingModel.value.isEnabled == true || controller.cashOnDeliverySettingModel.value.isEnabled == true) + if (controller.walletSettingModel.value.isEnabled == + true || + controller + .cashOnDeliverySettingModel + .value + .isEnabled == + true) Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark100 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark100 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ Visibility( - visible: controller.walletSettingModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.wallet, isDark, "assets/images/ic_wallet.png"), + visible: + controller + .walletSettingModel + .value + .isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.wallet, + isDark, + "assets/images/ic_wallet.png", + ), ), Visibility( - visible: controller.cashOnDeliverySettingModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.cod, isDark, "assets/images/ic_cash.png"), + visible: + controller + .cashOnDeliverySettingModel + .value + .isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.cod, + isDark, + "assets/images/ic_cash.png", + ), ), ], ), ), ), - if (controller.walletSettingModel.value.isEnabled == true || controller.cashOnDeliverySettingModel.value.isEnabled == true) + if (controller.walletSettingModel.value.isEnabled == + true || + controller + .cashOnDeliverySettingModel + .value + .isEnabled == + true) Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const SizedBox(height: 10), Text( - "Other Payment Options".tr, + ConstTexts.otherPaymentOptions.tr, textAlign: TextAlign.start, - style: AppThemeData.boldTextStyle(fontSize: 15, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500), + style: AppThemeData.boldTextStyle( + fontSize: 15, + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), ), const SizedBox(height: 10), ], @@ -559,32 +1010,136 @@ class IntercityHomeScreen extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark100 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark100 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ - Visibility(visible: controller.stripeModel.value.isEnabled == true, child: cardDecoration(controller, PaymentGateway.stripe, isDark, "assets/images/stripe.png")), - Visibility(visible: controller.payPalModel.value.isEnabled == true, child: cardDecoration(controller, PaymentGateway.paypal, isDark, "assets/images/paypal.png")), - Visibility(visible: controller.payStackModel.value.isEnable == true, child: cardDecoration(controller, PaymentGateway.payStack, isDark, "assets/images/paystack.png")), Visibility( - visible: controller.mercadoPagoModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.mercadoPago, isDark, "assets/images/mercado-pago.png"), + visible: + controller.stripeModel.value.isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.stripe, + isDark, + "assets/images/stripe.png", + ), ), Visibility( - visible: controller.flutterWaveModel.value.isEnable == true, - child: cardDecoration(controller, PaymentGateway.flutterWave, isDark, "assets/images/flutterwave_logo.png"), + visible: + controller.payPalModel.value.isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.paypal, + isDark, + "assets/images/paypal.png", + ), ), - Visibility(visible: controller.payFastModel.value.isEnable == true, child: cardDecoration(controller, PaymentGateway.payFast, isDark, "assets/images/payfast.png")), - Visibility(visible: controller.razorPayModel.value.isEnabled == true, child: cardDecoration(controller, PaymentGateway.razorpay, isDark, "assets/images/razorpay.png")), - Visibility(visible: controller.midTransModel.value.enable == true, child: cardDecoration(controller, PaymentGateway.midTrans, isDark, "assets/images/midtrans.png")), Visibility( - visible: controller.orangeMoneyModel.value.enable == true, - child: cardDecoration(controller, PaymentGateway.orangeMoney, isDark, "assets/images/orange_money.png"), + visible: + controller.payStackModel.value.isEnable == + true, + child: cardDecoration( + controller, + PaymentGateway.payStack, + isDark, + "assets/images/paystack.png", + ), + ), + Visibility( + visible: + controller + .mercadoPagoModel + .value + .isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.mercadoPago, + isDark, + "assets/images/mercado-pago.png", + ), + ), + Visibility( + visible: + controller + .flutterWaveModel + .value + .isEnable == + true, + child: cardDecoration( + controller, + PaymentGateway.flutterWave, + isDark, + "assets/images/flutterwave_logo.png", + ), + ), + Visibility( + visible: + controller.payFastModel.value.isEnable == + true, + child: cardDecoration( + controller, + PaymentGateway.payFast, + isDark, + "assets/images/payfast.png", + ), + ), + Visibility( + visible: + controller.razorPayModel.value.isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.razorpay, + isDark, + "assets/images/razorpay.png", + ), + ), + Visibility( + visible: + controller.midTransModel.value.enable == + true, + child: cardDecoration( + controller, + PaymentGateway.midTrans, + isDark, + "assets/images/midtrans.png", + ), + ), + Visibility( + visible: + controller.orangeMoneyModel.value.enable == + true, + child: cardDecoration( + controller, + PaymentGateway.orangeMoney, + isDark, + "assets/images/orange_money.png", + ), + ), + Visibility( + visible: + controller.xenditModel.value.enable == true, + child: cardDecoration( + controller, + PaymentGateway.xendit, + isDark, + "assets/images/xendit.png", + ), ), - Visibility(visible: controller.xenditModel.value.enable == true, child: cardDecoration(controller, PaymentGateway.xendit, isDark, "assets/images/xendit.png")), ], ), ), @@ -594,18 +1149,24 @@ class IntercityHomeScreen extends StatelessWidget { ), ), RoundedButtonFill( - title: "Continue".tr, + borderRadius: 10.r, + title: ConstTexts.continueT.tr, color: AppThemeData.primary300, textColor: AppThemeData.grey900, onPress: () async { if (controller.selectedPaymentMethod.value.isEmpty) { - ShowToastDialog.showToast("Please select a payment method".tr); + ShowToastDialog.showToast( + ConstTexts.plsSelectPaymentMethod.tr, + ); return; } if (controller.selectedPaymentMethod.value == "wallet") { - num walletAmount = controller.userModel.value.walletAmount ?? 0; + num walletAmount = + controller.userModel.value.walletAmount ?? 0; if (walletAmount <= 0) { - ShowToastDialog.showToast("Insufficient wallet balance. Please select another payment method.".tr); + ShowToastDialog.showToast( + ConstTexts.insufficientWallet.tr, + ); return; } } @@ -652,13 +1213,29 @@ class IntercityHomeScreen extends StatelessWidget { init: IntercityHomeController(), builder: (controller) { return Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.grey700 : Colors.white, borderRadius: BorderRadius.only(topLeft: Radius.circular(30), topRight: Radius.circular(30))), + decoration: BoxDecoration( + color: isDark ? AppThemeData.grey700 : Colors.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(30), + topRight: Radius.circular(30), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 15.0, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 15.0, + vertical: 10, + ), child: Column( mainAxisSize: MainAxisSize.min, children: [ - Container(decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), color: AppThemeData.grey400), height: 4, width: 33), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: AppThemeData.grey400, + ), + height: 4, + width: 33, + ), Expanded( child: ListView( controller: scrollController, @@ -668,75 +1245,177 @@ class IntercityHomeScreen extends StatelessWidget { Stack( children: [ Container( - decoration: BoxDecoration(color: isDark ? Colors.transparent : Colors.white, borderRadius: BorderRadius.circular(12)), + decoration: BoxDecoration( + color: + isDark + ? Colors.transparent + : Colors.white, + borderRadius: BorderRadius.circular(12), + ), child: Column( mainAxisSize: MainAxisSize.min, children: [ // Pickup Location InkWell( onTap: () async { - if (Constant.selectedMapType == 'osm') { - final result = await Get.to(() => MapPickerPage()); + if (Constant.selectedMapType == + 'osm') { + final result = await Get.to( + () => MapPickerPage(), + ); if (result != null) { - controller.sourceTextEditController.value.text = ''; + controller + .sourceTextEditController + .value + .text = ''; final firstPlace = result; - final lat = firstPlace.coordinates.latitude; - final lng = firstPlace.coordinates.longitude; - final address = firstPlace.address; - controller.sourceTextEditController.value.text = address.toString(); - controller.setDepartureMarker(lat, lng); + final lat = + firstPlace + .coordinates + .latitude; + final lng = + firstPlace + .coordinates + .longitude; + final address = + firstPlace.address; + controller + .sourceTextEditController + .value + .text = address.toString(); + controller.setDepartureMarker( + lat, + lng, + ); } } else { - Get.to(LocationPickerScreen())!.then((value) async { + Get.to( + LocationPickerScreen(), + )!.then((value) async { if (value != null) { - SelectedLocationModel selectedLocationModel = value; + SelectedLocationModel + selectedLocationModel = value; - controller.sourceTextEditController.value.text = Utils.formatAddress(selectedLocation: selectedLocationModel); - controller.setDepartureMarker(selectedLocationModel.latLng!.latitude, selectedLocationModel.latLng!.longitude); + controller + .sourceTextEditController + .value + .text = Utils.formatAddress( + selectedLocation: + selectedLocationModel, + ); + controller.setDepartureMarker( + selectedLocationModel + .latLng! + .latitude, + selectedLocationModel + .latLng! + .longitude, + ); } }); } }, child: TextFieldWidget( - controller: controller.sourceTextEditController.value, - hintText: "Pickup Location".tr, + controller: + controller + .sourceTextEditController + .value, + hintText: + ConstTexts.pickUpLocation.tr, enable: false, - prefix: const Padding(padding: EdgeInsets.only(left: 10, right: 10), child: Icon(Icons.stop_circle_outlined, color: Colors.green)), + prefix: const Padding( + padding: EdgeInsets.only( + left: 10, + right: 10, + ), + child: Icon( + Icons.stop_circle_outlined, + color: Colors.green, + ), + ), ), ), const SizedBox(height: 10), // Destination Location InkWell( onTap: () async { - if (Constant.selectedMapType == 'osm') { - final result = await Get.to(() => MapPickerPage()); + if (Constant.selectedMapType == + 'osm') { + final result = await Get.to( + () => MapPickerPage(), + ); if (result != null) { - controller.destinationTextEditController.value.text = ''; + controller + .destinationTextEditController + .value + .text = ''; final firstPlace = result; - final lat = firstPlace.coordinates.latitude; - final lng = firstPlace.coordinates.longitude; - final address = firstPlace.address; - controller.destinationTextEditController.value.text = address.toString(); - controller.setDestinationMarker(lat, lng); + final lat = + firstPlace + .coordinates + .latitude; + final lng = + firstPlace + .coordinates + .longitude; + final address = + firstPlace.address; + controller + .destinationTextEditController + .value + .text = address.toString(); + controller.setDestinationMarker( + lat, + lng, + ); } } else { - Get.to(LocationPickerScreen())!.then((value) async { + Get.to( + LocationPickerScreen(), + )!.then((value) async { if (value != null) { - SelectedLocationModel selectedLocationModel = value; + SelectedLocationModel + selectedLocationModel = value; - controller.destinationTextEditController.value.text = Utils.formatAddress(selectedLocation: selectedLocationModel); - controller.setDestinationMarker(selectedLocationModel.latLng!.latitude, selectedLocationModel.latLng!.longitude); + controller + .destinationTextEditController + .value + .text = Utils.formatAddress( + selectedLocation: + selectedLocationModel, + ); + controller.setDestinationMarker( + selectedLocationModel + .latLng! + .latitude, + selectedLocationModel + .latLng! + .longitude, + ); } }); } }, child: TextFieldWidget( - controller: controller.destinationTextEditController.value, + controller: + controller + .destinationTextEditController + .value, // backgroundColor: AppThemeData.grey50, // borderColor: AppThemeData.grey50, - hintText: "Destination Location".tr, + hintText: + ConstTexts.destinationLocation.tr, enable: false, - prefix: const Padding(padding: EdgeInsets.only(left: 10, right: 10), child: Icon(Icons.radio_button_checked, color: Colors.red)), + prefix: const Padding( + padding: EdgeInsets.only( + left: 10, + right: 10, + ), + child: Icon( + Icons.radio_button_checked, + color: Colors.red, + ), + ), ), ), ], @@ -754,9 +1433,15 @@ class IntercityHomeScreen extends StatelessWidget { (size) => Path() ..moveTo(size.width / 2, 0) - ..lineTo(size.width / 2, size.height), + ..lineTo( + size.width / 2, + size.height, + ), + ), + child: const SizedBox( + width: 20, + height: 40, ), - child: const SizedBox(width: 20, height: 40), ), ), ], @@ -765,24 +1450,54 @@ class IntercityHomeScreen extends StatelessWidget { Row( children: [ - Expanded(child: Text("Promo code".tr, style: AppThemeData.boldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900))), + Expanded( + child: Text( + ConstTexts.promoCode.tr, + style: AppThemeData.boldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + ), InkWell( onTap: () { - Get.to(CabCouponCodeScreen())!.then((value) { + Get.to(CabCouponCodeScreen())!.then(( + value, + ) { if (value != null) { - double couponAmount = Constant.calculateDiscount(amount: controller.subTotal.value.toString(), offerModel: value); - if (couponAmount < controller.subTotal.value) { - controller.selectedCouponModel.value = value; + double couponAmount = + Constant.calculateDiscount( + amount: + controller.subTotal.value + .toString(), + offerModel: value, + ); + if (couponAmount < + controller.subTotal.value) { + controller.selectedCouponModel.value = + value; controller.calculateTotalAmount(); } else { - ShowToastDialog.showToast("This offer not eligible for this booking".tr); + ShowToastDialog.showToast( + ConstTexts.thisOfferNotEligible.tr, + ); } } }); }, child: Text( - "View All".tr, - style: AppThemeData.boldTextStyle(decoration: TextDecoration.underline, fontSize: 14, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300), + ConstTexts.viewAll.tr, + style: AppThemeData.boldTextStyle( + decoration: TextDecoration.underline, + fontSize: 14, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + ), ), ), ], @@ -795,55 +1510,129 @@ class IntercityHomeScreen extends StatelessWidget { height: Responsive.height(6, context), color: AppThemeData.carRent50, child: DottedBorder( - options: RectDottedBorderOptions(dashPattern: [10, 5], strokeWidth: 1, padding: EdgeInsets.all(0), color: AppThemeData.carRent400), + options: RectDottedBorderOptions( + dashPattern: [10, 5], + strokeWidth: 1, + padding: EdgeInsets.all(0), + color: AppThemeData.carRent400, + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, children: [ - SvgPicture.asset("assets/icons/ic_coupon.svg"), + SvgPicture.asset( + "assets/icons/ic_coupon.svg", + ), Expanded( child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10), + padding: const EdgeInsets.symmetric( + horizontal: 10, + ), child: TextFormField( - controller: controller.couponCodeTextEditController.value, - style: AppThemeData.semiBoldTextStyle(color: AppThemeData.parcelService500, fontSize: 16), + controller: + controller + .couponCodeTextEditController + .value, + style: + AppThemeData.semiBoldTextStyle( + color: + AppThemeData + .parcelService500, + fontSize: 16, + ), decoration: InputDecoration( border: InputBorder.none, - hintText: 'Write coupon Code'.tr, - contentPadding: EdgeInsets.only(bottom: 10), - hintStyle: AppThemeData.semiBoldTextStyle(color: AppThemeData.parcelService500, fontSize: 16), + hintText: + ConstTexts.writeCoupon.tr, + contentPadding: EdgeInsets.only( + bottom: 10, + ), + hintStyle: + AppThemeData.semiBoldTextStyle( + color: + AppThemeData + .parcelService500, + fontSize: 16, + ), ), ), ), ), RoundedButtonFill( - title: "Redeem now".tr, - width: 27, - borderRadius: 10, + borderRadius: 10.r, + title: ConstTexts.redeemNow.tr, + width: 27.w, + fontSizes: 14, onPress: () async { if (controller.cabCouponList - .where((element) => element.code!.toLowerCase() == controller.couponCodeTextEditController.value.text.toLowerCase()) + .where( + (element) => + element.code! + .toLowerCase() == + controller + .couponCodeTextEditController + .value + .text + .toLowerCase(), + ) .isNotEmpty) { - CouponModel couponModel = controller.cabCouponList.firstWhere( - (p0) => p0.code!.toLowerCase() == controller.couponCodeTextEditController.value.text.toLowerCase(), - ); - if (couponModel.expiresAt!.toDate().isAfter(DateTime.now())) { - double couponAmount = Constant.calculateDiscount(amount: controller.subTotal.value.toString(), offerModel: couponModel); - if (couponAmount < controller.subTotal.value) { - controller.selectedCouponModel.value = couponModel; - controller.calculateTotalAmount(); + CouponModel + couponModel = controller + .cabCouponList + .firstWhere( + (p0) => + p0.code! + .toLowerCase() == + controller + .couponCodeTextEditController + .value + .text + .toLowerCase(), + ); + if (couponModel.expiresAt! + .toDate() + .isAfter(DateTime.now())) { + double couponAmount = + Constant.calculateDiscount( + amount: + controller + .subTotal + .value + .toString(), + offerModel: couponModel, + ); + if (couponAmount < + controller.subTotal.value) { + controller + .selectedCouponModel + .value = couponModel; + controller + .calculateTotalAmount(); controller.update(); } else { - ShowToastDialog.showToast("This offer not eligible for this booking".tr); + ShowToastDialog.showToast( + ConstTexts + .thisOfferNotEligible + .tr, + ); } } else { - ShowToastDialog.showToast("This coupon code has been expired".tr); + ShowToastDialog.showToast( + ConstTexts.couponExpired.tr, + ); } } else { - ShowToastDialog.showToast("Invalid coupon code".tr); + ShowToastDialog.showToast( + ConstTexts.invalidCouponCode.tr, + ); } }, color: AppThemeData.parcelService300, @@ -860,46 +1649,121 @@ class IntercityHomeScreen extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("Order Summary".tr, style: AppThemeData.boldTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500)), + Text( + ConstTexts.orderSummary.tr, + style: AppThemeData.boldTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), + ), const SizedBox(height: 8), Padding( - padding: const EdgeInsets.symmetric(vertical: 4), + padding: const EdgeInsets.symmetric( + vertical: 4, + ), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ - Text("Subtotal".tr, style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), Text( - Constant.amountShow(amount: controller.subTotal.value.toString()), - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + ConstTexts.subtotal.tr, + style: AppThemeData.mediumTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + Text( + Constant.amountShow( + amount: + controller.subTotal.value + .toString(), + ), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ], ), ), Padding( - padding: const EdgeInsets.symmetric(vertical: 4), + padding: const EdgeInsets.symmetric( + vertical: 4, + ), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ Row( children: [ - Text("Discount".tr, style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + ConstTexts.discount.tr, + style: + AppThemeData.mediumTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), + ), SizedBox(width: 5), Text( - controller.selectedCouponModel.value.id == null ? "" : "(${controller.selectedCouponModel.value.code})", - style: AppThemeData.mediumTextStyle(fontSize: 16, color: AppThemeData.primary300), + controller + .selectedCouponModel + .value + .id == + null + ? "" + : "(${controller.selectedCouponModel.value.code})", + style: + AppThemeData.mediumTextStyle( + fontSize: 16, + color: + AppThemeData.primary300, + ), ), ], ), - Text(Constant.amountShow(amount: controller.discount.value.toString()), style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: AppThemeData.danger300)), + Text( + Constant.amountShow( + amount: + controller.discount.value + .toString(), + ), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: AppThemeData.danger300, + ), + ), ], ), ), @@ -911,24 +1775,56 @@ class IntercityHomeScreen extends StatelessWidget { physics: NeverScrollableScrollPhysics(), padding: EdgeInsets.zero, itemBuilder: (context, index) { - TaxModel taxModel = Constant.taxList[index]; + TaxModel taxModel = + Constant.taxList[index]; return Padding( - padding: const EdgeInsets.only(bottom: 5), + padding: const EdgeInsets.only( + bottom: 5, + ), child: Row( children: [ Expanded( child: Text( - '${taxModel.title} (${taxModel.tax} ${taxModel.type == "Fixed" ? Constant.currencyData!.code : "%"})'.tr, + '${taxModel.title} (${taxModel.tax} ${taxModel.type == "Fixed" ? Constant.currencyData!.code : "%"})', textAlign: TextAlign.start, - style: AppThemeData.mediumTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: + AppThemeData.mediumTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), ), ), Text( Constant.amountShow( - amount: Constant.calculateTax(amount: (controller.subTotal.value - controller.discount.value).toString(), taxModel: taxModel).toString(), - ).tr, + amount: + Constant.calculateTax( + amount: + (controller + .subTotal + .value - + controller + .discount + .value) + .toString(), + taxModel: taxModel, + ).toString(), + ), textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: + AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), ), ], ), @@ -938,14 +1834,36 @@ class IntercityHomeScreen extends StatelessWidget { const Divider(), Padding( - padding: const EdgeInsets.symmetric(vertical: 4), + padding: const EdgeInsets.symmetric( + vertical: 4, + ), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ - Text("Order Total".tr, style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), Text( - Constant.amountShow(amount: controller.totalAmount.value.toString()), - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + ConstTexts.orderTotal.tr, + style: AppThemeData.mediumTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + Text( + Constant.amountShow( + amount: + controller.totalAmount.value + .toString(), + ), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ], ), @@ -957,42 +1875,154 @@ class IntercityHomeScreen extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), padding: const EdgeInsets.all(10), child: Row( children: [ controller.selectedPaymentMethod.value == '' - ? cardDecorationScreen(controller, PaymentGateway.wallet, isDark, "") - : controller.selectedPaymentMethod.value == PaymentGateway.wallet.name - ? cardDecorationScreen(controller, PaymentGateway.wallet, isDark, "assets/images/ic_wallet.png") - : controller.selectedPaymentMethod.value == PaymentGateway.cod.name - ? cardDecorationScreen(controller, PaymentGateway.cod, isDark, "assets/images/ic_cash.png") - : controller.selectedPaymentMethod.value == PaymentGateway.stripe.name - ? cardDecorationScreen(controller, PaymentGateway.stripe, isDark, "assets/images/stripe.png") - : controller.selectedPaymentMethod.value == PaymentGateway.paypal.name - ? cardDecorationScreen(controller, PaymentGateway.paypal, isDark, "assets/images/paypal.png") - : controller.selectedPaymentMethod.value == PaymentGateway.payStack.name - ? cardDecorationScreen(controller, PaymentGateway.payStack, isDark, "assets/images/paystack.png") - : controller.selectedPaymentMethod.value == PaymentGateway.mercadoPago.name - ? cardDecorationScreen(controller, PaymentGateway.mercadoPago, isDark, "assets/images/mercado-pago.png") - : controller.selectedPaymentMethod.value == PaymentGateway.flutterWave.name - ? cardDecorationScreen(controller, PaymentGateway.flutterWave, isDark, "assets/images/flutterwave_logo.png") - : controller.selectedPaymentMethod.value == PaymentGateway.payFast.name - ? cardDecorationScreen(controller, PaymentGateway.payFast, isDark, "assets/images/payfast.png") - : controller.selectedPaymentMethod.value == PaymentGateway.midTrans.name - ? cardDecorationScreen(controller, PaymentGateway.midTrans, isDark, "assets/images/midtrans.png") - : controller.selectedPaymentMethod.value == PaymentGateway.orangeMoney.name - ? cardDecorationScreen(controller, PaymentGateway.orangeMoney, isDark, "assets/images/orange_money.png") - : controller.selectedPaymentMethod.value == PaymentGateway.xendit.name - ? cardDecorationScreen(controller, PaymentGateway.xendit, isDark, "assets/images/xendit.png") - : cardDecorationScreen(controller, PaymentGateway.razorpay, isDark, "assets/images/razorpay.png"), + ? cardDecorationScreen( + controller, + PaymentGateway.wallet, + isDark, + "", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.wallet.name + ? cardDecorationScreen( + controller, + PaymentGateway.wallet, + isDark, + "assets/images/ic_wallet.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.cod.name + ? cardDecorationScreen( + controller, + PaymentGateway.cod, + isDark, + "assets/images/ic_cash.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.stripe.name + ? cardDecorationScreen( + controller, + PaymentGateway.stripe, + isDark, + "assets/images/stripe.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.paypal.name + ? cardDecorationScreen( + controller, + PaymentGateway.paypal, + isDark, + "assets/images/paypal.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.payStack.name + ? cardDecorationScreen( + controller, + PaymentGateway.payStack, + isDark, + "assets/images/paystack.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.mercadoPago.name + ? cardDecorationScreen( + controller, + PaymentGateway.mercadoPago, + isDark, + "assets/images/mercado-pago.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.flutterWave.name + ? cardDecorationScreen( + controller, + PaymentGateway.flutterWave, + isDark, + "assets/images/flutterwave_logo.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.payFast.name + ? cardDecorationScreen( + controller, + PaymentGateway.payFast, + isDark, + "assets/images/payfast.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.midTrans.name + ? cardDecorationScreen( + controller, + PaymentGateway.midTrans, + isDark, + "assets/images/midtrans.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.orangeMoney.name + ? cardDecorationScreen( + controller, + PaymentGateway.orangeMoney, + isDark, + "assets/images/orange_money.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.xendit.name + ? cardDecorationScreen( + controller, + PaymentGateway.xendit, + isDark, + "assets/images/xendit.png", + ) + : cardDecorationScreen( + controller, + PaymentGateway.razorpay, + isDark, + "assets/images/razorpay.png", + ), SizedBox(width: 22), Text( - controller.selectedPaymentMethod.value.tr, + controller.selectedPaymentMethod.value, textAlign: TextAlign.start, - style: AppThemeData.boldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: AppThemeData.boldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ], ), @@ -1001,7 +2031,8 @@ class IntercityHomeScreen extends StatelessWidget { ), ), RoundedButtonFill( - title: "Confirm Booking".tr, + borderRadius: 10.r, + title: ConstTexts.confirmBooking.tr, onPress: () async { controller.placeOrder(); }, @@ -1019,7 +2050,11 @@ class IntercityHomeScreen extends StatelessWidget { ); } - Widget waitingDialog(BuildContext context, IntercityHomeController controller, bool isDark) { + Widget waitingDialog( + BuildContext context, + IntercityHomeController controller, + bool isDark, + ) { return Positioned.fill( child: DraggableScrollableSheet( initialChildSize: 0.4, @@ -1028,18 +2063,41 @@ class IntercityHomeScreen extends StatelessWidget { expand: false, builder: (context, scrollController) { return Container( - decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.only(topLeft: Radius.circular(30), topRight: Radius.circular(30))), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(30), + topRight: Radius.circular(30), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 15.0, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 15.0, + vertical: 10, + ), child: Column( mainAxisSize: MainAxisSize.min, children: [ - Container(decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), color: AppThemeData.grey400), height: 4, width: 33), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: AppThemeData.grey400, + ), + height: 4, + width: 33, + ), SizedBox(height: 30), - Text("Waiting for driver....".tr, style: AppThemeData.mediumTextStyle(fontSize: 18, color: AppThemeData.grey900)), + Text( + ConstTexts.waitingForDriver.tr, + style: AppThemeData.mediumTextStyle( + fontSize: 18, + color: AppThemeData.grey900, + ), + ), Image.asset('assets/loader.gif', width: 250), RoundedButtonFill( - title: "Cancel Ride".tr, + borderRadius: 10.r, + title: ConstTexts.cancelRide.tr, onPress: () async { try { // 1. Update current order status @@ -1051,7 +2109,9 @@ class IntercityHomeScreen extends StatelessWidget { // 2. Save to Firestore if (controller.currentOrder.value.id != null) { - await FireStoreUtils.updateCabOrder(controller.currentOrder.value); + await FireStoreUtils.updateCabOrder( + controller.currentOrder.value, + ); } // 3. Reset controller states @@ -1062,10 +2122,22 @@ class IntercityHomeScreen extends StatelessWidget { controller.routePoints.clear(); controller.sourceTextEditController.value.clear(); controller.destinationTextEditController.value.clear(); - controller.departureLatLong.value = const LatLng(0.0, 0.0); - controller.destinationLatLong.value = const LatLng(0.0, 0.0); - controller.departureLatLongOsm.value = latlong.LatLng(0.0, 0.0); - controller.destinationLatLongOsm.value = latlong.LatLng(0.0, 0.0); + controller.departureLatLong.value = const LatLng( + 0.0, + 0.0, + ); + controller.destinationLatLong.value = const LatLng( + 0.0, + 0.0, + ); + controller.departureLatLongOsm.value = latlong.LatLng( + 0.0, + 0.0, + ); + controller.destinationLatLongOsm.value = latlong.LatLng( + 0.0, + 0.0, + ); // 4. Reset user’s in-progress order if (Constant.userModel != null) { @@ -1074,12 +2146,16 @@ class IntercityHomeScreen extends StatelessWidget { } // 5. Optional feedback - ShowToastDialog.showToast("Ride cancelled successfully".tr); + ShowToastDialog.showToast( + ConstTexts.riderCancelledSucces.tr, + ); Get.back(); - CabDashboardController cabDashboardController = Get.put(CabDashboardController()); + CabDashboardController cabDashboardController = Get.put( + CabDashboardController(), + ); cabDashboardController.selectedIndex.value = 0; } catch (e) { - ShowToastDialog.showToast("Failed to cancel ride".tr); + ShowToastDialog.showToast(ConstTexts.failedToCancel.tr); } }, color: AppThemeData.danger300, @@ -1094,7 +2170,11 @@ class IntercityHomeScreen extends StatelessWidget { ); } - Widget driverDialog(BuildContext context, IntercityHomeController controller, bool isDark) { + Widget driverDialog( + BuildContext context, + IntercityHomeController controller, + bool isDark, + ) { return Positioned.fill( child: DraggableScrollableSheet( initialChildSize: 0.7, @@ -1103,13 +2183,29 @@ class IntercityHomeScreen extends StatelessWidget { expand: false, builder: (context, scrollController) { return Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.grey700 : Colors.white, borderRadius: BorderRadius.only(topLeft: Radius.circular(30), topRight: Radius.circular(30))), + decoration: BoxDecoration( + color: isDark ? AppThemeData.grey700 : Colors.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(30), + topRight: Radius.circular(30), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 15.0, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 15.0, + vertical: 10, + ), child: Column( mainAxisSize: MainAxisSize.min, children: [ - Container(decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), color: AppThemeData.grey400), height: 4, width: 33), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: AppThemeData.grey400, + ), + height: 4, + width: 33, + ), Expanded( child: ListView( controller: scrollController, @@ -1119,7 +2215,11 @@ class IntercityHomeScreen extends StatelessWidget { Stack( children: [ Container( - decoration: BoxDecoration(color: isDark ? Colors.transparent : Colors.white, borderRadius: BorderRadius.circular(12)), + decoration: BoxDecoration( + color: + isDark ? Colors.transparent : Colors.white, + borderRadius: BorderRadius.circular(12), + ), child: Column( mainAxisSize: MainAxisSize.min, children: [ @@ -1149,11 +2249,23 @@ class IntercityHomeScreen extends StatelessWidget { // } }, child: TextFieldWidget( - controller: controller.sourceTextEditController.value, - hintText: "Pickup Location".tr, + controller: + controller + .sourceTextEditController + .value, + hintText: ConstTexts.pickUpLocation.tr, enable: false, readOnly: true, - prefix: const Padding(padding: EdgeInsets.only(left: 10, right: 10), child: Icon(Icons.stop_circle_outlined, color: Colors.green)), + prefix: const Padding( + padding: EdgeInsets.only( + left: 10, + right: 10, + ), + child: Icon( + Icons.stop_circle_outlined, + color: Colors.green, + ), + ), ), ), const SizedBox(height: 10), @@ -1183,13 +2295,26 @@ class IntercityHomeScreen extends StatelessWidget { // } }, child: TextFieldWidget( - controller: controller.destinationTextEditController.value, + controller: + controller + .destinationTextEditController + .value, // backgroundColor: AppThemeData.grey50, // borderColor: AppThemeData.grey50, - hintText: "Destination Location".tr, + hintText: + ConstTexts.destinationLocation.tr, enable: false, readOnly: true, - prefix: const Padding(padding: EdgeInsets.only(left: 10, right: 10), child: Icon(Icons.radio_button_checked, color: Colors.red)), + prefix: const Padding( + padding: EdgeInsets.only( + left: 10, + right: 10, + ), + child: Icon( + Icons.radio_button_checked, + color: Colors.red, + ), + ), ), ), ], @@ -1207,7 +2332,10 @@ class IntercityHomeScreen extends StatelessWidget { (size) => Path() ..moveTo(size.width / 2, 0) - ..lineTo(size.width / 2, size.height), + ..lineTo( + size.width / 2, + size.height, + ), ), child: const SizedBox(width: 20, height: 40), ), @@ -1221,7 +2349,18 @@ class IntercityHomeScreen extends StatelessWidget { children: [ ClipRRect( borderRadius: BorderRadiusGeometry.circular(10), - child: NetworkImageWidget(imageUrl: controller.currentOrder.value.driver?.profilePictureURL ?? '', height: 70, width: 70, borderRadius: 35), + child: NetworkImageWidget( + imageUrl: + controller + .currentOrder + .value + .driver + ?.profilePictureURL ?? + '', + height: 70, + width: 70, + borderRadius: 35, + ), ), SizedBox(width: 10), Expanded( @@ -1230,22 +2369,51 @@ class IntercityHomeScreen extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - controller.currentOrder.value.driver?.fullName() ?? '', - style: AppThemeData.boldTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, fontSize: 18), + controller.currentOrder.value.driver + ?.fullName() ?? + '', + style: AppThemeData.boldTextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + fontSize: 18, + ), ), Text( "${controller.currentOrder.value.driver?.vehicleType ?? ''} | ${controller.currentOrder.value.driver?.carMakes ?? ''}", - style: TextStyle(fontFamily: AppThemeData.medium, color: isDark ? AppThemeData.greyDark700 : AppThemeData.grey700, fontSize: 14), + style: TextStyle( + fontFamily: AppThemeData.medium, + color: + isDark + ? AppThemeData.greyDark700 + : AppThemeData.grey700, + fontSize: 14, + ), ), Text( - controller.currentOrder.value.driver?.carNumber ?? '', - style: AppThemeData.boldTextStyle(color: isDark ? AppThemeData.greyDark700 : AppThemeData.grey700, fontSize: 16), + controller + .currentOrder + .value + .driver + ?.carNumber ?? + '', + style: AppThemeData.boldTextStyle( + color: + isDark + ? AppThemeData.greyDark700 + : AppThemeData.grey700, + fontSize: 16, + ), ), ], ), ), RoundedButtonBorder( - title: controller.driverModel.value.averageRating.toStringAsFixed(1) ?? '', + title: + controller.driverModel.value.averageRating + .toStringAsFixed(1) ?? + '', width: 20, height: 3.5, radius: 10, @@ -1254,7 +2422,9 @@ class IntercityHomeScreen extends StatelessWidget { textColor: AppThemeData.warning400, borderColor: AppThemeData.warning400, color: AppThemeData.warning50, - icon: SvgPicture.asset("assets/icons/ic_start.svg"), + icon: SvgPicture.asset( + "assets/icons/ic_start.svg", + ), onPress: () {}, ), ], @@ -1263,37 +2433,98 @@ class IntercityHomeScreen extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("Order Summary".tr, style: AppThemeData.boldTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500)), + Text( + ConstTexts.orderSummary.tr, + style: AppThemeData.boldTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), + ), const SizedBox(height: 8), Padding( - padding: const EdgeInsets.symmetric(vertical: 4), + padding: const EdgeInsets.symmetric( + vertical: 4, + ), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ - Text("Subtotal".tr, style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), Text( - Constant.amountShow(amount: controller.subTotal.value.toString()), - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + ConstTexts.subtotal.tr, + style: AppThemeData.mediumTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + Text( + Constant.amountShow( + amount: + controller.subTotal.value + .toString(), + ), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ], ), ), Padding( - padding: const EdgeInsets.symmetric(vertical: 4), + padding: const EdgeInsets.symmetric( + vertical: 4, + ), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ - Text("Discount".tr, style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), - Text(Constant.amountShow(amount: controller.discount.value.toString()), style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: AppThemeData.danger300)), + Text( + ConstTexts.discount.tr, + style: AppThemeData.mediumTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + Text( + Constant.amountShow( + amount: + controller.discount.value + .toString(), + ), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: AppThemeData.danger300, + ), + ), ], ), ), @@ -1312,17 +2543,40 @@ class IntercityHomeScreen extends StatelessWidget { children: [ Expanded( child: Text( - '${taxModel.title} (${taxModel.tax} ${taxModel.type == "Fixed" ? Constant.currencyData!.code : "%"})'.tr, + '${taxModel.title} (${taxModel.tax} ${taxModel.type == "Fixed" ? Constant.currencyData!.code : "%"})', textAlign: TextAlign.start, - style: AppThemeData.mediumTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: AppThemeData.mediumTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ), Text( Constant.amountShow( - amount: Constant.calculateTax(amount: (controller.subTotal.value - controller.discount.value).toString(), taxModel: taxModel).toString(), - ).tr, + amount: + Constant.calculateTax( + amount: + (controller + .subTotal + .value - + controller + .discount + .value) + .toString(), + taxModel: taxModel, + ).toString(), + ), textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ], ), @@ -1332,14 +2586,36 @@ class IntercityHomeScreen extends StatelessWidget { const Divider(), Padding( - padding: const EdgeInsets.symmetric(vertical: 4), + padding: const EdgeInsets.symmetric( + vertical: 4, + ), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ - Text("Order Total".tr, style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), Text( - Constant.amountShow(amount: controller.totalAmount.value.toString()), - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + ConstTexts.orderTotal.tr, + style: AppThemeData.mediumTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + Text( + Constant.amountShow( + amount: + controller.totalAmount.value + .toString(), + ), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ], ), @@ -1351,8 +2627,16 @@ class IntercityHomeScreen extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), padding: const EdgeInsets.all(10), child: InkWell( @@ -1361,34 +2645,111 @@ class IntercityHomeScreen extends StatelessWidget { }, child: Row( children: [ - controller.selectedPaymentMethod.value == PaymentGateway.wallet.name - ? cardDecorationScreen(controller, PaymentGateway.wallet, isDark, "assets/images/ic_wallet.png") - : controller.selectedPaymentMethod.value == PaymentGateway.cod.name - ? cardDecorationScreen(controller, PaymentGateway.cod, isDark, "assets/images/ic_cash.png") - : controller.selectedPaymentMethod.value == PaymentGateway.stripe.name - ? cardDecorationScreen(controller, PaymentGateway.stripe, isDark, "assets/images/stripe.png") - : controller.selectedPaymentMethod.value == PaymentGateway.paypal.name - ? cardDecorationScreen(controller, PaymentGateway.paypal, isDark, "assets/images/paypal.png") - : controller.selectedPaymentMethod.value == PaymentGateway.payStack.name - ? cardDecorationScreen(controller, PaymentGateway.payStack, isDark, "assets/images/paystack.png") - : controller.selectedPaymentMethod.value == PaymentGateway.mercadoPago.name - ? cardDecorationScreen(controller, PaymentGateway.mercadoPago, isDark, "assets/images/mercado-pago.png") - : controller.selectedPaymentMethod.value == PaymentGateway.flutterWave.name - ? cardDecorationScreen(controller, PaymentGateway.flutterWave, isDark, "assets/images/flutterwave_logo.png") - : controller.selectedPaymentMethod.value == PaymentGateway.payFast.name - ? cardDecorationScreen(controller, PaymentGateway.payFast, isDark, "assets/images/payfast.png") - : controller.selectedPaymentMethod.value == PaymentGateway.midTrans.name - ? cardDecorationScreen(controller, PaymentGateway.midTrans, isDark, "assets/images/midtrans.png") - : controller.selectedPaymentMethod.value == PaymentGateway.orangeMoney.name - ? cardDecorationScreen(controller, PaymentGateway.orangeMoney, isDark, "assets/images/orange_money.png") - : controller.selectedPaymentMethod.value == PaymentGateway.xendit.name - ? cardDecorationScreen(controller, PaymentGateway.xendit, isDark, "assets/images/xendit.png") - : cardDecorationScreen(controller, PaymentGateway.razorpay, isDark, "assets/images/razorpay.png"), + controller.selectedPaymentMethod.value == + PaymentGateway.wallet.name + ? cardDecorationScreen( + controller, + PaymentGateway.wallet, + isDark, + "assets/images/ic_wallet.png", + ) + : controller.selectedPaymentMethod.value == + PaymentGateway.cod.name + ? cardDecorationScreen( + controller, + PaymentGateway.cod, + isDark, + "assets/images/ic_cash.png", + ) + : controller.selectedPaymentMethod.value == + PaymentGateway.stripe.name + ? cardDecorationScreen( + controller, + PaymentGateway.stripe, + isDark, + "assets/images/stripe.png", + ) + : controller.selectedPaymentMethod.value == + PaymentGateway.paypal.name + ? cardDecorationScreen( + controller, + PaymentGateway.paypal, + isDark, + "assets/images/paypal.png", + ) + : controller.selectedPaymentMethod.value == + PaymentGateway.payStack.name + ? cardDecorationScreen( + controller, + PaymentGateway.payStack, + isDark, + "assets/images/paystack.png", + ) + : controller.selectedPaymentMethod.value == + PaymentGateway.mercadoPago.name + ? cardDecorationScreen( + controller, + PaymentGateway.mercadoPago, + isDark, + "assets/images/mercado-pago.png", + ) + : controller.selectedPaymentMethod.value == + PaymentGateway.flutterWave.name + ? cardDecorationScreen( + controller, + PaymentGateway.flutterWave, + isDark, + "assets/images/flutterwave_logo.png", + ) + : controller.selectedPaymentMethod.value == + PaymentGateway.payFast.name + ? cardDecorationScreen( + controller, + PaymentGateway.payFast, + isDark, + "assets/images/payfast.png", + ) + : controller.selectedPaymentMethod.value == + PaymentGateway.midTrans.name + ? cardDecorationScreen( + controller, + PaymentGateway.midTrans, + isDark, + "assets/images/midtrans.png", + ) + : controller.selectedPaymentMethod.value == + PaymentGateway.orangeMoney.name + ? cardDecorationScreen( + controller, + PaymentGateway.orangeMoney, + isDark, + "assets/images/orange_money.png", + ) + : controller.selectedPaymentMethod.value == + PaymentGateway.xendit.name + ? cardDecorationScreen( + controller, + PaymentGateway.xendit, + isDark, + "assets/images/xendit.png", + ) + : cardDecorationScreen( + controller, + PaymentGateway.razorpay, + isDark, + "assets/images/razorpay.png", + ), SizedBox(width: 22), Text( - controller.selectedPaymentMethod.value.tr, + controller.selectedPaymentMethod.value, textAlign: TextAlign.start, - style: AppThemeData.boldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: AppThemeData.boldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ], ), @@ -1396,47 +2757,78 @@ class IntercityHomeScreen extends StatelessWidget { ), const SizedBox(height: 20), Obx(() { - if (controller.currentOrder.value.status == Constant.orderInTransit) { + if (controller.currentOrder.value.status == + Constant.orderInTransit) { return Column( children: [ RoundedButtonFill( - title: "SOS".tr, - color: Colors.red.withOpacity(0.50), + borderRadius: 10.r, + title: "SOS", + color: Colors.red.withValues(alpha: 0.50), textColor: AppThemeData.grey50, isCenter: true, icon: Icon(Icons.call, color: Colors.white), onPress: () async { - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader( + ConstTexts.pleaseWait.tr, + ); - LocationData location = await controller.currentLocation.value.getLocation(); + LocationData location = + await controller.currentLocation.value + .getLocation(); - await FireStoreUtils.getSOS(controller.currentOrder.value.id ?? '').then((value) async { + await FireStoreUtils.getSOS( + controller.currentOrder.value.id ?? '', + ).then((value) async { if (value == false) { - await FireStoreUtils.setSos(controller.currentOrder.value.id ?? '', UserLocation(latitude: location.latitude!, longitude: location.longitude!)).then((value) { + await FireStoreUtils.setSos( + controller.currentOrder.value.id ?? + '', + UserLocation( + latitude: location.latitude!, + longitude: location.longitude!, + ), + ).then((value) { ShowToastDialog.closeLoader(); - ScaffoldMessenger.of(context).showSnackBar( + ScaffoldMessenger.of( + context, + ).showSnackBar( SnackBar( content: Builder( builder: (context) { - return Text("Your SOS request has been submitted to admin".tr); + return Text( + ConstTexts + .yourSosRequest + .tr, + ); }, ), backgroundColor: Colors.green, - duration: const Duration(seconds: 3), + duration: const Duration( + seconds: 3, + ), ), ); }); } else { ShowToastDialog.closeLoader(); - ScaffoldMessenger.of(context).showSnackBar( + ScaffoldMessenger.of( + context, + ).showSnackBar( SnackBar( content: Builder( builder: (context) { - return Text("Your SOS request is already submitted".tr); + return Text( + ConstTexts + .yourSosrequestAlreadySubmitted + .tr, + ); }, ), backgroundColor: Colors.red, - duration: const Duration(seconds: 3), + duration: const Duration( + seconds: 3, + ), ), ); } @@ -1454,44 +2846,100 @@ class IntercityHomeScreen extends StatelessWidget { ), ), Obx(() { - if (controller.currentOrder.value.status == Constant.orderInTransit && controller.currentOrder.value.paymentStatus == false) { + if (controller.currentOrder.value.status == + Constant.orderInTransit && + controller.currentOrder.value.paymentStatus == false) { return RoundedButtonFill( - title: "Pay Now".tr, + borderRadius: 10.r, + title: ConstTexts.payNow.tr, onPress: () async { - if (controller.selectedPaymentMethod.value == PaymentGateway.stripe.name) { - controller.stripeMakePayment(amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.paypal.name) { - controller.paypalPaymentSheet(controller.totalAmount.value.toString(), context); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.payStack.name) { - controller.payStackPayment(controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.mercadoPago.name) { - controller.mercadoPagoMakePayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.flutterWave.name) { - controller.flutterWaveInitiatePayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.payFast.name) { - controller.payFastPayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.cod.name) { + if (controller.selectedPaymentMethod.value == + PaymentGateway.stripe.name) { + controller.stripeMakePayment( + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.paypal.name) { + controller.paypalPaymentSheet( + controller.totalAmount.value.toString(), + context, + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.payStack.name) { + controller.payStackPayment( + controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.mercadoPago.name) { + controller.mercadoPagoMakePayment( + context: context, + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.flutterWave.name) { + controller.flutterWaveInitiatePayment( + context: context, + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.payFast.name) { + controller.payFastPayment( + context: context, + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.cod.name) { controller.completeOrder(); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.wallet.name) { + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.wallet.name) { controller.completeOrder(); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.midTrans.name) { - controller.midtransMakePayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.orangeMoney.name) { - controller.orangeMakePayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.xendit.name) { - controller.xenditPayment(context, controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.razorpay.name) { - RazorPayController().createOrderRazorPay(amount: double.parse(controller.totalAmount.value.toString()), razorpayModel: controller.razorPayModel.value).then((value) { - if (value == null) { - Get.back(); - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); - } else { - CreateRazorPayOrderModel result = value; - controller.openCheckout(amount: controller.totalAmount.value.toString(), orderId: result.id); - } - }); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.midTrans.name) { + controller.midtransMakePayment( + context: context, + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.orangeMoney.name) { + controller.orangeMakePayment( + context: context, + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.xendit.name) { + controller.xenditPayment( + context, + controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.razorpay.name) { + RazorPayController() + .createOrderRazorPay( + amount: double.parse( + controller.totalAmount.value.toString(), + ), + razorpayModel: controller.razorPayModel.value, + ) + .then((value) { + if (value == null) { + Get.back(); + ShowToastDialog.showToast( + ConstTexts.somethingWentWrong.tr, + ); + } else { + CreateRazorPayOrderModel result = value; + controller.openCheckout( + amount: + controller.totalAmount.value + .toString(), + orderId: result.id, + ); + } + }); } else { - ShowToastDialog.showToast("Please select payment method".tr); + ShowToastDialog.showToast( + ConstTexts.plsSelectPaymentMethod.tr, + ); } }, color: AppThemeData.primary300, @@ -1510,19 +2958,42 @@ class IntercityHomeScreen extends StatelessWidget { ); } - Padding cardDecorationScreen(IntercityHomeController controller, PaymentGateway value, isDark, String image) { + Padding cardDecorationScreen( + IntercityHomeController controller, + PaymentGateway value, + isDark, + String image, + ) { return Padding( padding: const EdgeInsets.symmetric(vertical: 5), child: Container( width: 40, height: 40, - decoration: ShapeDecoration(shape: RoundedRectangleBorder(side: const BorderSide(width: 1, color: Color(0xFFE5E7EB)), borderRadius: BorderRadius.circular(8))), - child: Padding(padding: EdgeInsets.all(value.name == "payFast" ? 0 : 8.0), child: image == '' ? Container(color: isDark ? AppThemeData.grey800 : AppThemeData.grey100) : Image.asset(image)), + decoration: ShapeDecoration( + shape: RoundedRectangleBorder( + side: const BorderSide(width: 1, color: Color(0xFFE5E7EB)), + borderRadius: BorderRadius.circular(8), + ), + ), + child: Padding( + padding: EdgeInsets.all(value.name == "payFast" ? 0 : 8.0), + child: + image == '' + ? Container( + color: isDark ? AppThemeData.grey800 : AppThemeData.grey100, + ) + : Image.asset(image), + ), ), ); } - Obx cardDecoration(IntercityHomeController controller, PaymentGateway value, isDark, String image) { + Obx cardDecoration( + IntercityHomeController controller, + PaymentGateway value, + isDark, + String image, + ) { return Obx( () => Padding( padding: const EdgeInsets.symmetric(vertical: 5), @@ -1537,8 +3008,21 @@ class IntercityHomeScreen extends StatelessWidget { Container( width: 50, height: 50, - decoration: ShapeDecoration(shape: RoundedRectangleBorder(side: const BorderSide(width: 1, color: Color(0xFFE5E7EB)), borderRadius: BorderRadius.circular(8))), - child: Padding(padding: EdgeInsets.all(value.name == "payFast" ? 0 : 8.0), child: Image.asset(image)), + decoration: ShapeDecoration( + shape: RoundedRectangleBorder( + side: const BorderSide( + width: 1, + color: Color(0xFFE5E7EB), + ), + borderRadius: BorderRadius.circular(8), + ), + ), + child: Padding( + padding: EdgeInsets.all( + value.name == "payFast" ? 0 : 8.0, + ), + child: Image.asset(image), + ), ), const SizedBox(width: 10), value.name == "wallet" @@ -1549,12 +3033,34 @@ class IntercityHomeScreen extends StatelessWidget { Text( value.name.capitalizeString(), textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), Text( - Constant.amountShow(amount: controller.userModel.value.walletAmount == null ? '0.0' : controller.userModel.value.walletAmount.toString()), + Constant.amountShow( + amount: + controller.userModel.value.walletAmount == + null + ? '0.0' + : controller + .userModel + .value + .walletAmount + .toString(), + ), textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(fontSize: 14, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300), + style: AppThemeData.semiBoldTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + ), ), ], ), @@ -1563,14 +3069,23 @@ class IntercityHomeScreen extends StatelessWidget { child: Text( value.name.capitalizeString(), textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), ), const Expanded(child: SizedBox()), Radio( value: value.name, groupValue: controller.selectedPaymentMethod.value, - activeColor: isDark ? AppThemeData.primary300 : AppThemeData.primary300, + activeColor: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, onChanged: (value) { controller.selectedPaymentMethod.value = value.toString(); }, diff --git a/lib/screen_ui/cab_service_screens/cab_booking_screen.dart b/lib/screen_ui/cab_service_screens/cab_booking_screen.dart index dfb6c7c..93ed78c 100644 --- a/lib/screen_ui/cab_service_screens/cab_booking_screen.dart +++ b/lib/screen_ui/cab_service_screens/cab_booking_screen.dart @@ -1,5 +1,6 @@ import 'dart:io'; import 'package:cached_network_image/cached_network_image.dart'; +import 'package:customer/constant/const_texts.dart'; import 'package:customer/models/coupon_model.dart'; import 'package:customer/models/tax_model.dart'; import 'package:customer/models/vehicle_type.dart'; @@ -14,6 +15,7 @@ import 'package:customer/utils/network_image_widget.dart'; import 'package:customer/utils/utils.dart'; import 'package:dotted_border/dotted_border.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:get/get.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; @@ -56,22 +58,57 @@ class CabBookingScreen extends StatelessWidget { options: flutterMap.MapOptions( initialCenter: Constant.currentLocation != null - ? latlong.LatLng(Constant.currentLocation!.latitude, Constant.currentLocation!.longitude) + ? latlong.LatLng( + Constant.currentLocation!.latitude, + Constant.currentLocation!.longitude, + ) : controller.currentOrder.value.id != null ? latlong.LatLng( - double.parse(controller.currentOrder.value.sourceLocation!.latitude.toString()), - double.parse(controller.currentOrder.value.sourceLocation!.longitude.toString()), + double.parse( + controller + .currentOrder + .value + .sourceLocation! + .latitude + .toString(), + ), + double.parse( + controller + .currentOrder + .value + .sourceLocation! + .longitude + .toString(), + ), ) - : latlong.LatLng(41.4219057, -102.0840772), - initialZoom: 10, + : latlong.LatLng( + 41.4219057, + -102.0840772, + ), + initialZoom: 14, ), children: [ flutterMap.TileLayer( - urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', - userAgentPackageName: Platform.isAndroid ? "com.emart.customer" : "com.emart.customer.ios", + urlTemplate: + 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', + userAgentPackageName: + Platform.isAndroid + ? "felix.fondex.uz" + : "felix.fondex.uz.ios", ), - flutterMap.MarkerLayer(markers: controller.osmMarker), - if (controller.routePoints.isNotEmpty) flutterMap.PolylineLayer(polylines: [flutterMap.Polyline(points: controller.routePoints, strokeWidth: 5.0, color: Colors.blue)]), + flutterMap.MarkerLayer( + markers: controller.osmMarker, + ), + if (controller.routePoints.isNotEmpty) + flutterMap.PolylineLayer( + polylines: [ + flutterMap.Polyline( + points: controller.routePoints, + strokeWidth: 5.0, + color: Colors.blue, + ), + ], + ), ], ) : GoogleMap( @@ -79,16 +116,26 @@ class CabBookingScreen extends StatelessWidget { controller.mapController = googleMapController; if (Constant.currentLocation != null) { - controller.setDepartureMarker(Constant.currentLocation!.latitude, Constant.currentLocation!.longitude); + controller.setDepartureMarker( + Constant.currentLocation!.latitude, + Constant.currentLocation!.longitude, + ); controller.searchPlaceNameGoogle(); } }, - initialCameraPosition: CameraPosition(target: controller.currentPosition.value, zoom: 14), + initialCameraPosition: CameraPosition( + target: controller.currentPosition.value, + zoom: 14, + ), myLocationEnabled: true, zoomControlsEnabled: true, zoomGesturesEnabled: true, - polylines: Set.of(controller.polyLines.values), - markers: controller.markers.toSet(), // reactive marker set + polylines: Set.of( + controller.polyLines.values, + ), + markers: + controller.markers + .toSet(), // reactive marker set ), Positioned( @@ -97,36 +144,64 @@ class CabBookingScreen extends StatelessWidget { right: Constant.isRtl ? 20 : null, child: InkWell( onTap: () { - if (controller.bottomSheetType.value == "vehicleSelection") { + if (controller.bottomSheetType.value == + "vehicleSelection") { controller.bottomSheetType.value = "location"; - } else if (controller.bottomSheetType.value == "payment") { - controller.bottomSheetType.value = "vehicleSelection"; - } else if (controller.bottomSheetType.value == "conformRide") { + } else if (controller.bottomSheetType.value == + "payment") { + controller.bottomSheetType.value = + "vehicleSelection"; + } else if (controller.bottomSheetType.value == + "conformRide") { controller.bottomSheetType.value = "payment"; - } else if (controller.bottomSheetType.value == "waitingDriver" || controller.bottomSheetType.value == "driverDetails") { + } else if (controller.bottomSheetType.value == + "waitingDriver" || + controller.bottomSheetType.value == + "driverDetails") { Get.back(result: true); } else { Get.back(); } }, child: Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, borderRadius: BorderRadius.circular(30)), + decoration: BoxDecoration( + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + borderRadius: BorderRadius.circular(30), + ), child: Padding( padding: const EdgeInsets.all(10), - child: Center(child: Icon(Icons.arrow_back_ios_new, color: isDark ? AppThemeData.grey50 : AppThemeData.greyDark50, size: 20)), + child: Center( + child: Icon( + Icons.arrow_back_ios_new, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.greyDark50, + size: 20, + ), + ), ), ), ), ), controller.bottomSheetType.value == "location" - ? searchLocationBottomSheet(context, controller, isDark) - : controller.bottomSheetType.value == "vehicleSelection" + ? searchLocationBottomSheet( + context, + controller, + isDark, + ) + : controller.bottomSheetType.value == + "vehicleSelection" ? vehicleSelection(context, controller, isDark) : controller.bottomSheetType.value == "payment" ? paymentBottomSheet(context, controller, isDark) : controller.bottomSheetType.value == "conformRide" ? conformBottomSheet(context, isDark) - : controller.bottomSheetType.value == "waitingForDriver" + : controller.bottomSheetType.value == + "waitingForDriver" ? waitingDialog(context, controller, isDark) : controller.bottomSheetType.value == "driverDetails" ? driverDialog(context, controller, isDark) @@ -138,7 +213,11 @@ class CabBookingScreen extends StatelessWidget { ); } - Widget searchLocationBottomSheet(BuildContext context, CabBookingController controller, bool isDark) { + Widget searchLocationBottomSheet( + BuildContext context, + CabBookingController controller, + bool isDark, + ) { return Positioned.fill( child: DraggableScrollableSheet( initialChildSize: 0.30, @@ -151,16 +230,29 @@ class CabBookingScreen extends StatelessWidget { builder: (context, scrollController) { return Container( padding: const EdgeInsets.all(16), - decoration: BoxDecoration(color: isDark ? AppThemeData.grey700 : Colors.white, borderRadius: BorderRadius.vertical(top: Radius.circular(35))), + decoration: BoxDecoration( + color: isDark ? AppThemeData.grey700 : Colors.white, + borderRadius: BorderRadius.vertical(top: Radius.circular(35)), + ), child: Column( mainAxisSize: MainAxisSize.min, children: [ - Container(decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), color: AppThemeData.grey400), height: 4, width: 33), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: AppThemeData.grey400, + ), + height: 4, + width: 33, + ), SizedBox(height: 10), Stack( children: [ Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.grey700 : Colors.white, borderRadius: BorderRadius.circular(12)), + decoration: BoxDecoration( + color: isDark ? AppThemeData.grey700 : Colors.white, + borderRadius: BorderRadius.circular(12), + ), child: Column( mainAxisSize: MainAxisSize.min, children: [ @@ -168,40 +260,85 @@ class CabBookingScreen extends StatelessWidget { InkWell( onTap: () async { if (Constant.selectedMapType == 'osm') { - final result = await Get.to(() => MapPickerPage()); + final result = await Get.to( + () => MapPickerPage(), + ); if (result != null) { - controller.sourceTextEditController.value.text = ''; + controller + .sourceTextEditController + .value + .text = ''; final firstPlace = result; - if (Constant.checkZoneCheck(firstPlace.coordinates.latitude, firstPlace.coordinates.longitude) == true) { + if (Constant.checkZoneCheck( + firstPlace.coordinates.latitude, + firstPlace.coordinates.longitude, + ) == + true) { final lat = firstPlace.coordinates.latitude; - final lng = firstPlace.coordinates.longitude; + final lng = + firstPlace.coordinates.longitude; final address = firstPlace.address; - controller.sourceTextEditController.value.text = address.toString(); + controller + .sourceTextEditController + .value + .text = address.toString(); controller.setDepartureMarker(lat, lng); } else { - ShowToastDialog.showToast("Service is unavailable at the selected address.".tr); + ShowToastDialog.showToast( + ConstTexts.serviceIsUnavailable.tr, + ); } } } else { - Get.to(LocationPickerScreen())!.then((value) async { + Get.to(LocationPickerScreen())!.then(( + value, + ) async { if (value != null) { - SelectedLocationModel selectedLocationModel = value; + SelectedLocationModel + selectedLocationModel = value; - if (Constant.checkZoneCheck(selectedLocationModel.latLng!.latitude, selectedLocationModel.latLng!.longitude) == true) { - controller.sourceTextEditController.value.text = Utils.formatAddress(selectedLocation: selectedLocationModel); - controller.setDepartureMarker(selectedLocationModel.latLng!.latitude, selectedLocationModel.latLng!.longitude); + if (Constant.checkZoneCheck( + selectedLocationModel + .latLng! + .latitude, + selectedLocationModel + .latLng! + .longitude, + ) == + true) { + controller + .sourceTextEditController + .value + .text = Utils.formatAddress( + selectedLocation: selectedLocationModel, + ); + controller.setDepartureMarker( + selectedLocationModel.latLng!.latitude, + selectedLocationModel.latLng!.longitude, + ); } else { - ShowToastDialog.showToast("Service is unavailable at the selected address.".tr); + ShowToastDialog.showToast( + ConstTexts.serviceIsUnavailable.tr, + ); } } }); } }, child: TextFieldWidget( - controller: controller.sourceTextEditController.value, - hintText: "Pickup Location".tr, + controller: + controller.sourceTextEditController.value, + // backgroundColor: AppThemeData.cardColor, + hintText: ConstTexts.pickUpLocation.tr, enable: false, - prefix: Padding(padding: EdgeInsets.only(left: 10, right: 10), child: Image.asset("assets/icons/pickup.png", height: 22, width: 22)), + prefix: Padding( + padding: EdgeInsets.only(left: 10, right: 10), + child: Image.asset( + "assets/icons/pickup.png", + height: 22, + width: 22, + ), + ), ), ), const SizedBox(height: 10), @@ -209,34 +346,63 @@ class CabBookingScreen extends StatelessWidget { InkWell( onTap: () async { if (Constant.selectedMapType == 'osm') { - final result = await Get.to(() => MapPickerPage()); + final result = await Get.to( + () => MapPickerPage(), + ); if (result != null) { - controller.destinationTextEditController.value.text = ''; + controller + .destinationTextEditController + .value + .text = ''; final firstPlace = result; final lat = firstPlace.coordinates.latitude; final lng = firstPlace.coordinates.longitude; final address = firstPlace.address; - controller.destinationTextEditController.value.text = address.toString(); + controller + .destinationTextEditController + .value + .text = address.toString(); controller.setDestinationMarker(lat, lng); } } else { - Get.to(LocationPickerScreen())!.then((value) async { + Get.to(LocationPickerScreen())!.then(( + value, + ) async { if (value != null) { - SelectedLocationModel selectedLocationModel = value; + SelectedLocationModel + selectedLocationModel = value; - controller.destinationTextEditController.value.text = Utils.formatAddress(selectedLocation: selectedLocationModel); - controller.setDestinationMarker(selectedLocationModel.latLng!.latitude, selectedLocationModel.latLng!.longitude); + controller + .destinationTextEditController + .value + .text = Utils.formatAddress( + selectedLocation: selectedLocationModel, + ); + controller.setDestinationMarker( + selectedLocationModel.latLng!.latitude, + selectedLocationModel.latLng!.longitude, + ); } }); } }, child: TextFieldWidget( - controller: controller.destinationTextEditController.value, + controller: + controller + .destinationTextEditController + .value, // backgroundColor: AppThemeData.grey50, // borderColor: AppThemeData.grey50, - hintText: "Destination Location".tr, + hintText: ConstTexts.destinationLocation.tr, + // backgroundColor: AppThemeData.cardColor, enable: false, - prefix: const Padding(padding: EdgeInsets.only(left: 10, right: 10), child: Icon(Icons.radio_button_checked, color: Colors.red)), + prefix: const Padding( + padding: EdgeInsets.only(left: 10, right: 10), + child: Icon( + Icons.radio_button_checked, + color: Colors.red, + ), + ), ), ), ], @@ -263,18 +429,31 @@ class CabBookingScreen extends StatelessWidget { ), SizedBox(height: 15), RoundedButtonFill( - title: "Continue".tr, + borderRadius: 10.r, + title: ConstTexts.continueT.tr, onPress: () { - if (controller.sourceTextEditController.value.text.isEmpty) { - ShowToastDialog.showToast("Please select source location".tr); - } else if (controller.destinationTextEditController.value.text.isEmpty) { - ShowToastDialog.showToast("Please select destination location".tr); + if (controller + .sourceTextEditController + .value + .text + .isEmpty) { + ShowToastDialog.showToast( + ConstTexts.plsSelectSourceLocation.tr, + ); + } else if (controller + .destinationTextEditController + .value + .text + .isEmpty) { + ShowToastDialog.showToast( + ConstTexts.plsSelectDestinationLocations.tr, + ); } else { controller.bottomSheetType.value = "vehicleSelection"; } }, - color: AppThemeData.primary300, - textColor: AppThemeData.grey900, + color: AppThemeData.mainColor, + textColor: AppThemeData.grey50, ), ], ), @@ -284,112 +463,196 @@ class CabBookingScreen extends StatelessWidget { ); } - Widget vehicleSelection(BuildContext context, CabBookingController controller, bool isDark) { + Widget vehicleSelection( + BuildContext context, + CabBookingController controller, + bool isDark, + ) { return Positioned.fill( child: DraggableScrollableSheet( - initialChildSize: 0.40, - minChildSize: 0.40, - maxChildSize: 0.8, + initialChildSize: 0.36, + minChildSize: 0.36, + maxChildSize: 0.36, expand: false, builder: (context, scrollController) { return Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.grey700 : Colors.white, borderRadius: const BorderRadius.only(topLeft: Radius.circular(24), topRight: Radius.circular(24))), + decoration: BoxDecoration( + color: isDark ? AppThemeData.grey700 : Colors.white, + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(24), + topRight: Radius.circular(24), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 15.0, vertical: 10), + padding: EdgeInsets.symmetric(vertical: 10.r), child: Column( - mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Container(decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), color: AppThemeData.grey400), height: 4, width: 33), - Align( - alignment: Alignment.topLeft, - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 10), - child: Text( - "Select Your Vehicle Type".tr, - style: AppThemeData.boldTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), - textAlign: TextAlign.start, + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: AppThemeData.grey400, + ), + height: 4.h, + width: 33.w, ), + ], + ), + SizedBox(height: 10.h), + Padding( + padding: EdgeInsetsGeometry.symmetric(horizontal: 16.r), + child: Text( + ConstTexts.selectVehicleType.tr, + style: AppThemeData.boldTextStyle( + fontSize: 18.sp, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + textAlign: TextAlign.start, ), ), + SizedBox(height: 10.h), Expanded( child: ListView.builder( itemCount: controller.vehicleTypes.length, - shrinkWrap: true, - padding: EdgeInsets.only(bottom: 20), + physics: AlwaysScrollableScrollPhysics(), controller: scrollController, - scrollDirection: Axis.vertical, + scrollDirection: Axis.horizontal, itemBuilder: (context, index) { - VehicleType vehicleType = controller.vehicleTypes[index]; + VehicleType vehicleType = + controller.vehicleTypes[index]; return Obx( () => InkWell( onTap: () { - controller.selectedVehicleType.value = controller.vehicleTypes[index]; + controller.selectedVehicleType.value = + controller.vehicleTypes[index]; }, - child: Padding( - padding: const EdgeInsets.only(bottom: 10), - child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(15), - border: Border.all( - color: - isDark - ? controller.selectedVehicleType.value.id == vehicleType.id - ? Colors.white - : AppThemeData.grey500 - : controller.selectedVehicleType.value.id == vehicleType.id - ? AppThemeData.grey300 - : Colors.transparent, - width: 1, - ), - color: - controller.selectedVehicleType.value.id == vehicleType.id - ? AppThemeData.grey50 - : isDark - ? AppThemeData.grey300 - : Colors.white, - ), - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10), - child: Row( - children: [ - ClipRRect( - //borderRadius: BorderRadius.circular(10), - child: CachedNetworkImage( - imageUrl: vehicleType.vehicleIcon.toString(), - height: 60, - width: 60, - imageBuilder: - (context, imageProvider) => - Container(decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), image: DecorationImage(image: imageProvider, fit: BoxFit.cover))), - placeholder: (context, url) => Center(child: CircularProgressIndicator.adaptive(valueColor: AlwaysStoppedAnimation(AppThemeData.primary300))), - errorWidget: (context, url, error) => ClipRRect(borderRadius: BorderRadius.circular(20), child: Image.network(Constant.placeHolderImage, fit: BoxFit.cover)), - fit: BoxFit.cover, - ), + child: Container( + width: 130.w, + margin: + index == 0 + ? EdgeInsets.only(left: 16.r, right: 10.r) + : index == + controller.vehicleTypes.length - 1 + ? EdgeInsets.only(right: 10.r) + : EdgeInsets.only(right: 10.r), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(16.r), + color: + controller.selectedVehicleType.value.id == + vehicleType.id + ? AppThemeData.mainColor + : AppThemeData.grey300, + ), + child: Padding( + padding: EdgeInsets.fromLTRB(8.r, 8.r, 0, 0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + // "${vehicleType.name} | ${controller.distance.toStringAsFixed(2)}${'km'.tr}", + "${vehicleType.name}", + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontFamily: "Inter", + fontSize: 15.sp, + overflow: TextOverflow.ellipsis, + color: + controller + .selectedVehicleType + .value + .id == + vehicleType.id + ? AppThemeData.grey50 + : AppThemeData.darkGrey, + fontWeight: FontWeight.bold, ), - Expanded( - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "${vehicleType.name} | ${controller.distance.toStringAsFixed(2)}${'km'.tr}", - style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold, letterSpacing: 1), + ), + Text( + Constant.amountShow( + amount: + controller + .getAmount(vehicleType) + .toString(), + ), + + style: TextStyle( + fontSize: 13.sp, + fontWeight: FontWeight.w500, + color: + controller + .selectedVehicleType + .value + .id == + vehicleType.id + ? AppThemeData.grey50 + : AppThemeData.darkGrey + .withValues(alpha: 0.7), + ), + ), + Text( + "(${controller.duration.value})", + style: TextStyle( + fontWeight: FontWeight.w400, + color: + controller + .selectedVehicleType + .value + .id == + vehicleType.id + ? AppThemeData.grey50 + : AppThemeData.darkGrey + .withValues(alpha: 0.7), + ), + ), + Expanded( + child: CachedNetworkImage( + imageUrl: + vehicleType.vehicleIcon.toString(), + + imageBuilder: + (context, imageProvider) => + Container( + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular( + 10, + ), + image: DecorationImage( + image: imageProvider, + fit: BoxFit.cover, + ), + ), + ), + placeholder: + (context, url) => Center( + child: + CircularProgressIndicator.adaptive( + valueColor: + AlwaysStoppedAnimation( + AppThemeData + .primary300, + ), + ), + ), + errorWidget: + (context, url, error) => ClipRRect( + borderRadius: + BorderRadius.circular(20), + child: Image.network( + Constant.placeHolderImage, + fit: BoxFit.cover, ), - Padding( - padding: const EdgeInsets.only(top: 2.0), - child: Text(controller.duration.value, style: const TextStyle(fontWeight: FontWeight.w400, letterSpacing: 1)), - ), - ], - ), - ), + ), + fit: BoxFit.cover, ), - Text( - Constant.amountShow(amount: controller.getAmount(vehicleType).toString()), - style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold, letterSpacing: 1), - ), - ], - ), + ), + ], ), ), ), @@ -398,24 +661,41 @@ class CabBookingScreen extends StatelessWidget { }, ), ), - Obx( - () => RoundedButtonFill( - title: 'pay_amount'.trParams({ - 'amount': - controller.selectedVehicleType.value.id == null - ? Constant.amountShow(amount: "0.0") - : Constant.amountShow(amount: controller.getAmount(controller.selectedVehicleType.value).toString()), - }), - onPress: () async { - if (controller.selectedVehicleType.value.id != null) { - controller.calculateTotalAmount(); - controller.bottomSheetType.value = "payment"; - } else { - ShowToastDialog.showToast("Please select a vehicle type first.".tr); - } - }, - color: AppThemeData.primary300, - textColor: AppThemeData.grey900, + SizedBox(height: 30.h), + Padding( + padding: EdgeInsetsGeometry.symmetric(horizontal: 16.r), + child: Obx( + () => RoundedButtonFill( + borderRadius: 10.r, + title: 'pay_amount'.trParams({ + 'amount': + controller.selectedVehicleType.value.id == null + ? Constant.amountShow(amount: "0.0") + : Constant.amountShow( + amount: + controller + .getAmount( + controller + .selectedVehicleType + .value, + ) + .toString(), + ), + }), + + onPress: () async { + if (controller.selectedVehicleType.value.id != null) { + controller.calculateTotalAmount(); + controller.bottomSheetType.value = "payment"; + } else { + ShowToastDialog.showToast( + ConstTexts.plsSelectVehicleTypeFirst.tr, + ); + } + }, + color: AppThemeData.mainColor, + textColor: AppThemeData.grey50, + ), ), ), ], @@ -427,29 +707,51 @@ class CabBookingScreen extends StatelessWidget { ); } - Widget paymentBottomSheet(BuildContext context, CabBookingController controller, bool isDark) { + Widget paymentBottomSheet( + BuildContext context, + CabBookingController controller, + bool isDark, + ) { return Positioned.fill( child: DraggableScrollableSheet( - initialChildSize: 0.70, - minChildSize: 0.30, - maxChildSize: 0.8, + initialChildSize: 0.5, + minChildSize: 0.5, + maxChildSize: 0.5, expand: false, builder: (context, scrollController) { return Container( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20), - decoration: BoxDecoration(color: isDark ? AppThemeData.grey700 : Colors.white, borderRadius: BorderRadius.vertical(top: Radius.circular(24))), + decoration: BoxDecoration( + color: isDark ? AppThemeData.grey700 : Colors.white, + borderRadius: BorderRadius.vertical(top: Radius.circular(24)), + ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text("Select Payment Method".tr, style: AppThemeData.mediumTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + "Select Payment Method", + style: AppThemeData.boldTextStyle( + fontSize: 18.sp, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.darkGrey, + ), + ), GestureDetector( onTap: () { Get.back(); }, - child: Icon(Icons.close, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + child: Icon( + Icons.close, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ], ), @@ -459,75 +761,146 @@ class CabBookingScreen extends StatelessWidget { padding: EdgeInsets.zero, controller: scrollController, children: [ - Text("Preferred Payment".tr, textAlign: TextAlign.start, style: AppThemeData.boldTextStyle(fontSize: 15, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500)), - const SizedBox(height: 10), - if (controller.walletSettingModel.value.isEnabled == true || controller.cashOnDeliverySettingModel.value.isEnabled == true) - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark100 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), - ), - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - children: [ - Visibility( - visible: controller.walletSettingModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.wallet, isDark, "assets/images/ic_wallet.png"), - ), - Visibility( - visible: controller.cashOnDeliverySettingModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.cod, isDark, "assets/images/ic_cash.png"), - ), - ], - ), - ), + // Text( + // "Preferred Payment".tr, + // textAlign: TextAlign.start, + // style: AppThemeData.boldTextStyle( + // fontSize: 15, + // color: + // isDark + // ? AppThemeData.greyDark500 + // : AppThemeData.grey500, + // ), + // ), + // const SizedBox(height: 10), + // if (controller.walletSettingModel.value.isEnabled == + // true || + // controller + // .cashOnDeliverySettingModel + // .value + // .isEnabled == + // true) + // Container( + // decoration: BoxDecoration( + // borderRadius: BorderRadius.circular(15), + // color: + // isDark + // ? AppThemeData.greyDark100 + // : AppThemeData.grey50, + // border: Border.all( + // color: + // isDark + // ? AppThemeData.greyDark200 + // : AppThemeData.grey200, + // ), + // ), + // child: Padding( + // padding: const EdgeInsets.all(8.0), + // child: Column( + // children: [ + // Visibility( + // visible: + // controller + // .walletSettingModel + // .value + // .isEnabled == + // true, + // child: cardDecoration( + // controller, + // PaymentGateway.wallet, + // isDark, + // "assets/images/ic_wallet.png", + // ), + // ), + // Visibility( + // visible: + // controller + // .cashOnDeliverySettingModel + // .value + // .isEnabled == + // true, + // child: cardDecoration( + // controller, + // PaymentGateway.cod, + // isDark, + // "assets/images/ic_cash.png", + // ), + // ), + // ], + // ), + // ), + // ), + // if (controller.walletSettingModel.value.isEnabled == + // true || + // controller + // .cashOnDeliverySettingModel + // .value + // .isEnabled == + // true) + // Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // const SizedBox(height: 10), + // Text( + // "Other Payment Options".tr, + // textAlign: TextAlign.start, + // style: AppThemeData.boldTextStyle( + // fontSize: 15, + // color: + // isDark + // ? AppThemeData.greyDark500 + // : AppThemeData.grey500, + // ), + // ), + // const SizedBox(height: 10), + // ], + // ), + Visibility( + visible: + controller.walletSettingModel.value.isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.wallet, + isDark, + "assets/images/ic_wallet.png", ), - if (controller.walletSettingModel.value.isEnabled == true || controller.cashOnDeliverySettingModel.value.isEnabled == true) - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const SizedBox(height: 10), - Text( - "Other Payment Options".tr, - textAlign: TextAlign.start, - style: AppThemeData.boldTextStyle(fontSize: 15, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500), - ), - const SizedBox(height: 10), - ], + ), + Divider(color: AppThemeData.cardColor, thickness: 1.3.r), + Visibility( + visible: + controller + .cashOnDeliverySettingModel + .value + .isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.cod, + isDark, + "assets/images/ic_cash.png", ), - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark100 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + ), + Divider(color: AppThemeData.cardColor, thickness: 1.3.r), + Visibility( + visible: true, + child: cardDecoration( + controller, + PaymentGateway.payme, + isDark, + "assets/images/payme_logo.png", ), - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - children: [ - Visibility(visible: controller.stripeModel.value.isEnabled == true, child: cardDecoration(controller, PaymentGateway.stripe, isDark, "assets/images/stripe.png")), - Visibility(visible: controller.payPalModel.value.isEnabled == true, child: cardDecoration(controller, PaymentGateway.paypal, isDark, "assets/images/paypal.png")), - Visibility(visible: controller.payStackModel.value.isEnable == true, child: cardDecoration(controller, PaymentGateway.payStack, isDark, "assets/images/paystack.png")), - Visibility( - visible: controller.mercadoPagoModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.mercadoPago, isDark, "assets/images/mercado-pago.png"), - ), - Visibility( - visible: controller.flutterWaveModel.value.isEnable == true, - child: cardDecoration(controller, PaymentGateway.flutterWave, isDark, "assets/images/flutterwave_logo.png"), - ), - Visibility(visible: controller.payFastModel.value.isEnable == true, child: cardDecoration(controller, PaymentGateway.payFast, isDark, "assets/images/payfast.png")), - Visibility(visible: controller.razorPayModel.value.isEnabled == true, child: cardDecoration(controller, PaymentGateway.razorpay, isDark, "assets/images/razorpay.png")), - Visibility(visible: controller.midTransModel.value.enable == true, child: cardDecoration(controller, PaymentGateway.midTrans, isDark, "assets/images/midtrans.png")), - Visibility( - visible: controller.orangeMoneyModel.value.enable == true, - child: cardDecoration(controller, PaymentGateway.orangeMoney, isDark, "assets/images/orange_money.png"), - ), - Visibility(visible: controller.xenditModel.value.enable == true, child: cardDecoration(controller, PaymentGateway.xendit, isDark, "assets/images/xendit.png")), - ], - ), + ), + Divider(color: AppThemeData.cardColor, thickness: 1.3.r), + Visibility( + visible: + // controller.payPalModel.value.isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.click, + isDark, + "assets/images/click_logo.png", ), ), SizedBox(height: 20), @@ -535,18 +908,24 @@ class CabBookingScreen extends StatelessWidget { ), ), RoundedButtonFill( - title: "Continue".tr, - color: AppThemeData.primary300, - textColor: AppThemeData.grey900, + borderRadius: 10.r, + title: ConstTexts.continueT.tr, + color: AppThemeData.mainColor, + textColor: AppThemeData.grey50, onPress: () async { if (controller.selectedPaymentMethod.value.isEmpty) { - ShowToastDialog.showToast("Please select a payment method".tr); + ShowToastDialog.showToast( + ConstTexts.plsSelectPaymentMethod.tr, + ); return; } if (controller.selectedPaymentMethod.value == "wallet") { - num walletAmount = controller.userModel.value.walletAmount ?? 0; + num walletAmount = + controller.userModel.value.walletAmount ?? 0; if (walletAmount <= 0) { - ShowToastDialog.showToast("Insufficient wallet balance. Please select another payment method.".tr); + ShowToastDialog.showToast( + ConstTexts.insufficientWallet.tr, + ); return; } } @@ -577,13 +956,29 @@ class CabBookingScreen extends StatelessWidget { init: CabBookingController(), builder: (controller) { return Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.grey700 : Colors.white, borderRadius: BorderRadius.only(topLeft: Radius.circular(30), topRight: Radius.circular(30))), + decoration: BoxDecoration( + color: isDark ? AppThemeData.grey700 : Colors.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(30), + topRight: Radius.circular(30), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 15.0, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 15.0, + vertical: 10, + ), child: Column( mainAxisSize: MainAxisSize.min, children: [ - Container(decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), color: AppThemeData.grey400), height: 4, width: 33), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: AppThemeData.grey400, + ), + height: 4, + width: 33, + ), Expanded( child: ListView( controller: scrollController, @@ -593,75 +988,177 @@ class CabBookingScreen extends StatelessWidget { Stack( children: [ Container( - decoration: BoxDecoration(color: isDark ? Colors.transparent : Colors.white, borderRadius: BorderRadius.circular(12)), + decoration: BoxDecoration( + color: + isDark + ? Colors.transparent + : Colors.white, + borderRadius: BorderRadius.circular(12), + ), child: Column( mainAxisSize: MainAxisSize.min, children: [ // Pickup Location InkWell( onTap: () async { - if (Constant.selectedMapType == 'osm') { - final result = await Get.to(() => MapPickerPage()); + if (Constant.selectedMapType == + 'osm') { + final result = await Get.to( + () => MapPickerPage(), + ); if (result != null) { - controller.sourceTextEditController.value.text = ''; + controller + .sourceTextEditController + .value + .text = ''; final firstPlace = result; - final lat = firstPlace.coordinates.latitude; - final lng = firstPlace.coordinates.longitude; - final address = firstPlace.address; - controller.sourceTextEditController.value.text = address.toString(); - controller.setDepartureMarker(lat, lng); + final lat = + firstPlace + .coordinates + .latitude; + final lng = + firstPlace + .coordinates + .longitude; + final address = + firstPlace.address; + controller + .sourceTextEditController + .value + .text = address.toString(); + controller.setDepartureMarker( + lat, + lng, + ); } } else { - Get.to(LocationPickerScreen())!.then((value) async { + Get.to( + LocationPickerScreen(), + )!.then((value) async { if (value != null) { - SelectedLocationModel selectedLocationModel = value; + SelectedLocationModel + selectedLocationModel = value; - controller.sourceTextEditController.value.text = Utils.formatAddress(selectedLocation: selectedLocationModel); - controller.setDepartureMarker(selectedLocationModel.latLng!.latitude, selectedLocationModel.latLng!.longitude); + controller + .sourceTextEditController + .value + .text = Utils.formatAddress( + selectedLocation: + selectedLocationModel, + ); + controller.setDepartureMarker( + selectedLocationModel + .latLng! + .latitude, + selectedLocationModel + .latLng! + .longitude, + ); } }); } }, child: TextFieldWidget( - controller: controller.sourceTextEditController.value, - hintText: "Pickup Location".tr, + controller: + controller + .sourceTextEditController + .value, + hintText: + ConstTexts.pickUpLocation.tr, enable: false, - prefix: const Padding(padding: EdgeInsets.only(left: 10, right: 10), child: Icon(Icons.stop_circle_outlined, color: Colors.green)), + prefix: const Padding( + padding: EdgeInsets.only( + left: 10, + right: 10, + ), + child: Icon( + Icons.stop_circle_outlined, + color: Colors.green, + ), + ), ), ), const SizedBox(height: 10), // Destination Location InkWell( onTap: () async { - if (Constant.selectedMapType == 'osm') { - final result = await Get.to(() => MapPickerPage()); + if (Constant.selectedMapType == + 'osm') { + final result = await Get.to( + () => MapPickerPage(), + ); if (result != null) { - controller.destinationTextEditController.value.text = ''; + controller + .destinationTextEditController + .value + .text = ''; final firstPlace = result; - final lat = firstPlace.coordinates.latitude; - final lng = firstPlace.coordinates.longitude; - final address = firstPlace.address; - controller.destinationTextEditController.value.text = address.toString(); - controller.setDestinationMarker(lat, lng); + final lat = + firstPlace + .coordinates + .latitude; + final lng = + firstPlace + .coordinates + .longitude; + final address = + firstPlace.address; + controller + .destinationTextEditController + .value + .text = address.toString(); + controller.setDestinationMarker( + lat, + lng, + ); } } else { - Get.to(LocationPickerScreen())!.then((value) async { + Get.to( + LocationPickerScreen(), + )!.then((value) async { if (value != null) { - SelectedLocationModel selectedLocationModel = value; + SelectedLocationModel + selectedLocationModel = value; - controller.destinationTextEditController.value.text = Utils.formatAddress(selectedLocation: selectedLocationModel); - controller.setDestinationMarker(selectedLocationModel.latLng!.latitude, selectedLocationModel.latLng!.longitude); + controller + .destinationTextEditController + .value + .text = Utils.formatAddress( + selectedLocation: + selectedLocationModel, + ); + controller.setDestinationMarker( + selectedLocationModel + .latLng! + .latitude, + selectedLocationModel + .latLng! + .longitude, + ); } }); } }, child: TextFieldWidget( - controller: controller.destinationTextEditController.value, + controller: + controller + .destinationTextEditController + .value, // backgroundColor: AppThemeData.grey50, // borderColor: AppThemeData.grey50, - hintText: "Destination Location".tr, + hintText: + ConstTexts.destinationLocation.tr, enable: false, - prefix: const Padding(padding: EdgeInsets.only(left: 10, right: 10), child: Icon(Icons.radio_button_checked, color: Colors.red)), + prefix: const Padding( + padding: EdgeInsets.only( + left: 10, + right: 10, + ), + child: Icon( + Icons.radio_button_checked, + color: Colors.red, + ), + ), ), ), ], @@ -679,9 +1176,15 @@ class CabBookingScreen extends StatelessWidget { (size) => Path() ..moveTo(size.width / 2, 0) - ..lineTo(size.width / 2, size.height), + ..lineTo( + size.width / 2, + size.height, + ), + ), + child: const SizedBox( + width: 20, + height: 40, ), - child: const SizedBox(width: 20, height: 40), ), ), ], @@ -689,25 +1192,58 @@ class CabBookingScreen extends StatelessWidget { const SizedBox(height: 10), Row( children: [ - Expanded(child: Text("Promo code".tr, style: AppThemeData.boldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900))), + Expanded( + child: Text( + ConstTexts.promoCode.tr, + style: AppThemeData.boldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + ), InkWell( onTap: () { - Get.to(CabCouponCodeScreen())!.then((value) { + Get.to(CabCouponCodeScreen())!.then(( + value, + ) { if (value != null) { - controller.couponCodeTextEditController.value.text = value.code ?? ''; - double couponAmount = Constant.calculateDiscount(amount: controller.subTotal.value.toString(), offerModel: value); - if (couponAmount < controller.subTotal.value) { - controller.selectedCouponModel.value = value; + controller + .couponCodeTextEditController + .value + .text = value.code ?? ''; + double couponAmount = + Constant.calculateDiscount( + amount: + controller.subTotal.value + .toString(), + offerModel: value, + ); + if (couponAmount < + controller.subTotal.value) { + controller.selectedCouponModel.value = + value; controller.calculateTotalAmount(); } else { - ShowToastDialog.showToast("This offer not eligible for this booking".tr); + ShowToastDialog.showToast( + ConstTexts.thisOfferNotEligible.tr, + ); } } }); }, child: Text( - "View All".tr, - style: AppThemeData.boldTextStyle(decoration: TextDecoration.underline, fontSize: 14, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300), + ConstTexts.viewAll.tr, + style: AppThemeData.boldTextStyle( + decoration: TextDecoration.underline, + fontSize: 14, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + ), ), ), ], @@ -720,65 +1256,147 @@ class CabBookingScreen extends StatelessWidget { height: Responsive.height(6, context), color: AppThemeData.carRent50, child: DottedBorder( - options: RectDottedBorderOptions(dashPattern: [10, 5], strokeWidth: 1, padding: EdgeInsets.all(0), color: AppThemeData.carRent400), + options: RectDottedBorderOptions( + dashPattern: [10, 5], + strokeWidth: 1, + padding: EdgeInsets.all(0), + color: AppThemeData.carRent400, + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, children: [ - SvgPicture.asset("assets/icons/ic_coupon.svg"), + SvgPicture.asset( + "assets/icons/ic_coupon.svg", + ), Expanded( child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10), + padding: const EdgeInsets.symmetric( + horizontal: 10, + ), child: TextFormField( - controller: controller.couponCodeTextEditController.value, - style: AppThemeData.semiBoldTextStyle(color: AppThemeData.parcelService500, fontSize: 16), + controller: + controller + .couponCodeTextEditController + .value, + style: + AppThemeData.semiBoldTextStyle( + color: + AppThemeData + .parcelService500, + fontSize: 16, + ), decoration: InputDecoration( border: InputBorder.none, - hintText: 'Write coupon Code'.tr, - contentPadding: EdgeInsets.only(bottom: 10), - hintStyle: AppThemeData.semiBoldTextStyle(color: AppThemeData.parcelService500, fontSize: 16), + hintText: + ConstTexts.writeCoupon.tr, + contentPadding: EdgeInsets.only( + bottom: 10, + ), + hintStyle: + AppThemeData.semiBoldTextStyle( + color: + AppThemeData + .parcelService500, + fontSize: 16, + ), ), ), ), ), RoundedButtonFill( - title: "Redeem now".tr, - width: 27, - borderRadius: 10, + borderRadius: 10.r, + title: ConstTexts.redeemNow.tr, + width: 27.w, fontSizes: 14, onPress: () async { - if (controller.couponCodeTextEditController.value.text.trim().isEmpty) { - ShowToastDialog.showToast("Please enter a coupon code".tr); + if (controller + .couponCodeTextEditController + .value + .text + .trim() + .isEmpty) { + ShowToastDialog.showToast( + ConstTexts + .plsEnterCouponCode + .tr, + ); return; } List matchedCoupons = controller.cabCouponList - .where((element) => element.code!.toLowerCase().trim() == controller.couponCodeTextEditController.value.text.toLowerCase().trim()) + .where( + (element) => + element.code! + .toLowerCase() + .trim() == + controller + .couponCodeTextEditController + .value + .text + .toLowerCase() + .trim(), + ) .toList(); if (matchedCoupons.isNotEmpty) { - CouponModel couponModel = matchedCoupons.first; + CouponModel couponModel = + matchedCoupons.first; - if (couponModel.expiresAt != null && couponModel.expiresAt!.toDate().isAfter(DateTime.now())) { - double couponAmount = Constant.calculateDiscount(amount: controller.subTotal.value.toString(), offerModel: couponModel); + if (couponModel.expiresAt != + null && + couponModel.expiresAt! + .toDate() + .isAfter( + DateTime.now(), + )) { + double couponAmount = + Constant.calculateDiscount( + amount: + controller + .subTotal + .value + .toString(), + offerModel: couponModel, + ); - if (couponAmount < controller.subTotal.value) { - controller.selectedCouponModel.value = couponModel; - controller.discount.value = couponAmount; - controller.calculateTotalAmount(); - ShowToastDialog.showToast("Coupon applied successfully".tr); + if (couponAmount < + controller.subTotal.value) { + controller + .selectedCouponModel + .value = couponModel; + controller.discount.value = + couponAmount; + controller + .calculateTotalAmount(); + ShowToastDialog.showToast( + ConstTexts.couponApplied.tr, + ); controller.update(); } else { - ShowToastDialog.showToast("This offer not eligible for this booking".tr); + ShowToastDialog.showToast( + ConstTexts + .thisOfferNotEligible + .tr, + ); } } else { - ShowToastDialog.showToast("This coupon code has been expired".tr); + ShowToastDialog.showToast( + ConstTexts.couponExpired.tr, + ); } } else { - ShowToastDialog.showToast("Invalid coupon code".tr); + ShowToastDialog.showToast( + ConstTexts.invalidCouponCode.tr, + ); } }, color: AppThemeData.parcelService300, @@ -791,50 +1409,124 @@ class CabBookingScreen extends StatelessWidget { ), ), const SizedBox(height: 10), - Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("Order Summary".tr, style: AppThemeData.boldTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500)), + Text( + ConstTexts.orderSummary.tr, + style: AppThemeData.boldTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), + ), const SizedBox(height: 8), Padding( - padding: const EdgeInsets.symmetric(vertical: 4), + padding: const EdgeInsets.symmetric( + vertical: 4, + ), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ - Text("Subtotal".tr, style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800)), Text( - Constant.amountShow(amount: controller.subTotal.value.toString()), - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + ConstTexts.subtotal.tr, + style: AppThemeData.mediumTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark800 + : AppThemeData.grey800, + ), + ), + Text( + Constant.amountShow( + amount: + controller.subTotal.value + .toString(), + ), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ], ), ), Padding( - padding: const EdgeInsets.symmetric(vertical: 4), + padding: const EdgeInsets.symmetric( + vertical: 4, + ), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ Row( children: [ - Text("Discount".tr, style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + ConstTexts.discount.tr, + style: + AppThemeData.mediumTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), + ), SizedBox(width: 5), Text( - controller.selectedCouponModel.value.id == null ? "" : "(${controller.selectedCouponModel.value.code})", - style: AppThemeData.mediumTextStyle(fontSize: 16, color: AppThemeData.primary300), + controller + .selectedCouponModel + .value + .id == + null + ? "" + : "(${controller.selectedCouponModel.value.code})", + style: + AppThemeData.mediumTextStyle( + fontSize: 16, + color: + AppThemeData.primary300, + ), ), ], ), - Text(Constant.amountShow(amount: controller.discount.value.toString()), style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: AppThemeData.danger300)), + Text( + Constant.amountShow( + amount: + controller.discount.value + .toString(), + ), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: AppThemeData.danger300, + ), + ), ], ), ), @@ -846,24 +1538,56 @@ class CabBookingScreen extends StatelessWidget { physics: NeverScrollableScrollPhysics(), padding: EdgeInsets.zero, itemBuilder: (context, index) { - TaxModel taxModel = Constant.taxList[index]; + TaxModel taxModel = + Constant.taxList[index]; return Padding( - padding: const EdgeInsets.only(bottom: 5), + padding: const EdgeInsets.only( + bottom: 5, + ), child: Row( children: [ Expanded( child: Text( - '${taxModel.title} (${taxModel.tax} ${taxModel.type == "Fixed" ? Constant.currencyData!.code : "%"})'.tr, + '${taxModel.title} (${taxModel.tax} ${taxModel.type == "Fixed" ? Constant.currencyData!.code : "%"})', textAlign: TextAlign.start, - style: AppThemeData.mediumTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800), + style: + AppThemeData.mediumTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData + .greyDark800 + : AppThemeData + .grey800, + ), ), ), Text( Constant.amountShow( - amount: Constant.calculateTax(amount: (controller.subTotal.value - controller.discount.value).toString(), taxModel: taxModel).toString(), - ).tr, + amount: + Constant.calculateTax( + amount: + (controller + .subTotal + .value - + controller + .discount + .value) + .toString(), + taxModel: taxModel, + ).toString(), + ), textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: + AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), ), ], ), @@ -873,14 +1597,36 @@ class CabBookingScreen extends StatelessWidget { const Divider(), Padding( - padding: const EdgeInsets.symmetric(vertical: 4), + padding: const EdgeInsets.symmetric( + vertical: 4, + ), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ - Text("Order Total".tr, style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), Text( - Constant.amountShow(amount: controller.totalAmount.value.toString()), - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + ConstTexts.orderTotal.tr, + style: AppThemeData.mediumTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + Text( + Constant.amountShow( + amount: + controller.totalAmount.value + .toString(), + ), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ], ), @@ -889,45 +1635,164 @@ class CabBookingScreen extends StatelessWidget { ), ), const SizedBox(height: 20), + Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), padding: const EdgeInsets.all(10), child: Row( children: [ controller.selectedPaymentMethod.value == '' - ? cardDecorationScreen(controller, PaymentGateway.wallet, isDark, "") - : controller.selectedPaymentMethod.value == PaymentGateway.wallet.name - ? cardDecorationScreen(controller, PaymentGateway.wallet, isDark, "assets/images/ic_wallet.png") - : controller.selectedPaymentMethod.value == PaymentGateway.cod.name - ? cardDecorationScreen(controller, PaymentGateway.cod, isDark, "assets/images/ic_cash.png") - : controller.selectedPaymentMethod.value == PaymentGateway.stripe.name - ? cardDecorationScreen(controller, PaymentGateway.stripe, isDark, "assets/images/stripe.png") - : controller.selectedPaymentMethod.value == PaymentGateway.paypal.name - ? cardDecorationScreen(controller, PaymentGateway.paypal, isDark, "assets/images/paypal.png") - : controller.selectedPaymentMethod.value == PaymentGateway.payStack.name - ? cardDecorationScreen(controller, PaymentGateway.payStack, isDark, "assets/images/paystack.png") - : controller.selectedPaymentMethod.value == PaymentGateway.mercadoPago.name - ? cardDecorationScreen(controller, PaymentGateway.mercadoPago, isDark, "assets/images/mercado-pago.png") - : controller.selectedPaymentMethod.value == PaymentGateway.flutterWave.name - ? cardDecorationScreen(controller, PaymentGateway.flutterWave, isDark, "assets/images/flutterwave_logo.png") - : controller.selectedPaymentMethod.value == PaymentGateway.payFast.name - ? cardDecorationScreen(controller, PaymentGateway.payFast, isDark, "assets/images/payfast.png") - : controller.selectedPaymentMethod.value == PaymentGateway.midTrans.name - ? cardDecorationScreen(controller, PaymentGateway.midTrans, isDark, "assets/images/midtrans.png") - : controller.selectedPaymentMethod.value == PaymentGateway.orangeMoney.name - ? cardDecorationScreen(controller, PaymentGateway.orangeMoney, isDark, "assets/images/orange_money.png") - : controller.selectedPaymentMethod.value == PaymentGateway.xendit.name - ? cardDecorationScreen(controller, PaymentGateway.xendit, isDark, "assets/images/xendit.png") - : cardDecorationScreen(controller, PaymentGateway.razorpay, isDark, "assets/images/razorpay.png"), - SizedBox(width: 22), + ? cardDecorationScreen( + controller, + PaymentGateway.wallet, + isDark, + "", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.wallet.name + ? cardDecorationScreen( + controller, + PaymentGateway.wallet, + isDark, + "assets/images/ic_wallet.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.cod.name + ? cardDecorationScreen( + controller, + PaymentGateway.cod, + isDark, + "assets/images/ic_cash.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.stripe.name + ? cardDecorationScreen( + controller, + PaymentGateway.stripe, + isDark, + "assets/images/stripe.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.paypal.name + ? cardDecorationScreen( + controller, + PaymentGateway.paypal, + isDark, + "assets/images/paypal.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.payStack.name + ? cardDecorationScreen( + controller, + PaymentGateway.payStack, + isDark, + "assets/images/paystack.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.mercadoPago.name + ? cardDecorationScreen( + controller, + PaymentGateway.mercadoPago, + isDark, + "assets/images/mercado-pago.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.flutterWave.name + ? cardDecorationScreen( + controller, + PaymentGateway.flutterWave, + isDark, + "assets/images/flutterwave_logo.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.payFast.name + ? cardDecorationScreen( + controller, + PaymentGateway.payFast, + isDark, + "assets/images/payfast.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.midTrans.name + ? cardDecorationScreen( + controller, + PaymentGateway.midTrans, + isDark, + "assets/images/midtrans.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.orangeMoney.name + ? cardDecorationScreen( + controller, + PaymentGateway.orangeMoney, + isDark, + "assets/images/orange_money.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.xendit.name + ? cardDecorationScreen( + controller, + PaymentGateway.xendit, + isDark, + "assets/images/xendit.png", + ) + : cardDecorationScreen( + controller, + PaymentGateway.razorpay, + isDark, + "assets/images/razorpay.png", + ), + SizedBox(width: 10.w), Text( - controller.selectedPaymentMethod.value.tr, + controller.selectedPaymentMethod.value == + "cod" + ? "Наличными" + : controller + .selectedPaymentMethod + .value + .tr, textAlign: TextAlign.start, - style: AppThemeData.boldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: AppThemeData.boldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ], ), @@ -936,12 +1801,13 @@ class CabBookingScreen extends StatelessWidget { ), ), RoundedButtonFill( - title: "Confirm Booking".tr, + borderRadius: 10.r, + title: ConstTexts.confirmBooking.tr, onPress: () async { controller.placeOrder(); }, - color: AppThemeData.primary300, - textColor: AppThemeData.grey900, + color: AppThemeData.mainColor, + textColor: AppThemeData.grey50, ), ], ), @@ -954,7 +1820,11 @@ class CabBookingScreen extends StatelessWidget { ); } - Widget waitingDialog(BuildContext context, CabBookingController controller, bool isDark) { + Widget waitingDialog( + BuildContext context, + CabBookingController controller, + bool isDark, + ) { return Positioned.fill( child: DraggableScrollableSheet( initialChildSize: 0.4, @@ -963,19 +1833,45 @@ class CabBookingScreen extends StatelessWidget { expand: false, builder: (context, scrollController) { return Container( - decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.only(topLeft: Radius.circular(30), topRight: Radius.circular(30))), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(30), + topRight: Radius.circular(30), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 15.0, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 15.0, + vertical: 10, + ), child: Column( mainAxisSize: MainAxisSize.min, children: [ - Container(decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), color: AppThemeData.grey400), height: 4, width: 33), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: AppThemeData.grey400, + ), + height: 4, + width: 33, + ), SizedBox(height: 30), - Text("Waiting for driver....".tr, style: AppThemeData.mediumTextStyle(fontSize: 18, color: AppThemeData.grey900)), + Text( + ConstTexts.waitingForDriver.tr, + style: AppThemeData.boldTextStyle( + fontSize: 18.sp, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.darkGrey, + ), + ), Image.asset('assets/loader.gif', width: 250), RoundedButtonFill( - title: "Cancel Ride".tr, - color: AppThemeData.danger300, + borderRadius: 10.r, + title: ConstTexts.cancelRide.tr, + color: AppThemeData.mainColor, textColor: AppThemeData.surface, onPress: () async { try { @@ -986,7 +1882,9 @@ class CabBookingScreen extends StatelessWidget { }); if (controller.currentOrder.value.id != null) { - await FireStoreUtils.updateCabOrder(controller.currentOrder.value); + await FireStoreUtils.updateCabOrder( + controller.currentOrder.value, + ); } controller.bottomSheetType.value = ""; @@ -996,23 +1894,39 @@ class CabBookingScreen extends StatelessWidget { controller.routePoints.clear(); controller.sourceTextEditController.value.clear(); controller.destinationTextEditController.value.clear(); - controller.departureLatLong.value = const LatLng(0.0, 0.0); - controller.destinationLatLong.value = const LatLng(0.0, 0.0); - controller.departureLatLongOsm.value = latlong.LatLng(0.0, 0.0); - controller.destinationLatLongOsm.value = latlong.LatLng(0.0, 0.0); + controller.departureLatLong.value = const LatLng( + 0.0, + 0.0, + ); + controller.destinationLatLong.value = const LatLng( + 0.0, + 0.0, + ); + controller.departureLatLongOsm.value = latlong.LatLng( + 0.0, + 0.0, + ); + controller.destinationLatLongOsm.value = latlong.LatLng( + 0.0, + 0.0, + ); // 4. Reset user’s in-progress order if (Constant.userModel != null) { Constant.userModel!.inProgressOrderID = null; await FireStoreUtils.updateUser(Constant.userModel!); } - ShowToastDialog.showToast("Ride cancelled successfully".tr); + ShowToastDialog.showToast( + ConstTexts.riderCancelledSucces.tr, + ); // Get.offAll(const CabDashboardScreen()); Get.back(); - CabDashboardController cabDashboardController = Get.put(CabDashboardController()); + CabDashboardController cabDashboardController = Get.put( + CabDashboardController(), + ); cabDashboardController.selectedIndex.value = 0; } catch (e) { - ShowToastDialog.showToast("Failed to cancel ride".tr); + ShowToastDialog.showToast(ConstTexts.failedToCancel.tr); } }, ), @@ -1025,7 +1939,11 @@ class CabBookingScreen extends StatelessWidget { ); } - Widget driverDialog(BuildContext context, CabBookingController controller, bool isDark) { + Widget driverDialog( + BuildContext context, + CabBookingController controller, + bool isDark, + ) { return Positioned.fill( child: DraggableScrollableSheet( initialChildSize: 0.7, @@ -1034,13 +1952,29 @@ class CabBookingScreen extends StatelessWidget { expand: false, builder: (context, scrollController) { return Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.grey700 : Colors.white, borderRadius: BorderRadius.only(topLeft: Radius.circular(30), topRight: Radius.circular(30))), + decoration: BoxDecoration( + color: isDark ? AppThemeData.grey700 : Colors.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(30), + topRight: Radius.circular(30), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 15.0, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 15.0, + vertical: 10, + ), child: Column( mainAxisSize: MainAxisSize.min, children: [ - Container(decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), color: AppThemeData.grey400), height: 4, width: 33), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: AppThemeData.grey400, + ), + height: 4, + width: 33, + ), Expanded( child: ListView( controller: scrollController, @@ -1050,7 +1984,11 @@ class CabBookingScreen extends StatelessWidget { Stack( children: [ Container( - decoration: BoxDecoration(color: isDark ? Colors.transparent : Colors.white, borderRadius: BorderRadius.circular(12)), + decoration: BoxDecoration( + color: + isDark ? Colors.transparent : Colors.white, + borderRadius: BorderRadius.circular(12), + ), child: Column( mainAxisSize: MainAxisSize.min, children: [ @@ -1079,11 +2017,23 @@ class CabBookingScreen extends StatelessWidget { // } }, child: TextFieldWidget( - controller: controller.sourceTextEditController.value, - hintText: "Pickup Location".tr, + controller: + controller + .sourceTextEditController + .value, + hintText: ConstTexts.pickUpLocation.tr, enable: false, readOnly: true, - prefix: const Padding(padding: EdgeInsets.only(left: 10, right: 10), child: Icon(Icons.stop_circle_outlined, color: Colors.green)), + prefix: const Padding( + padding: EdgeInsets.only( + left: 10, + right: 10, + ), + child: Icon( + Icons.stop_circle_outlined, + color: Colors.green, + ), + ), ), ), const SizedBox(height: 10), @@ -1112,13 +2062,26 @@ class CabBookingScreen extends StatelessWidget { // } }, child: TextFieldWidget( - controller: controller.destinationTextEditController.value, + controller: + controller + .destinationTextEditController + .value, // backgroundColor: AppThemeData.grey50, // borderColor: AppThemeData.grey50, - hintText: "Destination Location".tr, + hintText: + ConstTexts.destinationLocation.tr, enable: false, readOnly: true, - prefix: const Padding(padding: EdgeInsets.only(left: 10, right: 10), child: Icon(Icons.radio_button_checked, color: Colors.red)), + prefix: const Padding( + padding: EdgeInsets.only( + left: 10, + right: 10, + ), + child: Icon( + Icons.radio_button_checked, + color: Colors.red, + ), + ), ), ), ], @@ -1136,7 +2099,10 @@ class CabBookingScreen extends StatelessWidget { (size) => Path() ..moveTo(size.width / 2, 0) - ..lineTo(size.width / 2, size.height), + ..lineTo( + size.width / 2, + size.height, + ), ), child: const SizedBox(width: 20, height: 40), ), @@ -1149,19 +2115,36 @@ class CabBookingScreen extends StatelessWidget { ? Padding( padding: EdgeInsets.symmetric(horizontal: 16), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ - Text("Otp :".tr, style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800)), + Text( + "Otp :", + style: AppThemeData.mediumTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark800 + : AppThemeData.grey800, + ), + ), Text( controller.currentOrder.value.otpCode ?? '', - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ], ), ) : SizedBox.shrink(), - if (Constant.isEnableOTPTripStart == true) SizedBox(height: 14), + if (Constant.isEnableOTPTripStart == true) + SizedBox(height: 14), controller.currentOrder.value.driver != null ? Row( @@ -1169,26 +2152,66 @@ class CabBookingScreen extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ ClipRRect( - borderRadius: BorderRadiusGeometry.circular(10), - child: NetworkImageWidget(imageUrl: controller.currentOrder.value.driver?.profilePictureURL ?? '', height: 70, width: 70, borderRadius: 35), + borderRadius: BorderRadiusGeometry.circular( + 10, + ), + child: NetworkImageWidget( + imageUrl: + controller + .currentOrder + .value + .driver + ?.profilePictureURL ?? + '', + height: 70, + width: 70, + borderRadius: 35, + ), ), SizedBox(width: 10), Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( - controller.currentOrder.value.driver?.fullName() ?? '', - style: AppThemeData.boldTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, fontSize: 18), + controller.currentOrder.value.driver + ?.fullName() ?? + '', + style: AppThemeData.boldTextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + fontSize: 18, + ), ), Text( "${controller.currentOrder.value.driver?.vehicleType ?? ''} | ${controller.currentOrder.value.driver?.carMakes.toString()}", - style: TextStyle(fontFamily: AppThemeData.medium, color: isDark ? AppThemeData.greyDark700 : AppThemeData.grey700, fontSize: 14), + style: TextStyle( + fontFamily: AppThemeData.medium, + color: + isDark + ? AppThemeData.greyDark700 + : AppThemeData.grey700, + fontSize: 14, + ), ), Text( - controller.currentOrder.value.driver?.carNumber ?? '', - style: AppThemeData.boldTextStyle(color: isDark ? AppThemeData.greyDark700 : AppThemeData.grey700, fontSize: 16), + controller + .currentOrder + .value + .driver + ?.carNumber ?? + '', + style: AppThemeData.boldTextStyle( + color: + isDark + ? AppThemeData.greyDark700 + : AppThemeData.grey700, + fontSize: 16, + ), ), ], ), @@ -1196,7 +2219,11 @@ class CabBookingScreen extends StatelessWidget { Column( children: [ RoundedButtonBorder( - title: controller.driverModel.value.averageRating.toStringAsFixed(1) ?? '', + title: controller + .driverModel + .value + .averageRating + .toStringAsFixed(1), width: 20, height: 3.5, radius: 10, @@ -1205,7 +2232,9 @@ class CabBookingScreen extends StatelessWidget { textColor: AppThemeData.warning400, borderColor: AppThemeData.warning400, color: AppThemeData.warning50, - icon: SvgPicture.asset("assets/icons/ic_start.svg"), + icon: SvgPicture.asset( + "assets/icons/ic_start.svg", + ), onPress: () {}, ), SizedBox(height: 10), @@ -1213,40 +2242,87 @@ class CabBookingScreen extends StatelessWidget { children: [ InkWell( onTap: () { - Constant.makePhoneCall(controller.currentOrder.value.driver!.phoneNumber.toString()); + Constant.makePhoneCall( + controller + .currentOrder + .value + .driver! + .phoneNumber + .toString(), + ); }, child: Container( width: 38, height: 38, decoration: ShapeDecoration( shape: RoundedRectangleBorder( - side: BorderSide(width: 1, color: isDark ? AppThemeData.grey200 : AppThemeData.grey200), - borderRadius: BorderRadius.circular(120), + side: BorderSide( + width: 1, + color: + isDark + ? AppThemeData.grey200 + : AppThemeData + .grey200, + ), + borderRadius: + BorderRadius.circular(120), + ), + ), + child: Padding( + padding: const EdgeInsets.all( + 8.0, + ), + child: SvgPicture.asset( + "assets/icons/ic_phone_call.svg", ), ), - child: Padding(padding: const EdgeInsets.all(8.0), child: SvgPicture.asset("assets/icons/ic_phone_call.svg")), ), ), SizedBox(width: 10), InkWell( onTap: () async { - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader( + ConstTexts.pleaseWait.tr, + ); - UserModel? customer = await FireStoreUtils.getUserProfile(controller.currentOrder.value.authorID ?? ''); - UserModel? driverUser = await FireStoreUtils.getUserProfile(controller.currentOrder.value.driverId ?? ''); + UserModel? customer = + await FireStoreUtils.getUserProfile( + controller + .currentOrder + .value + .authorID ?? + '', + ); + UserModel? driverUser = + await FireStoreUtils.getUserProfile( + controller + .currentOrder + .value + .driverId ?? + '', + ); ShowToastDialog.closeLoader(); Get.to( const ChatScreen(), arguments: { - "customerName": customer?.fullName(), - "restaurantName": driverUser?.fullName(), - "orderId": controller.currentOrder.value.id, + "customerName": + customer?.fullName(), + "restaurantName": + driverUser?.fullName(), + "orderId": + controller + .currentOrder + .value + .id, "restaurantId": driverUser?.id, "customerId": customer?.id, - "customerProfileImage": customer?.profilePictureURL, - "restaurantProfileImage": driverUser?.profilePictureURL, + "customerProfileImage": + customer?.profilePictureURL, + "restaurantProfileImage": + driverUser + ?.profilePictureURL, "token": driverUser?.fcmToken, "chatType": "Driver", }, @@ -1257,11 +2333,26 @@ class CabBookingScreen extends StatelessWidget { height: 42, decoration: ShapeDecoration( shape: RoundedRectangleBorder( - side: BorderSide(width: 1, color: isDark ? AppThemeData.grey200 : AppThemeData.grey200), - borderRadius: BorderRadius.circular(120), + side: BorderSide( + width: 1, + color: + isDark + ? AppThemeData.grey200 + : AppThemeData + .grey200, + ), + borderRadius: + BorderRadius.circular(120), + ), + ), + child: Padding( + padding: const EdgeInsets.all( + 8.0, + ), + child: SvgPicture.asset( + "assets/icons/ic_wechat.svg", ), ), - child: Padding(padding: const EdgeInsets.all(8.0), child: SvgPicture.asset("assets/icons/ic_wechat.svg")), ), ), ], @@ -1275,8 +2366,16 @@ class CabBookingScreen extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), padding: const EdgeInsets.all(10), child: InkWell( @@ -1285,38 +2384,125 @@ class CabBookingScreen extends StatelessWidget { }, child: Row( children: [ - controller.selectedPaymentMethod.value == PaymentGateway.wallet.name - ? cardDecorationScreen(controller, PaymentGateway.wallet, isDark, "assets/images/ic_wallet.png") - : controller.selectedPaymentMethod.value == PaymentGateway.cod.name - ? cardDecorationScreen(controller, PaymentGateway.cod, isDark, "assets/images/ic_cash.png") - : controller.selectedPaymentMethod.value == PaymentGateway.stripe.name - ? cardDecorationScreen(controller, PaymentGateway.stripe, isDark, "assets/images/stripe.png") - : controller.selectedPaymentMethod.value == PaymentGateway.paypal.name - ? cardDecorationScreen(controller, PaymentGateway.paypal, isDark, "assets/images/paypal.png") - : controller.selectedPaymentMethod.value == PaymentGateway.payStack.name - ? cardDecorationScreen(controller, PaymentGateway.payStack, isDark, "assets/images/paystack.png") - : controller.selectedPaymentMethod.value == PaymentGateway.mercadoPago.name - ? cardDecorationScreen(controller, PaymentGateway.mercadoPago, isDark, "assets/images/mercado-pago.png") - : controller.selectedPaymentMethod.value == PaymentGateway.flutterWave.name - ? cardDecorationScreen(controller, PaymentGateway.flutterWave, isDark, "assets/images/flutterwave_logo.png") - : controller.selectedPaymentMethod.value == PaymentGateway.payFast.name - ? cardDecorationScreen(controller, PaymentGateway.payFast, isDark, "assets/images/payfast.png") - : controller.selectedPaymentMethod.value == PaymentGateway.midTrans.name - ? cardDecorationScreen(controller, PaymentGateway.midTrans, isDark, "assets/images/midtrans.png") - : controller.selectedPaymentMethod.value == PaymentGateway.orangeMoney.name - ? cardDecorationScreen(controller, PaymentGateway.orangeMoney, isDark, "assets/images/orange_money.png") - : controller.selectedPaymentMethod.value == PaymentGateway.xendit.name - ? cardDecorationScreen(controller, PaymentGateway.xendit, isDark, "assets/images/xendit.png") - : cardDecorationScreen(controller, PaymentGateway.razorpay, isDark, "assets/images/razorpay.png"), + controller.selectedPaymentMethod.value == + PaymentGateway.wallet.name + ? cardDecorationScreen( + controller, + PaymentGateway.wallet, + isDark, + "assets/images/ic_wallet.png", + ) + : controller.selectedPaymentMethod.value == + PaymentGateway.cod.name + ? cardDecorationScreen( + controller, + PaymentGateway.cod, + isDark, + "assets/images/ic_cash.png", + ) + : controller.selectedPaymentMethod.value == + PaymentGateway.stripe.name + ? cardDecorationScreen( + controller, + PaymentGateway.stripe, + isDark, + "assets/images/stripe.png", + ) + : controller.selectedPaymentMethod.value == + PaymentGateway.paypal.name + ? cardDecorationScreen( + controller, + PaymentGateway.paypal, + isDark, + "assets/images/paypal.png", + ) + : controller.selectedPaymentMethod.value == + PaymentGateway.payStack.name + ? cardDecorationScreen( + controller, + PaymentGateway.payStack, + isDark, + "assets/images/paystack.png", + ) + : controller.selectedPaymentMethod.value == + PaymentGateway.mercadoPago.name + ? cardDecorationScreen( + controller, + PaymentGateway.mercadoPago, + isDark, + "assets/images/mercado-pago.png", + ) + : controller.selectedPaymentMethod.value == + PaymentGateway.flutterWave.name + ? cardDecorationScreen( + controller, + PaymentGateway.flutterWave, + isDark, + "assets/images/flutterwave_logo.png", + ) + : controller.selectedPaymentMethod.value == + PaymentGateway.payFast.name + ? cardDecorationScreen( + controller, + PaymentGateway.payFast, + isDark, + "assets/images/payfast.png", + ) + : controller.selectedPaymentMethod.value == + PaymentGateway.midTrans.name + ? cardDecorationScreen( + controller, + PaymentGateway.midTrans, + isDark, + "assets/images/midtrans.png", + ) + : controller.selectedPaymentMethod.value == + PaymentGateway.orangeMoney.name + ? cardDecorationScreen( + controller, + PaymentGateway.orangeMoney, + isDark, + "assets/images/orange_money.png", + ) + : controller.selectedPaymentMethod.value == + PaymentGateway.xendit.name + ? cardDecorationScreen( + controller, + PaymentGateway.xendit, + isDark, + "assets/images/xendit.png", + ) + : cardDecorationScreen( + controller, + PaymentGateway.razorpay, + isDark, + "assets/images/razorpay.png", + ), SizedBox(width: 22), Expanded( child: Text( - controller.selectedPaymentMethod.value.tr, + controller.selectedPaymentMethod.value, textAlign: TextAlign.start, - style: AppThemeData.boldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: AppThemeData.boldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + ), + Text( + ConstTexts.change.tr, + textAlign: TextAlign.start, + style: AppThemeData.boldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, ), ), - Text("Change".tr, textAlign: TextAlign.start, style: AppThemeData.boldTextStyle(fontSize: 16, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300)), ], ), ), @@ -1325,37 +2511,98 @@ class CabBookingScreen extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("Order Summary".tr, style: AppThemeData.boldTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500)), + Text( + ConstTexts.orderSummary.tr, + style: AppThemeData.boldTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), + ), const SizedBox(height: 8), Padding( - padding: const EdgeInsets.symmetric(vertical: 4), + padding: const EdgeInsets.symmetric( + vertical: 4, + ), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ - Text("Subtotal".tr, style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800)), Text( - Constant.amountShow(amount: controller.subTotal.value.toString()), - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + ConstTexts.subtotal.tr, + style: AppThemeData.mediumTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark800 + : AppThemeData.grey800, + ), + ), + Text( + Constant.amountShow( + amount: + controller.subTotal.value + .toString(), + ), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ], ), ), Padding( - padding: const EdgeInsets.symmetric(vertical: 4), + padding: const EdgeInsets.symmetric( + vertical: 4, + ), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ - Text("Discount".tr, style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), - Text(Constant.amountShow(amount: controller.discount.value.toString()), style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: AppThemeData.danger300)), + Text( + ConstTexts.discount.tr, + style: AppThemeData.mediumTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + Text( + Constant.amountShow( + amount: + controller.discount.value + .toString(), + ), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: AppThemeData.danger300, + ), + ), ], ), ), @@ -1374,17 +2621,40 @@ class CabBookingScreen extends StatelessWidget { children: [ Expanded( child: Text( - '${taxModel.title} (${taxModel.tax} ${taxModel.type == "Fixed" ? Constant.currencyData!.code : "%"})'.tr, + '${taxModel.title} (${taxModel.tax} ${taxModel.type == "Fixed" ? Constant.currencyData!.code : "%"})', textAlign: TextAlign.start, - style: AppThemeData.mediumTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800), + style: AppThemeData.mediumTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.greyDark800 + : AppThemeData.grey800, + ), ), ), Text( Constant.amountShow( - amount: Constant.calculateTax(amount: (controller.subTotal.value - controller.discount.value).toString(), taxModel: taxModel).toString(), - ).tr, + amount: + Constant.calculateTax( + amount: + (controller + .subTotal + .value - + controller + .discount + .value) + .toString(), + taxModel: taxModel, + ).toString(), + ), textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ], ), @@ -1394,14 +2664,36 @@ class CabBookingScreen extends StatelessWidget { const Divider(), Padding( - padding: const EdgeInsets.symmetric(vertical: 4), + padding: const EdgeInsets.symmetric( + vertical: 4, + ), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ - Text("Order Total".tr, style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), Text( - Constant.amountShow(amount: controller.totalAmount.value.toString()), - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + ConstTexts.orderTotal.tr, + style: AppThemeData.mediumTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + Text( + Constant.amountShow( + amount: + controller.totalAmount.value + .toString(), + ), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ], ), @@ -1415,33 +2707,61 @@ class CabBookingScreen extends StatelessWidget { ), Obx(() { - if (controller.currentOrder.value.status == Constant.orderInTransit) { + if (controller.currentOrder.value.status == + Constant.orderInTransit) { return Column( children: [ RoundedButtonFill( - title: "SOS".tr, - color: Colors.red.withOpacity(0.50), + borderRadius: 10.r, + title: "SOS", + color: Colors.red.withValues(alpha: 0.50), textColor: AppThemeData.grey50, isCenter: true, icon: const Icon(Icons.call, color: Colors.white), onPress: () async { - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader( + ConstTexts.pleaseWait.tr, + ); - LocationData location = await controller.currentLocation.value.getLocation(); + LocationData location = + await controller.currentLocation.value + .getLocation(); - await FireStoreUtils.getSOS(controller.currentOrder.value.id ?? '').then((value) async { + await FireStoreUtils.getSOS( + controller.currentOrder.value.id ?? '', + ).then((value) async { if (value == false) { - await FireStoreUtils.setSos(controller.currentOrder.value.id ?? '', UserLocation(latitude: location.latitude!, longitude: location.longitude!)).then((_) { + await FireStoreUtils.setSos( + controller.currentOrder.value.id ?? '', + UserLocation( + latitude: location.latitude!, + longitude: location.longitude!, + ), + ).then((_) { ShowToastDialog.closeLoader(); - ScaffoldMessenger.of( - context, - ).showSnackBar(SnackBar(content: Text("Your SOS request has been submitted to admin".tr), backgroundColor: Colors.green, duration: Duration(seconds: 3))); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + ConstTexts.yourSosRequest.tr, + ), + backgroundColor: Colors.green, + duration: Duration(seconds: 3), + ), + ); }); } else { ShowToastDialog.closeLoader(); - ScaffoldMessenger.of( - context, - ).showSnackBar(SnackBar(content: Text("Your SOS request is already submitted".tr), backgroundColor: Colors.red, duration: Duration(seconds: 3))); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + ConstTexts + .yourSosrequestAlreadySubmitted + .tr, + ), + backgroundColor: Colors.red, + duration: Duration(seconds: 3), + ), + ); } }); }, @@ -1454,48 +2774,110 @@ class CabBookingScreen extends StatelessWidget { } }), Obx(() { - if (controller.currentOrder.value.status == Constant.orderInTransit && controller.currentOrder.value.paymentStatus == false) { + if (controller.currentOrder.value.status == + Constant.orderInTransit && + controller.currentOrder.value.paymentStatus == false) { return RoundedButtonFill( - title: "Pay Now".tr, + borderRadius: 10.r, + title: ConstTexts.payNow.tr, onPress: () async { - if (controller.selectedPaymentMethod.value == PaymentGateway.stripe.name) { - controller.stripeMakePayment(amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.paypal.name) { - controller.paypalPaymentSheet(controller.totalAmount.value.toString(), context); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.payStack.name) { - controller.payStackPayment(controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.mercadoPago.name) { - controller.mercadoPagoMakePayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.flutterWave.name) { - controller.flutterWaveInitiatePayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.payFast.name) { - controller.payFastPayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.cod.name) { + if (controller.selectedPaymentMethod.value == + PaymentGateway.stripe.name) { + controller.stripeMakePayment( + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.paypal.name) { + controller.paypalPaymentSheet( + controller.totalAmount.value.toString(), + context, + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.payStack.name) { + controller.payStackPayment( + controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.mercadoPago.name) { + controller.mercadoPagoMakePayment( + context: context, + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.flutterWave.name) { + controller.flutterWaveInitiatePayment( + context: context, + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.payFast.name) { + controller.payFastPayment( + context: context, + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.cod.name) { controller.completeOrder(); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.wallet.name) { - if (Constant.userModel!.walletAmount == null || Constant.userModel!.walletAmount! < controller.totalAmount.value) { - ShowToastDialog.showToast("You do not have sufficient wallet balance".tr); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.wallet.name) { + if (Constant.userModel!.walletAmount == null || + Constant.userModel!.walletAmount! < + controller.totalAmount.value) { + ShowToastDialog.showToast( + ConstTexts + .youDoNothaveSufficientwalletBalance + .tr, + ); } else { controller.completeOrder(); } - } else if (controller.selectedPaymentMethod.value == PaymentGateway.midTrans.name) { - controller.midtransMakePayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.orangeMoney.name) { - controller.orangeMakePayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.xendit.name) { - controller.xenditPayment(context, controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.razorpay.name) { - RazorPayController().createOrderRazorPay(amount: double.parse(controller.totalAmount.value.toString()), razorpayModel: controller.razorPayModel.value).then((value) { - if (value == null) { - Get.back(); - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); - } else { - CreateRazorPayOrderModel result = value; - controller.openCheckout(amount: controller.totalAmount.value.toString(), orderId: result.id); - } - }); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.midTrans.name) { + controller.midtransMakePayment( + context: context, + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.orangeMoney.name) { + controller.orangeMakePayment( + context: context, + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.xendit.name) { + controller.xenditPayment( + context, + controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.razorpay.name) { + RazorPayController() + .createOrderRazorPay( + amount: double.parse( + controller.totalAmount.value.toString(), + ), + razorpayModel: controller.razorPayModel.value, + ) + .then((value) { + if (value == null) { + Get.back(); + ShowToastDialog.showToast( + ConstTexts.somethingWentWrong.tr, + ); + } else { + CreateRazorPayOrderModel result = value; + controller.openCheckout( + amount: + controller.totalAmount.value + .toString(), + orderId: result.id, + ); + } + }); } else { - ShowToastDialog.showToast("Please select payment method".tr); + ShowToastDialog.showToast( + ConstTexts.plsSelectPaymentMethod.tr, + ); } }, color: AppThemeData.primary300, @@ -1514,19 +2896,42 @@ class CabBookingScreen extends StatelessWidget { ); } - Padding cardDecorationScreen(CabBookingController controller, PaymentGateway value, isDark, String image) { + Padding cardDecorationScreen( + CabBookingController controller, + PaymentGateway value, + isDark, + String image, + ) { return Padding( padding: const EdgeInsets.symmetric(vertical: 5), child: Container( width: 40, height: 40, - decoration: ShapeDecoration(shape: RoundedRectangleBorder(side: const BorderSide(width: 1, color: Color(0xFFE5E7EB)), borderRadius: BorderRadius.circular(8))), - child: Padding(padding: EdgeInsets.all(value.name == "payFast" ? 0 : 8.0), child: image == '' ? Container(color: isDark ? AppThemeData.grey800 : AppThemeData.grey100) : Image.asset(image)), + decoration: ShapeDecoration( + shape: RoundedRectangleBorder( + side: const BorderSide(width: 1, color: Color(0xFFE5E7EB)), + borderRadius: BorderRadius.circular(8), + ), + ), + child: Padding( + padding: EdgeInsets.all(value.name == "payFast" ? 0 : 8.0), + child: + image == '' + ? Container( + color: isDark ? AppThemeData.grey800 : AppThemeData.grey100, + ) + : Image.asset(image), + ), ), ); } - Obx cardDecoration(CabBookingController controller, PaymentGateway value, isDark, String image) { + Obx cardDecoration( + CabBookingController controller, + PaymentGateway value, + isDark, + String image, + ) { return Obx( () => Padding( padding: const EdgeInsets.symmetric(vertical: 5), @@ -1539,10 +2944,27 @@ class CabBookingScreen extends StatelessWidget { child: Row( children: [ Container( - width: 50, - height: 50, - decoration: ShapeDecoration(shape: RoundedRectangleBorder(side: const BorderSide(width: 1, color: Color(0xFFE5E7EB)), borderRadius: BorderRadius.circular(8))), - child: Padding(padding: EdgeInsets.all(value.name == "payFast" ? 0 : 8.0), child: Image.asset(image)), + width: 42.r, + height: 42.r, + decoration: ShapeDecoration( + shape: RoundedRectangleBorder( + side: const BorderSide( + width: 1, + color: Color(0xFFE5E7EB), + ), + borderRadius: BorderRadius.circular(8), + ), + ), + child: + value == PaymentGateway.click || + value == PaymentGateway.payme + ? Image.asset(image) + : Padding( + padding: EdgeInsets.all( + value.name == "payFast" ? 0 : 8.0, + ), + child: Image.asset(image), + ), ), const SizedBox(width: 10), value.name == "wallet" @@ -1553,28 +2975,61 @@ class CabBookingScreen extends StatelessWidget { Text( value.name.capitalizeString(), textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), Text( - Constant.amountShow(amount: controller.userModel.value.walletAmount == null ? '0.0' : controller.userModel.value.walletAmount.toString()), + Constant.amountShow( + amount: + controller.userModel.value.walletAmount == + null + ? '0.0' + : controller + .userModel + .value + .walletAmount + .toString(), + ), textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(fontSize: 14, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300), + style: AppThemeData.semiBoldTextStyle( + fontSize: 12.sp, + color: + isDark + ? AppThemeData.mainColor + : AppThemeData.mainColor, + ), ), ], ), ) : Expanded( child: Text( - value.name.capitalizeString(), + value.name == "cod" + ? ConstTexts.cash.tr + : value.name.capitalizeString(), textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), ), const Expanded(child: SizedBox()), Radio( value: value.name, groupValue: controller.selectedPaymentMethod.value, - activeColor: isDark ? AppThemeData.primary300 : AppThemeData.primary300, + activeColor: + isDark + ? AppThemeData.mainColor + : AppThemeData.mainColor, onChanged: (value) { controller.selectedPaymentMethod.value = value.toString(); }, diff --git a/lib/screen_ui/cab_service_screens/cab_coupon_code_screen.dart b/lib/screen_ui/cab_service_screens/cab_coupon_code_screen.dart index e69a795..013c0fe 100644 --- a/lib/screen_ui/cab_service_screens/cab_coupon_code_screen.dart +++ b/lib/screen_ui/cab_service_screens/cab_coupon_code_screen.dart @@ -1,3 +1,4 @@ +import 'package:customer/constant/const_texts.dart'; import 'package:customer/constant/constant.dart'; import 'package:customer/controllers/cab_coupon_code_controller.dart'; import 'package:customer/controllers/theme_controller.dart'; @@ -6,6 +7,7 @@ import 'package:customer/themes/app_them_data.dart'; import 'package:customer/themes/responsive.dart'; import 'package:customer/widget/my_separator.dart'; import 'package:dotted_border/dotted_border.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -32,12 +34,30 @@ class CabCouponCodeScreen extends StatelessWidget { child: Container( height: 42, width: 42, - decoration: BoxDecoration(shape: BoxShape.circle, color: AppThemeData.grey50), - child: Center(child: Padding(padding: const EdgeInsets.only(left: 5), child: Icon(Icons.arrow_back_ios, color: AppThemeData.grey900, size: 20))), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: AppThemeData.grey50, + ), + child: Center( + child: Padding( + padding: const EdgeInsets.only(left: 5), + child: Icon( + Icons.arrow_back_ios, + color: AppThemeData.grey900, + size: 20, + ), + ), + ), ), ), const SizedBox(width: 10), - Text("Coupon".tr, style: AppThemeData.boldTextStyle(fontSize: 18, color: AppThemeData.grey900)), + Text( + ConstTexts.coupon.tr, + style: AppThemeData.boldTextStyle( + fontSize: 18, + color: AppThemeData.grey900, + ), + ), ], ), ), @@ -46,24 +66,44 @@ class CabCouponCodeScreen extends StatelessWidget { controller.isLoading.value ? Constant.loader() : controller.cabCouponList.isEmpty - ? Constant.showEmptyView(message: "Coupon not found".tr) + ? Constant.showEmptyView( + message: ConstTexts.couponNotFound.tr, + ) : ListView.builder( shrinkWrap: true, itemCount: controller.cabCouponList.length, itemBuilder: (context, index) { CouponModel couponModel = controller.cabCouponList[index]; return Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: Container( height: Responsive.height(16, context), - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + ), child: Row( children: [ ClipRRect( - borderRadius: const BorderRadius.only(topLeft: Radius.circular(10), bottomLeft: Radius.circular(10)), + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(10), + bottomLeft: Radius.circular(10), + ), child: Stack( children: [ - Image.asset("assets/images/ic_coupon_image.png", height: Responsive.height(16, context), fit: BoxFit.fill), + Image.asset( + "assets/images/ic_coupon_image.png", + height: Responsive.height(16, context), + fit: BoxFit.fill, + ), Padding( padding: const EdgeInsets.only(left: 10), child: Align( @@ -73,7 +113,14 @@ class CabCouponCodeScreen extends StatelessWidget { child: Text( "${couponModel.discountType == "Fix Price" ? Constant.amountShow(amount: couponModel.discount) : "${couponModel.discount}%"} ${'Off'.tr}", textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey50), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey50, + ), ), ), ), @@ -83,43 +130,92 @@ class CabCouponCodeScreen extends StatelessWidget { ), Expanded( child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 18), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 18, + ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Row( children: [ DottedBorder( - options: RoundedRectDottedBorderOptions(strokeWidth: 1, radius: const Radius.circular(6), color: isDark ? AppThemeData.grey400 : AppThemeData.grey500), + options: + RoundedRectDottedBorderOptions( + strokeWidth: 1, + radius: const Radius.circular( + 6, + ), + color: + isDark + ? AppThemeData.grey400 + : AppThemeData + .grey500, + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), + padding: + const EdgeInsets.symmetric( + horizontal: 16, + ), child: Text( "${couponModel.code}", textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.grey400 : AppThemeData.grey500), + style: TextStyle( + fontFamily: + AppThemeData.semiBold, + fontSize: 16, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData + .grey500, + ), ), ), ), - const Expanded(child: SizedBox(height: 10)), + const Expanded( + child: SizedBox(height: 10), + ), InkWell( onTap: () { Get.back(result: couponModel); }, child: Text( - "Tap To Apply".tr, + ConstTexts.tapToApply.tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300), + style: TextStyle( + fontFamily: AppThemeData.medium, + color: + isDark + ? AppThemeData + .primary300 + : AppThemeData + .primary300, + ), ), ), ], ), const SizedBox(height: 20), - MySeparator(color: isDark ? AppThemeData.grey700 : AppThemeData.grey200), + MySeparator( + color: + isDark + ? AppThemeData.grey700 + : AppThemeData.grey200, + ), const SizedBox(height: 20), Text( "${couponModel.description}", textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), ], ), diff --git a/lib/screen_ui/cab_service_screens/cab_dashboard_screen.dart b/lib/screen_ui/cab_service_screens/cab_dashboard_screen.dart index d87addb..f591e5f 100644 --- a/lib/screen_ui/cab_service_screens/cab_dashboard_screen.dart +++ b/lib/screen_ui/cab_service_screens/cab_dashboard_screen.dart @@ -1,8 +1,11 @@ +import 'package:customer/constant/const_texts.dart'; import 'package:customer/constant/constant.dart'; import 'package:customer/controllers/cab_dashboard_controller.dart'; import 'package:customer/controllers/theme_controller.dart'; import 'package:customer/themes/app_them_data.dart'; + import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:get/get.dart'; @@ -23,13 +26,19 @@ class CabDashboardScreen extends StatelessWidget { type: BottomNavigationBarType.fixed, showUnselectedLabels: true, showSelectedLabels: true, - selectedFontSize: 12, - selectedLabelStyle: const TextStyle(fontFamily: AppThemeData.bold), - unselectedLabelStyle: const TextStyle(fontFamily: AppThemeData.bold), + selectedFontSize: 12.sp, + selectedLabelStyle: const TextStyle( + fontFamily: AppThemeData.bold, + ), + unselectedLabelStyle: const TextStyle( + fontFamily: AppThemeData.bold, + ), currentIndex: controller.selectedIndex.value, - backgroundColor: isDark ? AppThemeData.grey900 : AppThemeData.grey50, - selectedItemColor: isDark ? AppThemeData.primary300 : AppThemeData.primary300, - unselectedItemColor: isDark ? AppThemeData.grey300 : AppThemeData.grey600, + backgroundColor: AppThemeData.cardColor, + selectedItemColor: + isDark ? AppThemeData.primary300 : AppThemeData.primary300, + unselectedItemColor: + isDark ? AppThemeData.grey300 : AppThemeData.grey600, onTap: (int index) { if (index == 0) { Get.put(CabDashboardController()); @@ -39,15 +48,57 @@ class CabDashboardScreen extends StatelessWidget { items: Constant.walletSetting == false ? [ - navigationBarItem(isDark, index: 0, assetIcon: "assets/icons/ic_home_cab.svg", label: 'Home'.tr, controller: controller), - navigationBarItem(isDark, index: 1, assetIcon: "assets/icons/ic_booking_cab.svg", label: 'My Bookings'.tr, controller: controller), - navigationBarItem(isDark, index: 2, assetIcon: "assets/icons/ic_profile.svg", label: 'Profile'.tr, controller: controller), + navigationBarItem( + isDark, + index: 0, + assetIcon: "assets/icons/ic_home_cab.svg", + label: ConstTexts.home.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 1, + assetIcon: "assets/icons/ic_booking_cab.svg", + label: ConstTexts.myBookings.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 2, + assetIcon: "assets/icons/ic_profile.svg", + label: ConstTexts.profile.tr, + controller: controller, + ), ] : [ - navigationBarItem(isDark, index: 0, assetIcon: "assets/icons/ic_home_cab.svg", label: 'Home'.tr, controller: controller), - navigationBarItem(isDark, index: 1, assetIcon: "assets/icons/ic_booking_cab.svg", label: 'My Bookings'.tr, controller: controller), - navigationBarItem(isDark, index: 2, assetIcon: "assets/icons/ic_wallet_cab.svg", label: 'Wallet'.tr, controller: controller), - navigationBarItem(isDark, index: 3, assetIcon: "assets/icons/ic_profile.svg", label: 'Profile'.tr, controller: controller), + navigationBarItem( + isDark, + index: 0, + assetIcon: "assets/icons/ic_home_cab.svg", + label: ConstTexts.home.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 1, + assetIcon: "assets/icons/ic_booking_cab.svg", + label: ConstTexts.myBookings.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 2, + assetIcon: "assets/icons/ic_wallet_cab.svg", + label: ConstTexts.wallet.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 3, + assetIcon: "assets/icons/ic_profile.svg", + label: ConstTexts.profile.tr, + controller: controller, + ), ], ), ); @@ -56,7 +107,13 @@ class CabDashboardScreen extends StatelessWidget { }); } - BottomNavigationBarItem navigationBarItem(isDark, {required int index, required String label, required String assetIcon, required CabDashboardController controller}) { + BottomNavigationBarItem navigationBarItem( + isDark, { + required int index, + required String label, + required String assetIcon, + required CabDashboardController controller, + }) { return BottomNavigationBarItem( icon: Padding( padding: const EdgeInsets.symmetric(vertical: 5), diff --git a/lib/screen_ui/cab_service_screens/cab_home_screen.dart b/lib/screen_ui/cab_service_screens/cab_home_screen.dart index fb21871..a498ceb 100644 --- a/lib/screen_ui/cab_service_screens/cab_home_screen.dart +++ b/lib/screen_ui/cab_service_screens/cab_home_screen.dart @@ -1,19 +1,21 @@ +import 'package:customer/constant/const_texts.dart'; import 'package:customer/constant/constant.dart'; import 'package:customer/controllers/cab_home_controller.dart'; import 'package:customer/controllers/theme_controller.dart'; import 'package:customer/models/banner_model.dart'; import 'package:customer/screen_ui/auth_screens/login_screen.dart'; import 'package:customer/themes/app_them_data.dart'; -import 'package:customer/themes/responsive.dart'; +import 'package:customer/utils/app_router.dart'; import 'package:customer/utils/network_image_widget.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_svg/flutter_svg.dart'; -import 'package:get/get.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; import 'Intercity_home_screen.dart'; import 'cab_booking_screen.dart'; -class CabHomeScreen extends StatelessWidget { +class CabHomeScreen extends HookWidget { const CabHomeScreen({super.key}); @override @@ -26,189 +28,244 @@ class CabHomeScreen extends StatelessWidget { return Scaffold( appBar: AppBar( automaticallyImplyLeading: false, - backgroundColor: AppThemeData.primary300, - title: Padding( - padding: const EdgeInsets.only(bottom: 10), - child: Row( - children: [ - GestureDetector( - onTap: () { - Get.back(); - }, - child: Container( - height: 42, - width: 42, - decoration: BoxDecoration(shape: BoxShape.circle, color: AppThemeData.grey50), - child: Center( - child: Padding( - padding: const EdgeInsets.only(left: 5), - child: Icon(Icons.arrow_back_ios, color: AppThemeData.grey900, size: 20), + backgroundColor: AppThemeData.cardColor, + title: Row( + children: [ + SizedBox(width: 5.w), + InkWell( + onTap: () { + Get.back(); + }, + child: Icon( + Icons.arrow_back_ios, + color: AppThemeData.grey900, + size: 20, + ), + ), + const SizedBox(width: 10), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Constant.userModel == null + ? InkWell( + onTap: () { + Get.offAll(const LoginScreen()); + }, + child: Text( + ConstTexts.login.tr, + textAlign: TextAlign.center, + style: AppThemeData.boldTextStyle( + color: AppThemeData.grey900, + fontSize: 17.sp, + ), + ), + ) + : Text( + Constant.userModel!.fullName(), + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.center, + style: AppThemeData.boldTextStyle( + color: AppThemeData.grey900, + fontSize: 17.sp, + ), + ), + Text( + Constant.selectedLocation.getFullAddress(), + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: AppThemeData.regularTextStyle( + fontSize: 12.sp, + color: AppThemeData.grey900, ), ), - ), + ], ), - const SizedBox(width: 10), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Constant.userModel == null - ? InkWell( - onTap: () { - Get.offAll(const LoginScreen()); - }, - child: Text( - "Login".tr, - textAlign: TextAlign.center, - style: AppThemeData.boldTextStyle(color: AppThemeData.grey900, fontSize: 12), - ), - ) - : Text( - Constant.userModel!.fullName(), - textAlign: TextAlign.center, - style: AppThemeData.boldTextStyle(color: AppThemeData.grey900, fontSize: 12), - ), - Text( - Constant.selectedLocation.getFullAddress(), - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: AppThemeData.boldTextStyle(fontSize: 18, color: AppThemeData.grey900), - ), - ], - ), - ), - ], - ), + ), + ], ), ), body: controller.isLoading.value ? Constant.loader() - : Padding( - padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 15), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - BannerView(bannerList: controller.bannerTopHome), + : Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + BannerView(bannerList: controller.bannerTopHome), - Column( + Padding( + padding: EdgeInsetsGeometry.symmetric(horizontal: 16.r), + child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox(height: 20), Text( - "Where are you going for?".tr, - style: AppThemeData.mediumTextStyle( - color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, - fontSize: 18, + ConstTexts.cabServiceType.tr, + style: AppThemeData.boldTextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.darkGrey, + fontSize: 16.sp, ), ), - SizedBox(height: 20), - Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Constant.sectionConstantModel!.rideType == "both" || Constant.sectionConstantModel!.rideType == "ride" - ? GestureDetector( - onTap: () { - Get.to(() => CabBookingScreen()); - }, - child: Container( - width: Responsive.width(40, context), - decoration: BoxDecoration( - color: AppThemeData.warning50, - borderRadius: BorderRadius.circular(15), - border: Border.all(color: AppThemeData.warning200), - ), - padding: EdgeInsets.all(16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SvgPicture.asset("assets/icons/ic_ride.svg", height: 38, width: 38), - SizedBox(height: 20), - Text( - "Ride".tr, - style: AppThemeData.semiBoldTextStyle(color: AppThemeData.taxiBooking500, fontSize: 16), - ), - Text( - "City rides, 24x7 availability".tr, - style: AppThemeData.mediumTextStyle(color: AppThemeData.taxiBooking600, fontSize: 14), - ), - ], - ), - ), - ) - : SizedBox(), - SizedBox(width: 20), - Constant.sectionConstantModel!.rideType == "both" || Constant.sectionConstantModel!.rideType == "intercity" - ? GestureDetector( - onTap: () { - Get.to(() => IntercityHomeScreen()); - }, - child: Container( - width: Responsive.width(44, context), - decoration: BoxDecoration( - color: AppThemeData.carRent50, - borderRadius: BorderRadius.circular(15), - border: Border.all(color: AppThemeData.carRent200), - ), - padding: EdgeInsets.all(15), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SvgPicture.asset("assets/icons/ic_intercity.svg", height: 38, width: 38), - SizedBox(height: 20), - Text( - "Intercity/Outstation".tr, - style: AppThemeData.semiBoldTextStyle(color: AppThemeData.carRent500, fontSize: 16), - ), - Text( - "Long trips, prepaid options".tr, - style: AppThemeData.mediumTextStyle(color: AppThemeData.parcelService600, fontSize: 14), - ), - ], - ), - ), - ) - : SizedBox(), - ], - ), - SizedBox(height: 30), + SizedBox(height: 10.h), + // Cab Service Types Section + _buildCabServiceTypesSection(), + + SizedBox(height: 35.h), + Row( children: [ Expanded( flex: 2, child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( - "Every Ride. Every Driver. Verified.".tr, + ConstTexts.everyRideVerified.tr, style: AppThemeData.boldTextStyle( - color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, fontSize: 22, ), ), Text( - "All drivers go through ID checks and background verification for your safety.".tr, + ConstTexts.allDriversIDCheck.tr, style: AppThemeData.mediumTextStyle( - color: isDark ? AppThemeData.greyDark700 : AppThemeData.grey700, + color: + isDark + ? AppThemeData.greyDark700 + : AppThemeData.grey700, fontSize: 14, ), ), ], ), ), - Expanded(child: Image.asset("assets/images/img_ride_driver.png", height: 118, width: 68)), + Expanded( + child: Image.asset( + "assets/images/img_ride_driver.png", + height: 118, + width: 68, + ), + ), ], ), ], ), - ], - ), + ), + ], ), ); }, ); } + + Row _buildCabServiceTypesSection() { + return Row( + spacing: 10.w, + children: [ + Constant.sectionConstantModel!.rideType == "both" || + Constant.sectionConstantModel!.rideType == "ride" + ? _cabOptionMaker( + title: ConstTexts.aroundTheCity.tr, + isMain: false, + image: "assets/images/taxi_option.png", + useGradient: false, + onTap: () { + Get.to(() => CabBookingScreen()); + }, + mainColor: AppThemeData.cardColor, + ) + : Expanded(child: SizedBox()), + _cabOptionMaker( + title: ConstTexts.intercity.tr, + isMain: false, + useGradient: false, + image: "assets/images/outer_city_taxi_option.png", + onTap: () { + Get.to(() => IntercityHomeScreen()); + }, + mainColor: AppThemeData.cardColor, + ), + ], + ); + } + + Expanded _cabOptionMaker({ + required String title, + required String image, + required VoidCallback onTap, + required Color mainColor, + required useGradient, + required bool isMain, + }) { + return Expanded( + child: InkWell( + onTap: onTap, + child: Container( + height: 100.h, + clipBehavior: Clip.hardEdge, + decoration: BoxDecoration( + color: mainColor, + borderRadius: BorderRadius.circular(16.r), + gradient: + useGradient + ? LinearGradient( + begin: Alignment.centerLeft, + end: Alignment.centerRight, + colors: [Color(0xFF2E2E37), Color(0xFF6A6A9E)], + ) + : null, + ), + child: Stack( + children: [ + Padding( + padding: EdgeInsets.only(left: 12.r, top: 12.r), + child: Row( + children: [ + Expanded( + child: Text( + maxLines: 2, + title, + style: TextStyle( + overflow: TextOverflow.ellipsis, + fontFamily: AppThemeData.semiBold, + fontSize: 14.sp, + fontWeight: FontWeight.w700, + color: + isMain + ? AppThemeData.grey50 + : AppThemeData.darkGrey, + ), + ), + ), + Expanded(child: SizedBox()), + ], + ), + ), + Transform.translate( + offset: Offset(25.w, 0), + child: Align( + alignment: Alignment.bottomRight, + child: Image.asset( + image, + height: 133.h, + width: 133.w, + fit: BoxFit.contain, + ), + ), + ), + ], + ), + ), + ), + ); + } } class BannerView extends StatelessWidget { @@ -242,43 +299,39 @@ class BannerView extends StatelessWidget { ? SizedBox() : Column( children: [ - SizedBox(height: 20), + SizedBox(height: 20.h), SizedBox( - height: 150, - child: ListView.separated( + height: 150.h, + child: ListView.builder( controller: scrollController, scrollDirection: Axis.horizontal, itemCount: bannerList.length, - separatorBuilder: (context, index) => const SizedBox(width: 15), + itemBuilder: (context, index) { final banner = bannerList[index]; - return ClipRRect( - borderRadius: BorderRadius.circular(15), - child: SizedBox( - width: MediaQuery.of(context).size.width * 0.8, - child: NetworkImageWidget(imageUrl: banner.photo ?? '', fit: BoxFit.cover), + return Container( + width: MediaQuery.of(context).size.width * 0.8, + margin: + index == 0 + ? EdgeInsets.only(left: 16.r, right: 10.r) + : index == bannerList.length - 1 + ? EdgeInsets.only(right: 16.r) + : EdgeInsets.only(right: 10.r), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + ), + + child: ClipRRect( + borderRadius: BorderRadius.circular(15), + child: NetworkImageWidget( + imageUrl: banner.photo ?? '', + fit: BoxFit.cover, + ), ), ); }, ), ), - const SizedBox(height: 8), - Obx(() { - return Row( - children: List.generate(bannerList.length, (index) { - bool isSelected = currentPage.value == index; - return Expanded( - child: Container( - height: 4, - decoration: BoxDecoration( - color: isSelected ? AppThemeData.grey300 : AppThemeData.grey100, - borderRadius: BorderRadius.circular(5), - ), - ), - ); - }), - ); - }), ], ); } diff --git a/lib/screen_ui/cab_service_screens/cab_order_details.dart b/lib/screen_ui/cab_service_screens/cab_order_details.dart index 40bbfbb..2574520 100644 --- a/lib/screen_ui/cab_service_screens/cab_order_details.dart +++ b/lib/screen_ui/cab_service_screens/cab_order_details.dart @@ -1,5 +1,8 @@ +import 'package:customer/constant/const_texts.dart'; import 'package:dotted_border/dotted_border.dart'; + import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_svg/svg.dart'; import 'package:get/get.dart'; import '../../constant/constant.dart'; @@ -43,12 +46,30 @@ class CabOrderDetails extends StatelessWidget { child: Container( height: 42, width: 42, - decoration: BoxDecoration(shape: BoxShape.circle, color: AppThemeData.grey50), - child: Center(child: Padding(padding: const EdgeInsets.only(left: 5), child: Icon(Icons.arrow_back_ios, color: AppThemeData.grey900, size: 20))), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: AppThemeData.grey50, + ), + child: Center( + child: Padding( + padding: const EdgeInsets.only(left: 5), + child: Icon( + Icons.arrow_back_ios, + color: AppThemeData.grey900, + size: 20, + ), + ), + ), ), ), const SizedBox(width: 10), - Text("Ride Details".tr, style: AppThemeData.boldTextStyle(fontSize: 18, color: AppThemeData.grey900)), + Text( + ConstTexts.rideDetails.tr, + style: AppThemeData.boldTextStyle( + fontSize: 18, + color: AppThemeData.grey900, + ), + ), ], ), ), @@ -63,15 +84,30 @@ class CabOrderDetails extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), width: double.infinity, padding: const EdgeInsets.all(16), child: Text( - "${'Order Id:'.tr} ${Constant.orderId(orderId: controller.cabOrder.value.id.toString())}".tr, + "${ConstTexts.orderId.tr} ${Constant.orderId(orderId: controller.cabOrder.value.id.toString())}", textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 18, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + fontSize: 18, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), ), const SizedBox(height: 16), @@ -79,24 +115,43 @@ class CabOrderDetails extends StatelessWidget { margin: const EdgeInsets.only(bottom: 16), padding: const EdgeInsets.all(16), decoration: BoxDecoration( - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, borderRadius: BorderRadius.circular(15), - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "${'Booking Date:'.tr} ${controller.formatDate(controller.cabOrder.value.scheduleDateTime!)}".tr, + "${ConstTexts.bookingData.tr} ${controller.formatDate(controller.cabOrder.value.scheduleDateTime!)}", + textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 18, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + fontSize: 18, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Column( children: [ - Icon(Icons.stop_circle_outlined, color: Colors.green), + Icon( + Icons.stop_circle_outlined, + color: Colors.green, + ), DottedBorder( options: CustomPathDottedBorderOptions( color: Colors.grey.shade400, @@ -106,25 +161,48 @@ class CabOrderDetails extends StatelessWidget { (size) => Path() ..moveTo(size.width / 2, 0) - ..lineTo(size.width / 2, size.height), + ..lineTo( + size.width / 2, + size.height, + ), + ), + child: const SizedBox( + width: 20, + height: 55, ), - child: const SizedBox(width: 20, height: 55), ), - Icon(Icons.radio_button_checked, color: Colors.red), + Icon( + Icons.radio_button_checked, + color: Colors.red, + ), ], ), const SizedBox(width: 12), Expanded( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Row( children: [ // Source Location Name Expanded( child: Text( - controller.cabOrder.value.sourceLocationName.toString(), - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + controller + .cabOrder + .value + .sourceLocationName + .toString(), + style: + AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), maxLines: 2, overflow: TextOverflow.ellipsis, ), @@ -132,14 +210,30 @@ class CabOrderDetails extends StatelessWidget { const SizedBox(width: 8), Container( decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - border: Border.all(color: AppThemeData.warning300, width: 1), + borderRadius: + BorderRadius.circular(10), + border: Border.all( + color: + AppThemeData.warning300, + width: 1, + ), color: AppThemeData.warning50, ), - padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 12), + padding: + const EdgeInsets.symmetric( + vertical: 8, + horizontal: 12, + ), child: Text( - controller.cabOrder.value.status.toString(), - style: AppThemeData.boldTextStyle(fontSize: 14, color: AppThemeData.warning500), + controller.cabOrder.value.status + .toString(), + style: + AppThemeData.boldTextStyle( + fontSize: 14, + color: + AppThemeData + .warning500, + ), overflow: TextOverflow.ellipsis, ), ), @@ -154,15 +248,34 @@ class CabOrderDetails extends StatelessWidget { customPath: (size) => Path() - ..moveTo(0, size.height / 2) // start from left center - ..lineTo(size.width, size.height / 2), // draw to right center + ..moveTo( + 0, + size.height / 2, + ) // start from left center + ..lineTo( + size.width, + size.height / 2, + ), // draw to right center + ), + child: const SizedBox( + width: 295, + height: 3, ), - child: const SizedBox(width: 295, height: 3), ), SizedBox(height: 15), Text( - controller.cabOrder.value.destinationLocationName.toString(), - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + controller + .cabOrder + .value + .destinationLocationName + .toString(), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ], ), @@ -177,8 +290,16 @@ class CabOrderDetails extends StatelessWidget { height: 180, decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), child: ClipRRect( borderRadius: BorderRadius.circular(15), @@ -186,39 +307,107 @@ class CabOrderDetails extends StatelessWidget { Constant.selectedMapType == "osm" ? fm.FlutterMap( options: fm.MapOptions( - initialCenter: osm.LatLng(controller.cabOrder.value.sourceLocation!.latitude!, controller.cabOrder.value.sourceLocation!.longitude!), + initialCenter: osm.LatLng( + controller + .cabOrder + .value + .sourceLocation! + .latitude!, + controller + .cabOrder + .value + .sourceLocation! + .longitude!, + ), initialZoom: 13, ), children: [ - fm.TileLayer(urlTemplate: "https://tile.openstreetmap.org/{z}/{x}/{y}.png"), + fm.TileLayer( + urlTemplate: + "https://tile.openstreetmap.org/{z}/{x}/{y}.png", + ), // Only show polyline if points exist - if (controller.osmPolyline.isNotEmpty) fm.PolylineLayer(polylines: [fm.Polyline(points: controller.osmPolyline.toList(), color: Colors.blue, strokeWidth: 4)]), + if (controller.osmPolyline.isNotEmpty) + fm.PolylineLayer( + polylines: [ + fm.Polyline( + points: + controller.osmPolyline + .toList(), + color: Colors.blue, + strokeWidth: 4, + ), + ], + ), fm.MarkerLayer( markers: [ fm.Marker( - point: osm.LatLng(controller.cabOrder.value.sourceLocation!.latitude!, controller.cabOrder.value.sourceLocation!.longitude!), + point: osm.LatLng( + controller + .cabOrder + .value + .sourceLocation! + .latitude!, + controller + .cabOrder + .value + .sourceLocation! + .longitude!, + ), width: 20, height: 20, - child: Image.asset('assets/icons/ic_cab_pickup.png', width: 10, height: 10), + child: Image.asset( + 'assets/icons/ic_cab_pickup.png', + width: 10, + height: 10, + ), ), fm.Marker( - point: osm.LatLng(controller.cabOrder.value.destinationLocation!.latitude!, controller.cabOrder.value.destinationLocation!.longitude!), + point: osm.LatLng( + controller + .cabOrder + .value + .destinationLocation! + .latitude!, + controller + .cabOrder + .value + .destinationLocation! + .longitude!, + ), width: 20, height: 20, - child: Image.asset('assets/icons/ic_cab_destination.png', width: 10, height: 10), + child: Image.asset( + 'assets/icons/ic_cab_destination.png', + width: 10, + height: 10, + ), ), ], ), ], ) : gmap.GoogleMap( - initialCameraPosition: gmap.CameraPosition( - target: gmap.LatLng(controller.cabOrder.value.sourceLocation!.latitude!, controller.cabOrder.value.sourceLocation!.longitude!), - zoom: 13, - ), - polylines: controller.googlePolylines.toSet(), + initialCameraPosition: + gmap.CameraPosition( + target: gmap.LatLng( + controller + .cabOrder + .value + .sourceLocation! + .latitude!, + controller + .cabOrder + .value + .sourceLocation! + .longitude!, + ), + zoom: 13, + ), + polylines: + controller.googlePolylines.toSet(), markers: controller.googleMarkers.toSet(), ), ), @@ -230,18 +419,38 @@ class CabOrderDetails extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), padding: const EdgeInsets.all(16), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ - Text("Ride & Fare Summary".tr, style: AppThemeData.boldTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500)), + Text( + ConstTexts.rideAndFareSummary.tr, + style: AppThemeData.boldTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), + ), const SizedBox(height: 8), Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Row( children: [ @@ -249,41 +458,101 @@ class CabOrderDetails extends StatelessWidget { width: 52, height: 52, child: ClipRRect( - borderRadius: BorderRadiusGeometry.circular(10), - child: NetworkImageWidget(imageUrl: controller.cabOrder.value.driver?.profilePictureURL ?? '', height: 70, width: 70, borderRadius: 35), + borderRadius: + BorderRadiusGeometry.circular( + 10, + ), + child: NetworkImageWidget( + imageUrl: + controller + .cabOrder + .value + .driver + ?.profilePictureURL ?? + '', + height: 70, + width: 70, + borderRadius: 35, + ), ), ), SizedBox(width: 20), Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( - controller.cabOrder.value.driver?.fullName() ?? '', - style: AppThemeData.boldTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, fontSize: 18), + controller + .cabOrder + .value + .driver + ?.fullName() ?? + '', + style: + AppThemeData.boldTextStyle( + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + fontSize: 18, + ), ), Text( "${controller.cabOrder.value.driver?.vehicleType ?? ''} | ${controller.cabOrder.value.driver?.carMakes.toString()}", - style: TextStyle(fontFamily: AppThemeData.medium, color: isDark ? AppThemeData.greyDark700 : AppThemeData.grey700, fontSize: 14), + style: TextStyle( + fontFamily: + AppThemeData.medium, + color: + isDark + ? AppThemeData + .greyDark700 + : AppThemeData + .grey700, + fontSize: 14, + ), ), Text( - controller.cabOrder.value.driver?.carNumber ?? '', - style: AppThemeData.boldTextStyle(color: isDark ? AppThemeData.greyDark700 : AppThemeData.grey700, fontSize: 16), + controller + .cabOrder + .value + .driver + ?.carNumber ?? + '', + style: + AppThemeData.boldTextStyle( + color: + isDark + ? AppThemeData + .greyDark700 + : AppThemeData + .grey700, + fontSize: 16, + ), ), ], ), ], ), RoundedButtonBorder( - title: controller.driverUser.value.averageRating.toStringAsFixed(1) ?? '', + title: controller + .driverUser + .value + .averageRating + .toStringAsFixed(1), width: 20, height: 3.5, radius: 10, isRight: false, isCenter: true, textColor: AppThemeData.warning400, - borderColor: AppThemeData.warning400, + borderColor: + AppThemeData.warning400, color: AppThemeData.warning50, - icon: SvgPicture.asset("assets/icons/ic_start.svg"), + icon: SvgPicture.asset( + "assets/icons/ic_start.svg", + ), onPress: () {}, ), ], @@ -292,23 +561,65 @@ class CabOrderDetails extends StatelessWidget { children: [ Expanded( child: Visibility( - visible: controller.cabOrder.value.status == Constant.orderCompleted ? true : false, + visible: + controller + .cabOrder + .value + .status == + Constant + .orderCompleted + ? true + : false, child: Padding( - padding: const EdgeInsets.symmetric(vertical: 10), + padding: + const EdgeInsets.symmetric( + vertical: 10, + ), child: RoundedButtonFill( - title: controller.ratingModel.value.id != null && controller.ratingModel.value.id!.isNotEmpty ? 'Update Review'.tr : 'Add Review'.tr, + borderRadius: 10.r, + title: + controller + .ratingModel + .value + .id != + null && + controller + .ratingModel + .value + .id! + .isNotEmpty + ? ConstTexts + .updateReview + .tr + : ConstTexts + .addReview + .tr, onPress: () async { - final result = await Get.to(() => CabReviewScreen(), arguments: {'order': controller.cabOrder.value}); + final result = await Get.to( + () => CabReviewScreen(), + arguments: { + 'order': + controller + .cabOrder + .value, + }, + ); // If review was submitted successfully if (result == true) { - await controller.fetchDriverDetails(); + await controller + .fetchDriverDetails(); } }, height: 5, - borderRadius: 15, + color: Colors.orange, - textColor: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + textColor: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, ), ), ), @@ -316,65 +627,145 @@ class CabOrderDetails extends StatelessWidget { SizedBox(width: 5), Expanded( child: Visibility( - visible: controller.cabOrder.value.status == Constant.orderCompleted ? true : false, + visible: + controller + .cabOrder + .value + .status == + Constant + .orderCompleted + ? true + : false, child: Padding( - padding: const EdgeInsets.symmetric(vertical: 10), + padding: + const EdgeInsets.symmetric( + vertical: 10, + ), child: RoundedButtonFill( - title: 'Complain'.tr, + borderRadius: 10.r, + title: ConstTexts.complain.tr, onPress: () async { - Get.to(() => ComplainScreen(), arguments: {'order': controller.cabOrder.value}); + Get.to( + () => ComplainScreen(), + arguments: { + 'order': + controller + .cabOrder + .value, + }, + ); }, height: 5, - borderRadius: 15, + color: Colors.orange, - textColor: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + textColor: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, ), ), ), ), ], ), - if (controller.cabOrder.value.status != Constant.orderCompleted) + if (controller.cabOrder.value.status != + Constant.orderCompleted) Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ InkWell( onTap: () { - Constant.makePhoneCall(controller.cabOrder.value.driver!.phoneNumber.toString()); + Constant.makePhoneCall( + controller + .cabOrder + .value + .driver! + .phoneNumber + .toString(), + ); }, child: Container( width: 150, height: 42, decoration: ShapeDecoration( shape: RoundedRectangleBorder( - side: BorderSide(width: 1, color: isDark ? AppThemeData.grey700 : AppThemeData.grey200), - borderRadius: BorderRadius.circular(120), + side: BorderSide( + width: 1, + color: + isDark + ? AppThemeData + .grey700 + : AppThemeData + .grey200, + ), + borderRadius: + BorderRadius.circular( + 120, + ), + ), + ), + child: Padding( + padding: const EdgeInsets.all( + 8.0, + ), + child: SvgPicture.asset( + "assets/icons/ic_phone_call.svg", ), ), - child: Padding(padding: const EdgeInsets.all(8.0), child: SvgPicture.asset("assets/icons/ic_phone_call.svg")), ), ), const SizedBox(width: 10), InkWell( onTap: () async { - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader( + ConstTexts.pleaseWait.tr, + ); - UserModel? customer = await FireStoreUtils.getUserProfile(controller.cabOrder.value.authorID ?? ''); - UserModel? driverUser = await FireStoreUtils.getUserProfile(controller.cabOrder.value.driverId ?? ''); + UserModel? customer = + await FireStoreUtils.getUserProfile( + controller + .cabOrder + .value + .authorID ?? + '', + ); + UserModel? driverUser = + await FireStoreUtils.getUserProfile( + controller + .cabOrder + .value + .driverId ?? + '', + ); ShowToastDialog.closeLoader(); Get.to( const ChatScreen(), arguments: { - "customerName": customer?.fullName(), - "restaurantName": driverUser?.fullName(), - "orderId": controller.cabOrder.value.id, - "restaurantId": driverUser?.id, + "customerName": + customer?.fullName(), + "restaurantName": + driverUser?.fullName(), + "orderId": + controller + .cabOrder + .value + .id, + "restaurantId": + driverUser?.id, "customerId": customer?.id, - "customerProfileImage": customer?.profilePictureURL, - "restaurantProfileImage": driverUser?.profilePictureURL, - "token": driverUser?.fcmToken, + "customerProfileImage": + customer + ?.profilePictureURL, + "restaurantProfileImage": + driverUser + ?.profilePictureURL, + "token": + driverUser?.fcmToken, "chatType": "Driver", }, ); @@ -384,11 +775,29 @@ class CabOrderDetails extends StatelessWidget { height: 42, decoration: ShapeDecoration( shape: RoundedRectangleBorder( - side: BorderSide(width: 1, color: isDark ? AppThemeData.grey700 : AppThemeData.grey200), - borderRadius: BorderRadius.circular(120), + side: BorderSide( + width: 1, + color: + isDark + ? AppThemeData + .grey700 + : AppThemeData + .grey200, + ), + borderRadius: + BorderRadius.circular( + 120, + ), + ), + ), + child: Padding( + padding: const EdgeInsets.all( + 8.0, + ), + child: SvgPicture.asset( + "assets/icons/ic_wechat.svg", ), ), - child: Padding(padding: const EdgeInsets.all(8.0), child: SvgPicture.asset("assets/icons/ic_wechat.svg")), ), ), ], @@ -403,16 +812,41 @@ class CabOrderDetails extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), padding: EdgeInsets.all(16), child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - _iconTile("${double.parse(controller.cabOrder.value.distance.toString()).toStringAsFixed(2)} ${'KM'.tr}", "Distance".tr, "assets/icons/ic_distance_parcel.svg", isDark), - _iconTile(controller.cabOrder.value.duration ?? '--', "Duration".tr, "assets/icons/ic_duration.svg", isDark), - _iconTile(Constant.amountShow(amount: controller.cabOrder.value.subTotal), "${controller.cabOrder.value.paymentMethod}".tr, "assets/icons/ic_rate_parcel.svg", isDark), + _iconTile( + "${double.parse(controller.cabOrder.value.distance.toString()).toStringAsFixed(2)} ${ConstTexts.km.tr}", + ConstTexts.distance.tr, + "assets/icons/ic_distance_parcel.svg", + isDark, + ), + _iconTile( + controller.cabOrder.value.duration ?? '--', + ConstTexts.duration.tr, + "assets/icons/ic_duration.svg", + isDark, + ), + _iconTile( + Constant.amountShow( + amount: controller.cabOrder.value.subTotal, + ), + "${controller.cabOrder.value.paymentMethod}".tr, + "assets/icons/ic_rate_parcel.svg", + isDark, + ), ], ), ), @@ -420,43 +854,98 @@ class CabOrderDetails extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("Order Summary".tr, style: AppThemeData.boldTextStyle(fontSize: 14, color: AppThemeData.grey500)), + Text( + ConstTexts.orderSummary.tr, + style: AppThemeData.boldTextStyle( + fontSize: 14, + color: AppThemeData.grey500, + ), + ), const SizedBox(height: 8), // Subtotal - _summaryTile("Subtotal", Constant.amountShow(amount: controller.subTotal.value.toString()), isDark), + _summaryTile( + ConstTexts.subtotal.tr, + Constant.amountShow( + amount: controller.subTotal.value.toString(), + ), + isDark, + ), // Discount - _summaryTile("Discount", Constant.amountShow(amount: controller.discount.value.toString()), isDark), + _summaryTile( + ConstTexts.discount.tr, + Constant.amountShow( + amount: controller.discount.value.toString(), + ), + isDark, + ), // Tax List - ...List.generate(controller.cabOrder.value.taxSetting!.length, (index) { - return _summaryTile( - "${controller.cabOrder.value.taxSetting![index].title} ${controller.cabOrder.value.taxSetting![index].type == 'fix' ? '' : '(${controller.cabOrder.value.taxSetting![index].tax}%)'}", - Constant.amountShow( - amount: - Constant.getTaxValue( - amount: - ((double.tryParse(controller.cabOrder.value.subTotal.toString()) ?? 0.0) - (double.tryParse(controller.cabOrder.value.discount.toString()) ?? 0.0)) - .toString(), - taxModel: controller.cabOrder.value.taxSetting![index], - ).toString(), - ), - isDark, - ); - }), + ...List.generate( + controller.cabOrder.value.taxSetting!.length, + (index) { + return _summaryTile( + "${controller.cabOrder.value.taxSetting![index].title} ${controller.cabOrder.value.taxSetting![index].type == 'fix' ? '' : '(${controller.cabOrder.value.taxSetting![index].tax}%)'}", + Constant.amountShow( + amount: + Constant.getTaxValue( + amount: + ((double.tryParse( + controller + .cabOrder + .value + .subTotal + .toString(), + ) ?? + 0.0) - + (double.tryParse( + controller + .cabOrder + .value + .discount + .toString(), + ) ?? + 0.0)) + .toString(), + taxModel: + controller + .cabOrder + .value + .taxSetting![index], + ).toString(), + ), + isDark, + ); + }, + ), const Divider(), // Total - _summaryTile("Order Total", Constant.amountShow(amount: controller.totalAmount.value.toString()), isDark), + _summaryTile( + ConstTexts.orderTotal.tr, + Constant.amountShow( + amount: + controller.totalAmount.value.toString(), + ), + isDark, + ), ], ), ), @@ -473,11 +962,28 @@ class CabOrderDetails extends StatelessWidget { return Column( children: [ // Icon(icon, color: AppThemeData.primary300), - SvgPicture.asset(icon, height: 28, width: 28, color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800), + SvgPicture.asset( + icon, + height: 28, + width: 28, + color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800, + ), const SizedBox(height: 6), - Text(value, style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800)), + Text( + value, + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800, + ), + ), const SizedBox(height: 6), - Text(title, style: AppThemeData.semiBoldTextStyle(fontSize: 12, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + title, + style: AppThemeData.semiBoldTextStyle( + fontSize: 12, + color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + ), + ), ], ); } @@ -488,8 +994,20 @@ class CabOrderDetails extends StatelessWidget { child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text(title.tr, style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800)), - Text(value, style: AppThemeData.semiBoldTextStyle(fontSize: title == "Order Total" ? 18 : 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + title, + style: AppThemeData.mediumTextStyle( + fontSize: 16, + color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800, + ), + ), + Text( + value, + style: AppThemeData.semiBoldTextStyle( + fontSize: title == ConstTexts.orderTotal.tr ? 18 : 16, + color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + ), + ), ], ), ); diff --git a/lib/screen_ui/cab_service_screens/cab_review_screen.dart b/lib/screen_ui/cab_service_screens/cab_review_screen.dart index 7cdece4..9ce4651 100644 --- a/lib/screen_ui/cab_service_screens/cab_review_screen.dart +++ b/lib/screen_ui/cab_service_screens/cab_review_screen.dart @@ -1,6 +1,9 @@ +import 'package:customer/constant/const_texts.dart'; import 'package:customer/controllers/cab_review_controller.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_rating_bar/flutter_rating_bar.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import '../../constant/constant.dart'; import '../../controllers/theme_controller.dart'; @@ -25,8 +28,22 @@ class CabReviewScreen extends StatelessWidget { centerTitle: true, elevation: 0, backgroundColor: AppThemeData.primary300, - leading: GestureDetector(onTap: () => Get.back(), child: Icon(Icons.arrow_back_ios, color: isDark ? Colors.white : Colors.black)), - title: Text(controller.ratingModel.value != null ? "Update Review".tr : "Add Review".tr, style: TextStyle(color: isDark ? Colors.white : Colors.black, fontSize: 16)), + leading: GestureDetector( + onTap: () => Get.back(), + child: Icon( + Icons.arrow_back_ios, + color: isDark ? Colors.white : Colors.black, + ), + ), + title: Text( + controller.ratingModel.value != null + ? ConstTexts.updateReview.tr + : ConstTexts.addReview.tr, + style: TextStyle( + color: isDark ? Colors.white : Colors.black, + fontSize: 16, + ), + ), ), body: Obx( () => @@ -37,11 +54,21 @@ class CabReviewScreen extends StatelessWidget { child: Stack( children: [ Padding( - padding: const EdgeInsets.only(left: 20, right: 20, top: 50, bottom: 20), + padding: const EdgeInsets.only( + left: 20, + right: 20, + top: 50, + bottom: 20, + ), child: Card( elevation: 2, - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), child: SingleChildScrollView( child: Padding( padding: const EdgeInsets.only(top: 65), @@ -49,80 +76,181 @@ class CabReviewScreen extends StatelessWidget { children: [ // Driver Name Padding( - padding: const EdgeInsets.only(top: 8.0), + padding: const EdgeInsets.only( + top: 8.0, + ), child: Text( - controller.order.value!.driver?.fullName() ?? "", - style: TextStyle(color: isDark ? Colors.white : Colors.black87, fontFamily: AppThemeData.medium, fontSize: 18), + controller.order.value!.driver + ?.fullName() ?? + "", + style: TextStyle( + color: + isDark + ? Colors.white + : Colors.black87, + fontFamily: AppThemeData.medium, + fontSize: 18, + ), ), ), // Car info Row( - mainAxisAlignment: MainAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment.center, children: [ Text( - controller.driverUser.value?.carNumber?.toUpperCase() ?? '', - style: TextStyle(color: isDark ? Colors.white : Colors.black87, fontFamily: AppThemeData.medium), + controller + .driverUser + .value + ?.carNumber + ?.toUpperCase() ?? + '', + style: TextStyle( + color: + isDark + ? Colors.white + : Colors.black87, + fontFamily: AppThemeData.medium, + ), ), const SizedBox(width: 8), Text( "${controller.driverUser.value?.carName} ${controller.driverUser.value?.carMakes}", - style: TextStyle(color: isDark ? Colors.white : Colors.black38, fontFamily: AppThemeData.medium), + style: TextStyle( + color: + isDark + ? Colors.white + : Colors.black38, + fontFamily: AppThemeData.medium, + ), ), ], ), - const Padding(padding: EdgeInsets.symmetric(vertical: 12), child: Divider(color: Colors.grey)), + const Padding( + padding: EdgeInsets.symmetric( + vertical: 12, + ), + child: Divider(color: Colors.grey), + ), // Title Padding( padding: const EdgeInsets.only(top: 16), - child: Text('How is your trip?'.tr, style: TextStyle(fontSize: 18, color: isDark ? Colors.white : Colors.black, fontWeight: FontWeight.bold, letterSpacing: 2)), + child: Text( + ConstTexts.howWasTrip.tr, + style: TextStyle( + fontSize: 18, + color: + isDark + ? Colors.white + : Colors.black, + fontWeight: FontWeight.bold, + letterSpacing: 2, + ), + ), ), Padding( padding: const EdgeInsets.only(top: 8), child: Text( - 'Your feedback will help us improve \n driving experience better'.tr, + ConstTexts.yourFeedbackWillHelp.tr, textAlign: TextAlign.center, - style: TextStyle(color: isDark ? Colors.white : Colors.black.withOpacity(0.60), letterSpacing: 0.8), + style: TextStyle( + color: + isDark + ? Colors.white + : Colors.black.withOpacity( + 0.60, + ), + letterSpacing: 0.8, + ), ), ), // Rating Padding( padding: const EdgeInsets.only(top: 20), - child: Text('Rate for'.tr, style: TextStyle(fontSize: 16, color: isDark ? Colors.white : Colors.black.withOpacity(0.60), letterSpacing: 0.8)), + child: Text( + ConstTexts.rateFor.tr, + style: TextStyle( + fontSize: 16, + color: + isDark + ? Colors.white + : Colors.black.withValues( + alpha: 0.60, + ), + letterSpacing: 0.8, + ), + ), ), Padding( padding: const EdgeInsets.only(top: 8), child: Text( - controller.order.value!.driver?.fullName() ?? "", - style: TextStyle(fontSize: 18, color: isDark ? Colors.white : Colors.black, fontWeight: FontWeight.bold, letterSpacing: 2), + controller.order.value!.driver + ?.fullName() ?? + "", + style: TextStyle( + fontSize: 18, + color: + isDark + ? Colors.white + : Colors.black, + fontWeight: FontWeight.bold, + letterSpacing: 2, + ), ), ), Padding( padding: const EdgeInsets.only(top: 10), child: RatingBar.builder( - initialRating: controller.ratings.value, + initialRating: + controller.ratings.value, minRating: 1, direction: Axis.horizontal, allowHalfRating: true, itemCount: 5, - itemBuilder: (context, _) => const Icon(Icons.star, color: Colors.amber), - unratedColor: isDark ? AppThemeData.greyDark400 : AppThemeData.grey400, - onRatingUpdate: (rating) => controller.ratings.value = rating, + itemBuilder: + (context, _) => const Icon( + Icons.star, + color: Colors.amber, + ), + unratedColor: + isDark + ? AppThemeData.greyDark400 + : AppThemeData.grey400, + onRatingUpdate: + (rating) => + controller.ratings.value = + rating, ), ), // Comment - Padding(padding: const EdgeInsets.all(20.0), child: TextFieldWidget(hintText: "Type comment....".tr, controller: controller.comment.value, maxLine: 5)), + Padding( + padding: const EdgeInsets.all(20.0), + child: TextFieldWidget( + hintText: ConstTexts.typeComment.tr, + controller: controller.comment.value, + maxLine: 5, + ), + ), // Submit Button Padding( padding: const EdgeInsets.all(20.0), child: RoundedButtonFill( - title: controller.ratingModel.value != null ? "Update Review".tr : "Add Review".tr, + borderRadius: 10.r, + title: + controller.ratingModel.value != + null + ? ConstTexts.updateReview.tr + : ConstTexts.addReview.tr, color: AppThemeData.primary300, - textColor: isDark ? Colors.white : Colors.black, + textColor: + isDark + ? Colors.white + : Colors.black, onPress: controller.submitReview, ), ), @@ -138,11 +266,28 @@ class CabReviewScreen extends StatelessWidget { decoration: BoxDecoration( borderRadius: BorderRadius.circular(60), color: Colors.white, - boxShadow: [BoxShadow(color: Colors.grey.withOpacity(0.15), blurRadius: 8, spreadRadius: 6)], + boxShadow: [ + BoxShadow( + color: Colors.grey.withValues(alpha: 0.15), + blurRadius: 8, + spreadRadius: 6, + ), + ], ), child: ClipRRect( borderRadius: BorderRadius.circular(60), - child: NetworkImageWidget(imageUrl: controller.order.value?.driver?.profilePictureURL ?? '', fit: BoxFit.cover, height: 110, width: 110), + child: NetworkImageWidget( + imageUrl: + controller + .order + .value + ?.driver + ?.profilePictureURL ?? + '', + fit: BoxFit.cover, + height: 110, + width: 110, + ), ), ), ), diff --git a/lib/screen_ui/cab_service_screens/complain_screen.dart b/lib/screen_ui/cab_service_screens/complain_screen.dart index 5d12323..898bf8f 100644 --- a/lib/screen_ui/cab_service_screens/complain_screen.dart +++ b/lib/screen_ui/cab_service_screens/complain_screen.dart @@ -1,4 +1,7 @@ +import 'package:customer/constant/const_texts.dart'; + import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import '../../controllers/complain_controller.dart'; import '../../controllers/theme_controller.dart'; @@ -32,12 +35,27 @@ class ComplainScreen extends StatelessWidget { child: Container( height: 42, width: 42, - decoration: BoxDecoration(shape: BoxShape.circle, color: AppThemeData.grey50), - child: const Center(child: Icon(Icons.arrow_back_ios, color: AppThemeData.grey900, size: 20)), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: AppThemeData.grey50, + ), + child: const Center( + child: Icon( + Icons.arrow_back_ios, + color: AppThemeData.grey900, + size: 20, + ), + ), ), ), const SizedBox(width: 10), - Text("Complain".tr, style: AppThemeData.boldTextStyle(fontSize: 18, color: AppThemeData.grey900)), + Text( + ConstTexts.complain.tr, + style: AppThemeData.boldTextStyle( + fontSize: 18, + color: AppThemeData.grey900, + ), + ), ], ), ), @@ -49,11 +67,30 @@ class ComplainScreen extends StatelessWidget { padding: const EdgeInsets.all(16), child: Column( children: [ - Obx(() => TextFieldWidget(title: "Title".tr, hintText: "Title".tr, controller: controller.title.value)), + Obx( + () => TextFieldWidget( + title: ConstTexts.title.tr, + hintText: ConstTexts.title.tr, + controller: controller.title.value, + ), + ), const SizedBox(height: 10), - Obx(() => TextFieldWidget(title: "Complain".tr, hintText: 'Type Description....'.tr, controller: controller.comment.value, maxLine: 8)), + Obx( + () => TextFieldWidget( + title: ConstTexts.complain.tr, + hintText: ConstTexts.typeDescription.tr, + controller: controller.comment.value, + maxLine: 8, + ), + ), const SizedBox(height: 20), - RoundedButtonFill(title: "Save".tr, color: AppThemeData.primary300, textColor: AppThemeData.grey50, onPress: () => controller.submitComplain()), + RoundedButtonFill( + borderRadius: 10.r, + title: ConstTexts.save.tr, + color: AppThemeData.primary300, + textColor: AppThemeData.grey50, + onPress: () => controller.submitComplain(), + ), ], ), ), diff --git a/lib/screen_ui/cab_service_screens/my_cab_booking_screen.dart b/lib/screen_ui/cab_service_screens/my_cab_booking_screen.dart index 2df32bc..5f427aa 100644 --- a/lib/screen_ui/cab_service_screens/my_cab_booking_screen.dart +++ b/lib/screen_ui/cab_service_screens/my_cab_booking_screen.dart @@ -1,3 +1,4 @@ +import 'package:customer/constant/const_texts.dart'; import 'package:customer/models/cab_order_model.dart'; import 'package:customer/payment/createRazorPayOrderModel.dart'; import 'package:customer/payment/rozorpayConroller.dart'; @@ -5,7 +6,10 @@ import 'package:customer/screen_ui/auth_screens/login_screen.dart'; import 'package:customer/screen_ui/multi_vendor_service/wallet_screen/wallet_screen.dart'; import 'package:customer/themes/round_button_fill.dart'; import 'package:customer/themes/show_toast_dialog.dart'; +import 'package:customer/utils/app_router.dart'; + import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import '../../constant/constant.dart'; import '../../controllers/my_cab_booking_controller.dart'; @@ -30,14 +34,27 @@ class MyCabBookingScreen extends StatelessWidget { // length: controller.tabTitles.length, // initialIndex: controller.tabTitles.indexOf(controller.selectedTab.value), length: controller.tabKeys.length, - initialIndex: controller.tabKeys.indexOf(controller.selectedTab.value), + initialIndex: controller.tabKeys.indexOf( + controller.selectedTab.value, + ), child: Scaffold( appBar: AppBar( automaticallyImplyLeading: false, backgroundColor: AppThemeData.primary300, title: Padding( padding: const EdgeInsets.only(bottom: 10), - child: Row(children: [const SizedBox(width: 10), Text("Ride History".tr, style: AppThemeData.boldTextStyle(fontSize: 18, color: AppThemeData.grey900))]), + child: Row( + children: [ + const SizedBox(width: 10), + Text( + ConstTexts.rideHistory.tr, + style: AppThemeData.boldTextStyle( + fontSize: 18, + color: AppThemeData.grey900, + ), + ), + ], + ), ), bottom: PreferredSize( preferredSize: const Size.fromHeight(48), @@ -50,7 +67,9 @@ class MyCabBookingScreen extends StatelessWidget { labelColor: AppThemeData.taxiBooking500, unselectedLabelColor: AppThemeData.taxiBooking500, labelStyle: AppThemeData.boldTextStyle(fontSize: 14), - unselectedLabelStyle: AppThemeData.mediumTextStyle(fontSize: 14), + unselectedLabelStyle: AppThemeData.mediumTextStyle( + fontSize: 14, + ), tabs: controller.tabKeys .map( @@ -60,7 +79,9 @@ class MyCabBookingScreen extends StatelessWidget { child: Text( controller.getLocalizedTabTitle(key), textAlign: TextAlign.center, - overflow: TextOverflow.visible, // 👈 show full text + overflow: + TextOverflow + .visible, // 👈 show full text ), ), ), @@ -80,16 +101,34 @@ class MyCabBookingScreen extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Text("Please Log In to Continue".tr, style: TextStyle(color: isDark ? AppThemeData.grey100 : AppThemeData.grey800, fontSize: 22, fontFamily: AppThemeData.semiBold)), + Text( + ConstTexts.plsLoginToAcc.tr, + style: TextStyle( + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey800, + fontSize: 22, + fontFamily: AppThemeData.semiBold, + ), + ), const SizedBox(height: 5), Text( - "You’re not logged in. Please sign in to access your account and explore all features.".tr, + ConstTexts.youAreNotLoggedIn.tr, textAlign: TextAlign.center, - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey500, fontSize: 16, fontFamily: AppThemeData.bold), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey500, + fontSize: 16, + fontFamily: AppThemeData.bold, + ), ), const SizedBox(height: 20), RoundedButtonFill( - title: "Log in".tr, + borderRadius: 10.r, + title: ConstTexts.login.tr, width: 55, height: 5.5, color: AppThemeData.primary300, @@ -107,7 +146,17 @@ class MyCabBookingScreen extends StatelessWidget { final orders = controller.getOrdersForTab(title); if (orders.isEmpty) { - return Center(child: Text("No order found".tr, style: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900))); + return Center( + child: Text( + ConstTexts.noOrderfound.tr, + style: AppThemeData.mediumTextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + ); } return ListView.builder( @@ -117,74 +166,150 @@ class MyCabBookingScreen extends StatelessWidget { CabOrderModel order = orders[index]; return GestureDetector( onTap: () { - Get.to(() => CabOrderDetails(), arguments: {"cabOrderModel": order}); + Get.to( + () => CabOrderDetails(), + arguments: {"cabOrderModel": order}, + ); }, child: Container( margin: const EdgeInsets.only(bottom: 16), padding: const EdgeInsets.all(16), decoration: BoxDecoration( - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, borderRadius: BorderRadius.circular(15), - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( - "${'Booking Date:'.tr} ${controller.formatDate(order.scheduleDateTime!)}".tr, + "${'Booking Date:'.tr} ${controller.formatDate(order.scheduleDateTime!)}", textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 18, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + fontSize: 18, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Column( children: [ - Icon(Icons.stop_circle_outlined, color: Colors.green), - DottedBorder( - options: CustomPathDottedBorderOptions( - color: Colors.grey.shade400, - strokeWidth: 2, - dashPattern: [4, 4], - customPath: - (size) => - Path() - ..moveTo(size.width / 2, 0) - ..lineTo(size.width / 2, size.height), - ), - child: const SizedBox(width: 20, height: 55), + Icon( + Icons.stop_circle_outlined, + color: Colors.green, + ), + DottedBorder( + options: + CustomPathDottedBorderOptions( + color: + Colors + .grey + .shade400, + strokeWidth: 2, + dashPattern: [4, 4], + customPath: + (size) => + Path() + ..moveTo( + size.width / + 2, + 0, + ) + ..lineTo( + size.width / + 2, + size.height, + ), + ), + child: const SizedBox( + width: 20, + height: 55, + ), + ), + Icon( + Icons.radio_button_checked, + color: Colors.red, ), - Icon(Icons.radio_button_checked, color: Colors.red), ], ), const SizedBox(width: 12), Expanded( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Row( children: [ // Source Location Name Expanded( child: Text( - order.sourceLocationName.toString(), - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + order + .sourceLocationName + .toString(), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), maxLines: 2, - overflow: TextOverflow.ellipsis, + overflow: + TextOverflow + .ellipsis, ), ), const SizedBox(width: 8), Container( decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - border: Border.all(color: AppThemeData.warning300, width: 1), - color: AppThemeData.warning50, + borderRadius: + BorderRadius.circular( + 10, + ), + border: Border.all( + color: + AppThemeData + .warning300, + width: 1, + ), + color: + AppThemeData + .warning50, ), - padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 12), + padding: + const EdgeInsets.symmetric( + vertical: 8, + horizontal: 12, + ), child: Text( - order.status.toString(), - style: AppThemeData.boldTextStyle(fontSize: 14, color: AppThemeData.warning500), - overflow: TextOverflow.ellipsis, + order.status + .toString(), + style: AppThemeData.boldTextStyle( + fontSize: 14, + color: + AppThemeData + .warning500, + ), + overflow: + TextOverflow + .ellipsis, ), ), ], @@ -192,45 +317,114 @@ class MyCabBookingScreen extends StatelessWidget { SizedBox(height: 15), DottedBorder( options: CustomPathDottedBorderOptions( - color: Colors.grey.shade400, + color: + Colors.grey.shade400, strokeWidth: 2, dashPattern: [4, 4], customPath: (size) => Path() - ..moveTo(0, size.height / 2) // start from left center - ..lineTo(size.width, size.height / 2), // draw to right center + ..moveTo( + 0, + size.height / + 2, + ) // start from left center + ..lineTo( + size.width, + size.height / + 2, + ), // draw to right center + ), + child: const SizedBox( + width: 295, + height: 3, ), - child: const SizedBox(width: 295, height: 3), ), SizedBox(height: 15), Text( - order.destinationLocationName.toString(), - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + order + .destinationLocationName + .toString(), + style: + AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), ), ], ), ), ], ), - if (Constant.isEnableOTPTripStart == true) + if (Constant.isEnableOTPTripStart == + true) Row( //mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, children: [ - Text("Otp :".tr, style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800)), + Text( + "Otp :", + style: + AppThemeData.mediumTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData + .greyDark800 + : AppThemeData + .grey800, + ), + ), SizedBox(width: 5), - Text(order.otpCode ?? '', style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + order.otpCode ?? '', + style: + AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), + ), ], ), - if (order.status == Constant.orderInTransit && order.paymentStatus == false) SizedBox(height: 14), - order.status == Constant.orderInTransit && order.paymentStatus == false + if (order.status == + Constant.orderInTransit && + order.paymentStatus == false) + SizedBox(height: 14), + order.status == + Constant.orderInTransit && + order.paymentStatus == false ? RoundedButtonFill( - title: "Pay Now".tr, + borderRadius: 10.r, + title: ConstTexts.payNow.tr, onPress: () async { - controller.selectedPaymentMethod.value = order.paymentMethod.toString(); - controller.calculateTotalAmount(order); - Get.bottomSheet(paymentBottomSheet(context, controller, isDark), isScrollControlled: true, backgroundColor: Colors.transparent); + controller + .selectedPaymentMethod + .value = order.paymentMethod + .toString(); + controller.calculateTotalAmount( + order, + ); + Get.bottomSheet( + paymentBottomSheet( + context, + controller, + isDark, + ), + isScrollControlled: true, + backgroundColor: + Colors.transparent, + ); }, color: AppThemeData.primary300, textColor: AppThemeData.grey900, @@ -250,7 +444,11 @@ class MyCabBookingScreen extends StatelessWidget { ); } - Widget paymentBottomSheet(BuildContext context, MyCabBookingController controller, bool isDark) { + Widget paymentBottomSheet( + BuildContext context, + MyCabBookingController controller, + bool isDark, + ) { return DraggableScrollableSheet( initialChildSize: 0.70, // Start height @@ -263,14 +461,26 @@ class MyCabBookingScreen extends StatelessWidget { builder: (context, scrollController) { return Container( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20), - decoration: BoxDecoration(color: isDark ? AppThemeData.grey500 : Colors.white, borderRadius: BorderRadius.vertical(top: Radius.circular(24))), + decoration: BoxDecoration( + color: isDark ? AppThemeData.grey500 : Colors.white, + borderRadius: BorderRadius.vertical(top: Radius.circular(24)), + ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text("Select Payment Method".tr, style: AppThemeData.mediumTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + ConstTexts.selectPaymentMethod.tr, + style: AppThemeData.mediumTextStyle( + fontSize: 18, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), GestureDetector( onTap: () { Get.back(); @@ -285,40 +495,88 @@ class MyCabBookingScreen extends StatelessWidget { padding: EdgeInsets.zero, controller: scrollController, children: [ - Text("Preferred Payment".tr, textAlign: TextAlign.start, style: AppThemeData.boldTextStyle(fontSize: 15, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500)), + Text( + ConstTexts.prefferedPayment.tr, + textAlign: TextAlign.start, + style: AppThemeData.boldTextStyle( + fontSize: 15, + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), + ), const SizedBox(height: 10), - if (controller.walletSettingModel.value.isEnabled == true || controller.cashOnDeliverySettingModel.value.isEnabled == true) + if (controller.walletSettingModel.value.isEnabled == true || + controller.cashOnDeliverySettingModel.value.isEnabled == + true) Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ Visibility( - visible: controller.walletSettingModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.wallet, isDark, "assets/images/ic_wallet.png"), + visible: + controller + .walletSettingModel + .value + .isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.wallet, + isDark, + "assets/images/ic_wallet.png", + ), ), Visibility( - visible: controller.cashOnDeliverySettingModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.cod, isDark, "assets/images/ic_cash.png"), + visible: + controller + .cashOnDeliverySettingModel + .value + .isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.cod, + isDark, + "assets/images/ic_cash.png", + ), ), ], ), ), ), - if (controller.walletSettingModel.value.isEnabled == true || controller.cashOnDeliverySettingModel.value.isEnabled == true) + if (controller.walletSettingModel.value.isEnabled == true || + controller.cashOnDeliverySettingModel.value.isEnabled == + true) Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const SizedBox(height: 10), Text( - "Other Payment Options".tr, + ConstTexts.otherPaymentOptions.tr, textAlign: TextAlign.start, - style: AppThemeData.boldTextStyle(fontSize: 15, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500), + style: AppThemeData.boldTextStyle( + fontSize: 15, + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), ), const SizedBox(height: 10), ], @@ -326,32 +584,129 @@ class MyCabBookingScreen extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ - Visibility(visible: controller.stripeModel.value.isEnabled == true, child: cardDecoration(controller, PaymentGateway.stripe, isDark, "assets/images/stripe.png")), - Visibility(visible: controller.payPalModel.value.isEnabled == true, child: cardDecoration(controller, PaymentGateway.paypal, isDark, "assets/images/paypal.png")), - Visibility(visible: controller.payStackModel.value.isEnable == true, child: cardDecoration(controller, PaymentGateway.payStack, isDark, "assets/images/paystack.png")), Visibility( - visible: controller.mercadoPagoModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.mercadoPago, isDark, "assets/images/mercado-pago.png"), + visible: + controller.stripeModel.value.isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.stripe, + isDark, + "assets/images/stripe.png", + ), ), Visibility( - visible: controller.flutterWaveModel.value.isEnable == true, - child: cardDecoration(controller, PaymentGateway.flutterWave, isDark, "assets/images/flutterwave_logo.png"), + visible: + controller.payPalModel.value.isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.paypal, + isDark, + "assets/images/paypal.png", + ), ), - Visibility(visible: controller.payFastModel.value.isEnable == true, child: cardDecoration(controller, PaymentGateway.payFast, isDark, "assets/images/payfast.png")), - Visibility(visible: controller.razorPayModel.value.isEnabled == true, child: cardDecoration(controller, PaymentGateway.razorpay, isDark, "assets/images/razorpay.png")), - Visibility(visible: controller.midTransModel.value.enable == true, child: cardDecoration(controller, PaymentGateway.midTrans, isDark, "assets/images/midtrans.png")), Visibility( - visible: controller.orangeMoneyModel.value.enable == true, - child: cardDecoration(controller, PaymentGateway.orangeMoney, isDark, "assets/images/orange_money.png"), + visible: + controller.payStackModel.value.isEnable == + true, + child: cardDecoration( + controller, + PaymentGateway.payStack, + isDark, + "assets/images/paystack.png", + ), + ), + Visibility( + visible: + controller.mercadoPagoModel.value.isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.mercadoPago, + isDark, + "assets/images/mercado-pago.png", + ), + ), + Visibility( + visible: + controller.flutterWaveModel.value.isEnable == + true, + child: cardDecoration( + controller, + PaymentGateway.flutterWave, + isDark, + "assets/images/flutterwave_logo.png", + ), + ), + Visibility( + visible: + controller.payFastModel.value.isEnable == + true, + child: cardDecoration( + controller, + PaymentGateway.payFast, + isDark, + "assets/images/payfast.png", + ), + ), + Visibility( + visible: + controller.razorPayModel.value.isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.razorpay, + isDark, + "assets/images/razorpay.png", + ), + ), + Visibility( + visible: + controller.midTransModel.value.enable == true, + child: cardDecoration( + controller, + PaymentGateway.midTrans, + isDark, + "assets/images/midtrans.png", + ), + ), + Visibility( + visible: + controller.orangeMoneyModel.value.enable == + true, + child: cardDecoration( + controller, + PaymentGateway.orangeMoney, + isDark, + "assets/images/orange_money.png", + ), + ), + Visibility( + visible: + controller.xenditModel.value.enable == true, + child: cardDecoration( + controller, + PaymentGateway.xendit, + isDark, + "assets/images/xendit.png", + ), ), - Visibility(visible: controller.xenditModel.value.enable == true, child: cardDecoration(controller, PaymentGateway.xendit, isDark, "assets/images/xendit.png")), ], ), ), @@ -361,51 +716,109 @@ class MyCabBookingScreen extends StatelessWidget { ), ), RoundedButtonFill( - title: "Continue".tr, + borderRadius: 10.r, + title: ConstTexts.continueT.tr, color: AppThemeData.primary300, textColor: AppThemeData.grey900, onPress: () async { if (controller.selectedPaymentMethod.value.isEmpty) { - ShowToastDialog.showToast("Please select a payment method".tr); + ShowToastDialog.showToast( + ConstTexts.plsSelectPaymentMethod.tr, + ); } else { - if (controller.selectedPaymentMethod.value == PaymentGateway.stripe.name) { - controller.stripeMakePayment(amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.paypal.name) { - controller.paypalPaymentSheet(controller.totalAmount.value.toString(), context); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.payStack.name) { - controller.payStackPayment(controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.mercadoPago.name) { - controller.mercadoPagoMakePayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.flutterWave.name) { - controller.flutterWaveInitiatePayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.payFast.name) { - controller.payFastPayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.cod.name) { + if (controller.selectedPaymentMethod.value == + PaymentGateway.stripe.name) { + controller.stripeMakePayment( + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.paypal.name) { + controller.paypalPaymentSheet( + controller.totalAmount.value.toString(), + context, + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.payStack.name) { + controller.payStackPayment( + controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.mercadoPago.name) { + controller.mercadoPagoMakePayment( + context: context, + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.flutterWave.name) { + controller.flutterWaveInitiatePayment( + context: context, + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.payFast.name) { + controller.payFastPayment( + context: context, + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.cod.name) { controller.completeOrder(); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.wallet.name) { - if (Constant.userModel!.walletAmount == null || Constant.userModel!.walletAmount! < controller.totalAmount.value) { - ShowToastDialog.showToast("You do not have sufficient wallet balance".tr); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.wallet.name) { + if (Constant.userModel!.walletAmount == null || + Constant.userModel!.walletAmount! < + controller.totalAmount.value) { + ShowToastDialog.showToast( + ConstTexts.youDoNothaveSufficientwalletBalance.tr, + ); } else { controller.completeOrder(); } - } else if (controller.selectedPaymentMethod.value == PaymentGateway.midTrans.name) { - controller.midtransMakePayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.orangeMoney.name) { - controller.orangeMakePayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.xendit.name) { - controller.xenditPayment(context, controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.razorpay.name) { - RazorPayController().createOrderRazorPay(amount: double.parse(controller.totalAmount.value.toString()), razorpayModel: controller.razorPayModel.value).then((value) { - if (value == null) { - Get.back(); - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); - } else { - CreateRazorPayOrderModel result = value; - controller.openCheckout(amount: controller.totalAmount.value.toString(), orderId: result.id); - } - }); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.midTrans.name) { + controller.midtransMakePayment( + context: context, + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.orangeMoney.name) { + controller.orangeMakePayment( + context: context, + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.xendit.name) { + controller.xenditPayment( + context, + controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.razorpay.name) { + RazorPayController() + .createOrderRazorPay( + amount: double.parse( + controller.totalAmount.value.toString(), + ), + razorpayModel: controller.razorPayModel.value, + ) + .then((value) { + if (value == null) { + Get.back(); + ShowToastDialog.showToast( + ConstTexts.somethingWentWrong.tr, + ); + } else { + CreateRazorPayOrderModel result = value; + controller.openCheckout( + amount: controller.totalAmount.value.toString(), + orderId: result.id, + ); + } + }); } else { - ShowToastDialog.showToast("Please select payment method".tr); + ShowToastDialog.showToast( + ConstTexts.plsSelectPaymentMethod.tr, + ); } } }, @@ -417,7 +830,12 @@ class MyCabBookingScreen extends StatelessWidget { ); } - Obx cardDecoration(MyCabBookingController controller, PaymentGateway value, isDark, String image) { + Obx cardDecoration( + MyCabBookingController controller, + PaymentGateway value, + isDark, + String image, + ) { return Obx( () => Padding( padding: const EdgeInsets.symmetric(vertical: 5), @@ -432,8 +850,21 @@ class MyCabBookingScreen extends StatelessWidget { Container( width: 50, height: 50, - decoration: ShapeDecoration(shape: RoundedRectangleBorder(side: const BorderSide(width: 1, color: Color(0xFFE5E7EB)), borderRadius: BorderRadius.circular(8))), - child: Padding(padding: EdgeInsets.all(value.name == "payFast" ? 0 : 8.0), child: Image.asset(image)), + decoration: ShapeDecoration( + shape: RoundedRectangleBorder( + side: const BorderSide( + width: 1, + color: Color(0xFFE5E7EB), + ), + borderRadius: BorderRadius.circular(8), + ), + ), + child: Padding( + padding: EdgeInsets.all( + value.name == "payFast" ? 0 : 8.0, + ), + child: Image.asset(image), + ), ), const SizedBox(width: 10), value.name == "wallet" @@ -444,12 +875,30 @@ class MyCabBookingScreen extends StatelessWidget { Text( value.name.capitalizeString(), textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), Text( - Constant.amountShow(amount: Constant.userModel!.walletAmount == null ? '0.0' : Constant.userModel!.walletAmount.toString()), + Constant.amountShow( + amount: + Constant.userModel!.walletAmount == null + ? '0.0' + : Constant.userModel!.walletAmount + .toString(), + ), textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(fontSize: 14, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300), + style: AppThemeData.semiBoldTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + ), ), ], ), @@ -458,14 +907,23 @@ class MyCabBookingScreen extends StatelessWidget { child: Text( value.name.capitalizeString(), textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), ), const Expanded(child: SizedBox()), Radio( value: value.name, groupValue: controller.selectedPaymentMethod.value, - activeColor: isDark ? AppThemeData.primary300 : AppThemeData.primary300, + activeColor: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, onChanged: (value) { controller.selectedPaymentMethod.value = value.toString(); }, diff --git a/lib/screen_ui/ecommarce/all_brand_product_screen.dart b/lib/screen_ui/ecommarce/all_brand_product_screen.dart index c50aa39..3cadbc7 100644 --- a/lib/screen_ui/ecommarce/all_brand_product_screen.dart +++ b/lib/screen_ui/ecommarce/all_brand_product_screen.dart @@ -22,23 +22,41 @@ class AllBrandProductScreen extends StatelessWidget { init: AllBrandProductController(), builder: (controller) { return Scaffold( - appBar: AppBar(backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, centerTitle: false, titleSpacing: 0), + appBar: AppBar( + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + centerTitle: false, + titleSpacing: 0, + ), body: controller.isLoading.value ? Constant.loader() : Padding( - padding: const EdgeInsets.symmetric(horizontal: 16,vertical: 20), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 20, + ), child: GridView.builder( shrinkWrap: true, - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: 3.5 / 6, crossAxisSpacing: 10), + gridDelegate: + const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 3, + childAspectRatio: 3.5 / 6, + crossAxisSpacing: 10, + ), padding: EdgeInsets.zero, - itemCount: controller.productList.length, + itemCount: controller.productList.length, itemBuilder: (context, index) { - ProductModel productModel = controller.productList[index]; + ProductModel productModel = + controller.productList[index]; return FutureBuilder( - future: FireStoreUtils.getVendorById(productModel.vendorID.toString()), + future: FireStoreUtils.getVendorById( + productModel.vendorID.toString(), + ), builder: (context, vendorSnapshot) { - if (!vendorSnapshot.hasData || vendorSnapshot.connectionState == ConnectionState.waiting) { + if (!vendorSnapshot.hasData || + vendorSnapshot.connectionState == + ConnectionState.waiting) { return const SizedBox(); // Show placeholder or loader } VendorModel? vendorModel = vendorSnapshot.data; @@ -48,34 +66,78 @@ class AllBrandProductScreen extends StatelessWidget { List selectedIndexVariants = []; List selectedIndexArray = []; if (productModel.itemAttribute != null) { - if (productModel.itemAttribute!.attributes!.isNotEmpty) { - for (var element in productModel.itemAttribute!.attributes!) { + if (productModel + .itemAttribute! + .attributes! + .isNotEmpty) { + for (var element + in productModel + .itemAttribute! + .attributes!) { if (element.attributeOptions!.isNotEmpty) { selectedVariants.add( - productModel.itemAttribute!.attributes![productModel.itemAttribute!.attributes!.indexOf(element)].attributeOptions![0].toString(), + productModel + .itemAttribute! + .attributes![productModel + .itemAttribute! + .attributes! + .indexOf(element)] + .attributeOptions![0] + .toString(), ); selectedIndexVariants.add( '${productModel.itemAttribute!.attributes!.indexOf(element)} _${productModel.itemAttribute!.attributes![0].attributeOptions![0].toString()}', ); - selectedIndexArray.add('${productModel.itemAttribute!.attributes!.indexOf(element)}_0'); + selectedIndexArray.add( + '${productModel.itemAttribute!.attributes!.indexOf(element)}_0', + ); } } } - if (productModel.itemAttribute!.variants!.where((element) => element.variantSku == selectedVariants.join('-')).isNotEmpty) { + if (productModel.itemAttribute!.variants! + .where( + (element) => + element.variantSku == + selectedVariants.join('-'), + ) + .isNotEmpty) { price = Constant.productCommissionPrice( vendorModel!, - productModel.itemAttribute!.variants!.where((element) => element.variantSku == selectedVariants.join('-')).first.variantPrice ?? '0', + productModel.itemAttribute!.variants! + .where( + (element) => + element.variantSku == + selectedVariants.join('-'), + ) + .first + .variantPrice ?? + '0', ); disPrice = "0"; } } else { - price = Constant.productCommissionPrice(vendorModel!, productModel.price.toString()); - disPrice = double.parse(productModel.disPrice.toString()) <= 0 ? "0" : Constant.productCommissionPrice(vendorModel, productModel.disPrice.toString()); + price = Constant.productCommissionPrice( + vendorModel!, + productModel.price.toString(), + ); + disPrice = + double.parse( + productModel.disPrice.toString(), + ) <= + 0 + ? "0" + : Constant.productCommissionPrice( + vendorModel, + productModel.disPrice.toString(), + ); } return GestureDetector( onTap: () async { - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": vendorModel}); + Get.to( + const RestaurantDetailsScreen(), + arguments: {"vendorModel": vendorModel}, + ); }, child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -85,47 +147,108 @@ class AllBrandProductScreen extends StatelessWidget { child: SizedBox( height: 90, width: Responsive.width(100, context), - child: NetworkImageWidget(imageUrl: productModel.photo.toString(), fit: BoxFit.cover), + child: NetworkImageWidget( + imageUrl: productModel.photo.toString(), + fit: BoxFit.cover, + ), ), ), Column( mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( productModel.name!.capitalizeString(), textAlign: TextAlign.start, maxLines: 1, - style: AppThemeData.semiBoldTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark600 : AppThemeData.grey600), + style: AppThemeData.semiBoldTextStyle( + fontSize: 18, + color: + isDark + ? AppThemeData.greyDark600 + : AppThemeData.grey600, + ), ), disPrice == "" || disPrice == "0" - ? Text(Constant.amountShow(amount: price), style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: AppThemeData.primary300)) + ? Text( + Constant.amountShow(amount: price), + style: + AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + AppThemeData.primary300, + ), + ) : Row( children: [ Text( - Constant.amountShow(amount: price), - style: AppThemeData.semiBoldTextStyle(fontSize: 14, color: Colors.grey, decoration: TextDecoration.lineThrough), + Constant.amountShow( + amount: price, + ), + style: + AppThemeData.semiBoldTextStyle( + fontSize: 14, + color: Colors.grey, + decoration: + TextDecoration + .lineThrough, + ), ), const SizedBox(width: 5), Text( - Constant.amountShow(amount: disPrice), - style: AppThemeData.semiBoldTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + Constant.amountShow( + amount: disPrice, + ), + style: + AppThemeData.semiBoldTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), ), ], ), Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.warning50 : AppThemeData.warning50, borderRadius: BorderRadius.circular(30)), + decoration: BoxDecoration( + color: + isDark + ? AppThemeData.warning50 + : AppThemeData.warning50, + borderRadius: BorderRadius.circular( + 30, + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 6, + ), child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ - Icon(Icons.star, size: 18, color: AppThemeData.warning400), + Icon( + Icons.star, + size: 18, + color: AppThemeData.warning400, + ), Text( "${Constant.calculateReview(reviewCount: productModel.reviewsCount.toString(), reviewSum: productModel.reviewsSum.toString())} (${productModel.reviewsSum})", - style: AppThemeData.semiBoldTextStyle(fontSize: 12, color: AppThemeData.warning400), + style: + AppThemeData.semiBoldTextStyle( + fontSize: 12, + color: + AppThemeData + .warning400, + ), ), ], ), diff --git a/lib/screen_ui/ecommarce/all_category_product_screen.dart b/lib/screen_ui/ecommarce/all_category_product_screen.dart index 16d9658..26e4825 100644 --- a/lib/screen_ui/ecommarce/all_category_product_screen.dart +++ b/lib/screen_ui/ecommarce/all_category_product_screen.dart @@ -22,23 +22,41 @@ class AllCategoryProductScreen extends StatelessWidget { init: AllCategoryProductController(), builder: (controller) { return Scaffold( - appBar: AppBar(backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, centerTitle: false, titleSpacing: 0), + appBar: AppBar( + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + centerTitle: false, + titleSpacing: 0, + ), body: controller.isLoading.value ? Constant.loader() : Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 20, + ), child: GridView.builder( shrinkWrap: true, - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: 3.5 / 6, crossAxisSpacing: 10), + gridDelegate: + const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 3, + childAspectRatio: 3.5 / 6, + crossAxisSpacing: 10, + ), padding: EdgeInsets.zero, itemCount: controller.productList.length, itemBuilder: (context, index) { - ProductModel productModel = controller.productList[index]; + ProductModel productModel = + controller.productList[index]; return FutureBuilder( - future: FireStoreUtils.getVendorById(productModel.vendorID.toString()), + future: FireStoreUtils.getVendorById( + productModel.vendorID.toString(), + ), builder: (context, vendorSnapshot) { - if (!vendorSnapshot.hasData || vendorSnapshot.connectionState == ConnectionState.waiting) { + if (!vendorSnapshot.hasData || + vendorSnapshot.connectionState == + ConnectionState.waiting) { return const SizedBox(); // Show placeholder or loader } VendorModel? vendorModel = vendorSnapshot.data; @@ -48,34 +66,78 @@ class AllCategoryProductScreen extends StatelessWidget { List selectedIndexVariants = []; List selectedIndexArray = []; if (productModel.itemAttribute != null) { - if (productModel.itemAttribute!.attributes!.isNotEmpty) { - for (var element in productModel.itemAttribute!.attributes!) { + if (productModel + .itemAttribute! + .attributes! + .isNotEmpty) { + for (var element + in productModel + .itemAttribute! + .attributes!) { if (element.attributeOptions!.isNotEmpty) { selectedVariants.add( - productModel.itemAttribute!.attributes![productModel.itemAttribute!.attributes!.indexOf(element)].attributeOptions![0].toString(), + productModel + .itemAttribute! + .attributes![productModel + .itemAttribute! + .attributes! + .indexOf(element)] + .attributeOptions![0] + .toString(), ); selectedIndexVariants.add( '${productModel.itemAttribute!.attributes!.indexOf(element)} _${productModel.itemAttribute!.attributes![0].attributeOptions![0].toString()}', ); - selectedIndexArray.add('${productModel.itemAttribute!.attributes!.indexOf(element)}_0'); + selectedIndexArray.add( + '${productModel.itemAttribute!.attributes!.indexOf(element)}_0', + ); } } } - if (productModel.itemAttribute!.variants!.where((element) => element.variantSku == selectedVariants.join('-')).isNotEmpty) { + if (productModel.itemAttribute!.variants! + .where( + (element) => + element.variantSku == + selectedVariants.join('-'), + ) + .isNotEmpty) { price = Constant.productCommissionPrice( vendorModel!, - productModel.itemAttribute!.variants!.where((element) => element.variantSku == selectedVariants.join('-')).first.variantPrice ?? '0', + productModel.itemAttribute!.variants! + .where( + (element) => + element.variantSku == + selectedVariants.join('-'), + ) + .first + .variantPrice ?? + '0', ); disPrice = "0"; } } else { - price = Constant.productCommissionPrice(vendorModel!, productModel.price.toString()); - disPrice = double.parse(productModel.disPrice.toString()) <= 0 ? "0" : Constant.productCommissionPrice(vendorModel, productModel.disPrice.toString()); + price = Constant.productCommissionPrice( + vendorModel!, + productModel.price.toString(), + ); + disPrice = + double.parse( + productModel.disPrice.toString(), + ) <= + 0 + ? "0" + : Constant.productCommissionPrice( + vendorModel, + productModel.disPrice.toString(), + ); } return GestureDetector( onTap: () async { - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": vendorModel}); + Get.to( + const RestaurantDetailsScreen(), + arguments: {"vendorModel": vendorModel}, + ); }, child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -85,47 +147,108 @@ class AllCategoryProductScreen extends StatelessWidget { child: SizedBox( height: 90, width: Responsive.width(100, context), - child: NetworkImageWidget(imageUrl: productModel.photo.toString(), fit: BoxFit.cover), + child: NetworkImageWidget( + imageUrl: productModel.photo.toString(), + fit: BoxFit.cover, + ), ), ), Column( mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( productModel.name!.capitalizeString(), textAlign: TextAlign.start, maxLines: 1, - style: AppThemeData.semiBoldTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark600 : AppThemeData.grey600), + style: AppThemeData.semiBoldTextStyle( + fontSize: 18, + color: + isDark + ? AppThemeData.greyDark600 + : AppThemeData.grey600, + ), ), disPrice == "" || disPrice == "0" - ? Text(Constant.amountShow(amount: price), style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: AppThemeData.primary300)) + ? Text( + Constant.amountShow(amount: price), + style: + AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + AppThemeData.primary300, + ), + ) : Row( children: [ Text( - Constant.amountShow(amount: price), - style: AppThemeData.semiBoldTextStyle(fontSize: 14, color: Colors.grey, decoration: TextDecoration.lineThrough), + Constant.amountShow( + amount: price, + ), + style: + AppThemeData.semiBoldTextStyle( + fontSize: 14, + color: Colors.grey, + decoration: + TextDecoration + .lineThrough, + ), ), const SizedBox(width: 5), Text( - Constant.amountShow(amount: disPrice), - style: AppThemeData.semiBoldTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + Constant.amountShow( + amount: disPrice, + ), + style: + AppThemeData.semiBoldTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), ), ], ), Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.warning50 : AppThemeData.warning50, borderRadius: BorderRadius.circular(30)), + decoration: BoxDecoration( + color: + isDark + ? AppThemeData.warning50 + : AppThemeData.warning50, + borderRadius: BorderRadius.circular( + 30, + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 6, + ), child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ - Icon(Icons.star, size: 18, color: AppThemeData.warning400), + Icon( + Icons.star, + size: 18, + color: AppThemeData.warning400, + ), Text( "${Constant.calculateReview(reviewCount: productModel.reviewsCount.toString(), reviewSum: productModel.reviewsSum.toString())} (${productModel.reviewsSum})", - style: AppThemeData.semiBoldTextStyle(fontSize: 12, color: AppThemeData.warning400), + style: + AppThemeData.semiBoldTextStyle( + fontSize: 12, + color: + AppThemeData + .warning400, + ), ), ], ), diff --git a/lib/screen_ui/ecommarce/dash_board_e_commerce_screen.dart b/lib/screen_ui/ecommarce/dash_board_e_commerce_screen.dart index cc530cb..8e42832 100644 --- a/lib/screen_ui/ecommarce/dash_board_e_commerce_screen.dart +++ b/lib/screen_ui/ecommarce/dash_board_e_commerce_screen.dart @@ -2,10 +2,10 @@ import 'package:customer/constant/constant.dart'; import 'package:customer/controllers/dash_board_controller.dart'; import 'package:customer/controllers/dash_board_ecommarce_controller.dart'; import 'package:customer/themes/app_them_data.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:get/get.dart'; - import '../../controllers/theme_controller.dart'; class DashBoardEcommerceScreen extends StatelessWidget { @@ -26,12 +26,19 @@ class DashBoardEcommerceScreen extends StatelessWidget { showUnselectedLabels: true, showSelectedLabels: true, selectedFontSize: 12, - selectedLabelStyle: const TextStyle(fontFamily: AppThemeData.bold), - unselectedLabelStyle: const TextStyle(fontFamily: AppThemeData.bold), + selectedLabelStyle: const TextStyle( + fontFamily: AppThemeData.bold, + ), + unselectedLabelStyle: const TextStyle( + fontFamily: AppThemeData.bold, + ), currentIndex: controller.selectedIndex.value, - backgroundColor: isDark ? AppThemeData.grey900 : AppThemeData.grey50, - selectedItemColor: isDark ? AppThemeData.primary300 : AppThemeData.primary300, - unselectedItemColor: isDark ? AppThemeData.grey300 : AppThemeData.grey600, + backgroundColor: + isDark ? AppThemeData.grey900 : AppThemeData.grey50, + selectedItemColor: + isDark ? AppThemeData.primary300 : AppThemeData.primary300, + unselectedItemColor: + isDark ? AppThemeData.grey300 : AppThemeData.grey600, onTap: (int index) { if (index == 0) { Get.put(DashBoardController()); @@ -41,17 +48,71 @@ class DashBoardEcommerceScreen extends StatelessWidget { items: Constant.walletSetting == false ? [ - navigationBarItem(isDark, index: 0, assetIcon: "assets/icons/ic_home.svg", label: 'Home'.tr, controller: controller), - navigationBarItem(isDark, index: 1, assetIcon: "assets/icons/ic_fav.svg", label: 'Favourites'.tr, controller: controller), - navigationBarItem(isDark, index: 2, assetIcon: "assets/icons/ic_orders.svg", label: 'Orders'.tr, controller: controller), - navigationBarItem(isDark, index: 3, assetIcon: "assets/icons/ic_profile.svg", label: 'Profile'.tr, controller: controller), + navigationBarItem( + isDark, + index: 0, + assetIcon: "assets/icons/ic_home.svg", + label: 'Home'.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 1, + assetIcon: "assets/icons/ic_fav.svg", + label: 'Favourites'.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 2, + assetIcon: "assets/icons/ic_orders.svg", + label: 'Orders'.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 3, + assetIcon: "assets/icons/ic_profile.svg", + label: 'Profile'.tr, + controller: controller, + ), ] : [ - navigationBarItem(isDark, index: 0, assetIcon: "assets/icons/ic_home.svg", label: 'Home'.tr, controller: controller), - navigationBarItem(isDark, index: 1, assetIcon: "assets/icons/ic_fav.svg", label: 'Favourites'.tr, controller: controller), - navigationBarItem(isDark, index: 2, assetIcon: "assets/icons/ic_wallet.svg", label: 'Wallet'.tr, controller: controller), - navigationBarItem(isDark, index: 3, assetIcon: "assets/icons/ic_orders.svg", label: 'Orders'.tr, controller: controller), - navigationBarItem(isDark, index: 4, assetIcon: "assets/icons/ic_profile.svg", label: 'Profile'.tr, controller: controller), + navigationBarItem( + isDark, + index: 0, + assetIcon: "assets/icons/ic_home.svg", + label: 'Home'.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 1, + assetIcon: "assets/icons/ic_fav.svg", + label: 'Favourites'.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 2, + assetIcon: "assets/icons/ic_wallet.svg", + label: 'Wallet'.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 3, + assetIcon: "assets/icons/ic_orders.svg", + label: 'Orders'.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 4, + assetIcon: "assets/icons/ic_profile.svg", + label: 'Profile'.tr, + controller: controller, + ), ], ), ); @@ -60,7 +121,13 @@ class DashBoardEcommerceScreen extends StatelessWidget { }); } - BottomNavigationBarItem navigationBarItem(isDark, {required int index, required String label, required String assetIcon, required DashBoardEcommerceController controller}) { + BottomNavigationBarItem navigationBarItem( + isDark, { + required int index, + required String label, + required String assetIcon, + required DashBoardEcommerceController controller, + }) { return BottomNavigationBarItem( icon: Padding( padding: const EdgeInsets.symmetric(vertical: 5), diff --git a/lib/screen_ui/ecommarce/home_e_commerce_screen.dart b/lib/screen_ui/ecommarce/home_e_commerce_screen.dart index 914beb2..6dbf7f8 100644 --- a/lib/screen_ui/ecommarce/home_e_commerce_screen.dart +++ b/lib/screen_ui/ecommarce/home_e_commerce_screen.dart @@ -1,4 +1,7 @@ +// ignore_for_file: depend_on_referenced_packages + import 'package:badges/badges.dart' as badges; +import 'package:customer/constant/const_texts.dart'; import 'package:customer/constant/constant.dart'; import 'package:customer/controllers/home_e_commerce_controller.dart'; import 'package:customer/controllers/theme_controller.dart'; @@ -17,7 +20,8 @@ import 'package:customer/screen_ui/location_enable_screens/address_list_screen.d import 'package:customer/screen_ui/multi_vendor_service/advertisement_screens/all_advertisement_screen.dart'; import 'package:customer/screen_ui/multi_vendor_service/cart_screen/cart_screen.dart'; import 'package:customer/screen_ui/multi_vendor_service/home_screen/category_restaurant_screen.dart'; -import 'package:customer/screen_ui/multi_vendor_service/home_screen/restaurant_list_screen.dart' show RestaurantListScreen; +import 'package:customer/screen_ui/multi_vendor_service/home_screen/restaurant_list_screen.dart' + show RestaurantListScreen; import 'package:customer/screen_ui/multi_vendor_service/home_screen/view_all_category_screen.dart'; import 'package:customer/screen_ui/multi_vendor_service/restaurant_details_screen/restaurant_details_screen.dart'; import 'package:customer/screen_ui/multi_vendor_service/search_screen/search_screen.dart'; @@ -52,13 +56,18 @@ class HomeECommerceScreen extends StatelessWidget { return Scaffold( backgroundColor: isDark ? AppThemeData.grey900 : AppThemeData.grey50, appBar: AppBar( - backgroundColor: isDark ? AppThemeData.ecommerce300 : AppThemeData.ecommerce300, + backgroundColor: + isDark ? AppThemeData.ecommerce300 : AppThemeData.ecommerce300, titleSpacing: 0, leading: InkWell( onTap: () { Get.back(); }, - child: Icon(Icons.arrow_back, color: isDark ? AppThemeData.grey50 : AppThemeData.grey50, size: 20), + child: Icon( + Icons.arrow_back, + color: isDark ? AppThemeData.grey50 : AppThemeData.grey50, + size: 20, + ), ), title: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -68,9 +77,27 @@ class HomeECommerceScreen extends StatelessWidget { onTap: () { Get.offAll(const LoginScreen()); }, - child: Text("Login".tr, textAlign: TextAlign.center, style: AppThemeData.semiBoldTextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey50, fontSize: 12)), + child: Text( + "Login".tr, + textAlign: TextAlign.center, + style: AppThemeData.semiBoldTextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey50, + fontSize: 12, + ), + ), ) - : Text(Constant.userModel!.fullName(), textAlign: TextAlign.center, style: AppThemeData.semiBoldTextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey50, fontSize: 12)), + : Text( + Constant.userModel!.fullName(), + textAlign: TextAlign.center, + style: AppThemeData.semiBoldTextStyle( + color: + isDark ? AppThemeData.grey50 : AppThemeData.grey50, + fontSize: 12, + ), + ), InkWell( onTap: () async { if (Constant.userModel != null) { @@ -84,7 +111,7 @@ class HomeECommerceScreen extends StatelessWidget { } else { Constant.checkPermission( onTap: () async { - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); // ✅ declare it once here! ShippingAddress shippingAddress = ShippingAddress(); @@ -95,7 +122,9 @@ class HomeECommerceScreen extends StatelessWidget { ShowToastDialog.closeLoader(); if (Constant.selectedMapType == 'osm') { - final result = await Get.to(() => MapPickerPage()); + final result = await Get.to( + () => MapPickerPage(), + ); if (result != null) { final firstPlace = result; final lat = firstPlace.coordinates.latitude; @@ -104,19 +133,31 @@ class HomeECommerceScreen extends StatelessWidget { shippingAddress.addressAs = "Home"; shippingAddress.locality = address.toString(); - shippingAddress.location = UserLocation(latitude: lat, longitude: lng); + shippingAddress.location = UserLocation( + latitude: lat, + longitude: lng, + ); Constant.selectedLocation = shippingAddress; controller.getData(); Get.back(); } } else { - Get.to(LocationPickerScreen())!.then((value) async { + Get.to(LocationPickerScreen())!.then(( + value, + ) async { if (value != null) { - SelectedLocationModel selectedLocationModel = value; + SelectedLocationModel selectedLocationModel = + value; shippingAddress.addressAs = "Home"; - shippingAddress.location = UserLocation(latitude: selectedLocationModel.latLng!.latitude, longitude: selectedLocationModel.latLng!.longitude); - shippingAddress.locality = "Picked from Map"; // You can reverse-geocode + shippingAddress.location = UserLocation( + latitude: + selectedLocationModel.latLng!.latitude, + longitude: + selectedLocationModel.latLng!.longitude, + ); + shippingAddress.locality = + "Picked from Map"; // You can reverse-geocode Constant.selectedLocation = shippingAddress; controller.getData(); @@ -124,9 +165,15 @@ class HomeECommerceScreen extends StatelessWidget { }); } } catch (e) { - await placemarkFromCoordinates(19.228825, 72.854118).then((valuePlaceMaker) { + await placemarkFromCoordinates( + 19.228825, + 72.854118, + ).then((valuePlaceMaker) { Placemark placeMark = valuePlaceMaker[0]; - shippingAddress.location = UserLocation(latitude: 19.228825, longitude: 72.854118); + shippingAddress.location = UserLocation( + latitude: 19.228825, + longitude: 72.854118, + ); String currentLocation = "${placeMark.name}, ${placeMark.subLocality}, ${placeMark.locality}, ${placeMark.administrativeArea}, ${placeMark.postalCode}, ${placeMark.country}"; shippingAddress.locality = currentLocation; @@ -146,8 +193,25 @@ class HomeECommerceScreen extends StatelessWidget { overflow: TextOverflow.ellipsis, TextSpan( children: [ - TextSpan(text: Constant.selectedLocation.getFullAddress(), style: AppThemeData.boldTextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey50, fontSize: 14)), - WidgetSpan(child: SvgPicture.asset("assets/icons/ic_down.svg", colorFilter: ColorFilter.mode(AppThemeData.grey50, BlendMode.srcIn))), + TextSpan( + text: Constant.selectedLocation.getFullAddress(), + style: AppThemeData.boldTextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey50, + fontSize: 14, + ), + ), + WidgetSpan( + child: SvgPicture.asset( + "assets/icons/ic_down.svg", + colorFilter: ColorFilter.mode( + AppThemeData.grey50, + BlendMode.srcIn, + ), + ), + ), ], ), ), @@ -167,10 +231,14 @@ class HomeECommerceScreen extends StatelessWidget { overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey50, + color: + isDark ? AppThemeData.grey50 : AppThemeData.grey50, ), ), - badgeStyle: badges.BadgeStyle(shape: badges.BadgeShape.circle, badgeColor: AppThemeData.info300), + badgeStyle: badges.BadgeStyle( + shape: badges.BadgeShape.circle, + badgeColor: AppThemeData.info300, + ), child: InkWell( onTap: () async { (await Get.to(const CartScreen())); @@ -181,11 +249,28 @@ class HomeECommerceScreen extends StatelessWidget { width: 30, height: 30, decoration: ShapeDecoration( - shape: RoundedRectangleBorder(side: BorderSide(width: 1, color: isDark ? AppThemeData.grey700 : AppThemeData.grey200), borderRadius: BorderRadius.circular(120)), + shape: RoundedRectangleBorder( + side: BorderSide( + width: 1, + color: + isDark + ? AppThemeData.grey700 + : AppThemeData.grey200, + ), + borderRadius: BorderRadius.circular(120), + ), ), child: Padding( padding: const EdgeInsets.all(8.0), - child: SvgPicture.asset("assets/icons/ic_shoping_cart.svg", colorFilter: ColorFilter.mode(isDark ? AppThemeData.grey50 : AppThemeData.grey50, BlendMode.srcIn)), + child: SvgPicture.asset( + "assets/icons/ic_shoping_cart.svg", + colorFilter: ColorFilter.mode( + isDark + ? AppThemeData.grey50 + : AppThemeData.grey50, + BlendMode.srcIn, + ), + ), ), ), ), @@ -195,22 +280,39 @@ class HomeECommerceScreen extends StatelessWidget { ), ], bottom: PreferredSize( - preferredSize: Size.fromHeight(50.0), // height of the bottom widget + preferredSize: Size.fromHeight( + 50.0, + ), // height of the bottom widget child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 8, + ), child: InkWell( onTap: () { - Get.to(const SearchScreen(), arguments: {"vendorList": controller.allNearestRestaurant}); + Get.to( + const SearchScreen(), + arguments: { + "vendorList": controller.allNearestRestaurant, + }, + ); }, child: TextFieldWidget( - hintText: 'Search the store, item and more...'.tr, + hintText: ConstTexts.searchStoreItem.tr, controller: null, enable: false, backgroundColor: AppThemeData.grey50, - hintColor: isDark ? AppThemeData.grey400 : AppThemeData.grey400, + hintColor: + isDark ? AppThemeData.grey400 : AppThemeData.grey400, prefix: Padding( padding: const EdgeInsets.symmetric(horizontal: 16), - child: SvgPicture.asset("assets/icons/ic_search.svg", colorFilter: ColorFilter.mode(isDark ? AppThemeData.grey400 : AppThemeData.grey400, BlendMode.srcIn)), + child: SvgPicture.asset( + "assets/icons/ic_search.svg", + colorFilter: ColorFilter.mode( + isDark ? AppThemeData.grey400 : AppThemeData.grey400, + BlendMode.srcIn, + ), + ), ), ), ), @@ -233,9 +335,15 @@ class HomeECommerceScreen extends StatelessWidget { children: [ Expanded( child: Text( - "Category".tr, + ConstTexts.category.tr, textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, fontSize: 16), + style: AppThemeData.semiBoldTextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + fontSize: 16, + ), ), ), InkWell( @@ -243,11 +351,14 @@ class HomeECommerceScreen extends StatelessWidget { Get.to(const ViewAllCategoryScreen()); }, child: Text( - "View all".tr, + ConstTexts.viewAll.tr, textAlign: TextAlign.start, style: AppThemeData.semiBoldTextStyle( decoration: TextDecoration.underline, - color: isDark ? AppThemeData.multiVendorDark300 : AppThemeData.multiVendor300, + color: + isDark + ? AppThemeData.multiVendorDark300 + : AppThemeData.multiVendor300, fontSize: 14, ), ), @@ -263,26 +374,51 @@ class HomeECommerceScreen extends StatelessWidget { child: ListView.builder( shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), - itemCount: controller.vendorCategoryModel.length, + itemCount: + controller.vendorCategoryModel.length, scrollDirection: Axis.horizontal, itemBuilder: (context, index) { - VendorCategoryModel vendorCategoryModel = controller.vendorCategoryModel[index]; + VendorCategoryModel vendorCategoryModel = + controller.vendorCategoryModel[index]; return InkWell( onTap: () { - Get.to(const CategoryRestaurantScreen(), arguments: {"vendorCategoryModel": vendorCategoryModel, "dineIn": false}); + Get.to( + const CategoryRestaurantScreen(), + arguments: { + "vendorCategoryModel": + vendorCategoryModel, + "dineIn": false, + }, + ); }, child: Padding( padding: const EdgeInsets.only(right: 18), child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.center, children: [ - NetworkImageWidget(imageUrl: vendorCategoryModel.photo.toString(), height: 60, width: 60, fit: BoxFit.cover), + NetworkImageWidget( + imageUrl: + vendorCategoryModel.photo + .toString(), + height: 60, + width: 60, + fit: BoxFit.cover, + ), const SizedBox(height: 5), Text( - vendorCategoryModel.title.toString(), + vendorCategoryModel.title + .toString(), textAlign: TextAlign.center, - style: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800, fontSize: 14), + style: AppThemeData.mediumTextStyle( + color: + isDark + ? AppThemeData.greyDark800 + : AppThemeData.grey800, + fontSize: 14, + ), ), ], ), @@ -293,40 +429,82 @@ class HomeECommerceScreen extends StatelessWidget { ), ), SizedBox(height: 10), - Padding(padding: const EdgeInsets.symmetric(horizontal: 16), child: controller.bannerModel.isEmpty ? const SizedBox() : BannerView(controller: controller)), - Visibility(visible: (Constant.isEnableAdsFeature == true && controller.advertisementList.isNotEmpty), child: const SizedBox(height: 20)), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: + controller.bannerModel.isEmpty + ? const SizedBox() + : BannerView(controller: controller), + ), + Visibility( + visible: + (Constant.isEnableAdsFeature == true && + controller.advertisementList.isNotEmpty), + child: const SizedBox(height: 20), + ), Visibility( visible: Constant.isEnableAdsFeature == true, child: controller.advertisementList.isEmpty ? const SizedBox() : Container( - color: AppThemeData.primary300.withAlpha(40), + color: AppThemeData.primary300.withAlpha( + 40, + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 16, + ), child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Row( children: [ Expanded( child: Text( - "Highlights for you".tr, + ConstTexts + .highlightsForU + .tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontFamily: + AppThemeData.semiBold, + fontSize: 16, + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, + ), ), ), InkWell( onTap: () { - Get.to(AllAdvertisementScreen())?.then((value) { - controller.getFavouriteRestaurant(); + Get.to( + AllAdvertisementScreen(), + )?.then((value) { + controller + .getFavouriteRestaurant(); }); }, child: Text( "View all".tr, textAlign: TextAlign.center, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300), + style: TextStyle( + fontFamily: + AppThemeData.regular, + color: + isDark + ? AppThemeData + .primary300 + : AppThemeData + .primary300, + ), ), ), ], @@ -335,12 +513,30 @@ class HomeECommerceScreen extends StatelessWidget { SizedBox( height: 220, child: ListView.builder( - physics: const BouncingScrollPhysics(), - scrollDirection: Axis.horizontal, - itemCount: controller.advertisementList.length >= 10 ? 10 : controller.advertisementList.length, + physics: + const BouncingScrollPhysics(), + scrollDirection: + Axis.horizontal, + itemCount: + controller + .advertisementList + .length >= + 10 + ? 10 + : controller + .advertisementList + .length, padding: EdgeInsets.all(0), - itemBuilder: (BuildContext context, int index) { - return AdvertisementHomeCard(controller: controller, model: controller.advertisementList[index]); + itemBuilder: ( + BuildContext context, + int index, + ) { + return AdvertisementHomeCard( + controller: controller, + model: + controller + .advertisementList[index], + ); }, ), ), @@ -353,9 +549,15 @@ class HomeECommerceScreen extends StatelessWidget { Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: Text( - "New Arrivals".tr, + ConstTexts.newArrival.tr, textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, fontSize: 16), + style: AppThemeData.semiBoldTextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + fontSize: 16, + ), ), ), SizedBox(height: 20), @@ -371,7 +573,13 @@ class HomeECommerceScreen extends StatelessWidget { childAspectRatio: 1 / 1.1, padding: EdgeInsets.zero, physics: NeverScrollableScrollPhysics(), - children: controller.newArrivalRestaurantList.take(4).map((item) => NewArrivalCard(item: item)).toList(), + children: + controller.newArrivalRestaurantList + .take(4) + .map( + (item) => NewArrivalCard(item: item), + ) + .toList(), ), ), ), @@ -380,11 +588,24 @@ class HomeECommerceScreen extends StatelessWidget { padding: const EdgeInsets.symmetric(horizontal: 16), child: RoundedButtonBorder( radius: 10, - color: isDark ? AppThemeData.greyDark100 : AppThemeData.grey100, - borderColor: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200, - title: 'View All Arrivals'.tr, + color: + isDark + ? AppThemeData.greyDark100 + : AppThemeData.grey100, + borderColor: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + title: ConstTexts.viewAllArrivals.tr, onPress: () { - Get.to(RestaurantListScreen(), arguments: {"vendorList": controller.newArrivalRestaurantList, "title": "New Arrivals".tr}); + Get.to( + RestaurantListScreen(), + arguments: { + "vendorList": + controller.newArrivalRestaurantList, + "title": ConstTexts.newArrival.tr, + }, + ); }, ), ), @@ -394,19 +615,38 @@ class HomeECommerceScreen extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("Top Brands".tr, textAlign: TextAlign.start, style: AppThemeData.semiBoldTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, fontSize: 16)), + Text( + ConstTexts.topBrands.tr, + textAlign: TextAlign.start, + style: AppThemeData.semiBoldTextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + fontSize: 16, + ), + ), SizedBox(height: 10), GridView.builder( padding: EdgeInsets.zero, - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4, childAspectRatio: 4.5 / 6, crossAxisSpacing: 2), + gridDelegate: + const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 4, + childAspectRatio: 4.5 / 6, + crossAxisSpacing: 2, + ), itemCount: controller.brandList.length, physics: const NeverScrollableScrollPhysics(), shrinkWrap: true, itemBuilder: (context, index) { - BrandsModel brandModel = controller.brandList[index]; + BrandsModel brandModel = + controller.brandList[index]; return InkWell( onTap: () { - Get.to(AllBrandProductScreen(), arguments: {"brandModel": brandModel}); + Get.to( + AllBrandProductScreen(), + arguments: {"brandModel": brandModel}, + ); }, child: Column( children: [ @@ -414,20 +654,49 @@ class HomeECommerceScreen extends StatelessWidget { width: 80, height: 80, decoration: ShapeDecoration( - color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, shape: RoundedRectangleBorder( - side: BorderSide(width: 1, strokeAlign: BorderSide.strokeAlignOutside, color: isDark ? AppThemeData.grey800 : AppThemeData.grey100), - borderRadius: BorderRadius.circular(10), + side: BorderSide( + width: 1, + strokeAlign: + BorderSide + .strokeAlignOutside, + color: + isDark + ? AppThemeData.grey800 + : AppThemeData + .grey100, + ), + borderRadius: + BorderRadius.circular(10), + ), + ), + child: Padding( + padding: const EdgeInsets.all(10), + child: ClipOval( + child: NetworkImageWidget( + imageUrl: + brandModel.photo + .toString(), + fit: BoxFit.cover, + ), ), ), - child: Padding(padding: const EdgeInsets.all(10), child: ClipOval(child: NetworkImageWidget(imageUrl: brandModel.photo.toString(), fit: BoxFit.cover))), ), SizedBox(height: 5), Text( '${brandModel.title}', textAlign: TextAlign.center, maxLines: 2, - style: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: AppThemeData.mediumTextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), ], ), @@ -442,137 +711,389 @@ class HomeECommerceScreen extends StatelessWidget { shrinkWrap: true, physics: const BouncingScrollPhysics(), padding: EdgeInsets.zero, - itemCount: controller.categoryWiseProductList.length, + itemCount: + controller.categoryWiseProductList.length, itemBuilder: (context, index) { - VendorCategoryModel item = controller.categoryWiseProductList[index]; - String imagePath = ["assets/images/ic_product_bg_1.png", "assets/images/ic_product_bg_2.png", "assets/images/ic_product_bg_3.png"][index % ["", "", ""].length]; + VendorCategoryModel item = + controller.categoryWiseProductList[index]; + String imagePath = + [ + "assets/images/ic_product_bg_1.png", + "assets/images/ic_product_bg_2.png", + "assets/images/ic_product_bg_3.png", + ][index % ["", "", ""].length]; return Container( width: Responsive.width(100, context), - decoration: BoxDecoration(image: DecorationImage(image: AssetImage(imagePath), fit: BoxFit.fill)), + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage(imagePath), + fit: BoxFit.fill, + ), + ), child: Padding( - padding: const EdgeInsets.only(left: 16, right: 16, top: 10, bottom: 20), + padding: const EdgeInsets.only( + left: 16, + right: 16, + top: 10, + bottom: 20, + ), child: FutureBuilder>( - future: FireStoreUtils.getProductListByCategoryId(item.id.toString()), + future: + FireStoreUtils.getProductListByCategoryId( + item.id.toString(), + ), builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { - return Center(child: CircularProgressIndicator.adaptive(valueColor: AlwaysStoppedAnimation(AppThemeData.primary300))); - } else if ((snapshot.hasData || (snapshot.data?.isNotEmpty ?? false))) { - List productList = snapshot.data!; + if (snapshot.connectionState == + ConnectionState.waiting) { + return Center( + child: + CircularProgressIndicator.adaptive( + valueColor: + AlwaysStoppedAnimation( + AppThemeData.primary300, + ), + ), + ); + } else if ((snapshot.hasData || + (snapshot.data?.isNotEmpty ?? + false))) { + List productList = + snapshot.data!; return snapshot.data!.isEmpty ? Container() : Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, children: [ - Text(item.title.toString(), textAlign: TextAlign.start, style: AppThemeData.boldTextStyle(color: AppThemeData.grey900, fontSize: 18)), Text( - "Style up with the latest fits, now at unbeatable prices.".tr, + item.title.toString(), textAlign: TextAlign.start, - style: AppThemeData.regularTextStyle(color: AppThemeData.grey900, fontSize: 12), + style: + AppThemeData.boldTextStyle( + color: + AppThemeData + .grey900, + fontSize: 18, + ), + ), + Text( + ConstTexts.styleUp.tr + .tr, + textAlign: TextAlign.start, + style: + AppThemeData.regularTextStyle( + color: + AppThemeData + .grey900, + fontSize: 12, + ), ), SizedBox(height: 20), GridView.builder( shrinkWrap: true, - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: 3.5 / 6, crossAxisSpacing: 10), + gridDelegate: + const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 3, + childAspectRatio: + 3.5 / 6, + crossAxisSpacing: 10, + ), padding: EdgeInsets.zero, - physics: NeverScrollableScrollPhysics(), - itemCount: productList.length > 6 ? 6 : productList.length, - itemBuilder: (context, index) { - ProductModel productModel = productList[index]; + physics: + NeverScrollableScrollPhysics(), + itemCount: + productList.length > 6 + ? 6 + : productList.length, + itemBuilder: ( + context, + index, + ) { + ProductModel productModel = + productList[index]; return FutureBuilder( - future: FireStoreUtils.getVendorById(productModel.vendorID.toString()), - builder: (context, vendorSnapshot) { - if (!vendorSnapshot.hasData || vendorSnapshot.connectionState == ConnectionState.waiting) { + future: + FireStoreUtils.getVendorById( + productModel + .vendorID + .toString(), + ), + builder: ( + context, + vendorSnapshot, + ) { + if (!vendorSnapshot + .hasData || + vendorSnapshot + .connectionState == + ConnectionState + .waiting) { return const SizedBox(); // Show placeholder or loader } - VendorModel? vendorModel = vendorSnapshot.data; + VendorModel? + vendorModel = + vendorSnapshot.data; String price = "0.0"; String disPrice = "0.0"; - List selectedVariants = []; - List selectedIndexVariants = []; - List selectedIndexArray = []; - if (productModel.itemAttribute != null) { - if (productModel.itemAttribute!.attributes!.isNotEmpty) { - for (var element in productModel.itemAttribute!.attributes!) { - if (element.attributeOptions!.isNotEmpty) { + List + selectedVariants = []; + List + selectedIndexVariants = + []; + List + selectedIndexArray = []; + if (productModel + .itemAttribute != + null) { + if (productModel + .itemAttribute! + .attributes! + .isNotEmpty) { + for (var element + in productModel + .itemAttribute! + .attributes!) { + if (element + .attributeOptions! + .isNotEmpty) { selectedVariants.add( - productModel.itemAttribute!.attributes![productModel.itemAttribute!.attributes!.indexOf(element)].attributeOptions![0].toString(), + productModel + .itemAttribute! + .attributes![productModel + .itemAttribute! + .attributes! + .indexOf( + element, + )] + .attributeOptions![0] + .toString(), ); - selectedIndexVariants.add( - '${productModel.itemAttribute!.attributes!.indexOf(element)} _${productModel.itemAttribute!.attributes![0].attributeOptions![0].toString()}', - ); - selectedIndexArray.add('${productModel.itemAttribute!.attributes!.indexOf(element)}_0'); + selectedIndexVariants + .add( + '${productModel.itemAttribute!.attributes!.indexOf(element)} _${productModel.itemAttribute!.attributes![0].attributeOptions![0].toString()}', + ); + selectedIndexArray + .add( + '${productModel.itemAttribute!.attributes!.indexOf(element)}_0', + ); } } } - if (productModel.itemAttribute!.variants!.where((element) => element.variantSku == selectedVariants.join('-')).isNotEmpty) { + if (productModel + .itemAttribute! + .variants! + .where( + (element) => + element + .variantSku == + selectedVariants + .join( + '-', + ), + ) + .isNotEmpty) { price = Constant.productCommissionPrice( vendorModel!, - productModel.itemAttribute!.variants!.where((element) => element.variantSku == selectedVariants.join('-')).first.variantPrice ?? '0', + productModel + .itemAttribute! + .variants! + .where( + ( + element, + ) => + element.variantSku == + selectedVariants.join( + '-', + ), + ) + .first + .variantPrice ?? + '0', ); disPrice = "0"; } } else { - price = Constant.productCommissionPrice(vendorModel!, productModel.price.toString()); + price = + Constant.productCommissionPrice( + vendorModel!, + productModel + .price + .toString(), + ); disPrice = - double.parse(productModel.disPrice.toString()) <= 0 + double.parse( + productModel + .disPrice + .toString(), + ) <= + 0 ? "0" - : Constant.productCommissionPrice(vendorModel, productModel.disPrice.toString()); + : Constant.productCommissionPrice( + vendorModel, + productModel + .disPrice + .toString(), + ); } return GestureDetector( onTap: () async { - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": vendorModel}); + Get.to( + const RestaurantDetailsScreen(), + arguments: { + "vendorModel": + vendorModel, + }, + ); }, child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ ClipRRect( - borderRadius: BorderRadius.circular(10), + borderRadius: + BorderRadius.circular( + 10, + ), child: SizedBox( height: 90, - width: Responsive.width(100, context), - child: NetworkImageWidget(imageUrl: productModel.photo.toString(), fit: BoxFit.cover), + width: + Responsive.width( + 100, + context, + ), + child: NetworkImageWidget( + imageUrl: + productModel + .photo + .toString(), + fit: + BoxFit + .cover, + ), ), ), Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment + .start, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ Text( - productModel.name!.capitalizeString(), - textAlign: TextAlign.start, + productModel + .name! + .capitalizeString(), + textAlign: + TextAlign + .start, maxLines: 1, - style: AppThemeData.semiBoldTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark600 : AppThemeData.grey600), + style: AppThemeData.semiBoldTextStyle( + fontSize: + 18, + color: + isDark + ? AppThemeData.greyDark600 + : AppThemeData.grey600, + ), ), - disPrice == "" || disPrice == "0" - ? Text(Constant.amountShow(amount: price), style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: AppThemeData.primary300)) + disPrice == + "" || + disPrice == + "0" + ? Text( + Constant.amountShow( + amount: + price, + ), + style: AppThemeData.semiBoldTextStyle( + fontSize: + 16, + color: + AppThemeData.primary300, + ), + ) : Column( children: [ Text( - Constant.amountShow(amount: price), - style: AppThemeData.semiBoldTextStyle(fontSize: 14, color: Colors.grey, decoration: TextDecoration.lineThrough), + Constant.amountShow( + amount: + price, + ), + style: AppThemeData.semiBoldTextStyle( + fontSize: + 14, + color: + Colors.grey, + decoration: + TextDecoration.lineThrough, + ), + ), + const SizedBox( + width: + 5, ), - const SizedBox(width: 5), Text( - Constant.amountShow(amount: disPrice), - style: AppThemeData.semiBoldTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + Constant.amountShow( + amount: + disPrice, + ), + style: AppThemeData.semiBoldTextStyle( + fontSize: + 14, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ], ), Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.warning50 : AppThemeData.warning50, borderRadius: BorderRadius.circular(30)), + decoration: BoxDecoration( + color: + isDark + ? AppThemeData.warning50 + : AppThemeData.warning50, + borderRadius: + BorderRadius.circular( + 30, + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6), + padding: const EdgeInsets.symmetric( + horizontal: + 10, + vertical: + 6, + ), child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisSize: MainAxisSize.min, + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + mainAxisSize: + MainAxisSize.min, children: [ - Icon(Icons.star, size: 18, color: AppThemeData.warning400), + Icon( + Icons.star, + size: + 18, + color: + AppThemeData.warning400, + ), Text( "${Constant.calculateReview(reviewCount: productModel.reviewsCount.toString(), reviewSum: productModel.reviewsSum.toString())} (${productModel.reviewsSum})", - style: AppThemeData.semiBoldTextStyle(fontSize: 12, color: AppThemeData.warning400), + style: AppThemeData.semiBoldTextStyle( + fontSize: + 12, + color: + AppThemeData.warning400, + ), ), ], ), @@ -589,11 +1110,26 @@ class HomeECommerceScreen extends StatelessWidget { ), RoundedButtonBorder( radius: 10, - color: isDark ? AppThemeData.greyDark100 : AppThemeData.grey100, - borderColor: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200, + color: + isDark + ? AppThemeData + .greyDark100 + : AppThemeData + .grey100, + borderColor: + isDark + ? AppThemeData + .greyDark200 + : AppThemeData + .grey200, title: 'View All Products', onPress: () { - Get.to(AllCategoryProductScreen(), arguments: {"categoryModel": item}); + Get.to( + AllCategoryProductScreen(), + arguments: { + "categoryModel": item, + }, + ); }, ), ], @@ -608,7 +1144,13 @@ class HomeECommerceScreen extends StatelessWidget { }, ), SizedBox(height: 10), - Padding(padding: const EdgeInsets.symmetric(horizontal: 16), child: controller.bannerModel.isEmpty ? const SizedBox() : BannerBottomView(controller: controller)), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: + controller.bannerModel.isEmpty + ? const SizedBox() + : BannerBottomView(controller: controller), + ), // Visibility( // visible: (Constant.isEnableAdsFeature == true && controller.advertisementList.isNotEmpty), // child: const SizedBox(height: 20), @@ -686,56 +1228,145 @@ class HomeECommerceScreen extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("All Store".tr, textAlign: TextAlign.start, style: AppThemeData.semiBoldTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, fontSize: 16)), + Text( + "All Store".tr, + textAlign: TextAlign.start, + style: AppThemeData.semiBoldTextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + fontSize: 16, + ), + ), SizedBox(height: 10), ListView.builder( padding: EdgeInsets.zero, shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), - itemCount: controller.allNearestRestaurant.length > 8 ? 8 : controller.allNearestRestaurant.length, + itemCount: + controller.allNearestRestaurant.length > 8 + ? 8 + : controller + .allNearestRestaurant + .length, itemBuilder: (context, index) { - VendorModel item = controller.allNearestRestaurant[index]; + VendorModel item = + controller.allNearestRestaurant[index]; return InkWell( onTap: () { - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": item}); + Get.to( + const RestaurantDetailsScreen(), + arguments: {"vendorModel": item}, + ); }, child: Padding( - padding: const EdgeInsets.only(bottom: 20), + padding: const EdgeInsets.only( + bottom: 20, + ), child: Row( children: [ - ClipRRect(borderRadius: BorderRadius.circular(10), child: NetworkImageWidget(imageUrl: item.photo.toString(), height: 80, width: 130, fit: BoxFit.cover)), + ClipRRect( + borderRadius: + BorderRadius.circular(10), + child: NetworkImageWidget( + imageUrl: item.photo.toString(), + height: 80, + width: 130, + fit: BoxFit.cover, + ), + ), SizedBox(width: 10), Expanded( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ - Text(item.title.toString(), style: AppThemeData.semiBoldTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, fontSize: 16)), + Text( + item.title.toString(), + style: + AppThemeData.semiBoldTextStyle( + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + fontSize: 16, + ), + ), Row( children: [ - Icon(Icons.location_on, size: 14, color: Colors.grey), + Icon( + Icons.location_on, + size: 14, + color: Colors.grey, + ), SizedBox(width: 4), Expanded( child: Text( - item.location.toString(), - style: AppThemeData.semiBoldTextStyle(fontSize: 12, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500), - overflow: TextOverflow.ellipsis, + item.location + .toString(), + style: AppThemeData.semiBoldTextStyle( + fontSize: 12, + color: + isDark + ? AppThemeData + .greyDark500 + : AppThemeData + .grey500, + ), + overflow: + TextOverflow + .ellipsis, ), ), ], ), Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.warning50 : AppThemeData.warning50, borderRadius: BorderRadius.circular(30)), + decoration: BoxDecoration( + color: + isDark + ? AppThemeData + .warning50 + : AppThemeData + .warning50, + borderRadius: + BorderRadius.circular( + 30, + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6), + padding: + const EdgeInsets.symmetric( + horizontal: 10, + vertical: 6, + ), child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisSize: MainAxisSize.min, + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + mainAxisSize: + MainAxisSize.min, children: [ - Icon(Icons.star, size: 18, color: AppThemeData.warning400), + Icon( + Icons.star, + size: 18, + color: + AppThemeData + .warning400, + ), Text( "${Constant.calculateReview(reviewCount: item.reviewsCount.toString(), reviewSum: item.reviewsSum.toString())} (${item.reviewsSum})", - style: AppThemeData.semiBoldTextStyle(fontSize: 12, color: AppThemeData.warning400), + style: AppThemeData.semiBoldTextStyle( + fontSize: 12, + color: + AppThemeData + .warning400, + ), ), ], ), @@ -752,11 +1383,23 @@ class HomeECommerceScreen extends StatelessWidget { ), RoundedButtonBorder( radius: 10, - color: isDark ? AppThemeData.greyDark100 : AppThemeData.grey100, - borderColor: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200, + color: + isDark + ? AppThemeData.greyDark100 + : AppThemeData.grey100, + borderColor: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, title: 'View All Stores'.tr, onPress: () { - Get.to(const RestaurantListScreen(), arguments: {"vendorList": controller.allNearestRestaurant}); + Get.to( + const RestaurantListScreen(), + arguments: { + "vendorList": + controller.allNearestRestaurant, + }, + ); }, ), ], @@ -783,7 +1426,10 @@ class NewArrivalCard extends StatelessWidget { final isDark = themeController.isDark.value; return InkWell( onTap: () { - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": item}); + Get.to( + const RestaurantDetailsScreen(), + arguments: {"vendorModel": item}, + ); }, child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -794,11 +1440,20 @@ class NewArrivalCard extends StatelessWidget { height: 100, width: double.infinity, fit: BoxFit.cover, - imageUrl: item.photo != null && item.photo!.isNotEmpty ? item.photo.toString() : Constant.placeHolderImage.toString(), + imageUrl: + item.photo != null && item.photo!.isNotEmpty + ? item.photo.toString() + : Constant.placeHolderImage.toString(), ), ), SizedBox(height: 5), - Text(item.title.toString(), style: AppThemeData.semiBoldTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, fontSize: 14)), + Text( + item.title.toString(), + style: AppThemeData.semiBoldTextStyle( + color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + fontSize: 14, + ), + ), Row( children: [ Icon(Icons.location_on, size: 14, color: Colors.grey), @@ -806,14 +1461,23 @@ class NewArrivalCard extends StatelessWidget { Expanded( child: Text( item.location.toString(), - style: AppThemeData.semiBoldTextStyle(fontSize: 12, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500), + style: AppThemeData.semiBoldTextStyle( + fontSize: 12, + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), overflow: TextOverflow.ellipsis, ), ), ], ), Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.warning50 : AppThemeData.warning50, borderRadius: BorderRadius.circular(30)), + decoration: BoxDecoration( + color: isDark ? AppThemeData.warning50 : AppThemeData.warning50, + borderRadius: BorderRadius.circular(30), + ), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6), child: Row( @@ -824,7 +1488,10 @@ class NewArrivalCard extends StatelessWidget { Icon(Icons.star, size: 18, color: AppThemeData.warning400), Text( "${Constant.calculateReview(reviewCount: item.reviewsCount.toString(), reviewSum: item.reviewsSum.toString())} (${item.reviewsSum})", - style: AppThemeData.semiBoldTextStyle(fontSize: 12, color: AppThemeData.warning400), + style: AppThemeData.semiBoldTextStyle( + fontSize: 12, + color: AppThemeData.warning400, + ), ), ], ), @@ -863,18 +1530,33 @@ class BannerView extends StatelessWidget { return InkWell( onTap: () async { if (bannerModel.redirect_type == "store") { - ShowToastDialog.showLoader("Please wait...".tr); - VendorModel? vendorModel = await FireStoreUtils.getVendorById(bannerModel.redirect_id.toString()); + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); + VendorModel? vendorModel = + await FireStoreUtils.getVendorById( + bannerModel.redirect_id.toString(), + ); ShowToastDialog.closeLoader(); - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": vendorModel}); + Get.to( + const RestaurantDetailsScreen(), + arguments: {"vendorModel": vendorModel}, + ); } else if (bannerModel.redirect_type == "product") { - ShowToastDialog.showLoader("Please wait...".tr); - ProductModel? productModel = await FireStoreUtils.getProductById(bannerModel.redirect_id.toString()); - VendorModel? vendorModel = await FireStoreUtils.getVendorById(productModel!.vendorID.toString()); + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); + ProductModel? productModel = + await FireStoreUtils.getProductById( + bannerModel.redirect_id.toString(), + ); + VendorModel? vendorModel = + await FireStoreUtils.getVendorById( + productModel!.vendorID.toString(), + ); ShowToastDialog.closeLoader(); - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": vendorModel}); + Get.to( + const RestaurantDetailsScreen(), + arguments: {"vendorModel": vendorModel}, + ); } else if (bannerModel.redirect_type == "external_link") { final uri = Uri.parse(bannerModel.redirect_id.toString()); if (await canLaunchUrl(uri)) { @@ -886,7 +1568,13 @@ class BannerView extends StatelessWidget { }, child: Padding( padding: const EdgeInsets.only(right: 14), - child: ClipRRect(borderRadius: const BorderRadius.all(Radius.circular(12)), child: NetworkImageWidget(imageUrl: bannerModel.photo.toString(), fit: BoxFit.cover)), + child: ClipRRect( + borderRadius: const BorderRadius.all(Radius.circular(12)), + child: NetworkImageWidget( + imageUrl: bannerModel.photo.toString(), + fit: BoxFit.cover, + ), + ), ), ); }, @@ -904,7 +1592,13 @@ class BannerView extends StatelessWidget { alignment: Alignment.centerLeft, height: 9, width: 9, - decoration: BoxDecoration(shape: BoxShape.circle, color: controller.currentPage.value == index ? AppThemeData.primary300 : Colors.black12), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: + controller.currentPage.value == index + ? AppThemeData.primary300 + : Colors.black12, + ), ), ); }), @@ -942,18 +1636,33 @@ class BannerBottomView extends StatelessWidget { return InkWell( onTap: () async { if (bannerModel.redirect_type == "store") { - ShowToastDialog.showLoader("Please wait...".tr); - VendorModel? vendorModel = await FireStoreUtils.getVendorById(bannerModel.redirect_id.toString()); + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); + VendorModel? vendorModel = + await FireStoreUtils.getVendorById( + bannerModel.redirect_id.toString(), + ); ShowToastDialog.closeLoader(); - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": vendorModel}); + Get.to( + const RestaurantDetailsScreen(), + arguments: {"vendorModel": vendorModel}, + ); } else if (bannerModel.redirect_type == "product") { - ShowToastDialog.showLoader("Please wait...".tr); - ProductModel? productModel = await FireStoreUtils.getProductById(bannerModel.redirect_id.toString()); - VendorModel? vendorModel = await FireStoreUtils.getVendorById(productModel!.vendorID.toString()); + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); + ProductModel? productModel = + await FireStoreUtils.getProductById( + bannerModel.redirect_id.toString(), + ); + VendorModel? vendorModel = + await FireStoreUtils.getVendorById( + productModel!.vendorID.toString(), + ); ShowToastDialog.closeLoader(); - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": vendorModel}); + Get.to( + const RestaurantDetailsScreen(), + arguments: {"vendorModel": vendorModel}, + ); } else if (bannerModel.redirect_type == "external_link") { final uri = Uri.parse(bannerModel.redirect_id.toString()); if (await canLaunchUrl(uri)) { @@ -965,7 +1674,13 @@ class BannerBottomView extends StatelessWidget { }, child: Padding( padding: const EdgeInsets.only(right: 14), - child: ClipRRect(borderRadius: const BorderRadius.all(Radius.circular(12)), child: NetworkImageWidget(imageUrl: bannerModel.photo.toString(), fit: BoxFit.cover)), + child: ClipRRect( + borderRadius: const BorderRadius.all(Radius.circular(12)), + child: NetworkImageWidget( + imageUrl: bannerModel.photo.toString(), + fit: BoxFit.cover, + ), + ), ), ); }, @@ -976,14 +1691,22 @@ class BannerBottomView extends StatelessWidget { child: Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, - children: List.generate(controller.bannerBottomModel.length, (index) { + children: List.generate(controller.bannerBottomModel.length, ( + index, + ) { return Obx( () => Container( margin: const EdgeInsets.only(right: 5), alignment: Alignment.centerLeft, height: 9, width: 9, - decoration: BoxDecoration(shape: BoxShape.circle, color: controller.currentBottomPage.value == index ? AppThemeData.primary300 : Colors.black12), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: + controller.currentBottomPage.value == index + ? AppThemeData.primary300 + : Colors.black12, + ), ), ); }), @@ -998,7 +1721,11 @@ class AdvertisementHomeCard extends StatelessWidget { final AdvertisementModel model; final HomeECommerceController controller; - const AdvertisementHomeCard({super.key, required this.controller, required this.model}); + const AdvertisementHomeCard({ + super.key, + required this.controller, + required this.model, + }); @override Widget build(BuildContext context) { @@ -1006,10 +1733,15 @@ class AdvertisementHomeCard extends StatelessWidget { final isDark = themeController.isDark.value; return InkWell( onTap: () async { - ShowToastDialog.showLoader("Please wait...".tr); - VendorModel? vendorModel = await FireStoreUtils.getVendorById(model.vendorId!); + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); + VendorModel? vendorModel = await FireStoreUtils.getVendorById( + model.vendorId!, + ); ShowToastDialog.closeLoader(); - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": vendorModel}); + Get.to( + const RestaurantDetailsScreen(), + arguments: {"vendorModel": vendorModel}, + ); }, child: Container( margin: EdgeInsets.only(right: 16), @@ -1017,7 +1749,14 @@ class AdvertisementHomeCard extends StatelessWidget { decoration: BoxDecoration( color: isDark ? AppThemeData.info600 : AppThemeData.surface, borderRadius: BorderRadius.circular(16), - boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.1), blurRadius: isDark ? 6 : 2, spreadRadius: 0, offset: Offset(0, isDark ? 3 : 1))], + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.1), + blurRadius: isDark ? 6 : 2, + spreadRadius: 0, + offset: Offset(0, isDark ? 3 : 1), + ), + ], ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -1026,18 +1765,32 @@ class AdvertisementHomeCard extends StatelessWidget { children: [ model.type == 'restaurant_promotion' ? ClipRRect( - borderRadius: BorderRadius.vertical(top: Radius.circular(16)), - child: NetworkImageWidget(imageUrl: model.coverImage ?? '', height: 135, width: double.infinity, fit: BoxFit.cover), + borderRadius: BorderRadius.vertical( + top: Radius.circular(16), + ), + child: NetworkImageWidget( + imageUrl: model.coverImage ?? '', + height: 135, + width: double.infinity, + fit: BoxFit.cover, + ), ) - : VideoAdvWidget(url: model.video ?? '', height: 135, width: double.infinity), - if (model.type != 'video_promotion' && model.vendorId != null && (model.showRating == true || model.showReview == true)) + : VideoAdvWidget( + url: model.video ?? '', + height: 135, + width: double.infinity, + ), + if (model.type != 'video_promotion' && + model.vendorId != null && + (model.showRating == true || model.showReview == true)) Positioned( bottom: 8, right: 8, child: FutureBuilder( future: FireStoreUtils.getVendorById(model.vendorId!), builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { + if (snapshot.connectionState == + ConnectionState.waiting) { return const SizedBox(); } else { if (snapshot.hasError) { @@ -1047,16 +1800,43 @@ class AdvertisementHomeCard extends StatelessWidget { } else { VendorModel vendorModel = snapshot.data!; return Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.primary600 : AppThemeData.primary50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.primary600 + : AppThemeData.primary50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(120), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 8, + ), child: Row( children: [ - if (model.showRating == true) SvgPicture.asset("assets/icons/ic_star.svg", colorFilter: ColorFilter.mode(AppThemeData.primary300, BlendMode.srcIn)), - if (model.showRating == true) const SizedBox(width: 5), + if (model.showRating == true) + SvgPicture.asset( + "assets/icons/ic_star.svg", + colorFilter: ColorFilter.mode( + AppThemeData.primary300, + BlendMode.srcIn, + ), + ), + if (model.showRating == true) + const SizedBox(width: 5), Text( "${model.showRating == true ? Constant.calculateReview(reviewCount: vendorModel.reviewsCount!.toStringAsFixed(0), reviewSum: vendorModel.reviewsSum.toString()) : ''} ${model.showReview == true ? '(${vendorModel.reviewsCount!.toStringAsFixed(0)})' : ''}", - style: TextStyle(fontSize: 14, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600), + style: TextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w600, + ), ), ], ), @@ -1075,7 +1855,15 @@ class AdvertisementHomeCard extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ if (model.type == 'restaurant_promotion') - ClipRRect(borderRadius: BorderRadius.circular(30), child: NetworkImageWidget(imageUrl: model.profileImage ?? '', height: 50, width: 50, fit: BoxFit.cover)), + ClipRRect( + borderRadius: BorderRadius.circular(30), + child: NetworkImageWidget( + imageUrl: model.profileImage ?? '', + height: 50, + width: 50, + fit: BoxFit.cover, + ), + ), SizedBox(width: 8), Expanded( child: Column( @@ -1083,12 +1871,26 @@ class AdvertisementHomeCard extends StatelessWidget { children: [ Text( model.title ?? '', - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 14, fontWeight: FontWeight.bold), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 14, + fontWeight: FontWeight.bold, + ), overflow: TextOverflow.ellipsis, ), Text( model.description ?? '', - style: TextStyle(fontSize: 12, fontFamily: AppThemeData.medium, color: isDark ? AppThemeData.grey400 : AppThemeData.grey600), + style: TextStyle( + fontSize: 12, + fontFamily: AppThemeData.medium, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey600, + ), overflow: TextOverflow.ellipsis, maxLines: 2, ), @@ -1099,26 +1901,73 @@ class AdvertisementHomeCard extends StatelessWidget { ? IconButton( icon: Obx( () => - controller.favouriteList.where((p0) => p0.restaurantId == model.vendorId).isNotEmpty - ? SvgPicture.asset("assets/icons/ic_like_fill.svg") - : SvgPicture.asset("assets/icons/ic_like.svg", colorFilter: ColorFilter.mode(isDark ? AppThemeData.grey400 : AppThemeData.grey600, BlendMode.srcIn)), + controller.favouriteList + .where( + (p0) => + p0.restaurantId == model.vendorId, + ) + .isNotEmpty + ? SvgPicture.asset( + "assets/icons/ic_like_fill.svg", + ) + : SvgPicture.asset( + "assets/icons/ic_like.svg", + colorFilter: ColorFilter.mode( + isDark + ? AppThemeData.grey400 + : AppThemeData.grey600, + BlendMode.srcIn, + ), + ), ), onPressed: () async { - if (controller.favouriteList.where((p0) => p0.restaurantId == model.vendorId).isNotEmpty) { - FavouriteModel favouriteModel = FavouriteModel(restaurantId: model.vendorId, userId: FireStoreUtils.getCurrentUid()); - controller.favouriteList.removeWhere((item) => item.restaurantId == model.vendorId); - await FireStoreUtils.removeFavouriteRestaurant(favouriteModel); + if (controller.favouriteList + .where((p0) => p0.restaurantId == model.vendorId) + .isNotEmpty) { + FavouriteModel favouriteModel = FavouriteModel( + restaurantId: model.vendorId, + userId: FireStoreUtils.getCurrentUid(), + ); + controller.favouriteList.removeWhere( + (item) => item.restaurantId == model.vendorId, + ); + await FireStoreUtils.removeFavouriteRestaurant( + favouriteModel, + ); } else { - FavouriteModel favouriteModel = FavouriteModel(restaurantId: model.vendorId, userId: FireStoreUtils.getCurrentUid()); + FavouriteModel favouriteModel = FavouriteModel( + restaurantId: model.vendorId, + userId: FireStoreUtils.getCurrentUid(), + ); controller.favouriteList.add(favouriteModel); - await FireStoreUtils.setFavouriteRestaurant(favouriteModel); + await FireStoreUtils.setFavouriteRestaurant( + favouriteModel, + ); } controller.update(); }, ) : Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.primary600 : AppThemeData.primary50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5))), - child: Padding(padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4), child: Icon(Icons.arrow_forward, size: 20, color: AppThemeData.primary300)), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.primary600 + : AppThemeData.primary50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), + ), + ), + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 4, + ), + child: Icon( + Icons.arrow_forward, + size: 20, + color: AppThemeData.primary300, + ), + ), ), ], ), diff --git a/lib/screen_ui/location_enable_screens/address_list_screen.dart b/lib/screen_ui/location_enable_screens/address_list_screen.dart index 2584ba2..accfd1f 100644 --- a/lib/screen_ui/location_enable_screens/address_list_screen.dart +++ b/lib/screen_ui/location_enable_screens/address_list_screen.dart @@ -6,7 +6,9 @@ import 'package:customer/models/user_model.dart'; import 'package:customer/screen_ui/location_enable_screens/enter_manually_location.dart'; import 'package:customer/themes/app_them_data.dart' show AppThemeData; import 'package:customer/themes/round_button_fill.dart'; + import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:get/get.dart'; @@ -37,50 +39,120 @@ class AddressListScreen extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("My Addresses".tr, style: AppThemeData.boldTextStyle(fontSize: 24, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + "My Addresses".tr, + style: AppThemeData.boldTextStyle( + fontSize: 24, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), const SizedBox(height: 5), - Text("Allows users to view, manage, add, or edit delivery addresses.".tr, style: AppThemeData.mediumTextStyle(fontSize: 14, color: AppThemeData.grey600)), + Text( + "Allows users to view, manage, add, or edit delivery addresses." + .tr, + style: AppThemeData.mediumTextStyle( + fontSize: 14, + color: AppThemeData.grey600, + ), + ), const SizedBox(height: 24), Expanded( child: controller.shippingAddressList.isEmpty - ? Constant.showEmptyView(message: "Address not found".tr) + ? Constant.showEmptyView( + message: "Address not found".tr, + ) : ListView.separated( - itemCount: controller.shippingAddressList.length, + itemCount: + controller.shippingAddressList.length, itemBuilder: (context, index) { - ShippingAddress address = controller.shippingAddressList[index]; + ShippingAddress address = + controller.shippingAddressList[index]; return InkWell( onTap: () { Get.back(result: address); }, child: Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Expanded( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Row( children: [ Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.greyDark100 : AppThemeData.grey100, borderRadius: BorderRadius.circular(8)), + decoration: BoxDecoration( + color: + isDark + ? AppThemeData + .greyDark100 + : AppThemeData + .grey100, + borderRadius: + BorderRadius.circular( + 8, + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5), + padding: + const EdgeInsets.symmetric( + horizontal: 10, + vertical: 5, + ), child: Text( - address.addressAs.toString(), - style: AppThemeData.semiBoldTextStyle(fontSize: 12, color: isDark ? AppThemeData.greyDark600 : AppThemeData.grey600), + address.addressAs + .toString(), + style: AppThemeData.semiBoldTextStyle( + fontSize: 12, + color: + isDark + ? AppThemeData + .greyDark600 + : AppThemeData + .grey600, + ), ), ), ), SizedBox(width: 10), address.isDefault == true ? Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.success100 : AppThemeData.success100, borderRadius: BorderRadius.circular(8)), + decoration: BoxDecoration( + color: + isDark + ? AppThemeData + .success100 + : AppThemeData + .success100, + borderRadius: + BorderRadius.circular( + 8, + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5), + padding: + const EdgeInsets.symmetric( + horizontal: + 10, + vertical: 5, + ), child: Text( "Default".tr, - style: AppThemeData.semiBoldTextStyle(fontSize: 12, color: isDark ? AppThemeData.greyDark600 : AppThemeData.grey600), + style: AppThemeData.semiBoldTextStyle( + fontSize: 12, + color: + isDark + ? AppThemeData + .greyDark600 + : AppThemeData + .grey600, + ), ), ), ) @@ -89,35 +161,72 @@ class AddressListScreen extends StatelessWidget { ), SizedBox(height: 10), Text( - address.getFullAddress().toString(), - style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800), + address + .getFullAddress() + .toString(), + style: + AppThemeData.mediumTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData + .greyDark800 + : AppThemeData + .grey800, + ), ), ], ), ), InkWell( onTap: () async { - await controller.deleteAddress(index); + await controller.deleteAddress( + index, + ); }, - child: SvgPicture.asset("assets/icons/ic_delete_address.svg"), + child: SvgPicture.asset( + "assets/icons/ic_delete_address.svg", + ), ), SizedBox(width: 10), InkWell( onTap: () { - Get.to(EnterManuallyLocationScreen(), arguments: {"address": address, "mode": "Edit"})!.then((value) { + Get.to( + EnterManuallyLocationScreen(), + arguments: { + "address": address, + "mode": "Edit", + }, + )!.then((value) { if (value == true) { controller.getUser(); } }); }, - child: SvgPicture.asset("assets/icons/ic_edit_address.svg"), + child: SvgPicture.asset( + "assets/icons/ic_edit_address.svg", + ), ), ], ), ); }, - separatorBuilder: (BuildContext context, int index) { - return Padding(padding: const EdgeInsets.symmetric(vertical: 20), child: Divider(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200, height: 1)); + separatorBuilder: ( + BuildContext context, + int index, + ) { + return Padding( + padding: const EdgeInsets.symmetric( + vertical: 20, + ), + child: Divider( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + height: 1, + ), + ); }, ), ), @@ -125,8 +234,14 @@ class AddressListScreen extends StatelessWidget { ), ), bottomNavigationBar: Padding( - padding: const EdgeInsets.only(bottom: 30, left: 16, right: 16, top: 20), + padding: const EdgeInsets.only( + bottom: 30, + left: 16, + right: 16, + top: 20, + ), child: RoundedButtonFill( + borderRadius: 10.r, title: "Add New Address", onPress: () { Get.to(EnterManuallyLocationScreen())!.then((value) { @@ -137,7 +252,15 @@ class AddressListScreen extends StatelessWidget { }, isRight: false, isCenter: true, - icon: SvgPicture.asset(AppAssets.icPlus, width: 20, height: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.greyDark900), + icon: SvgPicture.asset( + AppAssets.icPlus, + width: 20, + height: 18, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.greyDark900, + ), color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, textColor: isDark ? AppThemeData.grey50 : AppThemeData.grey50, ), diff --git a/lib/screen_ui/location_enable_screens/enter_manually_location.dart b/lib/screen_ui/location_enable_screens/enter_manually_location.dart index f53d8ee..fec9134 100644 --- a/lib/screen_ui/location_enable_screens/enter_manually_location.dart +++ b/lib/screen_ui/location_enable_screens/enter_manually_location.dart @@ -1,3 +1,4 @@ +import 'package:customer/constant/const_texts.dart'; import 'package:customer/constant/constant.dart'; import 'package:customer/models/user_model.dart'; import 'package:customer/service/fire_store_utils.dart'; @@ -6,9 +7,10 @@ import 'package:customer/utils/utils.dart'; import 'package:customer/widget/osm_map/map_picker_page.dart'; import 'package:customer/widget/place_picker/location_picker_screen.dart'; import 'package:customer/widget/place_picker/selected_location_model.dart'; -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; import '../../controllers/enter_manually_location_controller.dart'; import '../../controllers/theme_controller.dart'; import '../../themes/app_them_data.dart'; @@ -38,23 +40,50 @@ class EnterManuallyLocationScreen extends StatelessWidget { controller.isLoading.value ? Constant.loader() : Padding( - padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 15, + vertical: 10, + ), child: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - controller.mode == "Edit" ? "Edit Address".tr : "Add a New Address".tr, - style: AppThemeData.boldTextStyle(fontSize: 24, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + controller.mode == "Edit" + ? "Edit Address".tr + : "Add a New Address".tr, + style: AppThemeData.boldTextStyle( + fontSize: 24, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), const SizedBox(height: 10), - Text("Enter your location details so we can deliver your orders quickly and accurately.".tr, style: AppThemeData.mediumTextStyle(fontSize: 14, color: AppThemeData.grey600)), + Text( + "Enter your location details so we can deliver your orders quickly and accurately." + .tr, + style: AppThemeData.mediumTextStyle( + fontSize: 14, + color: AppThemeData.grey600, + ), + ), const SizedBox(height: 24), Row( children: [ - Expanded(child: Text("Set as Default Address".tr, style: AppThemeData.mediumTextStyle(fontSize: 14, color: AppThemeData.grey600))), + Expanded( + child: Text( + "Set as Default Address".tr, + style: AppThemeData.mediumTextStyle( + fontSize: 14, + color: AppThemeData.grey600, + ), + ), + ), Transform.scale( - scale: 0.7, // Decrease the size (try 0.5, 0.6, etc.) + scale: + 0.7, // Decrease the size (try 0.5, 0.6, etc.) child: Switch( value: controller.isDefault.value, onChanged: (value) { @@ -72,23 +101,53 @@ class EnterManuallyLocationScreen extends StatelessWidget { context: context, onTap: () async { if (Constant.selectedMapType == 'osm') { - final result = await Get.to(() => MapPickerPage()); + final result = await Get.to( + () => MapPickerPage(), + ); if (result != null) { final firstPlace = result; - final lat = firstPlace.coordinates.latitude; - final lng = firstPlace.coordinates.longitude; + final lat = + firstPlace.coordinates.latitude; + final lng = + firstPlace.coordinates.longitude; final address = firstPlace.address; - controller.localityEditingController.value.text = address.toString(); - controller.location.value = UserLocation(latitude: lat, longitude: lng); + controller + .localityEditingController + .value + .text = address.toString(); + controller.location.value = UserLocation( + latitude: lat, + longitude: lng, + ); } } else { - Get.to(LocationPickerScreen())!.then((value) async { + Get.to(LocationPickerScreen())!.then(( + value, + ) async { if (value != null) { - SelectedLocationModel selectedLocationModel = value; + SelectedLocationModel + selectedLocationModel = value; - controller.localityEditingController.value.text = Utils.formatAddress(selectedLocation: selectedLocationModel); - controller.location.value = UserLocation(latitude: selectedLocationModel.latLng!.latitude, longitude: selectedLocationModel.latLng!.longitude); + controller + .localityEditingController + .value + .text = Utils.formatAddress( + selectedLocation: + selectedLocationModel, + ); + controller + .location + .value = UserLocation( + latitude: + selectedLocationModel + .latLng! + .latitude, + longitude: + selectedLocationModel + .latLng! + .longitude, + ); } }); } @@ -107,23 +166,55 @@ class EnterManuallyLocationScreen extends StatelessWidget { context: context, onTap: () async { if (Constant.selectedMapType == 'osm') { - final result = await Get.to(() => MapPickerPage()); + final result = await Get.to( + () => MapPickerPage(), + ); if (result != null) { final firstPlace = result; - final lat = firstPlace.coordinates.latitude; - final lng = firstPlace.coordinates.longitude; + final lat = + firstPlace.coordinates.latitude; + final lng = + firstPlace.coordinates.longitude; final address = firstPlace.address; - controller.localityEditingController.value.text = address.toString(); - controller.location.value = UserLocation(latitude: lat, longitude: lng); + controller + .localityEditingController + .value + .text = address.toString(); + controller + .location + .value = UserLocation( + latitude: lat, + longitude: lng, + ); } } else { - Get.to(LocationPickerScreen())!.then((value) async { + Get.to(LocationPickerScreen())!.then(( + value, + ) async { if (value != null) { - SelectedLocationModel selectedLocationModel = value; + SelectedLocationModel + selectedLocationModel = value; - controller.localityEditingController.value.text = Utils.formatAddress(selectedLocation: selectedLocationModel); - controller.location.value = UserLocation(latitude: selectedLocationModel.latLng!.latitude, longitude: selectedLocationModel.latLng!.longitude); + controller + .localityEditingController + .value + .text = Utils.formatAddress( + selectedLocation: + selectedLocationModel, + ); + controller + .location + .value = UserLocation( + latitude: + selectedLocationModel + .latLng! + .latitude, + longitude: + selectedLocationModel + .latLng! + .longitude, + ); Get.back(); } }); @@ -131,20 +222,50 @@ class EnterManuallyLocationScreen extends StatelessWidget { }, ); }, - child: Padding(padding: const EdgeInsets.only(right: 10), child: Icon(Icons.gps_fixed, size: 24, color: AppThemeData.ecommerce300)), + child: Padding( + padding: const EdgeInsets.only(right: 10), + child: Icon( + Icons.gps_fixed, + size: 24, + color: AppThemeData.ecommerce300, + ), + ), ), ), ), const SizedBox(height: 15), - TextFieldWidget(title: "Flat/House/Floor/Building*".tr, hintText: "Enter address details".tr, controller: controller.houseBuildingTextEditingController.value), + TextFieldWidget( + title: "Flat/House/Floor/Building*".tr, + hintText: "Enter address details".tr, + controller: + controller + .houseBuildingTextEditingController + .value, + ), const SizedBox(height: 15), - TextFieldWidget(title: "Area/Sector/Locality*".tr, hintText: "Enter area/locality".tr, controller: controller.localityEditingController.value), + TextFieldWidget( + title: "Area/Sector/Locality*".tr, + hintText: "Enter area/locality".tr, + controller: + controller.localityEditingController.value, + ), const SizedBox(height: 15), - TextFieldWidget(title: "Nearby Landmark".tr, hintText: "Add a landmark".tr, controller: controller.landmarkEditingController.value), + TextFieldWidget( + title: "Nearby Landmark".tr, + hintText: "Add a landmark".tr, + controller: + controller.landmarkEditingController.value, + ), const SizedBox(height: 30), Container(height: 1, color: AppThemeData.grey200), const SizedBox(height: 25), - Text("Save Address As".tr, style: AppThemeData.boldTextStyle(fontSize: 14, color: AppThemeData.grey900)), + Text( + "Save Address As".tr, + style: AppThemeData.boldTextStyle( + fontSize: 14, + color: AppThemeData.grey900, + ), + ), const SizedBox(height: 10), Wrap( spacing: 10, @@ -153,17 +274,37 @@ class EnterManuallyLocationScreen extends StatelessWidget { .map( (item) => GestureDetector( onTap: () { - controller.selectedSaveAs.value = item; + controller.selectedSaveAs.value = + item; }, child: Container( decoration: BoxDecoration( - color: controller.selectedSaveAs.value == item ? AppThemeData.primary300 : AppThemeData.grey100, - borderRadius: BorderRadius.circular(10), + color: + controller + .selectedSaveAs + .value == + item + ? AppThemeData.primary300 + : AppThemeData.grey100, + borderRadius: BorderRadius.circular( + 10, + ), + ), + padding: const EdgeInsets.symmetric( + horizontal: 20, + vertical: 10, ), - padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10), child: Text( controller.getLocalizedSaveAs(item), - style: AppThemeData.mediumTextStyle(color: controller.selectedSaveAs.value == item ? AppThemeData.grey50 : AppThemeData.grey600), + style: AppThemeData.mediumTextStyle( + color: + controller + .selectedSaveAs + .value == + item + ? AppThemeData.grey50 + : AppThemeData.grey600, + ), textAlign: TextAlign.center, ), ), @@ -173,54 +314,111 @@ class EnterManuallyLocationScreen extends StatelessWidget { ), const SizedBox(height: 30), RoundedButtonFill( + borderRadius: 10.r, title: "Save Address".tr, color: AppThemeData.primary300, textColor: AppThemeData.grey50, onPress: () async { - if (controller.location.value.latitude == null || controller.location.value.longitude == null) { - ShowToastDialog.showToast("Please select Location".tr); - } else if (controller.houseBuildingTextEditingController.value.text.isEmpty) { - ShowToastDialog.showToast("Please Enter Flat / House / Floor / Building".tr); - } else if (controller.localityEditingController.value.text.isEmpty) { - ShowToastDialog.showToast("Please Enter Area / Sector / Locality".tr); + if (controller.location.value.latitude == null || + controller.location.value.longitude == null) { + ShowToastDialog.showToast( + "Please select Location".tr, + ); + } else if (controller + .houseBuildingTextEditingController + .value + .text + .isEmpty) { + ShowToastDialog.showToast( + "Please Enter Flat / House / Floor / Building" + .tr, + ); + } else if (controller + .localityEditingController + .value + .text + .isEmpty) { + ShowToastDialog.showToast( + "Please Enter Area / Sector / Locality".tr, + ); } else { - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader( + ConstTexts.pleaseWait.tr, + ); //Common values - controller.shippingModel.value.location = controller.location.value; - controller.shippingModel.value.addressAs = controller.selectedSaveAs.value; - controller.shippingModel.value.address = controller.houseBuildingTextEditingController.value.text; - controller.shippingModel.value.locality = controller.localityEditingController.value.text; - controller.shippingModel.value.landmark = controller.landmarkEditingController.value.text; + controller.shippingModel.value.location = + controller.location.value; + controller.shippingModel.value.addressAs = + controller.selectedSaveAs.value; + controller.shippingModel.value.address = + controller + .houseBuildingTextEditingController + .value + .text; + controller.shippingModel.value.locality = + controller + .localityEditingController + .value + .text; + controller.shippingModel.value.landmark = + controller + .landmarkEditingController + .value + .text; if (controller.mode.value == "Edit") { //Edit Mode controller.shippingAddressList.value = - controller.shippingAddressList.map((address) { - if (address.id == controller.shippingModel.value.id) { - return controller.shippingModel.value; // replace existing one + controller.shippingAddressList.map(( + address, + ) { + if (address.id == + controller.shippingModel.value.id) { + return controller + .shippingModel + .value; // replace existing one } return address; }).toList(); - Constant.selectedLocation = controller.shippingModel.value; + Constant.selectedLocation = + controller.shippingModel.value; } else { //Add Mode - controller.shippingModel.value.id = Constant.getUuid(); - controller.shippingModel.value.isDefault = controller.shippingAddressList.isEmpty ? true : false; - controller.shippingAddressList.add(controller.shippingModel.value); + controller.shippingModel.value.id = + Constant.getUuid(); + controller.shippingModel.value.isDefault = + controller.shippingAddressList.isEmpty + ? true + : false; + controller.shippingAddressList.add( + controller.shippingModel.value, + ); } //Handle default address switch if (controller.isDefault.value) { controller.shippingAddressList.value = - controller.shippingAddressList.map((address) { - address.isDefault = address.id == controller.shippingModel.value.id ? true : false; + controller.shippingAddressList.map(( + address, + ) { + address.isDefault = + address.id == + controller + .shippingModel + .value + .id + ? true + : false; return address; }).toList(); } - controller.userModel.value.shippingAddress = controller.shippingAddressList; - await FireStoreUtils.updateUser(controller.userModel.value); + controller.userModel.value.shippingAddress = + controller.shippingAddressList; + await FireStoreUtils.updateUser( + controller.userModel.value, + ); ShowToastDialog.closeLoader(); Get.back(result: true); diff --git a/lib/screen_ui/location_enable_screens/location_permission_screen.dart b/lib/screen_ui/location_enable_screens/location_permission_screen.dart index 0e0f069..1a7726c 100644 --- a/lib/screen_ui/location_enable_screens/location_permission_screen.dart +++ b/lib/screen_ui/location_enable_screens/location_permission_screen.dart @@ -1,3 +1,4 @@ +import 'package:customer/constant/const_texts.dart'; import 'package:customer/constant/constant.dart'; import 'package:customer/controllers/theme_controller.dart'; import 'package:customer/models/user_model.dart'; @@ -6,14 +7,16 @@ import 'package:customer/screen_ui/service_home_screen/service_list_screen.dart' import 'package:customer/themes/app_them_data.dart'; import 'package:customer/themes/round_button_fill.dart'; import 'package:customer/themes/show_toast_dialog.dart'; +import 'package:customer/utils/app_router.dart'; import 'package:customer/widget/osm_map/map_picker_page.dart'; import 'package:customer/widget/place_picker/location_picker_screen.dart'; import 'package:customer/widget/place_picker/selected_location_model.dart'; + import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:geocoding/geocoding.dart'; import 'package:geolocator/geolocator.dart'; import 'package:get/get.dart'; - import '../../constant/assets.dart'; import '../../utils/utils.dart'; @@ -38,8 +41,14 @@ class LocationPermissionScreen extends StatelessWidget { Padding( padding: const EdgeInsets.symmetric(horizontal: 25), child: Text( - "Enable Location for a Personalized Experience".tr, - style: AppThemeData.boldTextStyle(fontSize: 24, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + ConstTexts.enableLocation.tr, + style: AppThemeData.boldTextStyle( + fontSize: 24.sp, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), textAlign: TextAlign.center, ), ), @@ -47,50 +56,75 @@ class LocationPermissionScreen extends StatelessWidget { Padding( padding: const EdgeInsets.symmetric(horizontal: 50), child: Text( - "Allow location access to discover beauty stores and services near you.".tr, - style: AppThemeData.mediumTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark600 : AppThemeData.grey600), + ConstTexts.allowLocation.tr, + style: AppThemeData.mediumTextStyle( + fontSize: 16.sp, + color: + isDark + ? AppThemeData.greyDark600 + : AppThemeData.grey600, + ), textAlign: TextAlign.center, ), ), const SizedBox(height: 30), RoundedButtonFill( - title: "Use current location".tr, + borderRadius: 10.r, + fontSizes: 14.sp, + title: ConstTexts.useCurrentLocation.tr, onPress: () async { Constant.checkPermission( context: context, onTap: () async { - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); ShippingAddress addressModel = ShippingAddress(); try { await Geolocator.requestPermission(); - Position newLocalData = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high); - await placemarkFromCoordinates(newLocalData.latitude, newLocalData.longitude).then((valuePlaceMaker) { + Position newLocalData = + await Geolocator.getCurrentPosition( + desiredAccuracy: LocationAccuracy.high, + ); + await placemarkFromCoordinates( + newLocalData.latitude, + newLocalData.longitude, + ).then((valuePlaceMaker) { Placemark placeMark = valuePlaceMaker[0]; addressModel.addressAs = "Home"; - addressModel.location = UserLocation(latitude: newLocalData.latitude, longitude: newLocalData.longitude); + addressModel.location = UserLocation( + latitude: newLocalData.latitude, + longitude: newLocalData.longitude, + ); String currentLocation = "${placeMark.name}, ${placeMark.subLocality}, ${placeMark.locality}, ${placeMark.administrativeArea}, ${placeMark.postalCode}, ${placeMark.country}"; addressModel.locality = currentLocation; }); Constant.selectedLocation = addressModel; - Constant.currentLocation = await Utils.getCurrentLocation(); + Constant.currentLocation = + await Utils.getCurrentLocation(); ShowToastDialog.closeLoader(); Get.offAll(const ServiceListScreen()); } catch (e) { - await placemarkFromCoordinates(19.228825, 72.854118).then((valuePlaceMaker) { + await placemarkFromCoordinates( + 19.228825, + 72.854118, + ).then((valuePlaceMaker) { Placemark placeMark = valuePlaceMaker[0]; addressModel.addressAs = "Home"; - addressModel.location = UserLocation(latitude: 19.228825, longitude: 72.854118); + addressModel.location = UserLocation( + latitude: 19.228825, + longitude: 72.854118, + ); String currentLocation = "${placeMark.name}, ${placeMark.subLocality}, ${placeMark.locality}, ${placeMark.administrativeArea}, ${placeMark.postalCode}, ${placeMark.country}"; addressModel.locality = currentLocation; }); Constant.selectedLocation = addressModel; - Constant.currentLocation = await Utils.getCurrentLocation(); + Constant.currentLocation = + await Utils.getCurrentLocation(); ShowToastDialog.closeLoader(); @@ -104,16 +138,20 @@ class LocationPermissionScreen extends StatelessWidget { ), const SizedBox(height: 10), RoundedButtonFill( - title: "Set from map".tr, + borderRadius: 10.r, + fontSizes: 14.sp, + title: ConstTexts.setFromMap.tr, onPress: () async { Constant.checkPermission( context: context, onTap: () async { - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); ShippingAddress addressModel = ShippingAddress(); try { await Geolocator.requestPermission(); - await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high); + await Geolocator.getCurrentPosition( + desiredAccuracy: LocationAccuracy.high, + ); ShowToastDialog.closeLoader(); if (Constant.selectedMapType == 'osm') { final result = await Get.to(() => MapPickerPage()); @@ -125,18 +163,29 @@ class LocationPermissionScreen extends StatelessWidget { addressModel.addressAs = "Home"; addressModel.locality = address.toString(); - addressModel.location = UserLocation(latitude: lat, longitude: lng); + addressModel.location = UserLocation( + latitude: lat, + longitude: lng, + ); Constant.selectedLocation = addressModel; Get.offAll(const ServiceListScreen()); } } else { Get.to(LocationPickerScreen())!.then((value) async { if (value != null) { - SelectedLocationModel selectedLocationModel = value; + SelectedLocationModel selectedLocationModel = + value; addressModel.addressAs = "Home"; - addressModel.locality = Utils.formatAddress(selectedLocation: selectedLocationModel); - addressModel.location = UserLocation(latitude: selectedLocationModel.latLng!.latitude, longitude: selectedLocationModel.latLng!.longitude); + addressModel.locality = Utils.formatAddress( + selectedLocation: selectedLocationModel, + ); + addressModel.location = UserLocation( + latitude: + selectedLocationModel.latLng!.latitude, + longitude: + selectedLocationModel.latLng!.longitude, + ); Constant.selectedLocation = addressModel; Get.offAll(const ServiceListScreen()); @@ -144,10 +193,16 @@ class LocationPermissionScreen extends StatelessWidget { }); } } catch (e) { - await placemarkFromCoordinates(19.228825, 72.854118).then((valuePlaceMaker) { + await placemarkFromCoordinates( + 19.228825, + 72.854118, + ).then((valuePlaceMaker) { Placemark placeMark = valuePlaceMaker[0]; addressModel.addressAs = "Home"; - addressModel.location = UserLocation(latitude: 19.228825, longitude: 72.854118); + addressModel.location = UserLocation( + latitude: 19.228825, + longitude: 72.854118, + ); String currentLocation = "${placeMark.name}, ${placeMark.subLocality}, ${placeMark.locality}, ${placeMark.administrativeArea}, ${placeMark.postalCode}, ${placeMark.country}"; addressModel.locality = currentLocation; @@ -177,7 +232,16 @@ class LocationPermissionScreen extends StatelessWidget { } }); }, - child: Text("Enter Manually location".tr, style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + child: Text( + ConstTexts.enterManuallyLocation.tr, + style: AppThemeData.semiBoldTextStyle( + fontSize: 16.sp, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), ), ], ), diff --git a/lib/screen_ui/maintenance_mode_screen/maintenance_mode_screen.dart b/lib/screen_ui/maintenance_mode_screen/maintenance_mode_screen.dart index e95bc4f..188dc9e 100644 --- a/lib/screen_ui/maintenance_mode_screen/maintenance_mode_screen.dart +++ b/lib/screen_ui/maintenance_mode_screen/maintenance_mode_screen.dart @@ -1,4 +1,5 @@ import 'package:customer/themes/app_them_data.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -13,14 +14,24 @@ class MaintenanceModeScreen extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Center(child: Image.asset('assets/images/maintenance.png', height: 200, width: 200)), + Center( + child: Image.asset( + 'assets/images/maintenance.png', + height: 200, + width: 200, + ), + ), const SizedBox(height: 20), - Text("We'll be back soon!".tr, style: const TextStyle(fontSize: 24, fontWeight: FontWeight.bold)), + Text( + "We'll be back soon!".tr, + style: const TextStyle(fontSize: 24, fontWeight: FontWeight.bold), + ), const SizedBox(height: 10), Padding( padding: const EdgeInsets.symmetric(horizontal: 20.0), child: Text( - "Sorry for the inconvenience but we're performing some maintenance at the moment. We'll be back online shortly!".tr, + "Sorry for the inconvenience but we're performing some maintenance at the moment. We'll be back online shortly!" + .tr, textAlign: TextAlign.center, style: const TextStyle(fontSize: 16), ), diff --git a/lib/screen_ui/multi_vendor_service/advertisement_screens/all_advertisement_screen.dart b/lib/screen_ui/multi_vendor_service/advertisement_screens/all_advertisement_screen.dart index ce39b54..88c6875 100644 --- a/lib/screen_ui/multi_vendor_service/advertisement_screens/all_advertisement_screen.dart +++ b/lib/screen_ui/multi_vendor_service/advertisement_screens/all_advertisement_screen.dart @@ -1,3 +1,4 @@ +import 'package:customer/constant/const_texts.dart'; import 'package:customer/constant/constant.dart'; import 'package:customer/controllers/advertisement_list_controller.dart'; import 'package:customer/models/advertisement_model.dart'; @@ -6,10 +7,10 @@ import 'package:customer/models/vendor_model.dart'; import 'package:customer/themes/app_them_data.dart'; import 'package:customer/themes/responsive.dart'; import 'package:customer/utils/network_image_widget.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:get/get.dart'; - import '../../../controllers/theme_controller.dart'; import '../../../service/fire_store_utils.dart'; import '../../../themes/show_toast_dialog.dart'; @@ -29,20 +30,27 @@ class AllAdvertisementScreen extends StatelessWidget { builder: (controller) { return Scaffold( appBar: AppBar( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, centerTitle: false, titleSpacing: 0, title: Text( "Highlights for you".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 16, + color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + ), ), ), body: controller.isLoading.value ? Constant.loader() : controller.advertisementList.isEmpty - ? Constant.showEmptyView(message: "Highlights for you not found.".tr) + ? Constant.showEmptyView( + message: "Highlights for you not found.".tr, + ) : Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: ListView.builder( @@ -50,7 +58,10 @@ class AllAdvertisementScreen extends StatelessWidget { itemCount: controller.advertisementList.length, padding: EdgeInsets.all(0), itemBuilder: (BuildContext context, int index) { - return AdvertisementCard(controller: controller, model: controller.advertisementList[index]); + return AdvertisementCard( + controller: controller, + model: controller.advertisementList[index], + ); }, ), ), @@ -64,7 +75,11 @@ class AdvertisementCard extends StatelessWidget { final AdvertisementModel model; final AdvertisementListController controller; - const AdvertisementCard({super.key, required this.controller, required this.model}); + const AdvertisementCard({ + super.key, + required this.controller, + required this.model, + }); @override Widget build(BuildContext context) { @@ -72,10 +87,15 @@ class AdvertisementCard extends StatelessWidget { final isDark = themeController.isDark.value; return InkWell( onTap: () async { - ShowToastDialog.showLoader("Please wait...".tr); - VendorModel? vendorModel = await FireStoreUtils.getVendorById(model.vendorId!); + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); + VendorModel? vendorModel = await FireStoreUtils.getVendorById( + model.vendorId!, + ); ShowToastDialog.closeLoader(); - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": vendorModel}); + Get.to( + const RestaurantDetailsScreen(), + arguments: {"vendorModel": vendorModel}, + ); }, child: Container( margin: EdgeInsets.only(bottom: 16), @@ -83,7 +103,14 @@ class AdvertisementCard extends StatelessWidget { decoration: BoxDecoration( color: isDark ? AppThemeData.info600 : AppThemeData.surface, borderRadius: BorderRadius.circular(16), - boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.1), blurRadius: isDark ? 6 : 2, spreadRadius: 0, offset: Offset(0, isDark ? 3 : 1))], + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.1), + blurRadius: isDark ? 6 : 2, + spreadRadius: 0, + offset: Offset(0, isDark ? 3 : 1), + ), + ], ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -92,18 +119,32 @@ class AdvertisementCard extends StatelessWidget { children: [ model.type == 'restaurant_promotion' ? ClipRRect( - borderRadius: BorderRadius.vertical(top: Radius.circular(16)), - child: NetworkImageWidget(imageUrl: model.coverImage ?? '', height: 150, width: double.infinity, fit: BoxFit.cover), + borderRadius: BorderRadius.vertical( + top: Radius.circular(16), + ), + child: NetworkImageWidget( + imageUrl: model.coverImage ?? '', + height: 150, + width: double.infinity, + fit: BoxFit.cover, + ), ) - : VideoAdvWidget(url: model.video ?? '', height: 150, width: double.infinity), - if (model.type != 'video_promotion' && model.vendorId != null && (model.showRating == true || model.showReview == true)) + : VideoAdvWidget( + url: model.video ?? '', + height: 150, + width: double.infinity, + ), + if (model.type != 'video_promotion' && + model.vendorId != null && + (model.showRating == true || model.showReview == true)) Positioned( bottom: 8, right: 8, child: FutureBuilder( future: FireStoreUtils.getVendorById(model.vendorId!), builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { + if (snapshot.connectionState == + ConnectionState.waiting) { return const SizedBox(); } else { if (snapshot.hasError) { @@ -113,16 +154,42 @@ class AdvertisementCard extends StatelessWidget { } else { VendorModel vendorModel = snapshot.data!; return Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.primary600 : AppThemeData.primary50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.primary600 + : AppThemeData.primary50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(120), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 8, + ), child: Row( children: [ - if (model.showRating == true) SvgPicture.asset("assets/icons/ic_star.svg", colorFilter: ColorFilter.mode(AppThemeData.primary300, BlendMode.srcIn)), - if (model.showRating == true) const SizedBox(width: 5), + if (model.showRating == true) + SvgPicture.asset( + "assets/icons/ic_star.svg", + colorFilter: ColorFilter.mode( + AppThemeData.primary300, + BlendMode.srcIn, + ), + ), + if (model.showRating == true) + const SizedBox(width: 5), Text( "${model.showRating == true ? Constant.calculateReview(reviewCount: vendorModel.reviewsCount!.toStringAsFixed(0), reviewSum: vendorModel.reviewsSum.toString()) : ''}${model.showRating == true && model.showReview == true ? ' ' : ''}${model.showReview == true ? '(${vendorModel.reviewsCount!.toStringAsFixed(0)})' : ''}", - style: TextStyle(color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600), + style: TextStyle( + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w600, + ), ), ], ), @@ -141,7 +208,15 @@ class AdvertisementCard extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ if (model.type == 'restaurant_promotion') - ClipRRect(borderRadius: BorderRadius.circular(30), child: NetworkImageWidget(imageUrl: model.profileImage ?? '', height: 50, width: 50, fit: BoxFit.cover)), + ClipRRect( + borderRadius: BorderRadius.circular(30), + child: NetworkImageWidget( + imageUrl: model.profileImage ?? '', + height: 50, + width: 50, + fit: BoxFit.cover, + ), + ), SizedBox(width: 8), Expanded( child: Column( @@ -149,12 +224,26 @@ class AdvertisementCard extends StatelessWidget { children: [ Text( model.title ?? '', - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16, fontWeight: FontWeight.bold), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 16, + fontWeight: FontWeight.bold, + ), overflow: TextOverflow.ellipsis, ), Text( model.description ?? '', - style: TextStyle(fontSize: 14, fontFamily: AppThemeData.medium, color: isDark ? AppThemeData.grey400 : AppThemeData.grey600), + style: TextStyle( + fontSize: 14, + fontFamily: AppThemeData.medium, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey600, + ), overflow: TextOverflow.ellipsis, maxLines: 2, ), @@ -165,25 +254,74 @@ class AdvertisementCard extends StatelessWidget { ? Obx( () => IconButton( icon: - controller.favouriteList.where((p0) => p0.restaurantId == model.vendorId).isNotEmpty - ? SvgPicture.asset("assets/icons/ic_like_fill.svg") - : SvgPicture.asset("assets/icons/ic_like.svg", colorFilter: ColorFilter.mode(isDark ? AppThemeData.grey400 : AppThemeData.grey600, BlendMode.srcIn)), + controller.favouriteList + .where( + (p0) => + p0.restaurantId == model.vendorId, + ) + .isNotEmpty + ? SvgPicture.asset( + "assets/icons/ic_like_fill.svg", + ) + : SvgPicture.asset( + "assets/icons/ic_like.svg", + colorFilter: ColorFilter.mode( + isDark + ? AppThemeData.grey400 + : AppThemeData.grey600, + BlendMode.srcIn, + ), + ), onPressed: () async { - if (controller.favouriteList.where((p0) => p0.restaurantId == model.vendorId).isNotEmpty) { - FavouriteModel favouriteModel = FavouriteModel(restaurantId: model.vendorId, userId: FireStoreUtils.getCurrentUid()); - controller.favouriteList.removeWhere((item) => item.restaurantId == model.vendorId); - await FireStoreUtils.removeFavouriteRestaurant(favouriteModel); + if (controller.favouriteList + .where( + (p0) => p0.restaurantId == model.vendorId, + ) + .isNotEmpty) { + FavouriteModel favouriteModel = FavouriteModel( + restaurantId: model.vendorId, + userId: FireStoreUtils.getCurrentUid(), + ); + controller.favouriteList.removeWhere( + (item) => item.restaurantId == model.vendorId, + ); + await FireStoreUtils.removeFavouriteRestaurant( + favouriteModel, + ); } else { - FavouriteModel favouriteModel = FavouriteModel(restaurantId: model.vendorId, userId: FireStoreUtils.getCurrentUid()); + FavouriteModel favouriteModel = FavouriteModel( + restaurantId: model.vendorId, + userId: FireStoreUtils.getCurrentUid(), + ); controller.favouriteList.add(favouriteModel); - await FireStoreUtils.setFavouriteRestaurant(favouriteModel); + await FireStoreUtils.setFavouriteRestaurant( + favouriteModel, + ); } }, ), ) : Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.primary600 : AppThemeData.primary50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5))), - child: Padding(padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4), child: Icon(Icons.arrow_forward, size: 20, color: AppThemeData.primary300)), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.primary600 + : AppThemeData.primary50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), + ), + ), + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 4, + ), + child: Icon( + Icons.arrow_forward, + size: 20, + color: AppThemeData.primary300, + ), + ), ), ], ), diff --git a/lib/screen_ui/multi_vendor_service/cart_screen/cart_screen.dart b/lib/screen_ui/multi_vendor_service/cart_screen/cart_screen.dart index 03a0869..47499f8 100644 --- a/lib/screen_ui/multi_vendor_service/cart_screen/cart_screen.dart +++ b/lib/screen_ui/multi_vendor_service/cart_screen/cart_screen.dart @@ -14,11 +14,12 @@ import 'package:customer/themes/responsive.dart'; import 'package:customer/themes/round_button_fill.dart'; import 'package:customer/themes/text_field_widget.dart'; import 'package:customer/utils/network_image_widget.dart'; + import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:get/get.dart'; - import '../../../controllers/theme_controller.dart'; import '../../../models/user_model.dart'; import '../../../service/fire_store_utils.dart'; @@ -39,8 +40,12 @@ class CartScreen extends StatelessWidget { init: CartController(), builder: (controller) { return Scaffold( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, - appBar: AppBar(backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface), + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + appBar: AppBar( + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + ), body: cartItem.isEmpty ? Constant.showEmptyView(message: "Item Not available".tr) @@ -51,17 +56,28 @@ class CartScreen extends StatelessWidget { controller.selectedFoodType.value == 'TakeAway' ? const SizedBox() : Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), + padding: const EdgeInsets.symmetric( + horizontal: 16, + ), child: InkWell( onTap: () { Get.to(AddressListScreen())!.then((value) { if (value != null) { ShippingAddress shippingAddress = value; - if (Constant.checkZoneCheck(shippingAddress.location!.latitude ?? 0.0, shippingAddress.location!.longitude ?? 0.0)) { - controller.selectedAddress.value = shippingAddress; + if (Constant.checkZoneCheck( + shippingAddress.location!.latitude ?? + 0.0, + shippingAddress.location!.longitude ?? + 0.0, + )) { + controller.selectedAddress.value = + shippingAddress; controller.calculatePrice(); } else { - ShowToastDialog.showToast("Service not available in this area".tr); + ShowToastDialog.showToast( + "Service not available in this area" + .tr, + ); } } }); @@ -69,33 +85,71 @@ class CartScreen extends StatelessWidget { child: Column( children: [ Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular( + 8, + ), + ), + ), child: Padding( padding: const EdgeInsets.all(10), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ - SvgPicture.asset("assets/icons/ic_send_one.svg"), + SvgPicture.asset( + "assets/icons/ic_send_one.svg", + ), const SizedBox(width: 10), Expanded( child: Text( - controller.selectedAddress.value.addressAs.toString(), + controller + .selectedAddress + .value + .addressAs + .toString(), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, fontSize: 16), + style: TextStyle( + fontFamily: + AppThemeData.semiBold, + color: + isDark + ? AppThemeData + .primary300 + : AppThemeData + .primary300, + fontSize: 16, + ), ), ), - SvgPicture.asset("assets/icons/ic_down.svg"), + SvgPicture.asset( + "assets/icons/ic_down.svg", + ), ], ), const SizedBox(height: 5), Text( - controller.selectedAddress.value.getFullAddress(), + controller.selectedAddress.value + .getFullAddress(), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, color: isDark ? AppThemeData.grey400 : AppThemeData.grey500), + style: TextStyle( + fontFamily: AppThemeData.medium, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey500, + ), ), ], ), @@ -109,87 +163,189 @@ class CartScreen extends StatelessWidget { Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10), + padding: const EdgeInsets.symmetric( + vertical: 10, + horizontal: 10, + ), child: ListView.separated( shrinkWrap: true, padding: EdgeInsets.zero, itemCount: cartItem.length, physics: const NeverScrollableScrollPhysics(), itemBuilder: (context, index) { - CartProductModel cartProductModel = cartItem[index]; + CartProductModel cartProductModel = + cartItem[index]; ProductModel? productModel; - FireStoreUtils.getProductById(cartProductModel.id!.split('~').first).then((value) { + FireStoreUtils.getProductById( + cartProductModel.id!.split('~').first, + ).then((value) { productModel = value; }); - print("cartItem[index] :: ${cartItem[index].extras} ::${cartItem[index].extrasPrice}"); + print( + "cartItem[index] :: ${cartItem[index].extras} ::${cartItem[index].extrasPrice}", + ); return InkWell( onTap: () async { - await FireStoreUtils.getVendorById(productModel!.vendorID.toString()).then((value) { + await FireStoreUtils.getVendorById( + productModel!.vendorID.toString(), + ).then((value) { if (value != null) { - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": value}); + Get.to( + const RestaurantDetailsScreen(), + arguments: {"vendorModel": value}, + ); } }); }, child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10), + padding: const EdgeInsets.symmetric( + horizontal: 10, + ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Row( - crossAxisAlignment: CrossAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, children: [ ClipRRect( - borderRadius: const BorderRadius.all(Radius.circular(16)), + borderRadius: + const BorderRadius.all( + Radius.circular(16), + ), child: NetworkImageWidget( - imageUrl: cartProductModel.photo.toString(), - height: Responsive.height(10, context), - width: Responsive.width(20, context), + imageUrl: + cartProductModel.photo + .toString(), + height: Responsive.height( + 10, + context, + ), + width: Responsive.width( + 20, + context, + ), fit: BoxFit.cover, ), ), const SizedBox(width: 10), Expanded( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( "${cartProductModel.name}", - textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + textAlign: + TextAlign.start, + style: TextStyle( + fontFamily: + AppThemeData + .regular, + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, + fontSize: 16, + ), ), - double.parse(cartProductModel.discountPrice.toString()) <= 0 + double.parse( + cartProductModel + .discountPrice + .toString(), + ) <= + 0 ? Text( - Constant.amountShow(amount: cartProductModel.price), + Constant.amountShow( + amount: + cartProductModel + .price, + ), style: TextStyle( fontSize: 16, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, + fontFamily: + AppThemeData + .semiBold, + fontWeight: + FontWeight.w600, ), ) : Row( children: [ Text( - Constant.amountShow(amount: cartProductModel.discountPrice.toString()), + Constant.amountShow( + amount: + cartProductModel + .discountPrice + .toString(), + ), style: TextStyle( fontSize: 16, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, + fontFamily: + AppThemeData + .semiBold, + fontWeight: + FontWeight + .w600, ), ), - const SizedBox(width: 5), + const SizedBox( + width: 5, + ), Text( - Constant.amountShow(amount: cartProductModel.price), + Constant.amountShow( + amount: + cartProductModel + .price, + ), style: TextStyle( fontSize: 14, - decoration: TextDecoration.lineThrough, - decorationColor: isDark ? AppThemeData.grey500 : AppThemeData.grey400, - color: isDark ? AppThemeData.grey500 : AppThemeData.grey400, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + decoration: + TextDecoration + .lineThrough, + decorationColor: + isDark + ? AppThemeData + .grey500 + : AppThemeData + .grey400, + color: + isDark + ? AppThemeData + .grey500 + : AppThemeData + .grey400, + fontFamily: + AppThemeData + .semiBold, + fontWeight: + FontWeight + .w600, ), ), ], @@ -199,76 +355,219 @@ class CartScreen extends StatelessWidget { ), Container( decoration: ShapeDecoration( - color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, - shape: RoundedRectangleBorder(side: const BorderSide(width: 1, color: Color(0xFFD1D5DB)), borderRadius: BorderRadius.circular(200)), + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + side: const BorderSide( + width: 1, + color: Color(0xFFD1D5DB), + ), + borderRadius: + BorderRadius.circular( + 200, + ), + ), ), child: Padding( - padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 5), + padding: + const EdgeInsets.symmetric( + vertical: 5, + horizontal: 5, + ), child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, children: [ InkWell( onTap: () { - controller.addToCart(cartProductModel: cartProductModel, isIncrement: false, quantity: cartProductModel.quantity! - 1); + controller.addToCart( + cartProductModel: + cartProductModel, + isIncrement: false, + quantity: + cartProductModel + .quantity! - + 1, + ); }, - child: Icon(Icons.remove, color: isDark ? AppThemeData.grey100 : AppThemeData.grey800), + child: Icon( + Icons.remove, + color: + isDark + ? AppThemeData + .grey100 + : AppThemeData + .grey800, + ), ), Padding( - padding: const EdgeInsets.symmetric(horizontal: 10), + padding: + const EdgeInsets.symmetric( + horizontal: 10, + ), child: Text( - cartProductModel.quantity.toString(), - textAlign: TextAlign.start, + cartProductModel + .quantity + .toString(), + textAlign: + TextAlign.start, maxLines: 1, style: TextStyle( fontSize: 16, - overflow: TextOverflow.ellipsis, - fontFamily: AppThemeData.medium, - fontWeight: FontWeight.w500, - color: isDark ? AppThemeData.grey100 : AppThemeData.grey800, + overflow: + TextOverflow + .ellipsis, + fontFamily: + AppThemeData + .medium, + fontWeight: + FontWeight.w500, + color: + isDark + ? AppThemeData + .grey100 + : AppThemeData + .grey800, ), ), ), InkWell( onTap: () { - if (productModel!.itemAttribute != null) { - if (productModel!.itemAttribute!.variants!.where((element) => element.variantSku == cartProductModel.variantInfo!.variantSku).isNotEmpty) { + if (productModel! + .itemAttribute != + null) { + if (productModel! + .itemAttribute! + .variants! + .where( + (element) => + element + .variantSku == + cartProductModel + .variantInfo! + .variantSku, + ) + .isNotEmpty) { if (int.parse( - productModel!.itemAttribute!.variants! - .where((element) => element.variantSku == cartProductModel.variantInfo!.variantSku) + productModel! + .itemAttribute! + .variants! + .where( + ( + element, + ) => + element.variantSku == + cartProductModel.variantInfo!.variantSku, + ) .first .variantQuantity .toString(), ) > - (cartProductModel.quantity ?? 0) || + (cartProductModel + .quantity ?? + 0) || int.parse( - productModel!.itemAttribute!.variants! - .where((element) => element.variantSku == cartProductModel.variantInfo!.variantSku) + productModel! + .itemAttribute! + .variants! + .where( + ( + element, + ) => + element.variantSku == + cartProductModel.variantInfo!.variantSku, + ) .first .variantQuantity .toString(), ) == -1) { - controller.addToCart(cartProductModel: cartProductModel, isIncrement: true, quantity: cartProductModel.quantity! + 1); + controller.addToCart( + cartProductModel: + cartProductModel, + isIncrement: + true, + quantity: + cartProductModel + .quantity! + + 1, + ); } else { - ShowToastDialog.showToast("Out of stock".tr); + ShowToastDialog.showToast( + "Out of stock" + .tr, + ); } } else { - if ((productModel!.quantity ?? 0) > (cartProductModel.quantity ?? 0) || productModel!.quantity == -1) { - controller.addToCart(cartProductModel: cartProductModel, isIncrement: true, quantity: cartProductModel.quantity! + 1); + if ((productModel! + .quantity ?? + 0) > + (cartProductModel + .quantity ?? + 0) || + productModel! + .quantity == + -1) { + controller.addToCart( + cartProductModel: + cartProductModel, + isIncrement: + true, + quantity: + cartProductModel + .quantity! + + 1, + ); } else { - ShowToastDialog.showToast("Out of stock".tr); + ShowToastDialog.showToast( + "Out of stock" + .tr, + ); } } } else { - if ((productModel!.quantity ?? 0) > (cartProductModel.quantity ?? 0) || productModel!.quantity == -1) { - controller.addToCart(cartProductModel: cartProductModel, isIncrement: true, quantity: cartProductModel.quantity! + 1); + if ((productModel! + .quantity ?? + 0) > + (cartProductModel + .quantity ?? + 0) || + productModel! + .quantity == + -1) { + controller.addToCart( + cartProductModel: + cartProductModel, + isIncrement: + true, + quantity: + cartProductModel + .quantity! + + 1, + ); } else { - ShowToastDialog.showToast("Out of stock".tr); + ShowToastDialog.showToast( + "Out of stock" + .tr, + ); } } }, - child: Icon(Icons.add, color: isDark ? AppThemeData.grey100 : AppThemeData.grey800), + child: Icon( + Icons.add, + color: + isDark + ? AppThemeData + .grey100 + : AppThemeData + .grey800, + ), ), ], ), @@ -276,47 +575,112 @@ class CartScreen extends StatelessWidget { ), ], ), - cartProductModel.variantInfo == null || cartProductModel.variantInfo!.variantOptions == null || cartProductModel.variantInfo!.variantOptions!.isEmpty + cartProductModel.variantInfo == + null || + cartProductModel + .variantInfo! + .variantOptions == + null || + cartProductModel + .variantInfo! + .variantOptions! + .isEmpty ? Container() : Padding( - padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 10), + padding: + const EdgeInsets.symmetric( + horizontal: 5, + vertical: 10, + ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( "Variants".tr, - textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontSize: 16), + textAlign: + TextAlign.start, + style: TextStyle( + fontFamily: + AppThemeData + .semiBold, + color: + isDark + ? AppThemeData + .grey300 + : AppThemeData + .grey600, + fontSize: 16, + ), ), const SizedBox(height: 5), Wrap( spacing: 6.0, runSpacing: 6.0, children: - List.generate(cartProductModel.variantInfo!.variantOptions!.length, (i) { - return Container( - decoration: ShapeDecoration( - color: isDark ? AppThemeData.grey800 : AppThemeData.grey100, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), - ), - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 5), - child: Text( - "${cartProductModel.variantInfo!.variantOptions!.keys.elementAt(i)} : ${cartProductModel.variantInfo!.variantOptions![cartProductModel.variantInfo!.variantOptions!.keys.elementAt(i)]}", - textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, color: isDark ? AppThemeData.grey500 : AppThemeData.grey400), + List.generate( + cartProductModel + .variantInfo! + .variantOptions! + .length, + (i) { + return Container( + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData + .grey800 + : AppThemeData + .grey100, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 8, + ), + ), ), - ), - ); - }).toList(), + child: Padding( + padding: + const EdgeInsets.symmetric( + horizontal: + 16, + vertical: + 5, + ), + child: Text( + "${cartProductModel.variantInfo!.variantOptions!.keys.elementAt(i)} : ${cartProductModel.variantInfo!.variantOptions![cartProductModel.variantInfo!.variantOptions!.keys.elementAt(i)]}", + textAlign: + TextAlign + .start, + style: TextStyle( + fontFamily: + AppThemeData + .medium, + color: + isDark + ? AppThemeData.grey500 + : AppThemeData.grey400, + ), + ), + ), + ); + }, + ).toList(), ), ], ), ), - cartProductModel.extras == null || cartProductModel.extras!.isEmpty || cartProductModel.extrasPrice == '0' + cartProductModel.extras == null || + cartProductModel + .extras! + .isEmpty || + cartProductModel + .extrasPrice == + '0' ? const SizedBox() : Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ const SizedBox(height: 10), Row( @@ -324,16 +688,51 @@ class CartScreen extends StatelessWidget { Expanded( child: Text( "Addons".tr, - textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontSize: 16), + textAlign: + TextAlign.start, + style: TextStyle( + fontFamily: + AppThemeData + .semiBold, + color: + isDark + ? AppThemeData + .grey300 + : AppThemeData + .grey600, + fontSize: 16, + ), ), ), Text( Constant.amountShow( - amount: (double.parse(cartProductModel.extrasPrice.toString()) * double.parse(cartProductModel.quantity.toString())).toString(), + amount: + (double.parse( + cartProductModel + .extrasPrice + .toString(), + ) * + double.parse( + cartProductModel + .quantity + .toString(), + )) + .toString(), + ), + textAlign: + TextAlign.start, + style: TextStyle( + fontFamily: + AppThemeData + .semiBold, + color: + isDark + ? AppThemeData + .primary300 + : AppThemeData + .primary300, + fontSize: 16, ), - textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, fontSize: 16), ), ], ), @@ -342,22 +741,55 @@ class CartScreen extends StatelessWidget { spacing: 6.0, runSpacing: 6.0, children: - List.generate(cartProductModel.extras!.length, (i) { - return Container( - decoration: ShapeDecoration( - color: isDark ? AppThemeData.grey800 : AppThemeData.grey100, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), - ), - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 5), - child: Text( - cartProductModel.extras![i].toString(), - textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, color: isDark ? AppThemeData.grey500 : AppThemeData.grey400), + List.generate( + cartProductModel + .extras! + .length, + (i) { + return Container( + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData + .grey800 + : AppThemeData + .grey100, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 8, + ), + ), ), - ), - ); - }).toList(), + child: Padding( + padding: + const EdgeInsets.symmetric( + horizontal: + 16, + vertical: + 5, + ), + child: Text( + cartProductModel + .extras![i] + .toString(), + textAlign: + TextAlign + .start, + style: TextStyle( + fontFamily: + AppThemeData + .medium, + color: + isDark + ? AppThemeData.grey500 + : AppThemeData.grey400, + ), + ), + ), + ); + }, + ).toList(), ), ], ), @@ -367,7 +799,17 @@ class CartScreen extends StatelessWidget { ); }, separatorBuilder: (context, index) { - return Padding(padding: const EdgeInsets.symmetric(vertical: 10), child: MySeparator(color: isDark ? AppThemeData.grey700 : AppThemeData.grey200)); + return Padding( + padding: const EdgeInsets.symmetric( + vertical: 10, + ), + child: MySeparator( + color: + isDark + ? AppThemeData.grey700 + : AppThemeData.grey200, + ), + ); }, ), ), @@ -380,44 +822,84 @@ class CartScreen extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "${'Delivery Type'.tr} (${controller.selectedFoodType.value})".tr, + "${'Delivery Type'.tr} (${controller.selectedFoodType.value})" + .tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 16, + ), ), const SizedBox(height: 10), controller.selectedFoodType.value == 'TakeAway' ? const SizedBox() : Container( width: Responsive.width(100, context), - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), child: Padding( padding: const EdgeInsets.all(10), child: Row( children: [ Expanded( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( "Instant Delivery".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, fontSize: 16), + style: TextStyle( + fontFamily: + AppThemeData.medium, + color: + isDark + ? AppThemeData + .primary300 + : AppThemeData + .primary300, + fontSize: 16, + ), ), const SizedBox(height: 5), Text( "Standard".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 12, color: isDark ? AppThemeData.grey400 : AppThemeData.grey500), + style: TextStyle( + fontFamily: + AppThemeData.medium, + fontSize: 12, + color: + isDark + ? AppThemeData + .grey400 + : AppThemeData + .grey500, + ), ), ], ), ), Radio( - value: controller.deliveryType.value, + value: + controller.deliveryType.value, groupValue: "instant".tr, - activeColor: AppThemeData.primary300, + activeColor: + AppThemeData.primary300, onChanged: (value) { - controller.deliveryType.value = "instant"; + controller.deliveryType.value = + "instant"; }, ), ], @@ -427,18 +909,28 @@ class CartScreen extends StatelessWidget { const SizedBox(height: 10), Container( width: Responsive.width(100, context), - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), child: InkWell( onTap: () { controller.deliveryType.value = "schedule"; BottomPicker.dateTime( onSubmit: (index) { - controller.scheduleDateTime.value = index; + controller.scheduleDateTime.value = + index; }, minDateTime: DateTime.now(), displaySubmitButton: true, pickerTitle: Text('Schedule Time'.tr), - buttonSingleColor: AppThemeData.primary300, + buttonSingleColor: + AppThemeData.primary300, ).show(context); }, child: Padding( @@ -447,18 +939,38 @@ class CartScreen extends StatelessWidget { children: [ Expanded( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( "Schedule Time".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, fontSize: 16), + style: TextStyle( + fontFamily: + AppThemeData.medium, + color: + isDark + ? AppThemeData + .primary300 + : AppThemeData + .primary300, + fontSize: 16, + ), ), const SizedBox(height: 5), Text( "${'Your preferred time'.tr} ${controller.deliveryType.value == "schedule" ? Constant.timestampToDateTime(Timestamp.fromDate(controller.scheduleDateTime.value)) : ""}", textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 12, color: isDark ? AppThemeData.grey400 : AppThemeData.grey500), + style: TextStyle( + fontFamily: + AppThemeData.medium, + fontSize: 12, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData + .grey500, + ), ), ], ), @@ -468,16 +980,28 @@ class CartScreen extends StatelessWidget { groupValue: "schedule".tr, activeColor: AppThemeData.primary300, onChanged: (value) { - controller.deliveryType.value = "schedule"; + controller.deliveryType.value = + "schedule"; BottomPicker.dateTime( - initialDateTime: controller.scheduleDateTime.value, + initialDateTime: + controller + .scheduleDateTime + .value, onSubmit: (index) { - controller.scheduleDateTime.value = index; + controller + .scheduleDateTime + .value = index; }, - minDateTime: controller.scheduleDateTime.value, + minDateTime: + controller + .scheduleDateTime + .value, displaySubmitButton: true, - pickerTitle: Text('Schedule Time'.tr), - buttonSingleColor: AppThemeData.primary300, + pickerTitle: Text( + 'Schedule Time'.tr, + ), + buttonSingleColor: + AppThemeData.primary300, ).show(context); }, ), @@ -498,7 +1022,14 @@ class CartScreen extends StatelessWidget { Text( "Offers & Benefits".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 16, + ), ), const SizedBox(height: 10), InkWell( @@ -508,20 +1039,43 @@ class CartScreen extends StatelessWidget { child: Container( width: Responsive.width(100, context), decoration: ShapeDecoration( - color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), - shadows: const [BoxShadow(color: Color(0x14000000), blurRadius: 52, offset: Offset(0, 0), spreadRadius: 0)], + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + shadows: const [ + BoxShadow( + color: Color(0x14000000), + blurRadius: 52, + offset: Offset(0, 0), + spreadRadius: 0, + ), + ], ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 14), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 14, + ), child: Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Expanded( child: Text( "Apply Coupons".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 16, + ), ), ), const SizedBox(height: 5), @@ -543,101 +1097,234 @@ class CartScreen extends StatelessWidget { Text( "Bill Details".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 16, + ), ), const SizedBox(height: 10), Container( width: Responsive.width(100, context), decoration: ShapeDecoration( - color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), - shadows: const [BoxShadow(color: Color(0x14000000), blurRadius: 52, offset: Offset(0, 0), spreadRadius: 0)], + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + shadows: const [ + BoxShadow( + color: Color(0x14000000), + blurRadius: 52, + offset: Offset(0, 0), + spreadRadius: 0, + ), + ], ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 14), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 14, + ), child: Column( children: [ Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Expanded( child: Text( "Item totals".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontSize: 16), + style: TextStyle( + fontFamily: + AppThemeData.regular, + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + fontSize: 16, + ), ), ), Text( - Constant.amountShow(amount: controller.subTotal.value.toString()), + Constant.amountShow( + amount: + controller.subTotal.value + .toString(), + ), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.regular, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 16, + ), ), ], ), const SizedBox(height: 10), - controller.selectedFoodType.value == 'TakeAway' + controller.selectedFoodType.value == + 'TakeAway' ? const SizedBox() : Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Expanded( child: Text( "Delivery Fee".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontSize: 16), + style: TextStyle( + fontFamily: + AppThemeData.regular, + color: + isDark + ? AppThemeData + .grey300 + : AppThemeData + .grey600, + fontSize: 16, + ), ), ), - (controller.vendorModel.value.isSelfDelivery == true && Constant.isSelfDeliveryFeature == true) + (controller + .vendorModel + .value + .isSelfDelivery == + true && + Constant.isSelfDeliveryFeature == + true) ? Text( 'Free Delivery'.tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: AppThemeData.success400, fontSize: 16), + style: TextStyle( + fontFamily: + AppThemeData.regular, + color: + AppThemeData + .success400, + fontSize: 16, + ), ) : Text( - Constant.amountShow(amount: controller.deliveryCharges.value.toString()), + Constant.amountShow( + amount: + controller + .deliveryCharges + .value + .toString(), + ), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + style: TextStyle( + fontFamily: + AppThemeData.regular, + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, + fontSize: 16, + ), ), ], ), const SizedBox(height: 10), - MySeparator(color: isDark ? AppThemeData.grey700 : AppThemeData.grey200), + MySeparator( + color: + isDark + ? AppThemeData.grey700 + : AppThemeData.grey200, + ), const SizedBox(height: 10), Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Expanded( child: Text( "Coupon Discount".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontSize: 16), + style: TextStyle( + fontFamily: + AppThemeData.regular, + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + fontSize: 16, + ), ), ), Text( "- (${Constant.amountShow(amount: controller.couponAmount.value.toString())})", textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.danger300 : AppThemeData.danger300, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.regular, + color: + isDark + ? AppThemeData.danger300 + : AppThemeData.danger300, + fontSize: 16, + ), ), ], ), - controller.vendorModel.value.specialDiscountEnable == true && Constant.specialDiscountOffer == true + controller + .vendorModel + .value + .specialDiscountEnable == + true && + Constant.specialDiscountOffer == + true ? Column( children: [ const SizedBox(height: 10), Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Expanded( child: Text( "Special Discount".tr, - textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontSize: 16), + textAlign: + TextAlign.start, + style: TextStyle( + fontFamily: + AppThemeData + .regular, + color: + isDark + ? AppThemeData + .grey300 + : AppThemeData + .grey600, + fontSize: 16, + ), ), ), Text( "- (${Constant.amountShow(amount: controller.specialDiscountAmount.value.toString())})", textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.danger300 : AppThemeData.danger300, fontSize: 16), + style: TextStyle( + fontFamily: + AppThemeData.regular, + color: + isDark + ? AppThemeData + .danger300 + : AppThemeData + .danger300, + fontSize: 16, + ), ), ], ), @@ -645,63 +1332,135 @@ class CartScreen extends StatelessWidget { ) : const SizedBox(), const SizedBox(height: 10), - controller.selectedFoodType.value == 'TakeAway' || (controller.vendorModel.value.isSelfDelivery == true && Constant.isSelfDeliveryFeature == true) + controller.selectedFoodType.value == + 'TakeAway' || + (controller + .vendorModel + .value + .isSelfDelivery == + true && + Constant.isSelfDeliveryFeature == + true) ? const SizedBox() : Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Expanded( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( "Delivery Tips".tr, - textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontSize: 16), + textAlign: + TextAlign.start, + style: TextStyle( + fontFamily: + AppThemeData + .regular, + color: + isDark + ? AppThemeData + .grey300 + : AppThemeData + .grey600, + fontSize: 16, + ), ), - controller.deliveryTips.value == 0 + controller + .deliveryTips + .value == + 0 ? const SizedBox() : InkWell( onTap: () { - controller.deliveryTips.value = 0; - controller.calculatePrice(); + controller + .deliveryTips + .value = 0; + controller + .calculatePrice(); }, child: Text( "Remove".tr, - textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300), + textAlign: + TextAlign.start, + style: TextStyle( + fontFamily: + AppThemeData + .medium, + color: + isDark + ? AppThemeData + .primary300 + : AppThemeData + .primary300, + ), ), ), ], ), ), Text( - Constant.amountShow(amount: controller.deliveryTips.toString()), + Constant.amountShow( + amount: + controller.deliveryTips + .toString(), + ), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + style: TextStyle( + fontFamily: + AppThemeData.regular, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData + .grey900, + fontSize: 16, + ), ), ], ), const SizedBox(height: 10), - MySeparator(color: isDark ? AppThemeData.grey700 : AppThemeData.grey200), + MySeparator( + color: + isDark + ? AppThemeData.grey700 + : AppThemeData.grey200, + ), const SizedBox(height: 10), ListView.builder( itemCount: Constant.taxList.length, shrinkWrap: true, padding: EdgeInsets.zero, - physics: const NeverScrollableScrollPhysics(), + physics: + const NeverScrollableScrollPhysics(), itemBuilder: (context, index) { - TaxModel taxModel = Constant.taxList[index]; + TaxModel taxModel = + Constant.taxList[index]; return Padding( - padding: const EdgeInsets.symmetric(vertical: 5), + padding: const EdgeInsets.symmetric( + vertical: 5, + ), child: Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Expanded( child: Text( "${taxModel.title.toString()} (${taxModel.type == "fix" ? Constant.amountShow(amount: taxModel.tax) : "${taxModel.tax}%"})", textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontSize: 16), + style: TextStyle( + fontFamily: + AppThemeData.regular, + color: + isDark + ? AppThemeData + .grey300 + : AppThemeData + .grey600, + fontSize: 16, + ), ), ), Text( @@ -709,12 +1468,34 @@ class CartScreen extends StatelessWidget { amount: Constant.calculateTax( amount: - (double.parse(controller.subTotal.value.toString()) - controller.couponAmount.value - controller.specialDiscountAmount.value).toString(), + (double.parse( + controller + .subTotal + .value + .toString(), + ) - + controller + .couponAmount + .value - + controller + .specialDiscountAmount + .value) + .toString(), taxModel: taxModel, ).toString(), ), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + style: TextStyle( + fontFamily: + AppThemeData.regular, + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, + fontSize: 16, + ), ), ], ), @@ -723,19 +1504,39 @@ class CartScreen extends StatelessWidget { ), const SizedBox(height: 10), Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Expanded( child: Text( "To Pay".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontSize: 16), + style: TextStyle( + fontFamily: + AppThemeData.regular, + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + fontSize: 16, + ), ), ), Text( - Constant.amountShow(amount: controller.totalAmount.value.toString()), + Constant.amountShow( + amount: + controller.totalAmount.value + .toString(), + ), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.regular, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 16, + ), ), ], ), @@ -746,10 +1547,15 @@ class CartScreen extends StatelessWidget { ], ), ), - controller.selectedFoodType.value == 'TakeAway' || (controller.vendorModel.value.isSelfDelivery == true && Constant.isSelfDeliveryFeature == true) + controller.selectedFoodType.value == 'TakeAway' || + (controller.vendorModel.value.isSelfDelivery == + true && + Constant.isSelfDeliveryFeature == true) ? const SizedBox() : Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), + padding: const EdgeInsets.symmetric( + horizontal: 16, + ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -757,32 +1563,67 @@ class CartScreen extends StatelessWidget { Text( "Thanks with a tip!".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 16, + ), ), const SizedBox(height: 10), Container( width: Responsive.width(100, context), decoration: ShapeDecoration( - color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), - shadows: const [BoxShadow(color: Color(0x14000000), blurRadius: 52, offset: Offset(0, 0), spreadRadius: 0)], + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + shadows: const [ + BoxShadow( + color: Color(0x14000000), + blurRadius: 52, + offset: Offset(0, 0), + spreadRadius: 0, + ), + ], ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 14), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 14, + ), child: Column( children: [ Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Expanded( child: Text( - "Around the clock, our delivery partners make it happen. Show gratitude with a tip..".tr, + "Around the clock, our delivery partners make it happen. Show gratitude with a tip.." + .tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600), + style: TextStyle( + fontFamily: + AppThemeData.medium, + color: + isDark + ? AppThemeData + .grey300 + : AppThemeData + .grey600, + ), ), ), const SizedBox(width: 10), - SvgPicture.asset("assets/images/ic_tips.svg"), + SvgPicture.asset( + "assets/images/ic_tips.svg", + ), ], ), const SizedBox(height: 20), @@ -791,7 +1632,9 @@ class CartScreen extends StatelessWidget { Expanded( child: InkWell( onTap: () { - controller.deliveryTips.value = 20; + controller + .deliveryTips + .value = 20; controller.calculatePrice(); }, child: Container( @@ -800,25 +1643,47 @@ class CartScreen extends StatelessWidget { side: BorderSide( width: 1, color: - controller.deliveryTips.value == 20 - ? AppThemeData.primary300 + controller + .deliveryTips + .value == + 20 + ? AppThemeData + .primary300 : isDark - ? AppThemeData.grey800 - : AppThemeData.grey100, + ? AppThemeData + .grey800 + : AppThemeData + .grey100, ), - borderRadius: BorderRadius.circular(8), + borderRadius: + BorderRadius.circular( + 8, + ), ), ), child: Padding( - padding: const EdgeInsets.symmetric(vertical: 10), + padding: + const EdgeInsets.symmetric( + vertical: 10, + ), child: Center( child: Text( - Constant.amountShow(amount: "20"), + Constant.amountShow( + amount: "20", + ), style: TextStyle( - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, fontSize: 14, - fontFamily: AppThemeData.medium, - fontWeight: FontWeight.w600, + fontFamily: + AppThemeData + .medium, + fontWeight: + FontWeight.w600, ), ), ), @@ -830,7 +1695,9 @@ class CartScreen extends StatelessWidget { Expanded( child: InkWell( onTap: () { - controller.deliveryTips.value = 30; + controller + .deliveryTips + .value = 30; controller.calculatePrice(); }, child: Container( @@ -839,25 +1706,47 @@ class CartScreen extends StatelessWidget { side: BorderSide( width: 1, color: - controller.deliveryTips.value == 30 - ? AppThemeData.primary300 + controller + .deliveryTips + .value == + 30 + ? AppThemeData + .primary300 : isDark - ? AppThemeData.grey800 - : AppThemeData.grey100, + ? AppThemeData + .grey800 + : AppThemeData + .grey100, ), - borderRadius: BorderRadius.circular(8), + borderRadius: + BorderRadius.circular( + 8, + ), ), ), child: Padding( - padding: const EdgeInsets.symmetric(vertical: 10), + padding: + const EdgeInsets.symmetric( + vertical: 10, + ), child: Center( child: Text( - Constant.amountShow(amount: "30"), + Constant.amountShow( + amount: "30", + ), style: TextStyle( - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, fontSize: 14, - fontFamily: AppThemeData.medium, - fontWeight: FontWeight.w600, + fontFamily: + AppThemeData + .medium, + fontWeight: + FontWeight.w600, ), ), ), @@ -869,7 +1758,9 @@ class CartScreen extends StatelessWidget { Expanded( child: InkWell( onTap: () { - controller.deliveryTips.value = 40; + controller + .deliveryTips + .value = 40; controller.calculatePrice(); }, child: Container( @@ -878,25 +1769,47 @@ class CartScreen extends StatelessWidget { side: BorderSide( width: 1, color: - controller.deliveryTips.value == 40 - ? AppThemeData.primary300 + controller + .deliveryTips + .value == + 40 + ? AppThemeData + .primary300 : isDark - ? AppThemeData.grey800 - : AppThemeData.grey100, + ? AppThemeData + .grey800 + : AppThemeData + .grey100, ), - borderRadius: BorderRadius.circular(8), + borderRadius: + BorderRadius.circular( + 8, + ), ), ), child: Padding( - padding: const EdgeInsets.symmetric(vertical: 10), + padding: + const EdgeInsets.symmetric( + vertical: 10, + ), child: Center( child: Text( - Constant.amountShow(amount: "40"), + Constant.amountShow( + amount: "40", + ), style: TextStyle( - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, fontSize: 14, - fontFamily: AppThemeData.medium, - fontWeight: FontWeight.w600, + fontFamily: + AppThemeData + .medium, + fontWeight: + FontWeight.w600, ), ), ), @@ -910,28 +1823,55 @@ class CartScreen extends StatelessWidget { onTap: () { showDialog( context: context, - builder: (BuildContext context) { - return tipsDialog(controller, isDark); + builder: ( + BuildContext context, + ) { + return tipsDialog( + controller, + isDark, + ); }, ); }, child: Container( decoration: ShapeDecoration( shape: RoundedRectangleBorder( - side: BorderSide(width: 1, color: isDark ? AppThemeData.grey800 : AppThemeData.grey100), - borderRadius: BorderRadius.circular(8), + side: BorderSide( + width: 1, + color: + isDark + ? AppThemeData + .grey800 + : AppThemeData + .grey100, + ), + borderRadius: + BorderRadius.circular( + 8, + ), ), ), child: Padding( - padding: const EdgeInsets.symmetric(vertical: 10), + padding: + const EdgeInsets.symmetric( + vertical: 10, + ), child: Center( child: Text( 'Other'.tr, style: TextStyle( - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, fontSize: 14, - fontFamily: AppThemeData.medium, - fontWeight: FontWeight.w600, + fontFamily: + AppThemeData + .medium, + fontWeight: + FontWeight.w600, ), ), ), @@ -951,7 +1891,16 @@ class CartScreen extends StatelessWidget { const SizedBox(height: 20), Padding( padding: const EdgeInsets.symmetric(horizontal: 16), - child: Column(children: [TextFieldWidget(title: 'Remarks'.tr, controller: controller.reMarkController.value, hintText: 'Write remarks for the store'.tr, maxLine: 4)]), + child: Column( + children: [ + TextFieldWidget( + title: 'Remarks'.tr, + controller: controller.reMarkController.value, + hintText: 'Write remarks for the store'.tr, + maxLine: 4, + ), + ], + ), ), ], ), @@ -960,8 +1909,12 @@ class CartScreen extends StatelessWidget { cartItem.isEmpty ? null : Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50), - height: controller.isCashbackApply.value == true ? 150 : 100, + decoration: BoxDecoration( + color: + isDark ? AppThemeData.grey900 : AppThemeData.grey50, + ), + height: + controller.isCashbackApply.value == true ? 150 : 100, child: Column( children: [ if (controller.isCashbackApply.value == true) @@ -972,77 +1925,240 @@ class CartScreen extends StatelessWidget { children: [ Padding( padding: const EdgeInsets.only(top: 8), - child: Text("Cashback Offer".tr, style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.semiBold, fontSize: 13)), + child: Text( + "Cashback Offer".tr, + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.semiBold, + fontSize: 13, + ), + ), ), Text( "${"Cashback Name :".tr} ${controller.bestCashback.value.title ?? ''}", - style: TextStyle(color: AppThemeData.success300, fontFamily: AppThemeData.semiBold, fontSize: 13), + style: TextStyle( + color: AppThemeData.success300, + fontFamily: AppThemeData.semiBold, + fontSize: 13, + ), ), Text( "${"You will get".tr} ${Constant.amountShow(amount: controller.bestCashback.value.cashbackValue?.toStringAsFixed(2))} ${"cashback after completing the order.".tr}", - style: TextStyle(color: AppThemeData.success300, fontFamily: AppThemeData.semiBold, fontSize: 13), + style: TextStyle( + color: AppThemeData.success300, + fontFamily: AppThemeData.semiBold, + fontSize: 13, + ), ), ], ), ), Padding( - padding: EdgeInsets.only(left: 16, right: 16, top: controller.isCashbackApply.value == false ? 16 : 12, bottom: 20), + padding: EdgeInsets.only( + left: 16, + right: 16, + top: + controller.isCashbackApply.value == false + ? 16 + : 12, + bottom: 20, + ), child: Row( children: [ Expanded( flex: 2, child: InkWell( onTap: () { - Get.to(const SelectPaymentScreen())?.then((v) { + Get.to(const SelectPaymentScreen())?.then(( + v, + ) { controller.getCashback(); }); }, child: Row( mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ - controller.selectedPaymentMethod.value == '' - ? cardDecoration(controller, PaymentGateway.wallet, isDark, "") - : controller.selectedPaymentMethod.value == PaymentGateway.wallet.name - ? cardDecoration(controller, PaymentGateway.wallet, isDark, "assets/images/ic_wallet.png") - : controller.selectedPaymentMethod.value == PaymentGateway.cod.name - ? cardDecoration(controller, PaymentGateway.cod, isDark, "assets/images/ic_cash.png") - : controller.selectedPaymentMethod.value == PaymentGateway.stripe.name - ? cardDecoration(controller, PaymentGateway.stripe, isDark, "assets/images/stripe.png") - : controller.selectedPaymentMethod.value == PaymentGateway.paypal.name - ? cardDecoration(controller, PaymentGateway.paypal, isDark, "assets/images/paypal.png") - : controller.selectedPaymentMethod.value == PaymentGateway.payStack.name - ? cardDecoration(controller, PaymentGateway.payStack, isDark, "assets/images/paystack.png") - : controller.selectedPaymentMethod.value == PaymentGateway.mercadoPago.name - ? cardDecoration(controller, PaymentGateway.mercadoPago, isDark, "assets/images/mercado-pago.png") - : controller.selectedPaymentMethod.value == PaymentGateway.flutterWave.name - ? cardDecoration(controller, PaymentGateway.flutterWave, isDark, "assets/images/flutterwave_logo.png") - : controller.selectedPaymentMethod.value == PaymentGateway.payFast.name - ? cardDecoration(controller, PaymentGateway.payFast, isDark, "assets/images/payfast.png") - : controller.selectedPaymentMethod.value == PaymentGateway.midTrans.name - ? cardDecoration(controller, PaymentGateway.midTrans, isDark, "assets/images/midtrans.png") - : controller.selectedPaymentMethod.value == PaymentGateway.orangeMoney.name - ? cardDecoration(controller, PaymentGateway.orangeMoney, isDark, "assets/images/orange_money.png") - : controller.selectedPaymentMethod.value == PaymentGateway.xendit.name - ? cardDecoration(controller, PaymentGateway.xendit, isDark, "assets/images/xendit.png") - : cardDecoration(controller, PaymentGateway.razorpay, isDark, "assets/images/razorpay.png"), + controller.selectedPaymentMethod.value == + '' + ? cardDecoration( + controller, + PaymentGateway.wallet, + isDark, + "", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.wallet.name + ? cardDecoration( + controller, + PaymentGateway.wallet, + isDark, + "assets/images/ic_wallet.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.cod.name + ? cardDecoration( + controller, + PaymentGateway.cod, + isDark, + "assets/images/ic_cash.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.stripe.name + ? cardDecoration( + controller, + PaymentGateway.stripe, + isDark, + "assets/images/stripe.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.paypal.name + ? cardDecoration( + controller, + PaymentGateway.paypal, + isDark, + "assets/images/paypal.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.payStack.name + ? cardDecoration( + controller, + PaymentGateway.payStack, + isDark, + "assets/images/paystack.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.mercadoPago.name + ? cardDecoration( + controller, + PaymentGateway.mercadoPago, + isDark, + "assets/images/mercado-pago.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.flutterWave.name + ? cardDecoration( + controller, + PaymentGateway.flutterWave, + isDark, + "assets/images/flutterwave_logo.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.payFast.name + ? cardDecoration( + controller, + PaymentGateway.payFast, + isDark, + "assets/images/payfast.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.midTrans.name + ? cardDecoration( + controller, + PaymentGateway.midTrans, + isDark, + "assets/images/midtrans.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.orangeMoney.name + ? cardDecoration( + controller, + PaymentGateway.orangeMoney, + isDark, + "assets/images/orange_money.png", + ) + : controller + .selectedPaymentMethod + .value == + PaymentGateway.xendit.name + ? cardDecoration( + controller, + PaymentGateway.xendit, + isDark, + "assets/images/xendit.png", + ) + : cardDecoration( + controller, + PaymentGateway.razorpay, + isDark, + "assets/images/razorpay.png", + ), const SizedBox(width: 10), Column( mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( "Pay Via".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.grey400 : AppThemeData.grey500, fontSize: 12), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey500, + fontSize: 12, + ), ), - controller.selectedPaymentMethod.value == '' - ? Padding(padding: const EdgeInsets.only(top: 4), child: Container(width: 60, height: 12, color: isDark ? AppThemeData.grey800 : AppThemeData.grey100)) + controller + .selectedPaymentMethod + .value == + '' + ? Padding( + padding: const EdgeInsets.only( + top: 4, + ), + child: Container( + width: 60, + height: 12, + color: + isDark + ? AppThemeData.grey800 + : AppThemeData + .grey100, + ), + ) : Text( - controller.selectedPaymentMethod.value, + controller + .selectedPaymentMethod + .value, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + style: TextStyle( + fontFamily: + AppThemeData.semiBold, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData + .grey900, + fontSize: 16, + ), ), ], ), @@ -1052,8 +2168,10 @@ class CartScreen extends StatelessWidget { ), Expanded( child: RoundedButtonFill( + borderRadius: 10.r, textColor: - controller.selectedPaymentMethod.value != '' + controller.selectedPaymentMethod.value != + '' ? AppThemeData.surface : isDark ? AppThemeData.grey800 @@ -1061,61 +2179,176 @@ class CartScreen extends StatelessWidget { title: "Pay Now".tr, height: 5, color: - controller.selectedPaymentMethod.value != '' + controller.selectedPaymentMethod.value != + '' ? AppThemeData.primary300 : isDark ? AppThemeData.grey800 : AppThemeData.grey100, fontSizes: 16, onPress: () async { - if ((controller.couponAmount.value >= 1) && (controller.couponAmount.value > controller.totalAmount.value)) { - ShowToastDialog.showToast("The total price must be greater than or equal to the coupon discount value for the code to apply. Please review your cart total.".tr); + if ((controller.couponAmount.value >= 1) && + (controller.couponAmount.value > + controller.totalAmount.value)) { + ShowToastDialog.showToast( + "The total price must be greater than or equal to the coupon discount value for the code to apply. Please review your cart total." + .tr, + ); return; } - if ((controller.specialDiscountAmount.value >= 1) && (controller.specialDiscountAmount.value > controller.totalAmount.value)) { - ShowToastDialog.showToast("The total price must be greater than or equal to the special discount value for the code to apply. Please review your cart total.".tr); + if ((controller + .specialDiscountAmount + .value >= + 1) && + (controller + .specialDiscountAmount + .value > + controller.totalAmount.value)) { + ShowToastDialog.showToast( + "The total price must be greater than or equal to the special discount value for the code to apply. Please review your cart total." + .tr, + ); return; } - if (controller.isOrderPlaced.value == false) { + if (controller.isOrderPlaced.value == + false) { controller.isOrderPlaced.value = true; await controller.getCashback(); - if (controller.selectedPaymentMethod.value == PaymentGateway.stripe.name) { - controller.stripeMakePayment(amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.paypal.name) { - controller.paypalPaymentSheet(controller.totalAmount.value.toString(), context); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.payStack.name) { - controller.payStackPayment(controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.mercadoPago.name) { - controller.mercadoPagoMakePayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.flutterWave.name) { - controller.flutterWaveInitiatePayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.payFast.name) { - controller.payFastPayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.cod.name) { + if (controller + .selectedPaymentMethod + .value == + PaymentGateway.stripe.name) { + controller.stripeMakePayment( + amount: + controller.totalAmount.value + .toString(), + ); + } else if (controller + .selectedPaymentMethod + .value == + PaymentGateway.paypal.name) { + controller.paypalPaymentSheet( + controller.totalAmount.value + .toString(), + context, + ); + } else if (controller + .selectedPaymentMethod + .value == + PaymentGateway.payStack.name) { + controller.payStackPayment( + controller.totalAmount.value + .toString(), + ); + } else if (controller + .selectedPaymentMethod + .value == + PaymentGateway.mercadoPago.name) { + controller.mercadoPagoMakePayment( + context: context, + amount: + controller.totalAmount.value + .toString(), + ); + } else if (controller + .selectedPaymentMethod + .value == + PaymentGateway.flutterWave.name) { + controller.flutterWaveInitiatePayment( + context: context, + amount: + controller.totalAmount.value + .toString(), + ); + } else if (controller + .selectedPaymentMethod + .value == + PaymentGateway.payFast.name) { + controller.payFastPayment( + context: context, + amount: + controller.totalAmount.value + .toString(), + ); + } else if (controller + .selectedPaymentMethod + .value == + PaymentGateway.cod.name) { controller.placeOrder(); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.wallet.name) { + } else if (controller + .selectedPaymentMethod + .value == + PaymentGateway.wallet.name) { controller.placeOrder(); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.midTrans.name) { - controller.midtransMakePayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.orangeMoney.name) { - controller.orangeMakePayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.xendit.name) { - controller.xenditPayment(context, controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.razorpay.name) { - RazorPayController().createOrderRazorPay(amount: double.parse(controller.totalAmount.value.toString()), razorpayModel: controller.razorPayModel.value).then(( - value, - ) { - if (value == null) { - Get.back(); - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); - } else { - CreateRazorPayOrderModel result = value; - controller.openCheckout(amount: controller.totalAmount.value.toString(), orderId: result.id); - } - }); + } else if (controller + .selectedPaymentMethod + .value == + PaymentGateway.midTrans.name) { + controller.midtransMakePayment( + context: context, + amount: + controller.totalAmount.value + .toString(), + ); + } else if (controller + .selectedPaymentMethod + .value == + PaymentGateway.orangeMoney.name) { + controller.orangeMakePayment( + context: context, + amount: + controller.totalAmount.value + .toString(), + ); + } else if (controller + .selectedPaymentMethod + .value == + PaymentGateway.xendit.name) { + controller.xenditPayment( + context, + controller.totalAmount.value + .toString(), + ); + } else if (controller + .selectedPaymentMethod + .value == + PaymentGateway.razorpay.name) { + RazorPayController() + .createOrderRazorPay( + amount: double.parse( + controller.totalAmount.value + .toString(), + ), + razorpayModel: + controller + .razorPayModel + .value, + ) + .then((value) { + if (value == null) { + Get.back(); + ShowToastDialog.showToast( + "Something went wrong, please contact admin." + .tr, + ); + } else { + CreateRazorPayOrderModel + result = value; + controller.openCheckout( + amount: + controller + .totalAmount + .value + .toString(), + orderId: result.id, + ); + } + }); } else { controller.isOrderPlaced.value = false; - ShowToastDialog.showToast("Please select payment method".tr); + ShowToastDialog.showToast( + "Please select payment method".tr, + ); } controller.isOrderPlaced.value = false; } @@ -1133,14 +2366,32 @@ class CartScreen extends StatelessWidget { ); } - Padding cardDecoration(CartController controller, PaymentGateway value, isDark, String image) { + Padding cardDecoration( + CartController controller, + PaymentGateway value, + isDark, + String image, + ) { return Padding( padding: const EdgeInsets.symmetric(vertical: 5), child: Container( width: 40, height: 40, - decoration: ShapeDecoration(shape: RoundedRectangleBorder(side: const BorderSide(width: 1, color: Color(0xFFE5E7EB)), borderRadius: BorderRadius.circular(8))), - child: Padding(padding: EdgeInsets.all(value.name == "payFast" ? 0 : 8.0), child: image == '' ? Container(color: isDark ? AppThemeData.grey800 : AppThemeData.grey100) : Image.asset(image)), + decoration: ShapeDecoration( + shape: RoundedRectangleBorder( + side: const BorderSide(width: 1, color: Color(0xFFE5E7EB)), + borderRadius: BorderRadius.circular(8), + ), + ), + child: Padding( + padding: EdgeInsets.all(value.name == "payFast" ? 0 : 8.0), + child: + image == '' + ? Container( + color: isDark ? AppThemeData.grey800 : AppThemeData.grey100, + ) + : Image.asset(image), + ), ), ); } @@ -1162,12 +2413,28 @@ class CartScreen extends StatelessWidget { TextFieldWidget( title: 'Tips Amount'.tr, controller: controller.tipsController.value, - textInputType: const TextInputType.numberWithOptions(signed: true, decimal: true), + textInputType: const TextInputType.numberWithOptions( + signed: true, + decimal: true, + ), textInputAction: TextInputAction.done, - inputFormatters: [FilteringTextInputFormatter.allow(RegExp('[0-9]'))], + inputFormatters: [ + FilteringTextInputFormatter.allow(RegExp('[0-9]')), + ], prefix: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14), - child: Text(Constant.currencyModel!.symbol.tr, style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.semiBold, fontSize: 18)), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 14, + ), + child: Text( + Constant.currencyModel!.symbol.tr, + style: TextStyle( + color: + isDark ? AppThemeData.grey50 : AppThemeData.grey900, + fontFamily: AppThemeData.semiBold, + fontSize: 18, + ), + ), ), hintText: 'Enter Tips Amount'.tr, ), @@ -1176,9 +2443,12 @@ class CartScreen extends StatelessWidget { children: [ Expanded( child: RoundedButtonFill( + borderRadius: 10.r, title: "Cancel".tr, - color: isDark ? AppThemeData.grey700 : AppThemeData.grey200, - textColor: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + color: + isDark ? AppThemeData.grey700 : AppThemeData.grey200, + textColor: + isDark ? AppThemeData.grey50 : AppThemeData.grey900, onPress: () async { Get.back(); }, @@ -1187,14 +2457,19 @@ class CartScreen extends StatelessWidget { const SizedBox(width: 20), Expanded( child: RoundedButtonFill( + borderRadius: 10.r, title: "Add".tr, color: AppThemeData.primary300, textColor: AppThemeData.grey50, onPress: () async { if (controller.tipsController.value.text.isEmpty) { - ShowToastDialog.showToast("Please enter tips Amount".tr); + ShowToastDialog.showToast( + "Please enter tips Amount".tr, + ); } else { - controller.deliveryTips.value = double.parse(controller.tipsController.value.text); + controller.deliveryTips.value = double.parse( + controller.tipsController.value.text, + ); controller.calculatePrice(); Get.back(); } diff --git a/lib/screen_ui/multi_vendor_service/cart_screen/coupon_list_screen.dart b/lib/screen_ui/multi_vendor_service/cart_screen/coupon_list_screen.dart index fec098c..0a31ba3 100644 --- a/lib/screen_ui/multi_vendor_service/cart_screen/coupon_list_screen.dart +++ b/lib/screen_ui/multi_vendor_service/cart_screen/coupon_list_screen.dart @@ -6,6 +6,7 @@ import 'package:customer/themes/responsive.dart'; import 'package:customer/themes/text_field_widget.dart'; import 'package:customer/widget/my_separator.dart'; import 'package:dotted_border/dotted_border.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../../../controllers/theme_controller.dart'; @@ -22,12 +23,22 @@ class CouponListScreen extends StatelessWidget { init: CartController(), builder: (controller) { return Scaffold( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, appBar: AppBar( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, centerTitle: false, titleSpacing: 0, - title: Text("Coupon Code".tr, textAlign: TextAlign.start, style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900)), + title: Text( + "Coupon Code".tr, + textAlign: TextAlign.start, + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 16, + color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + ), + ), bottom: PreferredSize( preferredSize: const Size.fromHeight(55), child: Padding( @@ -36,23 +47,44 @@ class CouponListScreen extends StatelessWidget { hintText: 'Enter coupon code'.tr, controller: controller.couponCodeController.value, suffix: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 12, + ), child: InkWell( onTap: () { - if (controller.couponCodeController.value.text.isEmpty) { - ShowToastDialog.showToast("Please enter coupon code".tr); + if (controller + .couponCodeController + .value + .text + .isEmpty) { + ShowToastDialog.showToast( + "Please enter coupon code".tr, + ); return; } - CouponModel? matchedCoupon = controller.couponList.firstWhereOrNull((coupon) => coupon.code!.toLowerCase() == controller.couponCodeController.value.text.toLowerCase()); + CouponModel? matchedCoupon = controller.couponList + .firstWhereOrNull( + (coupon) => + coupon.code!.toLowerCase() == + controller.couponCodeController.value.text + .toLowerCase(), + ); if (matchedCoupon != null) { - double couponAmount = Constant.calculateDiscount(amount: controller.subTotal.value.toString(), offerModel: matchedCoupon); + double couponAmount = Constant.calculateDiscount( + amount: controller.subTotal.value.toString(), + offerModel: matchedCoupon, + ); if (couponAmount < controller.subTotal.value) { - controller.selectedCouponModel.value = matchedCoupon; + controller.selectedCouponModel.value = + matchedCoupon; controller.calculatePrice(); Get.back(); } else { - ShowToastDialog.showToast("Coupon code not applied".tr); + ShowToastDialog.showToast( + "Coupon code not applied".tr, + ); } } else { ShowToastDialog.showToast("Invalid Coupon".tr); @@ -61,7 +93,14 @@ class CouponListScreen extends StatelessWidget { child: Text( "Apply".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + fontSize: 16, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + ), ), ), ), @@ -75,17 +114,32 @@ class CouponListScreen extends StatelessWidget { itemBuilder: (context, index) { CouponModel couponModel = controller.couponList[index]; return Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: Container( height: Responsive.height(16, context), - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10))), + decoration: ShapeDecoration( + color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + ), child: Row( children: [ ClipRRect( - borderRadius: const BorderRadius.only(topLeft: Radius.circular(10), bottomLeft: Radius.circular(10)), + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(10), + bottomLeft: Radius.circular(10), + ), child: Stack( children: [ - Image.asset("assets/images/ic_coupon_image.png", height: Responsive.height(16, context), fit: BoxFit.fill), + Image.asset( + "assets/images/ic_coupon_image.png", + height: Responsive.height(16, context), + fit: BoxFit.fill, + ), Padding( padding: const EdgeInsets.only(left: 10), child: Align( @@ -95,7 +149,14 @@ class CouponListScreen extends StatelessWidget { child: Text( "${couponModel.discountType == "Fix Price" ? Constant.amountShow(amount: couponModel.discount) : "${couponModel.discount}%"} ${'Off'.tr}", textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey50), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey50, + ), ), ), ), @@ -105,51 +166,98 @@ class CouponListScreen extends StatelessWidget { ), Expanded( child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 18), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 18, + ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ DottedBorder( - options: RoundedRectDottedBorderOptions(strokeWidth: 1, radius: const Radius.circular(6), color: isDark ? AppThemeData.grey400 : AppThemeData.grey500), + options: RoundedRectDottedBorderOptions( + strokeWidth: 1, + radius: const Radius.circular(6), + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey500, + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), + padding: const EdgeInsets.symmetric( + horizontal: 16, + ), child: Text( "${couponModel.code}", textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.grey400 : AppThemeData.grey500), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + fontSize: 16, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey500, + ), ), ), ), const Expanded(child: SizedBox(height: 10)), InkWell( onTap: () { - double couponAmount = Constant.calculateDiscount(amount: controller.subTotal.value.toString(), offerModel: couponModel); + double couponAmount = + Constant.calculateDiscount( + amount: + controller.subTotal.value + .toString(), + offerModel: couponModel, + ); - if (couponAmount < controller.subTotal.value) { - controller.selectedCouponModel.value = couponModel; + if (couponAmount < + controller.subTotal.value) { + controller.selectedCouponModel.value = + couponModel; controller.calculatePrice(); Get.back(); } else { - ShowToastDialog.showToast("Coupon code not applied".tr); + ShowToastDialog.showToast( + "Coupon code not applied".tr, + ); } }, child: Text( "Tap To Apply".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300), + style: TextStyle( + fontFamily: AppThemeData.medium, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + ), ), ), ], ), const SizedBox(height: 20), - MySeparator(color: isDark ? AppThemeData.grey700 : AppThemeData.grey200), + MySeparator( + color: + isDark + ? AppThemeData.grey700 + : AppThemeData.grey200, + ), const SizedBox(height: 20), Text( "${couponModel.description}", textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), ], ), diff --git a/lib/screen_ui/multi_vendor_service/cart_screen/oder_placing_screens.dart b/lib/screen_ui/multi_vendor_service/cart_screen/oder_placing_screens.dart index 5332234..3b711ac 100644 --- a/lib/screen_ui/multi_vendor_service/cart_screen/oder_placing_screens.dart +++ b/lib/screen_ui/multi_vendor_service/cart_screen/oder_placing_screens.dart @@ -6,10 +6,12 @@ import 'package:customer/models/cart_product_model.dart'; import 'package:customer/screen_ui/ecommarce/dash_board_e_commerce_screen.dart'; import 'package:customer/themes/app_them_data.dart'; import 'package:customer/themes/round_button_fill.dart'; +import 'package:customer/utils/app_router.dart'; + import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:get/get.dart'; - import '../../../controllers/theme_controller.dart'; import '../dash_board_screens/dash_board_screen.dart'; @@ -24,8 +26,14 @@ class OrderPlacingScreen extends StatelessWidget { init: OrderPlacingController(), builder: (controller) { return Scaffold( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, - appBar: AppBar(backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, centerTitle: false, titleSpacing: 0), + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + appBar: AppBar( + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + centerTitle: false, + titleSpacing: 0, + ), body: controller.isLoading.value ? Constant.loader() @@ -39,16 +47,41 @@ class OrderPlacingScreen extends StatelessWidget { Text( "Order Placed".tr, textAlign: TextAlign.start, - style: TextStyle(color: isDark ? AppThemeData.grey100 : AppThemeData.grey900, fontSize: 34, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w400), + style: TextStyle( + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey900, + fontSize: 34, + fontFamily: AppThemeData.medium, + fontWeight: FontWeight.w400, + ), ), Text( - "Hang tight — your items are being delivered quickly and safely!".tr, + "Hang tight — your items are being delivered quickly and safely!" + .tr, textAlign: TextAlign.start, - style: TextStyle(color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontSize: 16, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w400), + style: TextStyle( + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + fontSize: 16, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w400, + ), ), const SizedBox(height: 40), Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), child: Padding( padding: const EdgeInsets.all(10), child: Column( @@ -58,13 +91,26 @@ class OrderPlacingScreen extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - SvgPicture.asset("assets/icons/ic_location.svg", colorFilter: ColorFilter.mode(AppThemeData.primary300, BlendMode.srcIn)), + SvgPicture.asset( + "assets/icons/ic_location.svg", + colorFilter: ColorFilter.mode( + AppThemeData.primary300, + BlendMode.srcIn, + ), + ), const SizedBox(width: 10), Expanded( child: Text( "Order ID".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + fontSize: 16, + ), ), ), ], @@ -73,7 +119,13 @@ class OrderPlacingScreen extends StatelessWidget { Text( controller.orderModel.value.id.toString(), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, color: isDark ? AppThemeData.grey400 : AppThemeData.grey500), + style: TextStyle( + fontFamily: AppThemeData.medium, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey500, + ), ), ], ), @@ -88,21 +140,51 @@ class OrderPlacingScreen extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Center(child: Image.asset("assets/images/ic_timer.gif", height: 140)), + Center( + child: Image.asset( + "assets/images/ic_timer.gif", + height: 140, + ), + ), const SizedBox(height: 20), Text( "Placing your order".tr, textAlign: TextAlign.start, - style: TextStyle(color: isDark ? AppThemeData.grey100 : AppThemeData.grey900, fontSize: 34, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w400), + style: TextStyle( + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey900, + fontSize: 34, + fontFamily: AppThemeData.medium, + fontWeight: FontWeight.w400, + ), ), Text( - "Take a moment to review your order before proceeding to checkout.".tr, + "Take a moment to review your order before proceeding to checkout." + .tr, textAlign: TextAlign.start, - style: TextStyle(color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontSize: 16, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w400), + style: TextStyle( + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + fontSize: 16, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w400, + ), ), const SizedBox(height: 40), Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), child: Padding( padding: const EdgeInsets.all(10), child: Column( @@ -112,22 +194,42 @@ class OrderPlacingScreen extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - SvgPicture.asset("assets/icons/ic_location.svg", colorFilter: ColorFilter.mode(AppThemeData.primary300, BlendMode.srcIn)), + SvgPicture.asset( + "assets/icons/ic_location.svg", + colorFilter: ColorFilter.mode( + AppThemeData.primary300, + BlendMode.srcIn, + ), + ), const SizedBox(width: 10), Expanded( child: Text( "Delivery Address".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + fontSize: 16, + ), ), ), ], ), const SizedBox(height: 5), Text( - controller.orderModel.value.address!.getFullAddress(), + controller.orderModel.value.address! + .getFullAddress(), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, color: isDark ? AppThemeData.grey400 : AppThemeData.grey500), + style: TextStyle( + fontFamily: AppThemeData.medium, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey500, + ), ), ], ), @@ -135,7 +237,15 @@ class OrderPlacingScreen extends StatelessWidget { ), const SizedBox(height: 10), Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), child: Padding( padding: const EdgeInsets.all(10), child: Column( @@ -145,13 +255,27 @@ class OrderPlacingScreen extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - SvgPicture.asset("assets/icons/ic_book.svg", colorFilter: ColorFilter.mode(AppThemeData.primary300, BlendMode.srcIn), height: 22), + SvgPicture.asset( + "assets/icons/ic_book.svg", + colorFilter: ColorFilter.mode( + AppThemeData.primary300, + BlendMode.srcIn, + ), + height: 22, + ), const SizedBox(width: 10), Expanded( child: Text( "Order Summary".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + fontSize: 16, + ), ), ), ], @@ -159,21 +283,47 @@ class OrderPlacingScreen extends StatelessWidget { const SizedBox(height: 5), ListView.builder( shrinkWrap: true, - itemCount: controller.orderModel.value.products!.length, + itemCount: + controller + .orderModel + .value + .products! + .length, itemBuilder: (context, index) { - CartProductModel cartProductModel = controller.orderModel.value.products![index]; + CartProductModel cartProductModel = + controller + .orderModel + .value + .products![index]; return Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( "${cartProductModel.quantity} x".tr, textAlign: TextAlign.start, - style: TextStyle(color: isDark ? AppThemeData.grey100 : AppThemeData.grey900, fontSize: 14, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w400), + style: TextStyle( + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey900, + fontSize: 14, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w400, + ), ), Text( "${cartProductModel.name}".tr, textAlign: TextAlign.start, - style: TextStyle(color: isDark ? AppThemeData.grey100 : AppThemeData.grey900, fontSize: 14, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w400), + style: TextStyle( + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey900, + fontSize: 14, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w400, + ), ), ], ); @@ -194,28 +344,39 @@ class OrderPlacingScreen extends StatelessWidget { child: controller.isPlacing.value ? RoundedButtonFill( + borderRadius: 10.r, title: "Track Order".tr, height: 5.5, color: AppThemeData.primary300, textColor: AppThemeData.grey50, fontSizes: 16, onPress: () async { - if (Constant.sectionConstantModel!.serviceTypeFlag == "ecommerce-service") { + if (Constant.sectionConstantModel!.serviceTypeFlag == + "ecommerce-service") { Get.offAll(const DashBoardEcommerceScreen()); - DashBoardEcommerceController controller = Get.put(DashBoardEcommerceController()); + DashBoardEcommerceController controller = Get.put( + DashBoardEcommerceController(), + ); controller.selectedIndex.value = 3; } else { Get.offAll(const DashBoardScreen()); - DashBoardController controller = Get.put(DashBoardController()); + DashBoardController controller = Get.put( + DashBoardController(), + ); controller.selectedIndex.value = 3; } }, ) : RoundedButtonFill( + borderRadius: 10.r, title: "Track Order".tr, height: 5.5, - color: isDark ? AppThemeData.grey700 : AppThemeData.grey200, - textColor: isDark ? AppThemeData.grey900 : AppThemeData.grey50, + color: + isDark + ? AppThemeData.grey700 + : AppThemeData.grey200, + textColor: + isDark ? AppThemeData.grey900 : AppThemeData.grey50, fontSizes: 16, onPress: () async {}, ), diff --git a/lib/screen_ui/multi_vendor_service/cart_screen/select_payment_screen.dart b/lib/screen_ui/multi_vendor_service/cart_screen/select_payment_screen.dart index 17ac46a..3b39149 100644 --- a/lib/screen_ui/multi_vendor_service/cart_screen/select_payment_screen.dart +++ b/lib/screen_ui/multi_vendor_service/cart_screen/select_payment_screen.dart @@ -2,9 +2,10 @@ import 'package:customer/constant/constant.dart'; import 'package:customer/controllers/cart_controller.dart'; import 'package:customer/themes/app_them_data.dart'; import 'package:customer/themes/round_button_fill.dart'; -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; import '../../../controllers/theme_controller.dart'; import '../wallet_screen/wallet_screen.dart'; @@ -19,9 +20,11 @@ class SelectPaymentScreen extends StatelessWidget { init: CartController(), builder: (controller) { return Scaffold( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, appBar: AppBar( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, centerTitle: false, titleSpacing: 0, title: Text( @@ -46,16 +49,18 @@ class SelectPaymentScreen extends StatelessWidget { style: TextStyle( fontFamily: AppThemeData.semiBold, fontSize: 16, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + color: + isDark ? AppThemeData.grey50 : AppThemeData.grey900, ), ), - const SizedBox( - height: 10, - ), - if (controller.walletSettingModel.value.isEnabled == true || controller.cashOnDeliverySettingModel.value.isEnabled == true) + const SizedBox(height: 10), + if (controller.walletSettingModel.value.isEnabled == true || + controller.cashOnDeliverySettingModel.value.isEnabled == + true) Container( decoration: ShapeDecoration( - color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, + color: + isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(16), ), @@ -65,7 +70,7 @@ class SelectPaymentScreen extends StatelessWidget { blurRadius: 20, offset: Offset(0, 0), spreadRadius: 0, - ) + ), ], ), child: Padding( @@ -73,40 +78,62 @@ class SelectPaymentScreen extends StatelessWidget { child: Column( children: [ Visibility( - visible: controller.walletSettingModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.wallet, isDark, "assets/images/ic_wallet.png"), + visible: + controller + .walletSettingModel + .value + .isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.wallet, + isDark, + "assets/images/ic_wallet.png", + ), ), Visibility( - visible: controller.cashOnDeliverySettingModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.cod, isDark, "assets/images/ic_cash.png"), + visible: + controller + .cashOnDeliverySettingModel + .value + .isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.cod, + isDark, + "assets/images/ic_cash.png", + ), ), ], ), ), ), - if (controller.walletSettingModel.value.isEnabled == true || controller.cashOnDeliverySettingModel.value.isEnabled == true) + if (controller.walletSettingModel.value.isEnabled == true || + controller.cashOnDeliverySettingModel.value.isEnabled == + true) Column( children: [ - const SizedBox( - height: 10, - ), + const SizedBox(height: 10), Text( "Other Payment Options".tr, textAlign: TextAlign.start, style: TextStyle( fontFamily: AppThemeData.semiBold, fontSize: 16, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, ), ), - const SizedBox( - height: 10, - ), + const SizedBox(height: 10), ], ), Container( decoration: ShapeDecoration( - color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, + color: + isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(16), ), @@ -116,7 +143,7 @@ class SelectPaymentScreen extends StatelessWidget { blurRadius: 20, offset: Offset(0, 0), spreadRadius: 0, - ) + ), ], ), child: Padding( @@ -124,65 +151,137 @@ class SelectPaymentScreen extends StatelessWidget { child: Column( children: [ Visibility( - visible: controller.stripeModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.stripe, isDark, "assets/images/stripe.png"), + visible: + controller.stripeModel.value.isEnabled == true, + child: cardDecoration( + controller, + PaymentGateway.stripe, + isDark, + "assets/images/stripe.png", + ), ), Visibility( - visible: controller.payPalModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.paypal, isDark, "assets/images/paypal.png"), + visible: + controller.payPalModel.value.isEnabled == true, + child: cardDecoration( + controller, + PaymentGateway.paypal, + isDark, + "assets/images/paypal.png", + ), ), Visibility( - visible: controller.payStackModel.value.isEnable == true, - child: cardDecoration(controller, PaymentGateway.payStack, isDark, "assets/images/paystack.png"), + visible: + controller.payStackModel.value.isEnable == true, + child: cardDecoration( + controller, + PaymentGateway.payStack, + isDark, + "assets/images/paystack.png", + ), ), Visibility( - visible: controller.mercadoPagoModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.mercadoPago, isDark, "assets/images/mercado-pago.png"), + visible: + controller.mercadoPagoModel.value.isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.mercadoPago, + isDark, + "assets/images/mercado-pago.png", + ), ), Visibility( - visible: controller.flutterWaveModel.value.isEnable == true, - child: cardDecoration(controller, PaymentGateway.flutterWave, isDark, "assets/images/flutterwave_logo.png"), + visible: + controller.flutterWaveModel.value.isEnable == + true, + child: cardDecoration( + controller, + PaymentGateway.flutterWave, + isDark, + "assets/images/flutterwave_logo.png", + ), ), Visibility( - visible: controller.payFastModel.value.isEnable == true, - child: cardDecoration(controller, PaymentGateway.payFast, isDark, "assets/images/payfast.png"), + visible: + controller.payFastModel.value.isEnable == true, + child: cardDecoration( + controller, + PaymentGateway.payFast, + isDark, + "assets/images/payfast.png", + ), ), Visibility( - visible: controller.razorPayModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.razorpay, isDark, "assets/images/razorpay.png"), + visible: + controller.razorPayModel.value.isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.razorpay, + isDark, + "assets/images/razorpay.png", + ), ), Visibility( - visible: controller.midTransModel.value.enable == true, - child: cardDecoration(controller, PaymentGateway.midTrans, isDark, "assets/images/midtrans.png"), + visible: + controller.midTransModel.value.enable == true, + child: cardDecoration( + controller, + PaymentGateway.midTrans, + isDark, + "assets/images/midtrans.png", + ), ), Visibility( - visible: controller.orangeMoneyModel.value.enable == true, - child: cardDecoration(controller, PaymentGateway.orangeMoney, isDark, "assets/images/orange_money.png"), + visible: + controller.orangeMoneyModel.value.enable == + true, + child: cardDecoration( + controller, + PaymentGateway.orangeMoney, + isDark, + "assets/images/orange_money.png", + ), ), Visibility( - visible: controller.xenditModel.value.enable == true, - child: cardDecoration(controller, PaymentGateway.xendit, isDark, "assets/images/xendit.png"), + visible: + controller.xenditModel.value.enable == true, + child: cardDecoration( + controller, + PaymentGateway.xendit, + isDark, + "assets/images/xendit.png", + ), ), ], ), ), - ) + ), ], ), ), ), bottomNavigationBar: Container( decoration: BoxDecoration( - color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, borderRadius: const BorderRadius.only(topLeft: Radius.circular(20), topRight: Radius.circular(20))), + color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(20), + topRight: Radius.circular(20), + ), + ), padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20), child: Padding( padding: const EdgeInsets.only(bottom: 20), child: RoundedButtonFill( - title: "${'Pay Now'.tr} | ${Constant.amountShow(amount: controller.totalAmount.value.toString())}".tr, + borderRadius: 10.r, + title: + "${'Pay Now'.tr} | ${Constant.amountShow(amount: controller.totalAmount.value.toString())}" + .tr, height: 5, color: AppThemeData.primary300, textColor: AppThemeData.grey50, - fontSizes: 16, + fontSizes: 16.sp, onPress: () async { Get.back(); }, @@ -194,7 +293,12 @@ class SelectPaymentScreen extends StatelessWidget { ); } - Obx cardDecoration(CartController controller, PaymentGateway value, isDark, String image) { + Obx cardDecoration( + CartController controller, + PaymentGateway value, + isDark, + String image, + ) { return Obx( () => Padding( padding: const EdgeInsets.symmetric(vertical: 5), @@ -211,68 +315,89 @@ class SelectPaymentScreen extends StatelessWidget { height: 50, decoration: ShapeDecoration( shape: RoundedRectangleBorder( - side: const BorderSide(width: 1, color: Color(0xFFE5E7EB)), + side: const BorderSide( + width: 1, + color: Color(0xFFE5E7EB), + ), borderRadius: BorderRadius.circular(8), ), ), child: Padding( - padding: EdgeInsets.all(value.name == "payFast" ? 0 : 8.0), - child: Image.asset( - image, + padding: EdgeInsets.all( + value.name == "payFast" ? 0 : 8.0, ), + child: Image.asset(image), ), ), - const SizedBox( - width: 10, - ), + const SizedBox(width: 10), value.name == "wallet" ? Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - value.name.capitalizeString(), - textAlign: TextAlign.start, - style: TextStyle( - fontFamily: AppThemeData.medium, - fontSize: 16, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, - ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + value.name.capitalizeString(), + textAlign: TextAlign.start, + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, ), - Text( - Constant.amountShow(amount: controller.userModel.value.walletAmount == null ? '0.0' : controller.userModel.value.walletAmount.toString()), - textAlign: TextAlign.start, - style: TextStyle( - fontFamily: AppThemeData.semiBold, - fontSize: 16, - color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, - ), - ), - ], - ), - ) - : Expanded( - child: Text( - value.name.capitalizeString(), - textAlign: TextAlign.start, - style: TextStyle( - fontFamily: AppThemeData.medium, - fontSize: 16, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, ), + Text( + Constant.amountShow( + amount: + controller.userModel.value.walletAmount == + null + ? '0.0' + : controller + .userModel + .value + .walletAmount + .toString(), + ), + textAlign: TextAlign.start, + style: TextStyle( + fontFamily: AppThemeData.semiBold, + fontSize: 16, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + ), + ), + ], + ), + ) + : Expanded( + child: Text( + value.name.capitalizeString(), + textAlign: TextAlign.start, + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, ), ), - const Expanded( - child: SizedBox(), - ), + ), + const Expanded(child: SizedBox()), Radio( value: value.name, groupValue: controller.selectedPaymentMethod.value, - activeColor: isDark ? AppThemeData.primary300 : AppThemeData.primary300, + activeColor: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, onChanged: (value) { controller.selectedPaymentMethod.value = value.toString(); }, - ) + ), ], ), ), diff --git a/lib/screen_ui/multi_vendor_service/cashback_screen/cashback_offers_list.dart b/lib/screen_ui/multi_vendor_service/cashback_screen/cashback_offers_list.dart index 33d9863..f49f5fb 100644 --- a/lib/screen_ui/multi_vendor_service/cashback_screen/cashback_offers_list.dart +++ b/lib/screen_ui/multi_vendor_service/cashback_screen/cashback_offers_list.dart @@ -1,9 +1,9 @@ import 'package:customer/constant/constant.dart'; import 'package:customer/controllers/cashback_controller.dart'; import 'package:customer/themes/app_them_data.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; - import '../../../controllers/theme_controller.dart'; class CashbackOffersListScreen extends StatelessWidget { @@ -20,8 +20,17 @@ class CashbackOffersListScreen extends StatelessWidget { appBar: AppBar( centerTitle: false, titleSpacing: 0, - title: Text("Cashback Offers".tr, textAlign: TextAlign.start, style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900)), - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + title: Text( + "Cashback Offers".tr, + textAlign: TextAlign.start, + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 16, + color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + ), + ), + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, ), body: controller.isLoading.value @@ -34,9 +43,18 @@ class CashbackOffersListScreen extends StatelessWidget { padding: const EdgeInsets.all(16), margin: const EdgeInsets.symmetric(vertical: 6), decoration: BoxDecoration( - color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, borderRadius: BorderRadius.circular(12), - boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 6, offset: const Offset(0, 3))], + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.05), + blurRadius: 6, + offset: const Offset(0, 3), + ), + ], ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -46,25 +64,57 @@ class CashbackOffersListScreen extends StatelessWidget { Expanded( child: Text( controller.cashbackList[index].title ?? '', - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), ), Text( - controller.cashbackList[index].cashbackType == 'Percent' + controller.cashbackList[index].cashbackType == + 'Percent' ? "${controller.cashbackList[index].cashbackAmount}%" - : Constant.amountShow(amount: "${controller.cashbackList[index].cashbackAmount}"), - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + : Constant.amountShow( + amount: + "${controller.cashbackList[index].cashbackAmount}", + ), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), ], ), const SizedBox(height: 6), Text( "${"Min spent".tr} ${Constant.amountShow(amount: "${controller.cashbackList[index].minimumPurchaseAmount ?? 0.0}")} | ${"Valid till".tr} ${Constant.timestampToDateTime2(controller.cashbackList[index].endDate!)}", - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.regular, fontSize: 14), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.regular, + fontSize: 14, + ), ), Text( "${"Maximum cashback up to".tr} ${Constant.amountShow(amount: "${controller.cashbackList[index].maximumDiscount ?? 0.0}")}", - style: TextStyle(color: isDark ? AppThemeData.primary200 : AppThemeData.primary300, fontFamily: AppThemeData.regular, fontSize: 14), + style: TextStyle( + color: + isDark + ? AppThemeData.primary200 + : AppThemeData.primary300, + fontFamily: AppThemeData.regular, + fontSize: 14, + ), ), ], ), diff --git a/lib/screen_ui/multi_vendor_service/change langauge/change_language_screen.dart b/lib/screen_ui/multi_vendor_service/change langauge/change_language_screen.dart index 495b9a5..068d870 100644 --- a/lib/screen_ui/multi_vendor_service/change langauge/change_language_screen.dart +++ b/lib/screen_ui/multi_vendor_service/change langauge/change_language_screen.dart @@ -1,13 +1,16 @@ -import 'dart:convert'; +import 'package:customer/constant/const_texts.dart'; import 'package:customer/constant/constant.dart'; import 'package:customer/controllers/change_language_controller.dart'; +import 'package:customer/screen_ui/splash_screen/splash_screen.dart'; +import 'package:customer/service/localization_service.dart'; import 'package:customer/themes/app_them_data.dart'; -import 'package:customer/utils/network_image_widget.dart'; -import 'package:customer/utils/preferences.dart'; + +import 'package:flag/flag_enum.dart'; +import 'package:flag/flag_widget.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import '../../../controllers/theme_controller.dart'; -import '../../../service/localization_service.dart'; class ChangeLanguageScreen extends StatelessWidget { const ChangeLanguageScreen({super.key}); @@ -20,81 +23,194 @@ class ChangeLanguageScreen extends StatelessWidget { init: ChangeLanguageController(), builder: (controller) { return Scaffold( - appBar: AppBar(backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, centerTitle: false, titleSpacing: 0), + appBar: AppBar( + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + centerTitle: false, + titleSpacing: 0, + ), body: controller.isLoading.value ? Constant.loader() - : Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "Change Language".tr, - style: TextStyle(fontSize: 24, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w500), - ), - Text( - "Select your preferred language for a personalized app experience.".tr, - style: TextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w400), - ), - const SizedBox(height: 20), - Expanded( - child: GridView.count( - crossAxisCount: 2, - childAspectRatio: (1.1 / 1), - crossAxisSpacing: 5, - mainAxisSpacing: 1, - children: - controller.languageList - .map( - (data) => Obx( - () => GestureDetector( - onTap: () { - LocalizationService().changeLocale(data.slug.toString()); - Preferences.setString(Preferences.languageCodeKey, jsonEncode(data)); - controller.selectedLanguage.value = data; - }, - child: Container( - padding: const EdgeInsets.all(16), - child: Column( - children: [ - NetworkImageWidget(imageUrl: data.image.toString(), height: 80, width: 80), - // SvgPicture.network( - // data.image.toString(), - // height: 80, - // width: 80, - // fit: BoxFit.contain, - // placeholderBuilder: (context) => const Center(child: CircularProgressIndicator(strokeWidth: 1.5)), - // ), - const SizedBox(height: 5), - Text( - "${data.title}", - style: TextStyle( - fontSize: 16, - color: - controller.selectedLanguage.value.slug == data.slug - ? AppThemeData.primary300 - : isDark - ? AppThemeData.grey400 - : AppThemeData.grey500, - fontFamily: AppThemeData.medium, - fontWeight: FontWeight.w400, - ), - ), - ], - ), - ), - ), - ), - ) - .toList(), + : Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 100.h, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + ConstTexts.changeLanguage.tr, + style: TextStyle( + fontSize: 24, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w500, + ), + ), + Text( + ConstTexts.selectPrefferedLanguage.tr, + style: TextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w400, + ), + ), + ], ), ), - ], - ), + ), + _buildLanguageButton( + isActive: Get.locale == const Locale("uz", "UZ"), + flagCode: FlagsCode.UZ, + title: "O'zbekcha", + onTap: () async { + LocalizationService.changeLocale( + const Locale('uz', 'UZ'), + ); + }, + ), + _buildDivider(), + _buildLanguageButton( + isActive: Get.locale == const Locale('ru', 'RU'), + flagCode: FlagsCode.RU, + title: "Русский", + onTap: () async { + LocalizationService.changeLocale( + const Locale("ru", "RU"), + ); + }, + ), + _buildDivider(), + _buildLanguageButton( + isActive: Get.locale == const Locale("en", "US"), + flagCode: FlagsCode.US, + title: "English", + onTap: () async { + LocalizationService.changeLocale( + const Locale("en", "US"), + ); + }, + ), + + // Expanded( + // child: GridView.count( + // crossAxisCount: 2, + // childAspectRatio: (1.1 / 1), + // crossAxisSpacing: 5, + // mainAxisSpacing: 1, + // children: + // controller.languageList + // .map( + // (data) => Obx( + // () => GestureDetector( + // onTap: () { + // LocalizationService().changeLocale(data.slug.toString()); + // Preferences.setString(Preferences.languageCodeKey, jsonEncode(data)); + // controller.selectedLanguage.value = data; + // }, + // child: Container( + // padding: const EdgeInsets.all(16), + // child: Column( + // children: [ + // NetworkImageWidget(imageUrl: data.image.toString(), height: 80, width: 80), + // // SvgPicture.network( + // // data.image.toString(), + // // height: 80, + // // width: 80, + // // fit: BoxFit.contain, + // // placeholderBuilder: (context) => const Center(child: CircularProgressIndicator(strokeWidth: 1.5)), + // // ), + // const SizedBox(height: 5), + // Text( + // "${data.title}", + // style: TextStyle( + // fontSize: 16, + // color: + // controller.selectedLanguage.value.slug == data.slug + // ? AppThemeData.primary300 + // : isDark + // ? AppThemeData.grey400 + // : AppThemeData.grey500, + // fontFamily: AppThemeData.medium, + // fontWeight: FontWeight.w400, + // ), + // ), + // ], + // ), + // ), + // ), + // ), + // ) + // .toList(), + // ), + // ), + ], ), ); }, ); } + + Widget _buildDivider() => Padding( + padding: EdgeInsetsGeometry.symmetric(horizontal: 16.r), + child: Divider(thickness: 1.2.r), + ); + + InkWell _buildLanguageButton({ + required bool isActive, + required VoidCallback onTap, + required String title, + required FlagsCode flagCode, + }) { + return InkWell( + hoverColor: Colors.transparent, + splashColor: Colors.transparent, + overlayColor: WidgetStatePropertyAll(Colors.transparent), + onTap: onTap, + child: Padding( + padding: EdgeInsets.symmetric(vertical: 15.r).copyWith(right: 16.r), + + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Flag.fromCode( + flagCode, + height: 40.h, + width: 90.w, + borderRadius: 12.r, + ), + Text( + title, + style: AppThemeData.mediumTextStyle( + fontSize: 16.sp, + color: AppThemeData.darkGrey, + ), + ), + ], + ), + isActive + ? Icon( + Icons.circle, + color: AppThemeData.darkGrey.withValues(alpha: 0.6), + size: 15.r, + ) + : SizedBox.shrink(), + ], + ), + ), + ); + } } diff --git a/lib/screen_ui/multi_vendor_service/chat_screens/chat_screen.dart b/lib/screen_ui/multi_vendor_service/chat_screens/chat_screen.dart index d16d944..0931a83 100644 --- a/lib/screen_ui/multi_vendor_service/chat_screens/chat_screen.dart +++ b/lib/screen_ui/multi_vendor_service/chat_screens/chat_screen.dart @@ -5,6 +5,7 @@ import 'package:customer/constant/constant.dart'; import 'package:customer/controllers/chat_controller.dart'; import 'package:customer/models/conversation_model.dart'; import 'package:customer/themes/app_them_data.dart'; + import '../../../controllers/theme_controller.dart'; import 'package:customer/utils/network_image_widget.dart'; import 'package:flutter/cupertino.dart'; @@ -32,13 +33,18 @@ class ChatScreen extends StatelessWidget { builder: (controller) { return Scaffold( appBar: AppBar( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, centerTitle: false, titleSpacing: 0, title: Text( controller.restaurantName.value, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 16, + color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + ), ), ), body: Column( @@ -52,18 +58,28 @@ class ChatScreen extends StatelessWidget { controller: controller.scrollController, physics: const BouncingScrollPhysics(), itemBuilder: (context, documentSnapshots, index) { - ConversationModel inboxModel = ConversationModel.fromJson(documentSnapshots[index].data() as Map); - return chatItemView(isDark, inboxModel.senderId == FireStoreUtils.getCurrentUid(), inboxModel); + ConversationModel inboxModel = ConversationModel.fromJson( + documentSnapshots[index].data() as Map, + ); + return chatItemView( + isDark, + inboxModel.senderId == FireStoreUtils.getCurrentUid(), + inboxModel, + ); }, - onEmpty: Constant.showEmptyView(message: "No Conversion found".tr), + onEmpty: Constant.showEmptyView( + message: "No Conversion found".tr, + ), // orderBy is compulsory to enable pagination query: FirebaseFirestore.instance .collection( controller.chatType.value == "Driver" ? 'chat_driver' - : controller.chatType.value == "Provider" || controller.chatType.value == "provider" + : controller.chatType.value == "Provider" || + controller.chatType.value == "provider" ? 'chat_provider' - : controller.chatType.value == "worker" || controller.chatType.value == "Worker" + : controller.chatType.value == "worker" || + controller.chatType.value == "Worker" ? 'chat_worker' : 'chat_store', ) @@ -78,7 +94,10 @@ class ChatScreen extends StatelessWidget { Container( color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: Column( mainAxisSize: MainAxisSize.min, children: [ @@ -89,7 +108,9 @@ class ChatScreen extends StatelessWidget { onTap: () { onCameraClick(context, controller); }, - child: SvgPicture.asset("assets/icons/ic_picture_one.svg"), + child: SvgPicture.asset( + "assets/icons/ic_picture_one.svg", + ), ), Flexible( child: Padding( @@ -97,18 +118,39 @@ class ChatScreen extends StatelessWidget { child: TextField( textInputAction: TextInputAction.send, keyboardType: TextInputType.text, - textCapitalization: TextCapitalization.sentences, + textCapitalization: + TextCapitalization.sentences, controller: controller.messageController.value, decoration: InputDecoration( - contentPadding: const EdgeInsets.only(top: 3, left: 10), + contentPadding: const EdgeInsets.only( + top: 3, + left: 10, + ), focusedBorder: InputBorder.none, enabledBorder: InputBorder.none, hintText: 'Type message here....'.tr, ), onSubmitted: (value) async { - if (controller.messageController.value.text.isNotEmpty) { - controller.sendMessage(controller.messageController.value.text, null, '', 'text'); - Timer(const Duration(milliseconds: 500), () => controller.scrollController.jumpTo(controller.scrollController.position.maxScrollExtent)); + if (controller + .messageController + .value + .text + .isNotEmpty) { + controller.sendMessage( + controller.messageController.value.text, + null, + '', + 'text', + ); + Timer( + const Duration(milliseconds: 500), + () => controller.scrollController.jumpTo( + controller + .scrollController + .position + .maxScrollExtent, + ), + ); controller.messageController.value.clear(); } }, @@ -117,16 +159,36 @@ class ChatScreen extends StatelessWidget { ), InkWell( onTap: () { - if (controller.messageController.value.text.isNotEmpty) { - controller.sendMessage(controller.messageController.value.text, null, '', 'text'); + if (controller + .messageController + .value + .text + .isNotEmpty) { + controller.sendMessage( + controller.messageController.value.text, + null, + '', + 'text', + ); controller.messageController.value.clear(); // Timer(const Duration(milliseconds: 500), () => controller.scrollController.jumpTo(controller.scrollController.position.maxScrollExtent)); } }, child: Container( margin: const EdgeInsets.only(left: 10), - decoration: BoxDecoration(color: isDark ? AppThemeData.grey700 : AppThemeData.grey200, borderRadius: BorderRadius.circular(30)), - child: Padding(padding: const EdgeInsets.all(10), child: SvgPicture.asset("assets/icons/ic_send.svg")), + decoration: BoxDecoration( + color: + isDark + ? AppThemeData.grey700 + : AppThemeData.grey200, + borderRadius: BorderRadius.circular(30), + ), + child: Padding( + padding: const EdgeInsets.all(10), + child: SvgPicture.asset( + "assets/icons/ic_send.svg", + ), + ), ), ), ], @@ -156,23 +218,53 @@ class ChatScreen extends StatelessWidget { data.messageType == "text" ? Container( decoration: BoxDecoration( - borderRadius: const BorderRadius.only(topLeft: Radius.circular(12), topRight: Radius.circular(12), bottomLeft: Radius.circular(12)), + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(12), + topRight: Radius.circular(12), + bottomLeft: Radius.circular(12), + ), color: AppThemeData.primary300, ), - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), - child: Text(data.message.toString(), style: const TextStyle(fontFamily: AppThemeData.medium, fontSize: 16, color: AppThemeData.grey50)), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), + child: Text( + data.message.toString(), + style: const TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 16, + color: AppThemeData.grey50, + ), + ), ) : data.messageType == "image" ? ClipRRect( - borderRadius: const BorderRadius.only(topLeft: Radius.circular(12), topRight: Radius.circular(12), bottomLeft: Radius.circular(12)), + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(12), + topRight: Radius.circular(12), + bottomLeft: Radius.circular(12), + ), child: Stack( alignment: Alignment.center, children: [ GestureDetector( onTap: () { - Get.to(FullScreenImageViewer(imageUrl: data.url!.url)); + Get.to( + FullScreenImageViewer( + imageUrl: data.url!.url, + ), + ); }, - child: Hero(tag: data.url!.url, child: NetworkImageWidget(imageUrl: data.url!.url, height: 100, width: 100, fit: BoxFit.cover)), + child: Hero( + tag: data.url!.url, + child: NetworkImageWidget( + imageUrl: data.url!.url, + height: 100, + width: 100, + fit: BoxFit.cover, + ), + ), ), ], ), @@ -182,13 +274,25 @@ class ChatScreen extends StatelessWidget { heroTag: data.id, backgroundColor: AppThemeData.primary300, onPressed: () { - Get.to(FullScreenVideoViewer(heroTag: data.id.toString(), videoUrl: data.url!.url)); + Get.to( + FullScreenVideoViewer( + heroTag: data.id.toString(), + videoUrl: data.url!.url, + ), + ); }, - child: const Icon(Icons.play_arrow, color: Colors.white), + child: const Icon( + Icons.play_arrow, + color: Colors.white, + ), ), const SizedBox(height: 5), Text( - DateFormat('MMM d, yyyy hh:mm aa').format(DateTime.fromMillisecondsSinceEpoch(data.createdAt!.millisecondsSinceEpoch)), + DateFormat('MMM d, yyyy hh:mm aa').format( + DateTime.fromMillisecondsSinceEpoch( + data.createdAt!.millisecondsSinceEpoch, + ), + ), style: const TextStyle(color: Colors.grey, fontSize: 12), ), ], @@ -200,25 +304,61 @@ class ChatScreen extends StatelessWidget { data.messageType == "text" ? Container( decoration: BoxDecoration( - borderRadius: const BorderRadius.only(topLeft: Radius.circular(12), topRight: Radius.circular(12), bottomRight: Radius.circular(12)), - color: isDark ? AppThemeData.grey700 : AppThemeData.grey200, + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(12), + topRight: Radius.circular(12), + bottomRight: Radius.circular(12), + ), + color: + isDark + ? AppThemeData.grey700 + : AppThemeData.grey200, + ), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), + child: Text( + data.message.toString(), + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 16, + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey800, + ), ), - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), - child: Text(data.message.toString(), style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 16, color: isDark ? AppThemeData.grey100 : AppThemeData.grey800)), ) : data.messageType == "image" ? ConstrainedBox( - constraints: const BoxConstraints(minWidth: 50, maxWidth: 200), + constraints: const BoxConstraints( + minWidth: 50, + maxWidth: 200, + ), child: ClipRRect( - borderRadius: const BorderRadius.only(topLeft: Radius.circular(12), topRight: Radius.circular(12), bottomRight: Radius.circular(12)), + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(12), + topRight: Radius.circular(12), + bottomRight: Radius.circular(12), + ), child: Stack( alignment: Alignment.center, children: [ GestureDetector( onTap: () { - Get.to(FullScreenImageViewer(imageUrl: data.url!.url)); + Get.to( + FullScreenImageViewer( + imageUrl: data.url!.url, + ), + ); }, - child: Hero(tag: data.url!.url, child: NetworkImageWidget(imageUrl: data.url!.url)), + child: Hero( + tag: data.url!.url, + child: NetworkImageWidget( + imageUrl: data.url!.url, + ), + ), ), ], ), @@ -229,13 +369,25 @@ class ChatScreen extends StatelessWidget { heroTag: data.id, backgroundColor: AppThemeData.primary300, onPressed: () { - Get.to(FullScreenVideoViewer(heroTag: data.id.toString(), videoUrl: data.url!.url)); + Get.to( + FullScreenVideoViewer( + heroTag: data.id.toString(), + videoUrl: data.url!.url, + ), + ); }, - child: const Icon(Icons.play_arrow, color: Colors.white), + child: const Icon( + Icons.play_arrow, + color: Colors.white, + ), ), const SizedBox(height: 5), Text( - DateFormat('MMM d, yyyy hh:mm aa').format(DateTime.fromMillisecondsSinceEpoch(data.createdAt!.millisecondsSinceEpoch)), + DateFormat('MMM d, yyyy hh:mm aa').format( + DateTime.fromMillisecondsSinceEpoch( + data.createdAt!.millisecondsSinceEpoch, + ), + ), style: const TextStyle(color: Colors.grey, fontSize: 12), ), ], @@ -251,9 +403,14 @@ class ChatScreen extends StatelessWidget { isDefaultAction: false, onPressed: () async { Get.back(); - XFile? image = await controller.imagePicker.pickImage(source: ImageSource.gallery); + XFile? image = await controller.imagePicker.pickImage( + source: ImageSource.gallery, + ); if (image != null) { - Url url = await FireStoreUtils.uploadChatImageToFireStorage(File(image.path), context); + Url url = await FireStoreUtils.uploadChatImageToFireStorage( + File(image.path), + context, + ); controller.sendMessage('', url, '', 'image'); } }, @@ -263,11 +420,22 @@ class ChatScreen extends StatelessWidget { isDefaultAction: false, onPressed: () async { Get.back(); - XFile? galleryVideo = await controller.imagePicker.pickVideo(source: ImageSource.gallery); + XFile? galleryVideo = await controller.imagePicker.pickVideo( + source: ImageSource.gallery, + ); if (galleryVideo != null) { - ChatVideoContainer? videoContainer = await FireStoreUtils.uploadChatVideoToFireStorage(context, File(galleryVideo.path)); + ChatVideoContainer? videoContainer = + await FireStoreUtils.uploadChatVideoToFireStorage( + context, + File(galleryVideo.path), + ); if (videoContainer != null) { - controller.sendMessage('', videoContainer.videoUrl, videoContainer.thumbnailUrl, 'video'); + controller.sendMessage( + '', + videoContainer.videoUrl, + videoContainer.thumbnailUrl, + 'video', + ); } } }, @@ -277,9 +445,14 @@ class ChatScreen extends StatelessWidget { isDestructiveAction: false, onPressed: () async { Get.back(); - XFile? image = await controller.imagePicker.pickImage(source: ImageSource.camera); + XFile? image = await controller.imagePicker.pickImage( + source: ImageSource.camera, + ); if (image != null) { - Url url = await FireStoreUtils.uploadChatImageToFireStorage(File(image.path), context); + Url url = await FireStoreUtils.uploadChatImageToFireStorage( + File(image.path), + context, + ); controller.sendMessage('', url, '', 'image'); } }, diff --git a/lib/screen_ui/multi_vendor_service/chat_screens/driver_inbox_screen.dart b/lib/screen_ui/multi_vendor_service/chat_screens/driver_inbox_screen.dart index 9572a40..278191e 100644 --- a/lib/screen_ui/multi_vendor_service/chat_screens/driver_inbox_screen.dart +++ b/lib/screen_ui/multi_vendor_service/chat_screens/driver_inbox_screen.dart @@ -1,13 +1,14 @@ import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:customer/constant/const_texts.dart'; import 'package:customer/constant/constant.dart'; import 'package:customer/models/inbox_model.dart'; import 'package:customer/models/user_model.dart'; import 'package:customer/themes/app_them_data.dart'; import 'package:customer/themes/responsive.dart'; import 'package:customer/utils/network_image_widget.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; - import '../../../controllers/theme_controller.dart'; import '../../../service/fire_store_utils.dart'; import '../../../themes/show_toast_dialog.dart'; @@ -24,10 +25,19 @@ class DriverInboxScreen extends StatelessWidget { final isDark = themeController.isDark.value; return Scaffold( appBar: AppBar( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, centerTitle: false, titleSpacing: 0, - title: Text("Driver Inbox".tr, textAlign: TextAlign.start, style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900)), + title: Text( + "Driver Inbox".tr, + textAlign: TextAlign.start, + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 16, + color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + ), + ), ), body: FirestorePagination( //item builder type is compulsory. @@ -37,10 +47,14 @@ class DriverInboxScreen extends StatelessWidget { InboxModel inboxModel = InboxModel.fromJson(data!); return InkWell( onTap: () async { - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); - UserModel? customer = await FireStoreUtils.getUserProfile(inboxModel.customerId.toString()); - UserModel? restaurantUser = await FireStoreUtils.getUserProfile(inboxModel.restaurantId.toString()); + UserModel? customer = await FireStoreUtils.getUserProfile( + inboxModel.customerId.toString(), + ); + UserModel? restaurantUser = await FireStoreUtils.getUserProfile( + inboxModel.restaurantId.toString(), + ); ShowToastDialog.closeLoader(); Get.to( @@ -61,15 +75,23 @@ class DriverInboxScreen extends StatelessWidget { child: Padding( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 5), child: Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))), + decoration: ShapeDecoration( + color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), child: Padding( padding: const EdgeInsets.all(8.0), child: Row( children: [ ClipRRect( - borderRadius: const BorderRadius.all(Radius.circular(10)), + borderRadius: const BorderRadius.all( + Radius.circular(10), + ), child: NetworkImageWidget( - imageUrl: inboxModel.restaurantProfileImage.toString(), + imageUrl: + inboxModel.restaurantProfileImage.toString(), fit: BoxFit.cover, height: Responsive.height(6, context), width: Responsive.width(12, context), @@ -86,13 +108,29 @@ class DriverInboxScreen extends StatelessWidget { child: Text( "${inboxModel.restaurantName}", textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.grey100 : AppThemeData.grey800), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + fontSize: 16, + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey800, + ), ), ), Text( - Constant.timestampToDate(inboxModel.createdAt!), + Constant.timestampToDate( + inboxModel.createdAt!, + ), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, fontSize: 16, color: isDark ? AppThemeData.grey400 : AppThemeData.grey500), + style: TextStyle( + fontFamily: AppThemeData.regular, + fontSize: 16, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey500, + ), ), ], ), @@ -100,7 +138,14 @@ class DriverInboxScreen extends StatelessWidget { Text( "${inboxModel.lastMessage}", textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 14, color: isDark ? AppThemeData.grey200 : AppThemeData.grey700), + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 14, + color: + isDark + ? AppThemeData.grey200 + : AppThemeData.grey700, + ), ), ], ), @@ -115,7 +160,10 @@ class DriverInboxScreen extends StatelessWidget { shrinkWrap: true, onEmpty: Constant.showEmptyView(message: "No Conversion found".tr), // orderBy is compulsory to enable pagination - query: FirebaseFirestore.instance.collection('chat_driver').where("customerId", isEqualTo: FireStoreUtils.getCurrentUid()).orderBy('createdAt', descending: true), + query: FirebaseFirestore.instance + .collection('chat_driver') + .where("customerId", isEqualTo: FireStoreUtils.getCurrentUid()) + .orderBy('createdAt', descending: true), //Change types customerId viewType: ViewType.list, initialLoader: Constant.loader(), diff --git a/lib/screen_ui/multi_vendor_service/chat_screens/restaurant_inbox_screen.dart b/lib/screen_ui/multi_vendor_service/chat_screens/restaurant_inbox_screen.dart index f7d6948..016e01f 100644 --- a/lib/screen_ui/multi_vendor_service/chat_screens/restaurant_inbox_screen.dart +++ b/lib/screen_ui/multi_vendor_service/chat_screens/restaurant_inbox_screen.dart @@ -1,4 +1,5 @@ import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:customer/constant/const_texts.dart'; import 'package:customer/constant/constant.dart'; import 'package:customer/models/inbox_model.dart'; import 'package:customer/models/user_model.dart'; @@ -8,9 +9,9 @@ import 'package:customer/themes/responsive.dart'; import 'package:customer/utils/network_image_widget.dart'; import 'package:customer/widget/firebase_pagination/src/fireStore_pagination.dart'; import 'package:customer/widget/firebase_pagination/src/models/view_type.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; - import '../../../controllers/theme_controller.dart'; import '../../../service/fire_store_utils.dart'; import '../../../themes/show_toast_dialog.dart'; @@ -25,10 +26,19 @@ class RestaurantInboxScreen extends StatelessWidget { final isDark = themeController.isDark.value; return Scaffold( appBar: AppBar( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, centerTitle: false, titleSpacing: 0, - title: Text("Store Inbox".tr, textAlign: TextAlign.start, style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900)), + title: Text( + "Store Inbox".tr, + textAlign: TextAlign.start, + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 16, + color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + ), + ), ), body: FirestorePagination( //item builder type is compulsory. @@ -38,11 +48,17 @@ class RestaurantInboxScreen extends StatelessWidget { InboxModel inboxModel = InboxModel.fromJson(data!); return InkWell( onTap: () async { - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); - UserModel? customer = await FireStoreUtils.getUserProfile(inboxModel.customerId.toString()); - UserModel? restaurantUser = await FireStoreUtils.getUserProfile(inboxModel.restaurantId.toString()); - VendorModel? vendorModel = await FireStoreUtils.getVendorById(restaurantUser!.vendorID.toString()); + UserModel? customer = await FireStoreUtils.getUserProfile( + inboxModel.customerId.toString(), + ); + UserModel? restaurantUser = await FireStoreUtils.getUserProfile( + inboxModel.restaurantId.toString(), + ); + VendorModel? vendorModel = await FireStoreUtils.getVendorById( + restaurantUser!.vendorID.toString(), + ); ShowToastDialog.closeLoader(); Get.to( @@ -63,15 +79,23 @@ class RestaurantInboxScreen extends StatelessWidget { child: Padding( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 5), child: Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))), + decoration: ShapeDecoration( + color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), child: Padding( padding: const EdgeInsets.all(8.0), child: Row( children: [ ClipRRect( - borderRadius: const BorderRadius.all(Radius.circular(10)), + borderRadius: const BorderRadius.all( + Radius.circular(10), + ), child: NetworkImageWidget( - imageUrl: inboxModel.restaurantProfileImage.toString(), + imageUrl: + inboxModel.restaurantProfileImage.toString(), fit: BoxFit.cover, height: Responsive.height(6, context), width: Responsive.width(12, context), @@ -88,13 +112,29 @@ class RestaurantInboxScreen extends StatelessWidget { child: Text( "${inboxModel.restaurantName}", textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.grey100 : AppThemeData.grey800), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + fontSize: 16, + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey800, + ), ), ), Text( - Constant.timestampToDate(inboxModel.createdAt!), + Constant.timestampToDate( + inboxModel.createdAt!, + ), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, fontSize: 16, color: isDark ? AppThemeData.grey400 : AppThemeData.grey500), + style: TextStyle( + fontFamily: AppThemeData.regular, + fontSize: 16, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey500, + ), ), ], ), @@ -102,7 +142,14 @@ class RestaurantInboxScreen extends StatelessWidget { Text( "${inboxModel.lastMessage}", textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 14, color: isDark ? AppThemeData.grey200 : AppThemeData.grey700), + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 14, + color: + isDark + ? AppThemeData.grey200 + : AppThemeData.grey700, + ), ), ], ), @@ -117,7 +164,10 @@ class RestaurantInboxScreen extends StatelessWidget { shrinkWrap: true, onEmpty: Constant.showEmptyView(message: "No Conversion found".tr), // orderBy is compulsory to enable pagination - query: FirebaseFirestore.instance.collection('chat_store').where("customerId", isEqualTo: FireStoreUtils.getCurrentUid()).orderBy('createdAt', descending: true), + query: FirebaseFirestore.instance + .collection('chat_store') + .where("customerId", isEqualTo: FireStoreUtils.getCurrentUid()) + .orderBy('createdAt', descending: true), //Change types customerId viewType: ViewType.list, initialLoader: Constant.loader(), diff --git a/lib/screen_ui/multi_vendor_service/dash_board_screens/dash_board_screen.dart b/lib/screen_ui/multi_vendor_service/dash_board_screens/dash_board_screen.dart index 485f304..662490c 100644 --- a/lib/screen_ui/multi_vendor_service/dash_board_screens/dash_board_screen.dart +++ b/lib/screen_ui/multi_vendor_service/dash_board_screens/dash_board_screen.dart @@ -1,10 +1,11 @@ +import 'package:customer/constant/const_texts.dart'; import 'package:customer/constant/constant.dart'; import 'package:customer/controllers/dash_board_controller.dart'; import 'package:customer/themes/app_them_data.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:get/get.dart'; - import '../../../controllers/theme_controller.dart'; class DashBoardScreen extends StatelessWidget { @@ -25,12 +26,19 @@ class DashBoardScreen extends StatelessWidget { showUnselectedLabels: true, showSelectedLabels: true, selectedFontSize: 12, - selectedLabelStyle: const TextStyle(fontFamily: AppThemeData.bold), - unselectedLabelStyle: const TextStyle(fontFamily: AppThemeData.bold), + selectedLabelStyle: const TextStyle( + fontFamily: AppThemeData.bold, + ), + unselectedLabelStyle: const TextStyle( + fontFamily: AppThemeData.bold, + ), currentIndex: controller.selectedIndex.value, - backgroundColor: isDark ? AppThemeData.grey900 : AppThemeData.grey50, - selectedItemColor: isDark ? AppThemeData.primary300 : AppThemeData.primary300, - unselectedItemColor: isDark ? AppThemeData.grey300 : AppThemeData.grey600, + backgroundColor: + isDark ? AppThemeData.grey900 : AppThemeData.grey50, + selectedItemColor: + isDark ? AppThemeData.primary300 : AppThemeData.primary300, + unselectedItemColor: + isDark ? AppThemeData.grey300 : AppThemeData.grey600, onTap: (int index) { if (index == 0) { Get.put(DashBoardController()); @@ -40,17 +48,71 @@ class DashBoardScreen extends StatelessWidget { items: Constant.walletSetting == false ? [ - navigationBarItem(isDark, index: 0, assetIcon: "assets/icons/ic_home.svg", label: 'Home'.tr, controller: controller), - navigationBarItem(isDark, index: 1, assetIcon: "assets/icons/ic_fav.svg", label: 'Favourites'.tr, controller: controller), - navigationBarItem(isDark, index: 2, assetIcon: "assets/icons/ic_orders.svg", label: 'Orders'.tr, controller: controller), - navigationBarItem(isDark, index: 3, assetIcon: "assets/icons/ic_profile.svg", label: 'Profile'.tr, controller: controller), + navigationBarItem( + isDark, + index: 0, + assetIcon: "assets/icons/ic_home.svg", + label: ConstTexts.home.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 1, + assetIcon: "assets/icons/ic_fav.svg", + label: ConstTexts.favourites.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 2, + assetIcon: "assets/icons/ic_orders.svg", + label: ConstTexts.orders.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 3, + assetIcon: "assets/icons/ic_profile.svg", + label: ConstTexts.profile.tr, + controller: controller, + ), ] : [ - navigationBarItem(isDark, index: 0, assetIcon: "assets/icons/ic_home.svg", label: 'Home'.tr, controller: controller), - navigationBarItem(isDark, index: 1, assetIcon: "assets/icons/ic_fav.svg", label: 'Favourites'.tr, controller: controller), - navigationBarItem(isDark, index: 2, assetIcon: "assets/icons/ic_wallet.svg", label: 'Wallet'.tr, controller: controller), - navigationBarItem(isDark, index: 3, assetIcon: "assets/icons/ic_orders.svg", label: 'Orders'.tr, controller: controller), - navigationBarItem(isDark, index: 4, assetIcon: "assets/icons/ic_profile.svg", label: 'Profile'.tr, controller: controller), + navigationBarItem( + isDark, + index: 0, + assetIcon: "assets/icons/ic_home.svg", + label: ConstTexts.home.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 1, + assetIcon: "assets/icons/ic_fav.svg", + label: ConstTexts.favourites.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 2, + assetIcon: "assets/icons/ic_wallet.svg", + label: ConstTexts.wallet.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 3, + assetIcon: "assets/icons/ic_orders.svg", + label: ConstTexts.orders.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 4, + assetIcon: "assets/icons/ic_profile.svg", + label: ConstTexts.profile.tr, + controller: controller, + ), ], ), ); @@ -59,7 +121,13 @@ class DashBoardScreen extends StatelessWidget { }); } - BottomNavigationBarItem navigationBarItem(isDark, {required int index, required String label, required String assetIcon, required DashBoardController controller}) { + BottomNavigationBarItem navigationBarItem( + isDark, { + required int index, + required String label, + required String assetIcon, + required DashBoardController controller, + }) { return BottomNavigationBarItem( icon: Padding( padding: const EdgeInsets.symmetric(vertical: 5), diff --git a/lib/screen_ui/multi_vendor_service/dine_in_booking/dine_in_booking_details.dart b/lib/screen_ui/multi_vendor_service/dine_in_booking/dine_in_booking_details.dart index b08e3e9..bafde44 100644 --- a/lib/screen_ui/multi_vendor_service/dine_in_booking/dine_in_booking_details.dart +++ b/lib/screen_ui/multi_vendor_service/dine_in_booking/dine_in_booking_details.dart @@ -1,6 +1,7 @@ import 'package:customer/constant/constant.dart'; import 'package:customer/controllers/dine_in_booking_details_controller.dart'; import 'package:customer/themes/app_them_data.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:get/get.dart'; @@ -22,10 +23,16 @@ class DineInBookingDetails extends StatelessWidget { appBar: AppBar( centerTitle: false, titleSpacing: 0, - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, title: Text( "Dine in Bookings".tr, - style: TextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500), + style: TextStyle( + fontSize: 16, + color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + fontFamily: AppThemeData.medium, + fontWeight: FontWeight.w500, + ), ), ), body: @@ -44,25 +51,55 @@ class DineInBookingDetails extends StatelessWidget { children: [ Text( "${'Order'.tr} ${Constant.orderId(orderId: controller.bookingModel.value.id.toString())}", - style: TextStyle(fontSize: 18, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600), + style: TextStyle( + fontSize: 18, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w600, + ), ), Text( "${controller.bookingModel.value.totalGuest} ${'Peoples'.tr}", - style: TextStyle(fontSize: 14, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w400), + style: TextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w400, + ), ), ], ), ), Container( decoration: ShapeDecoration( - color: Constant.statusColor(status: controller.bookingModel.value.status), - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), + color: Constant.statusColor( + status: controller.bookingModel.value.status, + ), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 6, + ), child: Text( "${controller.bookingModel.value.status}", - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey50, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey50, + fontFamily: AppThemeData.medium, + fontWeight: FontWeight.w500, + ), ), ), ), @@ -70,7 +107,15 @@ class DineInBookingDetails extends StatelessWidget { ), const SizedBox(height: 20), Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( @@ -78,19 +123,47 @@ class DineInBookingDetails extends StatelessWidget { Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - SvgPicture.asset("assets/icons/ic_building.svg"), + SvgPicture.asset( + "assets/icons/ic_building.svg", + ), const SizedBox(width: 10), Expanded( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( - controller.bookingModel.value.vendor!.title.toString(), - style: TextStyle(fontSize: 18, color: isDark ? AppThemeData.grey100 : AppThemeData.grey800, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500), + controller + .bookingModel + .value + .vendor! + .title + .toString(), + style: TextStyle( + fontSize: 18, + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey800, + fontFamily: AppThemeData.medium, + fontWeight: FontWeight.w500, + ), ), Text( - controller.bookingModel.value.vendor!.location.toString(), - style: TextStyle(color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500), + controller + .bookingModel + .value + .vendor! + .location + .toString(), + style: TextStyle( + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + fontFamily: AppThemeData.medium, + fontWeight: FontWeight.w500, + ), ), ], ), @@ -106,9 +179,23 @@ class DineInBookingDetails extends StatelessWidget { onTap: () { launchUrl( Constant.createCoordinatesUrl( - controller.bookingModel.value.vendor!.latitude ?? 0.0, - controller.bookingModel.value.vendor!.longitude ?? 0.0, - controller.bookingModel.value.vendor!.title, + controller + .bookingModel + .value + .vendor! + .latitude ?? + 0.0, + controller + .bookingModel + .value + .vendor! + .longitude ?? + 0.0, + controller + .bookingModel + .value + .vendor! + .title, ), ); }, @@ -116,19 +203,44 @@ class DineInBookingDetails extends StatelessWidget { "View in Map".tr, style: TextStyle( fontSize: 16, - color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500, decoration: TextDecoration.underline, - decorationColor: AppThemeData.primary300, + decorationColor: + AppThemeData.primary300, ), ), ), - const Padding(padding: EdgeInsets.symmetric(horizontal: 16), child: SizedBox(height: 16, child: VerticalDivider(width: 1))), + const Padding( + padding: EdgeInsets.symmetric( + horizontal: 16, + ), + child: SizedBox( + height: 16, + child: VerticalDivider(width: 1), + ), + ), InkWell( onTap: () { - if (controller.bookingModel.value.vendor!.phonenumber!.isNotEmpty) { - final Uri launchUri = Uri(scheme: 'tel', path: controller.bookingModel.value.vendor!.phonenumber); + if (controller + .bookingModel + .value + .vendor! + .phonenumber! + .isNotEmpty) { + final Uri launchUri = Uri( + scheme: 'tel', + path: + controller + .bookingModel + .value + .vendor! + .phonenumber, + ); launchUrl(launchUri); } }, @@ -136,11 +248,15 @@ class DineInBookingDetails extends StatelessWidget { "Call Now".tr, style: TextStyle( fontSize: 16, - color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500, decoration: TextDecoration.underline, - decorationColor: AppThemeData.primary300, + decorationColor: + AppThemeData.primary300, ), ), ), @@ -155,11 +271,26 @@ class DineInBookingDetails extends StatelessWidget { Text( "Booking Details".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 16, + ), ), const SizedBox(height: 5), Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( @@ -170,14 +301,28 @@ class DineInBookingDetails extends StatelessWidget { Expanded( child: Text( "Name".tr, - style: TextStyle(color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w400), + style: TextStyle( + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w400, + ), ), ), Expanded( child: Text( "${controller.bookingModel.value.guestFirstName} ${controller.bookingModel.value.guestLastName}", textAlign: TextAlign.end, - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w600, + ), ), ), ], @@ -189,14 +334,28 @@ class DineInBookingDetails extends StatelessWidget { Expanded( child: Text( "Phone number".tr, - style: TextStyle(color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w400), + style: TextStyle( + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w400, + ), ), ), Expanded( child: Text( "${controller.bookingModel.value.guestPhone}", textAlign: TextAlign.end, - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w600, + ), ), ), ], @@ -208,14 +367,30 @@ class DineInBookingDetails extends StatelessWidget { Expanded( child: Text( "Date and Time".tr, - style: TextStyle(color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w400), + style: TextStyle( + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w400, + ), ), ), Expanded( child: Text( - Constant.timestampToDateTime(controller.bookingModel.value.date!), + Constant.timestampToDateTime( + controller.bookingModel.value.date!, + ), textAlign: TextAlign.end, - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w600, + ), ), ), ], @@ -227,14 +402,28 @@ class DineInBookingDetails extends StatelessWidget { Expanded( child: Text( "Guest".tr, - style: TextStyle(color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w400), + style: TextStyle( + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w400, + ), ), ), Expanded( child: Text( "${controller.bookingModel.value.totalGuest}", textAlign: TextAlign.end, - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w600, + ), ), ), ], @@ -246,14 +435,28 @@ class DineInBookingDetails extends StatelessWidget { Expanded( child: Text( "Discount".tr, - style: TextStyle(color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w400), + style: TextStyle( + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w400, + ), ), ), Expanded( child: Text( "${controller.bookingModel.value.discount} %", textAlign: TextAlign.end, - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w600, + ), ), ), ], diff --git a/lib/screen_ui/multi_vendor_service/dine_in_booking/dine_in_booking_screen.dart b/lib/screen_ui/multi_vendor_service/dine_in_booking/dine_in_booking_screen.dart index af8a5a3..8f45d83 100644 --- a/lib/screen_ui/multi_vendor_service/dine_in_booking/dine_in_booking_screen.dart +++ b/lib/screen_ui/multi_vendor_service/dine_in_booking/dine_in_booking_screen.dart @@ -3,6 +3,7 @@ import 'package:customer/controllers/dine_in_booking_controller.dart'; import 'package:customer/models/dine_in_booking_model.dart'; import 'package:customer/themes/responsive.dart'; import 'package:customer/utils/network_image_widget.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:get/get.dart'; @@ -25,10 +26,16 @@ class DineInBookingScreen extends StatelessWidget { appBar: AppBar( centerTitle: false, titleSpacing: 0, - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, title: Text( "Dine in Bookings".tr, - style: TextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500), + style: TextStyle( + fontSize: 16, + color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + fontFamily: AppThemeData.medium, + fontWeight: FontWeight.w500, + ), ), ), body: @@ -39,7 +46,15 @@ class DineInBookingScreen extends StatelessWidget { Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey700 : AppThemeData.grey200, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey700 + : AppThemeData.grey200, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(120), + ), + ), child: Padding( padding: const EdgeInsets.all(8.0), child: Row( @@ -53,16 +68,28 @@ class DineInBookingScreen extends StatelessWidget { decoration: controller.isFeature.value == false ? null - : ShapeDecoration(color: AppThemeData.primary300, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120))), + : ShapeDecoration( + color: AppThemeData.primary300, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 120, + ), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: Text( "Upcoming".tr, textAlign: TextAlign.center, style: TextStyle( fontFamily: AppThemeData.semiBold, color: - controller.isFeature.value == false + controller.isFeature.value == + false ? isDark ? AppThemeData.grey400 : AppThemeData.grey500 @@ -84,16 +111,28 @@ class DineInBookingScreen extends StatelessWidget { decoration: controller.isFeature.value == true ? null - : ShapeDecoration(color: AppThemeData.primary300, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120))), + : ShapeDecoration( + color: AppThemeData.primary300, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 120, + ), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: Text( "History".tr, textAlign: TextAlign.center, style: TextStyle( fontFamily: AppThemeData.semiBold, color: - controller.isFeature.value == true + controller.isFeature.value == + true ? isDark ? AppThemeData.grey400 : AppThemeData.grey500 @@ -118,26 +157,45 @@ class DineInBookingScreen extends StatelessWidget { child: controller.isFeature.value ? controller.featureList.isEmpty - ? Constant.showEmptyView(message: "Upcoming Booking not found.".tr) + ? Constant.showEmptyView( + message: + "Upcoming Booking not found.".tr, + ) : ListView.builder( shrinkWrap: true, padding: EdgeInsets.zero, scrollDirection: Axis.vertical, - itemCount: controller.featureList.length, - itemBuilder: (BuildContext context, int index) { - DineInBookingModel dineBookingModel = controller.featureList[index]; - return itemView(isDark, context, dineBookingModel); + itemCount: + controller.featureList.length, + itemBuilder: ( + BuildContext context, + int index, + ) { + DineInBookingModel dineBookingModel = + controller.featureList[index]; + return itemView( + isDark, + context, + dineBookingModel, + ); }, ) : controller.historyList.isEmpty - ? Constant.showEmptyView(message: "History not found.".tr) + ? Constant.showEmptyView( + message: "History not found.".tr, + ) : ListView.builder( itemCount: controller.historyList.length, shrinkWrap: true, padding: EdgeInsets.zero, itemBuilder: (context, index) { - DineInBookingModel dineBookingModel = controller.historyList[index]; - return itemView(isDark, context, dineBookingModel); + DineInBookingModel dineBookingModel = + controller.historyList[index]; + return itemView( + isDark, + context, + dineBookingModel, + ); }, ), ), @@ -149,15 +207,27 @@ class DineInBookingScreen extends StatelessWidget { ); } - InkWell itemView(isDark, BuildContext context, DineInBookingModel orderModel) { + InkWell itemView( + isDark, + BuildContext context, + DineInBookingModel orderModel, + ) { return InkWell( onTap: () { - Get.to(const DineInBookingDetails(), arguments: {"bookingModel": orderModel}); + Get.to( + const DineInBookingDetails(), + arguments: {"bookingModel": orderModel}, + ); }, child: Padding( padding: const EdgeInsets.symmetric(vertical: 5), child: Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12))), + decoration: ShapeDecoration( + color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + ), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( @@ -168,12 +238,24 @@ class DineInBookingScreen extends StatelessWidget { borderRadius: const BorderRadius.all(Radius.circular(16)), child: Stack( children: [ - NetworkImageWidget(imageUrl: orderModel.vendor!.photo.toString(), fit: BoxFit.cover, height: Responsive.height(10, context), width: Responsive.width(20, context)), + NetworkImageWidget( + imageUrl: orderModel.vendor!.photo.toString(), + fit: BoxFit.cover, + height: Responsive.height(10, context), + width: Responsive.width(20, context), + ), Container( height: Responsive.height(10, context), width: Responsive.width(20, context), decoration: BoxDecoration( - gradient: LinearGradient(begin: const Alignment(0.00, 1.00), end: const Alignment(0, -1), colors: [Colors.black.withOpacity(0), AppThemeData.grey900]), + gradient: LinearGradient( + begin: const Alignment(0.00, 1.00), + end: const Alignment(0, -1), + colors: [ + Colors.black.withOpacity(0), + AppThemeData.grey900, + ], + ), ), ), ], @@ -187,33 +269,79 @@ class DineInBookingScreen extends StatelessWidget { Text( orderModel.status.toString(), textAlign: TextAlign.right, - style: TextStyle(color: Constant.statusColor(status: orderModel.status.toString()), fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w500, fontSize: 12), + style: TextStyle( + color: Constant.statusColor( + status: orderModel.status.toString(), + ), + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w500, + fontSize: 12, + ), ), const SizedBox(height: 5), Text( orderModel.vendor!.title.toString(), - style: TextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w400), + style: TextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.medium, + fontWeight: FontWeight.w400, + ), ), const SizedBox(height: 5), Text( Constant.timestampToDateTime(orderModel.createdAt!), - style: TextStyle(color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500), + style: TextStyle( + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + fontFamily: AppThemeData.medium, + fontWeight: FontWeight.w500, + ), ), ], ), ), ], ), - Padding(padding: const EdgeInsets.symmetric(vertical: 14), child: MySeparator(color: isDark ? AppThemeData.grey700 : AppThemeData.grey200)), + Padding( + padding: const EdgeInsets.symmetric(vertical: 14), + child: MySeparator( + color: isDark ? AppThemeData.grey700 : AppThemeData.grey200, + ), + ), Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Expanded(child: Text("Name".tr, style: TextStyle(color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w400))), + Expanded( + child: Text( + "Name".tr, + style: TextStyle( + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w400, + ), + ), + ), Expanded( child: Text( "${orderModel.guestFirstName} ${orderModel.guestLastName}", textAlign: TextAlign.end, - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w600, + ), ), ), ], @@ -223,18 +351,40 @@ class DineInBookingScreen extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( - child: Text("Guest Number".tr, style: TextStyle(color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w400)), + child: Text( + "Guest Number".tr, + style: TextStyle( + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w400, + ), + ), ), Expanded( child: Text( orderModel.totalGuest.toString(), textAlign: TextAlign.end, - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w600, + ), ), ), ], ), - Padding(padding: const EdgeInsets.symmetric(vertical: 14), child: MySeparator(color: isDark ? AppThemeData.grey700 : AppThemeData.grey200)), + Padding( + padding: const EdgeInsets.symmetric(vertical: 14), + child: MySeparator( + color: isDark ? AppThemeData.grey700 : AppThemeData.grey200, + ), + ), Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -243,7 +393,14 @@ class DineInBookingScreen extends StatelessWidget { Expanded( child: Text( orderModel.vendor!.location.toString(), - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.medium, + fontWeight: FontWeight.w500, + ), ), ), ], diff --git a/lib/screen_ui/multi_vendor_service/dine_in_screeen/book_table_screen.dart b/lib/screen_ui/multi_vendor_service/dine_in_screeen/book_table_screen.dart index 2a5105f..a029d40 100644 --- a/lib/screen_ui/multi_vendor_service/dine_in_screeen/book_table_screen.dart +++ b/lib/screen_ui/multi_vendor_service/dine_in_screeen/book_table_screen.dart @@ -5,7 +5,9 @@ import 'package:customer/themes/responsive.dart'; import 'package:customer/themes/round_button_fill.dart'; import 'package:customer/themes/text_field_widget.dart'; import 'package:customer/utils/network_image_widget.dart'; + import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:intl/intl.dart'; @@ -25,8 +27,17 @@ class BookTableScreen extends StatelessWidget { appBar: AppBar( centerTitle: false, titleSpacing: 0, - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, - title: Text("Book Table".tr, style: TextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500)), + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + title: Text( + "Book Table".tr, + style: TextStyle( + fontSize: 16, + color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + fontFamily: AppThemeData.medium, + fontWeight: FontWeight.w500, + ), + ), ), body: Padding( padding: const EdgeInsets.symmetric(horizontal: 16), @@ -35,25 +46,55 @@ class BookTableScreen extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))), + decoration: ShapeDecoration( + color: + isDark ? AppThemeData.grey900 : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 12, + ), child: Row( children: [ Expanded( child: Text( "Numbers of Guests".tr, - style: TextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500), + style: TextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.medium, + fontWeight: FontWeight.w500, + ), ), ), Container( height: Responsive.height(4, context), decoration: ShapeDecoration( - color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(200), side: BorderSide(color: isDark ? AppThemeData.grey600 : AppThemeData.grey300)), + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(200), + side: BorderSide( + color: + isDark + ? AppThemeData.grey600 + : AppThemeData.grey300, + ), + ), ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 5), + padding: const EdgeInsets.symmetric( + horizontal: 5, + ), child: Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, @@ -67,7 +108,9 @@ class BookTableScreen extends StatelessWidget { child: const Icon(Icons.remove), ), Padding( - padding: const EdgeInsets.symmetric(horizontal: 10), + padding: const EdgeInsets.symmetric( + horizontal: 10, + ), child: Text( controller.noOfQuantity.toString(), textAlign: TextAlign.start, @@ -77,7 +120,10 @@ class BookTableScreen extends StatelessWidget { overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500, - color: isDark ? AppThemeData.grey100 : AppThemeData.grey800, + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey800, ), ), ), @@ -85,7 +131,10 @@ class BookTableScreen extends StatelessWidget { onTap: () { controller.noOfQuantity.value += 1; }, - child: Icon(Icons.add, color: AppThemeData.primary300), + child: Icon( + Icons.add, + color: AppThemeData.primary300, + ), ), ], ), @@ -97,7 +146,13 @@ class BookTableScreen extends StatelessWidget { ), const SizedBox(height: 10), Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))), + decoration: ShapeDecoration( + color: + isDark ? AppThemeData.grey900 : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( @@ -105,12 +160,22 @@ class BookTableScreen extends StatelessWidget { children: [ Text( "When are you visiting?".tr, - style: TextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w500), + style: TextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w500, + ), ), SizedBox( height: 120, child: ListView.builder( - padding: const EdgeInsets.symmetric(horizontal: 8), + padding: const EdgeInsets.symmetric( + horizontal: 8, + ), physics: const BouncingScrollPhysics(), itemCount: controller.dateList.length, scrollDirection: Axis.horizontal, @@ -118,11 +183,17 @@ class BookTableScreen extends StatelessWidget { return Stack( children: [ Padding( - padding: const EdgeInsets.symmetric(horizontal: 2.0, vertical: 8), + padding: const EdgeInsets.symmetric( + horizontal: 2.0, + vertical: 8, + ), child: GestureDetector( onTap: () { - controller.selectedDate.value = controller.dateList[index].date; - controller.timeSet(controller.dateList[index].date); + controller.selectedDate.value = + controller.dateList[index].date; + controller.timeSet( + controller.dateList[index].date, + ); }, child: Obx( () => Container( @@ -133,41 +204,93 @@ class BookTableScreen extends StatelessWidget { side: BorderSide( width: 1, color: - controller.selectedDate.value == controller.dateList[index].date - ? AppThemeData.primary300 + controller + .selectedDate + .value == + controller + .dateList[index] + .date + ? AppThemeData + .primary300 : isDark ? AppThemeData.grey800 - : AppThemeData.grey100, + : AppThemeData + .grey100, ), - borderRadius: BorderRadius.circular(8), + borderRadius: + BorderRadius.circular(8), ), ), child: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all( + 8.0, + ), child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, children: [ Text( - Constant.calculateDifference(controller.dateList[index].date.toDate()) == 0 + Constant.calculateDifference( + controller + .dateList[index] + .date + .toDate(), + ) == + 0 ? "Today".tr - : Constant.calculateDifference(controller.dateList[index].date.toDate()) == 1 + : Constant.calculateDifference( + controller + .dateList[index] + .date + .toDate(), + ) == + 1 ? "Tomorrow".tr - : DateFormat('EEE').format(controller.dateList[index].date.toDate()), + : DateFormat( + 'EEE', + ).format( + controller + .dateList[index] + .date + .toDate(), + ), style: TextStyle( fontSize: 12, - color: isDark ? AppThemeData.grey400 : AppThemeData.grey500, - fontFamily: AppThemeData.regular, - fontWeight: FontWeight.w500, + color: + isDark + ? AppThemeData + .grey400 + : AppThemeData + .grey500, + fontFamily: + AppThemeData.regular, + fontWeight: + FontWeight.w500, ), ), Text( - DateFormat('d MMM').format(controller.dateList[index].date.toDate()).toString(), + DateFormat('d MMM') + .format( + controller + .dateList[index] + .date + .toDate(), + ) + .toString(), style: TextStyle( fontSize: 16, - color: isDark ? AppThemeData.grey400 : AppThemeData.grey500, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + color: + isDark + ? AppThemeData + .grey400 + : AppThemeData + .grey500, + fontFamily: + AppThemeData.semiBold, + fontWeight: + FontWeight.w600, ), ), ], @@ -183,7 +306,10 @@ class BookTableScreen extends StatelessWidget { right: 0, child: Center( child: RoundedButtonFill( - title: "${controller.dateList[index].discountPer}%".tr, + borderRadius: 10.r, + title: + "${controller.dateList[index].discountPer}%" + .tr, color: AppThemeData.primary300, textColor: AppThemeData.grey50, width: 12, @@ -200,30 +326,69 @@ class BookTableScreen extends StatelessWidget { const SizedBox(height: 10), Text( "Select time slot and scroll to see offers".tr, - style: TextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w500), + style: TextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w500, + ), ), const SizedBox(height: 10), Container( decoration: ShapeDecoration( - shape: RoundedRectangleBorder(side: BorderSide(width: 1, color: isDark ? AppThemeData.grey600 : AppThemeData.grey300), borderRadius: BorderRadius.circular(12)), + shape: RoundedRectangleBorder( + side: BorderSide( + width: 1, + color: + isDark + ? AppThemeData.grey600 + : AppThemeData.grey300, + ), + borderRadius: BorderRadius.circular(12), + ), ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 5), + padding: const EdgeInsets.symmetric( + horizontal: 5, + vertical: 5, + ), child: Wrap( spacing: 5.0, children: [ ...controller.timeSlotList.map( (timeSlotList) => InputChip( - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30)), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(30), + ), side: BorderSide.none, - backgroundColor: isDark ? AppThemeData.grey800 : AppThemeData.grey100, + backgroundColor: + isDark + ? AppThemeData.grey800 + : AppThemeData.grey100, selectedColor: AppThemeData.primary300, - labelStyle: TextStyle(color: isDark ? AppThemeData.grey100 : AppThemeData.grey800), + labelStyle: TextStyle( + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey800, + ), label: Text( - DateFormat('hh:mm a').format(timeSlotList.time!), + DateFormat( + 'hh:mm a', + ).format(timeSlotList.time!), style: TextStyle( color: - controller.selectedTimeSlot.value == DateFormat('hh:mm a').format(timeSlotList.time!) + controller + .selectedTimeSlot + .value == + DateFormat( + 'hh:mm a', + ).format( + timeSlotList.time!, + ) ? AppThemeData.grey50 : isDark ? AppThemeData.grey400 @@ -233,11 +398,22 @@ class BookTableScreen extends StatelessWidget { ), ), showCheckmark: false, - selected: controller.selectedTimeSlot.value == DateFormat('hh:mm a').format(timeSlotList.time!), + selected: + controller.selectedTimeSlot.value == + DateFormat( + 'hh:mm a', + ).format(timeSlotList.time!), onSelected: (value) { - controller.selectedTimeSlot.value = DateFormat('hh:mm a').format(timeSlotList.time!); - controller.selectedTimeDiscount.value = timeSlotList.discountPer!; - controller.selectedTimeDiscountType.value = timeSlotList.discountType!; + controller + .selectedTimeSlot + .value = DateFormat( + 'hh:mm a', + ).format(timeSlotList.time!); + controller.selectedTimeDiscount.value = + timeSlotList.discountPer!; + controller + .selectedTimeDiscountType + .value = timeSlotList.discountType!; }, ), ), @@ -255,55 +431,120 @@ class BookTableScreen extends StatelessWidget { Expanded( child: Text( "Special Occasion".tr, - style: TextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w500), + style: TextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w500, + ), ), ), InkWell( onTap: () { controller.selectedOccasion.value = ""; }, - child: Text("Clear".tr, style: TextStyle(color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w500)), + child: Text( + "Clear".tr, + style: TextStyle( + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w500, + ), + ), ), ], ), const SizedBox(height: 10), Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))), + decoration: ShapeDecoration( + color: + isDark ? AppThemeData.grey900 : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - for (int i = 0; i < controller.occasionList[i].length; i++) + for ( + int i = 0; + i < controller.occasionList[i].length; + i++ + ) ListTile( - contentPadding: const EdgeInsets.symmetric(horizontal: 0.0, vertical: 0.0), - visualDensity: const VisualDensity(horizontal: 0, vertical: -4), + contentPadding: const EdgeInsets.symmetric( + horizontal: 0.0, + vertical: 0.0, + ), + visualDensity: const VisualDensity( + horizontal: 0, + vertical: -4, + ), dense: true, title: Text( //'${controller.occasionList[i]}'.tr, - controller.getLocalizedOccasion(controller.occasionList[i]), - style: TextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500), + controller.getLocalizedOccasion( + controller.occasionList[i], + ), + style: TextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.medium, + fontWeight: FontWeight.w500, + ), ), leading: Radio( - visualDensity: const VisualDensity(horizontal: 0, vertical: -4), + visualDensity: const VisualDensity( + horizontal: 0, + vertical: -4, + ), value: controller.occasionList[i], groupValue: controller.selectedOccasion.value, activeColor: AppThemeData.primary300, onChanged: (value) { - controller.selectedOccasion.value = controller.occasionList[i]; + controller.selectedOccasion.value = + controller.occasionList[i]; }, ), ), ListTile( - contentPadding: const EdgeInsets.symmetric(horizontal: 0.0, vertical: 0.0), - visualDensity: const VisualDensity(horizontal: 0, vertical: -4), + contentPadding: const EdgeInsets.symmetric( + horizontal: 0.0, + vertical: 0.0, + ), + visualDensity: const VisualDensity( + horizontal: 0, + vertical: -4, + ), dense: true, title: Text( 'Is this your first visit?'.tr, - style: TextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500), + style: TextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.medium, + fontWeight: FontWeight.w500, + ), ), leading: Checkbox( - visualDensity: const VisualDensity(horizontal: 0, vertical: -4), + visualDensity: const VisualDensity( + horizontal: 0, + vertical: -4, + ), value: controller.firstVisit.value, activeColor: AppThemeData.primary300, onChanged: (value) { @@ -318,22 +559,44 @@ class BookTableScreen extends StatelessWidget { const SizedBox(height: 10), Text( "Personal Details".tr, - style: TextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w500), + style: TextStyle( + fontSize: 16, + color: + isDark ? AppThemeData.grey50 : AppThemeData.grey900, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w500, + ), ), const SizedBox(height: 10), Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))), + decoration: ShapeDecoration( + color: + isDark ? AppThemeData.grey900 : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ ClipOval( child: NetworkImageWidget( - imageUrl: Constant.userModel!.profilePictureURL.toString(), + imageUrl: + Constant.userModel!.profilePictureURL + .toString(), width: 50, height: 50, - errorWidget: Image.asset(Constant.userPlaceHolder, fit: BoxFit.cover, width: 50, height: 50), + errorWidget: Image.asset( + Constant.userPlaceHolder, + fit: BoxFit.cover, + width: 50, + height: 50, + ), ), ), const SizedBox(width: 10), @@ -342,11 +605,27 @@ class BookTableScreen extends StatelessWidget { children: [ Text( Constant.userModel!.fullName(), - style: TextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w500), + style: TextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w500, + ), ), Text( "${Constant.userModel!.email}", - style: TextStyle(fontSize: 12, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500), + style: TextStyle( + fontSize: 12, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.medium, + fontWeight: FontWeight.w500, + ), ), ], ), @@ -357,10 +636,20 @@ class BookTableScreen extends StatelessWidget { const SizedBox(height: 10), Text( "Additional Requests".tr, - style: TextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w500), + style: TextStyle( + fontSize: 16, + color: + isDark ? AppThemeData.grey50 : AppThemeData.grey900, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w500, + ), ), const SizedBox(height: 10), - TextFieldWidget(controller: controller.additionRequestController.value, hintText: 'Add message here....'.tr, maxLine: 5), + TextFieldWidget( + controller: controller.additionRequestController.value, + hintText: 'Add message here....'.tr, + maxLine: 5, + ), const SizedBox(height: 20), ], ), @@ -372,6 +661,7 @@ class BookTableScreen extends StatelessWidget { child: Padding( padding: const EdgeInsets.only(bottom: 20), child: RoundedButtonFill( + borderRadius: 10.r, title: "Book Now".tr, height: 5.5, color: AppThemeData.primary300, diff --git a/lib/screen_ui/multi_vendor_service/dine_in_screeen/dine_in_details_screen.dart b/lib/screen_ui/multi_vendor_service/dine_in_screeen/dine_in_details_screen.dart index ca857d2..f4aa823 100644 --- a/lib/screen_ui/multi_vendor_service/dine_in_screeen/dine_in_details_screen.dart +++ b/lib/screen_ui/multi_vendor_service/dine_in_screeen/dine_in_details_screen.dart @@ -4,6 +4,7 @@ import 'package:customer/models/favourite_model.dart'; import 'package:customer/models/vendor_model.dart'; import 'package:customer/themes/app_them_data.dart'; import 'package:customer/themes/responsive.dart'; + import '../../../controllers/theme_controller.dart'; import '../../../service/fire_store_utils.dart'; import '../../../themes/show_toast_dialog.dart'; @@ -29,7 +30,10 @@ class DineInDetailsScreen extends StatelessWidget { builder: (controller) { return Scaffold( body: NestedScrollView( - headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { + headerSliverBuilder: ( + BuildContext context, + bool innerBoxIsScrolled, + ) { return [ SliverAppBar( expandedHeight: Responsive.height(30, context), @@ -43,26 +47,66 @@ class DineInDetailsScreen extends StatelessWidget { onTap: () { Get.back(); }, - child: Icon(Icons.arrow_back, color: isDark ? AppThemeData.grey50 : AppThemeData.grey50), + child: Icon( + Icons.arrow_back, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey50, + ), ), const Expanded(child: SizedBox()), InkWell( onTap: () async { - if (controller.favouriteList.where((p0) => p0.restaurantId == controller.vendorModel.value.id).isNotEmpty) { - FavouriteModel favouriteModel = FavouriteModel(restaurantId: controller.vendorModel.value.id, userId: FireStoreUtils.getCurrentUid()); - controller.favouriteList.removeWhere((item) => item.restaurantId == controller.vendorModel.value.id); - await FireStoreUtils.removeFavouriteRestaurant(favouriteModel); + if (controller.favouriteList + .where( + (p0) => + p0.restaurantId == + controller.vendorModel.value.id, + ) + .isNotEmpty) { + FavouriteModel favouriteModel = FavouriteModel( + restaurantId: controller.vendorModel.value.id, + userId: FireStoreUtils.getCurrentUid(), + ); + controller.favouriteList.removeWhere( + (item) => + item.restaurantId == + controller.vendorModel.value.id, + ); + await FireStoreUtils.removeFavouriteRestaurant( + favouriteModel, + ); } else { - FavouriteModel favouriteModel = FavouriteModel(restaurantId: controller.vendorModel.value.id, userId: FireStoreUtils.getCurrentUid()); + FavouriteModel favouriteModel = FavouriteModel( + restaurantId: controller.vendorModel.value.id, + userId: FireStoreUtils.getCurrentUid(), + ); controller.favouriteList.add(favouriteModel); - await FireStoreUtils.setFavouriteRestaurant(favouriteModel); + await FireStoreUtils.setFavouriteRestaurant( + favouriteModel, + ); } }, child: Obx( () => - controller.favouriteList.where((p0) => p0.restaurantId == controller.vendorModel.value.id).isNotEmpty - ? SvgPicture.asset("assets/icons/ic_like_fill.svg", colorFilter: const ColorFilter.mode(AppThemeData.grey50, BlendMode.srcIn)) - : SvgPicture.asset("assets/icons/ic_like.svg"), + controller.favouriteList + .where( + (p0) => + p0.restaurantId == + controller.vendorModel.value.id, + ) + .isNotEmpty + ? SvgPicture.asset( + "assets/icons/ic_like_fill.svg", + colorFilter: const ColorFilter.mode( + AppThemeData.grey50, + BlendMode.srcIn, + ), + ) + : SvgPicture.asset( + "assets/icons/ic_like.svg", + ), ), ), ], @@ -70,18 +114,28 @@ class DineInDetailsScreen extends StatelessWidget { flexibleSpace: FlexibleSpaceBar( background: Stack( children: [ - controller.vendorModel.value.photos == null || controller.vendorModel.value.photos!.isEmpty + controller.vendorModel.value.photos == null || + controller.vendorModel.value.photos!.isEmpty ? Stack( children: [ NetworkImageWidget( - imageUrl: controller.vendorModel.value.photo.toString(), + imageUrl: + controller.vendorModel.value.photo + .toString(), fit: BoxFit.cover, width: Responsive.width(100, context), height: Responsive.height(40, context), ), Container( decoration: BoxDecoration( - gradient: LinearGradient(begin: const Alignment(0.00, -1.00), end: const Alignment(0, 1), colors: [Colors.black.withOpacity(0), Colors.black]), + gradient: LinearGradient( + begin: const Alignment(0.00, -1.00), + end: const Alignment(0, 1), + colors: [ + Colors.black.withOpacity(0), + Colors.black, + ], + ), ), ), ], @@ -90,20 +144,34 @@ class DineInDetailsScreen extends StatelessWidget { physics: const BouncingScrollPhysics(), controller: controller.pageController.value, scrollDirection: Axis.horizontal, - itemCount: controller.vendorModel.value.photos!.length, + itemCount: + controller.vendorModel.value.photos!.length, padEnds: false, pageSnapping: true, onPageChanged: (value) { controller.currentPage.value = value; }, itemBuilder: (BuildContext context, int index) { - String image = controller.vendorModel.value.photos![index]; + String image = + controller.vendorModel.value.photos![index]; return Stack( children: [ - NetworkImageWidget(imageUrl: image.toString(), fit: BoxFit.cover, width: Responsive.width(100, context), height: Responsive.height(40, context)), + NetworkImageWidget( + imageUrl: image.toString(), + fit: BoxFit.cover, + width: Responsive.width(100, context), + height: Responsive.height(40, context), + ), Container( decoration: BoxDecoration( - gradient: LinearGradient(begin: const Alignment(0.00, -1.00), end: const Alignment(0, 1), colors: [Colors.black.withOpacity(0), Colors.black]), + gradient: LinearGradient( + begin: const Alignment(0.00, -1.00), + end: const Alignment(0, 1), + colors: [ + Colors.black.withOpacity(0), + Colors.black, + ], + ), ), ), ], @@ -117,17 +185,26 @@ class DineInDetailsScreen extends StatelessWidget { child: Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, - children: List.generate(controller.vendorModel.value.photos!.length, (index) { - return Obx( - () => Container( - margin: const EdgeInsets.only(right: 5), - alignment: Alignment.centerLeft, - height: 9, - width: 9, - decoration: BoxDecoration(shape: BoxShape.circle, color: controller.currentPage.value == index ? AppThemeData.primary300 : AppThemeData.grey300), - ), - ); - }), + children: List.generate( + controller.vendorModel.value.photos!.length, + (index) { + return Obx( + () => Container( + margin: const EdgeInsets.only(right: 5), + alignment: Alignment.centerLeft, + height: 9, + width: 9, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: + controller.currentPage.value == index + ? AppThemeData.primary300 + : AppThemeData.grey300, + ), + ), + ); + }, + ), ), ), ], @@ -148,38 +225,64 @@ class DineInDetailsScreen extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), + padding: const EdgeInsets.symmetric( + horizontal: 16, + ), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Expanded( child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( - controller.vendorModel.value.title.toString(), + controller.vendorModel.value.title + .toString(), textAlign: TextAlign.start, maxLines: 1, style: TextStyle( fontSize: 22, overflow: TextOverflow.ellipsis, - fontFamily: AppThemeData.semiBold, + fontFamily: + AppThemeData.semiBold, fontWeight: FontWeight.w600, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, ), ), SizedBox( - width: Responsive.width(78, context), + width: Responsive.width( + 78, + context, + ), child: Text( - controller.vendorModel.value.location.toString(), + controller + .vendorModel + .value + .location + .toString(), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500, color: isDark ? AppThemeData.grey400 : AppThemeData.grey400), + style: TextStyle( + fontFamily: + AppThemeData.medium, + fontWeight: FontWeight.w500, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData + .grey400, + ), ), ), ], @@ -189,21 +292,59 @@ class DineInDetailsScreen extends StatelessWidget { children: [ Container( decoration: ShapeDecoration( - color: isDark ? AppThemeData.primary600 : AppThemeData.primary50, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120)), + color: + isDark + ? AppThemeData.primary600 + : AppThemeData.primary50, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(120), + ), ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4), + padding: + const EdgeInsets.symmetric( + horizontal: 12, + vertical: 4, + ), child: Row( children: [ - SvgPicture.asset("assets/icons/ic_star.svg", colorFilter: ColorFilter.mode(AppThemeData.primary300, BlendMode.srcIn)), + SvgPicture.asset( + "assets/icons/ic_star.svg", + colorFilter: + ColorFilter.mode( + AppThemeData + .primary300, + BlendMode.srcIn, + ), + ), const SizedBox(width: 5), Text( Constant.calculateReview( - reviewCount: controller.vendorModel.value.reviewsCount!.toStringAsFixed(0), - reviewSum: controller.vendorModel.value.reviewsSum.toString(), + reviewCount: controller + .vendorModel + .value + .reviewsCount! + .toStringAsFixed(0), + reviewSum: + controller + .vendorModel + .value + .reviewsSum + .toString(), + ), + style: TextStyle( + color: + isDark + ? AppThemeData + .primary300 + : AppThemeData + .primary300, + fontFamily: + AppThemeData.semiBold, + fontWeight: + FontWeight.w600, ), - style: TextStyle(color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600), ), ], ), @@ -212,11 +353,28 @@ class DineInDetailsScreen extends StatelessWidget { const SizedBox(height: 5), InkWell( onTap: () { - Get.to(const ReviewListScreen(), arguments: {"vendorModel": controller.vendorModel.value}); + Get.to( + const ReviewListScreen(), + arguments: { + "vendorModel": + controller + .vendorModel + .value, + }, + ); }, child: Text( "${controller.vendorModel.value.reviewsCount} ${'Ratings'.tr}", - style: TextStyle(decoration: TextDecoration.underline, color: isDark ? AppThemeData.grey200 : AppThemeData.grey700, fontFamily: AppThemeData.regular), + style: TextStyle( + decoration: + TextDecoration.underline, + color: + isDark + ? AppThemeData.grey200 + : AppThemeData.grey700, + fontFamily: + AppThemeData.regular, + ), ), ), ], @@ -226,7 +384,9 @@ class DineInDetailsScreen extends StatelessWidget { Row( children: [ Text( - controller.isOpen.value ? "Open".tr : "Close".tr, + controller.isOpen.value + ? "Open".tr + : "Close".tr, textAlign: TextAlign.start, maxLines: 1, style: TextStyle( @@ -234,13 +394,31 @@ class DineInDetailsScreen extends StatelessWidget { overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600, - color: controller.isOpen.value ? AppThemeData.success400 : AppThemeData.danger300, + color: + controller.isOpen.value + ? AppThemeData.success400 + : AppThemeData.danger300, + ), + ), + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 10, + ), + child: Icon( + Icons.circle, + size: 5, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey500, ), ), - Padding(padding: const EdgeInsets.symmetric(horizontal: 10), child: Icon(Icons.circle, size: 5, color: isDark ? AppThemeData.grey400 : AppThemeData.grey500)), InkWell( onTap: () { - timeShowBottomSheet(context, controller); + timeShowBottomSheet( + context, + controller, + ); }, child: Text( "View Timings".tr, @@ -248,18 +426,36 @@ class DineInDetailsScreen extends StatelessWidget { maxLines: 1, style: TextStyle( fontSize: 14, - decoration: TextDecoration.underline, - decorationColor: AppThemeData.ecommerce300, + decoration: + TextDecoration.underline, + decorationColor: + AppThemeData.ecommerce300, overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600, - color: isDark ? AppThemeData.ecommerce300 : AppThemeData.ecommerce300, + color: + isDark + ? AppThemeData.ecommerce300 + : AppThemeData.ecommerce300, ), ), ), - Padding(padding: const EdgeInsets.symmetric(horizontal: 10), child: Icon(Icons.circle, size: 5, color: isDark ? AppThemeData.grey400 : AppThemeData.grey500)), + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 10, + ), + child: Icon( + Icons.circle, + size: 5, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey500, + ), + ), Text( - "${Constant.amountShow(amount: controller.vendorModel.value.restaurantCost)} ${'for two'.tr}".tr, + "${Constant.amountShow(amount: controller.vendorModel.value.restaurantCost)} ${'for two'.tr}" + .tr, textAlign: TextAlign.start, maxLines: 1, style: TextStyle( @@ -267,13 +463,17 @@ class DineInDetailsScreen extends StatelessWidget { overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600, - color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, ), ), ], ), Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ const SizedBox(height: 20), Text( @@ -285,62 +485,123 @@ class DineInDetailsScreen extends StatelessWidget { overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, ), ), const SizedBox(height: 10), InkWell( onTap: () { if (Constant.userModel == null) { - ShowToastDialog.showToast("Please log in to the application. You are not logged in.".tr); + ShowToastDialog.showToast( + "Please log in to the application. You are not logged in." + .tr, + ); } else { - Get.to(const BookTableScreen(), arguments: {"vendorModel": controller.vendorModel.value}); + Get.to( + const BookTableScreen(), + arguments: { + "vendorModel": + controller + .vendorModel + .value, + }, + ); } }, child: Container( height: 80, clipBehavior: Clip.antiAlias, decoration: ShapeDecoration( - color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, shape: RoundedRectangleBorder( - side: BorderSide(width: 1, color: isDark ? AppThemeData.grey900 : AppThemeData.grey50), - borderRadius: BorderRadius.circular(16), + side: BorderSide( + width: 1, + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + ), + borderRadius: + BorderRadius.circular(16), ), ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: Row( - crossAxisAlignment: CrossAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, children: [ Container( decoration: ShapeDecoration( - color: isDark ? AppThemeData.grey800 : AppThemeData.grey100, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), + color: + isDark + ? AppThemeData + .grey800 + : AppThemeData + .grey100, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 8, + ), + ), + ), + child: Image.asset( + "assets/images/ic_table.gif", ), - child: Image.asset("assets/images/ic_table.gif"), ), const SizedBox(width: 10), Expanded( child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ Text( "Table Booking".tr, style: TextStyle( fontSize: 16, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, + fontFamily: + AppThemeData + .semiBold, + fontWeight: + FontWeight.w600, ), ), Text( - "Quick Conformations".tr, + "Quick Conformations" + .tr, style: TextStyle( fontSize: 12, - color: isDark ? AppThemeData.grey400 : AppThemeData.grey500, - fontFamily: AppThemeData.medium, - fontWeight: FontWeight.w500, + color: + isDark + ? AppThemeData + .grey400 + : AppThemeData + .grey500, + fontFamily: + AppThemeData + .medium, + fontWeight: + FontWeight.w500, ), ), ], @@ -355,52 +616,109 @@ class DineInDetailsScreen extends StatelessWidget { const SizedBox(height: 10), InkWell( onTap: () { - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": controller.vendorModel.value}); + Get.to( + const RestaurantDetailsScreen(), + arguments: { + "vendorModel": + controller.vendorModel.value, + }, + ); }, child: Container( height: 80, clipBehavior: Clip.antiAlias, decoration: ShapeDecoration( - color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, shape: RoundedRectangleBorder( - side: BorderSide(width: 1, color: isDark ? AppThemeData.grey900 : AppThemeData.grey50), - borderRadius: BorderRadius.circular(16), + side: BorderSide( + width: 1, + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + ), + borderRadius: + BorderRadius.circular(16), ), ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: Row( - crossAxisAlignment: CrossAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, children: [ Container( decoration: ShapeDecoration( - color: isDark ? AppThemeData.grey800 : AppThemeData.grey100, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), + color: + isDark + ? AppThemeData + .grey800 + : AppThemeData + .grey100, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 8, + ), + ), + ), + child: Padding( + padding: + const EdgeInsets.all(4), + child: Image.asset( + "assets/images/food_delivery.gif", + ), ), - child: Padding(padding: const EdgeInsets.all(4), child: Image.asset("assets/images/food_delivery.gif")), ), const SizedBox(width: 10), Expanded( child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ Text( - "Available food delivery".tr, + "Available food delivery" + .tr, style: TextStyle( fontSize: 16, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, + fontFamily: + AppThemeData + .semiBold, + fontWeight: + FontWeight.w600, ), ), Text( "in 30-45 mins.".tr, style: TextStyle( fontSize: 12, - color: isDark ? AppThemeData.grey400 : AppThemeData.grey500, - fontFamily: AppThemeData.medium, - fontWeight: FontWeight.w500, + color: + isDark + ? AppThemeData + .grey400 + : AppThemeData + .grey500, + fontFamily: + AppThemeData + .medium, + fontWeight: + FontWeight.w500, ), ), ], @@ -414,10 +732,20 @@ class DineInDetailsScreen extends StatelessWidget { ), ], ), - controller.vendorModel.value.restaurantMenuPhotos == null || controller.vendorModel.value.restaurantMenuPhotos!.isEmpty + controller + .vendorModel + .value + .restaurantMenuPhotos == + null || + controller + .vendorModel + .value + .restaurantMenuPhotos! + .isEmpty ? const SizedBox() : Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ const SizedBox(height: 20), Text( @@ -429,28 +757,65 @@ class DineInDetailsScreen extends StatelessWidget { overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, ), ), SizedBox( - height: Responsive.height(12, context), + height: Responsive.height( + 12, + context, + ), child: ListView.builder( - itemCount: controller.vendorModel.value.restaurantMenuPhotos!.length, + itemCount: + controller + .vendorModel + .value + .restaurantMenuPhotos! + .length, scrollDirection: Axis.horizontal, padding: EdgeInsets.zero, itemBuilder: (context, index) { return InkWell( onTap: () { - Get.to(FullScreenImageViewer(imageUrl: controller.vendorModel.value.restaurantMenuPhotos![index])); + Get.to( + FullScreenImageViewer( + imageUrl: + controller + .vendorModel + .value + .restaurantMenuPhotos![index], + ), + ); }, child: Padding( - padding: const EdgeInsets.all(6.0), + padding: + const EdgeInsets.all( + 6.0, + ), child: ClipRRect( - borderRadius: BorderRadius.circular(10), + borderRadius: + BorderRadius.circular( + 10, + ), child: NetworkImageWidget( - imageUrl: controller.vendorModel.value.restaurantMenuPhotos![index], - height: Responsive.height(12, context), - width: Responsive.height(12, context), + imageUrl: + controller + .vendorModel + .value + .restaurantMenuPhotos![index], + height: + Responsive.height( + 12, + context, + ), + width: + Responsive.height( + 12, + context, + ), fit: BoxFit.fill, ), ), @@ -463,7 +828,8 @@ class DineInDetailsScreen extends StatelessWidget { ), const SizedBox(height: 20), Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( "Location, Timing & Costs".tr, @@ -474,36 +840,64 @@ class DineInDetailsScreen extends StatelessWidget { overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, ), ), const SizedBox(height: 20), Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ - SvgPicture.asset("assets/icons/ic_location.svg"), + SvgPicture.asset( + "assets/icons/ic_location.svg", + ), const SizedBox(width: 14), Expanded( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( - controller.vendorModel.value.location.toString(), + controller + .vendorModel + .value + .location + .toString(), textAlign: TextAlign.start, style: TextStyle( fontSize: 16, - fontFamily: AppThemeData.regular, + fontFamily: + AppThemeData.regular, fontWeight: FontWeight.w400, - color: isDark ? AppThemeData.grey400 : AppThemeData.grey500, + color: + isDark + ? AppThemeData + .grey400 + : AppThemeData + .grey500, ), ), InkWell( onTap: () { launchUrl( Constant.createCoordinatesUrl( - controller.vendorModel.value.latitude ?? 0.0, - controller.vendorModel.value.longitude ?? 0.0, - controller.vendorModel.value.title, + controller + .vendorModel + .value + .latitude ?? + 0.0, + controller + .vendorModel + .value + .longitude ?? + 0.0, + controller + .vendorModel + .value + .title, ), ); }, @@ -512,9 +906,16 @@ class DineInDetailsScreen extends StatelessWidget { textAlign: TextAlign.start, style: TextStyle( fontSize: 16, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, - color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, + fontFamily: + AppThemeData.semiBold, + fontWeight: + FontWeight.w600, + color: + isDark + ? AppThemeData + .primary300 + : AppThemeData + .primary300, ), ), ), @@ -525,21 +926,31 @@ class DineInDetailsScreen extends StatelessWidget { ), const SizedBox(height: 10), Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ - SvgPicture.asset("assets/icons/ic_alarm_clock.svg", height: 20), + SvgPicture.asset( + "assets/icons/ic_alarm_clock.svg", + height: 20, + ), const SizedBox(width: 14), Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( "Timing".tr, textAlign: TextAlign.start, style: TextStyle( fontSize: 16, - fontFamily: AppThemeData.regular, + fontFamily: + AppThemeData.regular, fontWeight: FontWeight.w400, - color: isDark ? AppThemeData.grey400 : AppThemeData.grey500, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData + .grey500, ), ), InkWell( @@ -549,9 +960,15 @@ class DineInDetailsScreen extends StatelessWidget { textAlign: TextAlign.start, style: TextStyle( fontSize: 16, - fontFamily: AppThemeData.semiBold, + fontFamily: + AppThemeData.semiBold, fontWeight: FontWeight.w600, - color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, + color: + isDark + ? AppThemeData + .primary300 + : AppThemeData + .primary300, ), ), ), @@ -561,25 +978,41 @@ class DineInDetailsScreen extends StatelessWidget { ), const SizedBox(height: 10), Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( - Constant.currencyModel!.symbol.toString(), + Constant.currencyModel!.symbol + .toString(), textAlign: TextAlign.center, - style: TextStyle(fontSize: 24, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w400, color: isDark ? AppThemeData.grey400 : AppThemeData.grey500), + style: TextStyle( + fontSize: 24, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w400, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey500, + ), ), const SizedBox(width: 20), Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( "Cost for Two".tr, textAlign: TextAlign.start, style: TextStyle( fontSize: 16, - fontFamily: AppThemeData.regular, + fontFamily: + AppThemeData.regular, fontWeight: FontWeight.w400, - color: isDark ? AppThemeData.grey400 : AppThemeData.grey500, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData + .grey500, ), ), Text( @@ -587,9 +1020,15 @@ class DineInDetailsScreen extends StatelessWidget { textAlign: TextAlign.start, style: TextStyle( fontSize: 16, - fontFamily: AppThemeData.semiBold, + fontFamily: + AppThemeData.semiBold, fontWeight: FontWeight.w600, - color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, + color: + isDark + ? AppThemeData + .primary300 + : AppThemeData + .primary300, ), ), ], @@ -600,7 +1039,8 @@ class DineInDetailsScreen extends StatelessWidget { ), const SizedBox(height: 20), Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( "Cuisines".tr, @@ -611,7 +1051,10 @@ class DineInDetailsScreen extends StatelessWidget { overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, ), ), const SizedBox(height: 10), @@ -620,10 +1063,21 @@ class DineInDetailsScreen extends StatelessWidget { children: [ ...controller.tags.map( (tag) => FilterChip( - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30)), + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(30), + ), side: BorderSide.none, - backgroundColor: isDark ? AppThemeData.grey700 : AppThemeData.grey200, - labelStyle: TextStyle(color: isDark ? AppThemeData.grey100 : AppThemeData.grey800), + backgroundColor: + isDark + ? AppThemeData.grey700 + : AppThemeData.grey200, + labelStyle: TextStyle( + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey800, + ), label: Text("$tag"), onSelected: (bool value) {}, ), @@ -645,12 +1099,17 @@ class DineInDetailsScreen extends StatelessWidget { ); } - Future timeShowBottomSheet(BuildContext context, DineInRestaurantDetailsController productModel) { + Future timeShowBottomSheet( + BuildContext context, + DineInRestaurantDetailsController productModel, + ) { return showModalBottomSheet( context: context, isScrollControlled: true, isDismissible: true, - shape: const RoundedRectangleBorder(borderRadius: BorderRadius.vertical(top: Radius.circular(30))), + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.vertical(top: Radius.circular(30)), + ), clipBehavior: Clip.antiAliasWithSaveLayer, builder: (context) => FractionallySizedBox( @@ -660,7 +1119,8 @@ class DineInDetailsScreen extends StatelessWidget { final themeController = Get.find(); final isDark = themeController.isDark.value; return Scaffold( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, body: Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: Column( @@ -672,7 +1132,15 @@ class DineInDetailsScreen extends StatelessWidget { width: 134, height: 5, margin: const EdgeInsets.only(bottom: 6), - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey50 : AppThemeData.grey800, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(3))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey800, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(3), + ), + ), ), ), ), @@ -680,11 +1148,22 @@ class DineInDetailsScreen extends StatelessWidget { child: ListView.builder( shrinkWrap: true, physics: const BouncingScrollPhysics(), - itemCount: productModel.vendorModel.value.workingHours!.length, + itemCount: + productModel + .vendorModel + .value + .workingHours! + .length, itemBuilder: (context, dayIndex) { - WorkingHours workingHours = productModel.vendorModel.value.workingHours![dayIndex]; + WorkingHours workingHours = + productModel + .vendorModel + .value + .workingHours![dayIndex]; return Padding( - padding: const EdgeInsets.symmetric(vertical: 10), + padding: const EdgeInsets.symmetric( + vertical: 10, + ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -697,34 +1176,72 @@ class DineInDetailsScreen extends StatelessWidget { overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, ), ), const SizedBox(height: 10), - workingHours.timeslot == null || workingHours.timeslot!.isEmpty + workingHours.timeslot == null || + workingHours.timeslot!.isEmpty ? const SizedBox() : ListView.builder( shrinkWrap: true, - physics: const NeverScrollableScrollPhysics(), - itemCount: workingHours.timeslot!.length, + physics: + const NeverScrollableScrollPhysics(), + itemCount: + workingHours.timeslot!.length, itemBuilder: (context, timeIndex) { - Timeslot timeSlotModel = workingHours.timeslot![timeIndex]; + Timeslot timeSlotModel = + workingHours + .timeslot![timeIndex]; return Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all( + 8.0, + ), child: Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Expanded( child: Container( - padding: const EdgeInsets.symmetric(vertical: 10), + padding: + const EdgeInsets.symmetric( + vertical: 10, + ), decoration: BoxDecoration( - borderRadius: const BorderRadius.all(Radius.circular(12)), - border: Border.all(color: isDark ? AppThemeData.grey400 : AppThemeData.grey200), + borderRadius: + const BorderRadius.all( + Radius.circular( + 12, + ), + ), + border: Border.all( + color: + isDark + ? AppThemeData + .grey400 + : AppThemeData + .grey200, + ), ), child: Center( child: Text( - timeSlotModel.from.toString(), - style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 14, color: isDark ? AppThemeData.grey400 : AppThemeData.grey500), + timeSlotModel.from + .toString(), + style: TextStyle( + fontFamily: + AppThemeData + .medium, + fontSize: 14, + color: + isDark + ? AppThemeData + .grey400 + : AppThemeData + .grey500, + ), ), ), ), @@ -732,15 +1249,42 @@ class DineInDetailsScreen extends StatelessWidget { const SizedBox(width: 10), Expanded( child: Container( - padding: const EdgeInsets.symmetric(vertical: 10), + padding: + const EdgeInsets.symmetric( + vertical: 10, + ), decoration: BoxDecoration( - borderRadius: const BorderRadius.all(Radius.circular(12)), - border: Border.all(color: isDark ? AppThemeData.grey400 : AppThemeData.grey200), + borderRadius: + const BorderRadius.all( + Radius.circular( + 12, + ), + ), + border: Border.all( + color: + isDark + ? AppThemeData + .grey400 + : AppThemeData + .grey200, + ), ), child: Center( child: Text( - timeSlotModel.to.toString(), - style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 14, color: isDark ? AppThemeData.grey400 : AppThemeData.grey500), + timeSlotModel.to + .toString(), + style: TextStyle( + fontFamily: + AppThemeData + .medium, + fontSize: 14, + color: + isDark + ? AppThemeData + .grey400 + : AppThemeData + .grey500, + ), ), ), ), diff --git a/lib/screen_ui/multi_vendor_service/dine_in_screeen/dine_in_restaurant_list_screen.dart b/lib/screen_ui/multi_vendor_service/dine_in_screeen/dine_in_restaurant_list_screen.dart index e80c5a8..a8651b3 100644 --- a/lib/screen_ui/multi_vendor_service/dine_in_screeen/dine_in_restaurant_list_screen.dart +++ b/lib/screen_ui/multi_vendor_service/dine_in_screeen/dine_in_restaurant_list_screen.dart @@ -119,40 +119,34 @@ class DineInRestaurantListScreen extends StatelessWidget { ) .isNotEmpty) { FavouriteModel - favouriteModel = - FavouriteModel( - restaurantId: - vendorModel.id, - userId: - FireStoreUtils - .getCurrentUid(), - ); + favouriteModel = FavouriteModel( + restaurantId: + vendorModel.id, + userId: + FireStoreUtils.getCurrentUid(), + ); controller.favouriteList .removeWhere( (item) => item.restaurantId == vendorModel.id, ); - await FireStoreUtils - .removeFavouriteRestaurant( - favouriteModel, - ); + await FireStoreUtils.removeFavouriteRestaurant( + favouriteModel, + ); } else { FavouriteModel - favouriteModel = - FavouriteModel( - restaurantId: - vendorModel.id, - userId: - FireStoreUtils - .getCurrentUid(), - ); + favouriteModel = FavouriteModel( + restaurantId: + vendorModel.id, + userId: + FireStoreUtils.getCurrentUid(), + ); controller.favouriteList .add(favouriteModel); - await FireStoreUtils - .setFavouriteRestaurant( - favouriteModel, - ); + await FireStoreUtils.setFavouriteRestaurant( + favouriteModel, + ); } }, child: Obx( diff --git a/lib/screen_ui/multi_vendor_service/dine_in_screeen/dine_in_screen.dart b/lib/screen_ui/multi_vendor_service/dine_in_screeen/dine_in_screen.dart index 9393aa7..5000f82 100644 --- a/lib/screen_ui/multi_vendor_service/dine_in_screeen/dine_in_screen.dart +++ b/lib/screen_ui/multi_vendor_service/dine_in_screeen/dine_in_screen.dart @@ -1,3 +1,4 @@ +import 'package:customer/constant/const_texts.dart'; import 'package:customer/constant/constant.dart'; import 'package:customer/controllers/dine_in_controller.dart'; import 'package:customer/models/favourite_model.dart'; @@ -9,8 +10,11 @@ import 'package:customer/screen_ui/multi_vendor_service/dine_in_screeen/view_all import 'package:customer/themes/app_them_data.dart'; import 'package:customer/themes/responsive.dart'; import 'package:customer/themes/round_button_fill.dart'; +import 'package:customer/utils/app_router.dart'; import 'package:customer/utils/network_image_widget.dart'; + import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:get/get.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -36,7 +40,10 @@ class DineInScreen extends StatelessWidget { builder: (controller) { return Scaffold( body: NestedScrollView( - headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { + headerSliverBuilder: ( + BuildContext context, + bool innerBoxIsScrolled, + ) { return [ SliverAppBar( expandedHeight: Responsive.height(38, context), @@ -50,14 +57,24 @@ class DineInScreen extends StatelessWidget { onTap: () { Get.back(); }, - child: Icon(Icons.arrow_back, color: isDark ? AppThemeData.grey50 : AppThemeData.grey50), + child: Icon( + Icons.arrow_back, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey50, + ), ), ], ), flexibleSpace: FlexibleSpaceBar( background: Stack( children: [ - Image.asset("assets/images/dine_in_bg.png", fit: BoxFit.fill, width: Responsive.width(100, context)), + Image.asset( + "assets/images/dine_in_bg.png", + fit: BoxFit.fill, + width: Responsive.width(100, context), + ), Center( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 16), @@ -67,12 +84,28 @@ class DineInScreen extends StatelessWidget { children: [ Text( "Dine-In Reservations".tr, - style: TextStyle(fontSize: 24, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600, color: isDark ? AppThemeData.grey900 : AppThemeData.grey900), + style: TextStyle( + fontSize: 24, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w600, + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey900, + ), ), Text( - "Book a table at your favorite restaurant and enjoy a delightful dining experience.".tr, + "Book a table at your favorite restaurant and enjoy a delightful dining experience." + .tr, textAlign: TextAlign.center, - style: TextStyle(fontSize: 14, fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey900 : AppThemeData.grey900), + style: TextStyle( + fontSize: 14, + fontFamily: AppThemeData.regular, + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey900, + ), ), ], ), @@ -87,24 +120,47 @@ class DineInScreen extends StatelessWidget { body: controller.isLoading.value ? Constant.loader() - : Constant.isZoneAvailable == false || controller.allNearestRestaurant.isEmpty + : Constant.isZoneAvailable == false || + controller.allNearestRestaurant.isEmpty ? Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Image.asset("assets/images/location.gif", height: 120), + Image.asset( + "assets/images/location.gif", + height: 120, + ), const SizedBox(height: 12), - Text("No Store Found in Your Area".tr, style: TextStyle(color: isDark ? AppThemeData.grey100 : AppThemeData.grey800, fontSize: 22, fontFamily: AppThemeData.semiBold)), + Text( + "No Store Found in Your Area".tr, + style: TextStyle( + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey800, + fontSize: 22, + fontFamily: AppThemeData.semiBold, + ), + ), const SizedBox(height: 5), Text( - "Currently, there are no available store in your zone. Try changing your location to find nearby options.".tr, + "Currently, there are no available store in your zone. Try changing your location to find nearby options." + .tr, textAlign: TextAlign.center, - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey500, fontSize: 16, fontFamily: AppThemeData.bold), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey500, + fontSize: 16, + fontFamily: AppThemeData.bold, + ), ), const SizedBox(height: 20), RoundedButtonFill( + borderRadius: 10.r, title: "Change Zone".tr, width: 55, height: 5.5, @@ -127,9 +183,13 @@ class DineInScreen extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ const SizedBox(height: 10), - titleView(isDark, "Explore the Categories".tr, () { - Get.to(const ViewAllCategoryDineInScreen()); - }), + titleView( + isDark, + "Explore the Categories".tr, + () { + Get.to(const ViewAllCategoryDineInScreen()); + }, + ), const SizedBox(height: 10), CategoryView(controller: controller), const SizedBox(height: 28), @@ -139,12 +199,23 @@ class DineInScreen extends StatelessWidget { controller.newArrivalRestaurantList.isEmpty ? const SizedBox() : Container( - decoration: const BoxDecoration(image: DecorationImage(image: AssetImage("assets/images/ic_new_arrival_dinein.png"), fit: BoxFit.cover)), + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage( + "assets/images/ic_new_arrival_dinein.png", + ), + fit: BoxFit.cover, + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 16, + ), child: Column( mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Row( children: [ @@ -152,17 +223,42 @@ class DineInScreen extends StatelessWidget { child: Text( "New Arrivals".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey50), + style: TextStyle( + fontFamily: + AppThemeData.semiBold, + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey50, + ), ), ), InkWell( onTap: () { - Get.to(const DineInRestaurantListScreen(), arguments: {"vendorList": controller.newArrivalRestaurantList, "title": "New Arrival"}); + Get.to( + const DineInRestaurantListScreen(), + arguments: { + "vendorList": + controller + .newArrivalRestaurantList, + "title": "New Arrival", + }, + ); }, child: Text( "View all".tr, textAlign: TextAlign.center, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300), + style: TextStyle( + fontFamily: + AppThemeData.regular, + color: + isDark + ? AppThemeData + .primary300 + : AppThemeData + .primary300, + ), ), ), ], @@ -175,11 +271,25 @@ class DineInScreen extends StatelessWidget { ), controller.bannerBottomModel.isEmpty ? const SizedBox() - : Padding(padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20), child: BannerBottomView(controller: controller)), + : Padding( + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 20, + ), + child: BannerBottomView(controller: controller), + ), Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey700 : AppThemeData.grey200, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey700 + : AppThemeData.grey200, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(120), + ), + ), child: Padding( padding: const EdgeInsets.all(8.0), child: Row( @@ -191,15 +301,36 @@ class DineInScreen extends StatelessWidget { }, child: Container( decoration: - controller.isPopular.value == false + controller.isPopular.value == + false ? null - : ShapeDecoration(color: AppThemeData.grey900, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120))), + : ShapeDecoration( + color: AppThemeData.grey900, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 120, + ), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: Text( "Popular Stores".tr, textAlign: TextAlign.center, - style: TextStyle(fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300), + style: TextStyle( + fontFamily: + AppThemeData.semiBold, + color: + isDark + ? AppThemeData + .primary300 + : AppThemeData + .primary300, + ), ), ), ), @@ -214,22 +345,41 @@ class DineInScreen extends StatelessWidget { decoration: controller.isPopular.value == true ? null - : ShapeDecoration(color: AppThemeData.grey900, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120))), + : ShapeDecoration( + color: AppThemeData.grey900, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 120, + ), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: Text( "All Stores".tr, textAlign: TextAlign.center, style: TextStyle( - fontFamily: AppThemeData.semiBold, + fontFamily: + AppThemeData.semiBold, color: - controller.isPopular.value == true + controller + .isPopular + .value == + true ? isDark - ? AppThemeData.grey400 - : AppThemeData.grey500 + ? AppThemeData + .grey400 + : AppThemeData + .grey500 : isDark - ? AppThemeData.primary300 - : AppThemeData.primary300, + ? AppThemeData + .primary300 + : AppThemeData + .primary300, ), ), ), @@ -242,8 +392,14 @@ class DineInScreen extends StatelessWidget { ), ), Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20), - child: controller.isPopular.value ? PopularRestaurant(controller: controller) : AllRestaurant(controller: controller), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 20, + ), + child: + controller.isPopular.value + ? PopularRestaurant(controller: controller) + : AllRestaurant(controller: controller), ), ], ), @@ -257,12 +413,28 @@ class DineInScreen extends StatelessWidget { Row titleView(isDark, String name, Function()? onPress) { return Row( children: [ - Expanded(child: Text(name, textAlign: TextAlign.start, style: TextStyle(fontFamily: AppThemeData.bold, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900))), + Expanded( + child: Text( + name, + textAlign: TextAlign.start, + style: TextStyle( + fontFamily: AppThemeData.bold, + color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + ), + ), + ), InkWell( onTap: () { onPress!(); }, - child: Text("View all".tr, textAlign: TextAlign.center, style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300)), + child: Text( + "View all".tr, + textAlign: TextAlign.center, + style: TextStyle( + fontFamily: AppThemeData.regular, + color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, + ), + ), ), ], ); @@ -288,19 +460,30 @@ class PopularRestaurant extends StatelessWidget { VendorModel vendorModel = controller.popularRestaurantList[index]; return InkWell( onTap: () { - Get.to(const DineInDetailsScreen(), arguments: {"vendorModel": vendorModel}); + Get.to( + const DineInDetailsScreen(), + arguments: {"vendorModel": vendorModel}, + ); }, child: Padding( padding: const EdgeInsets.only(bottom: 20), child: Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16))), + decoration: ShapeDecoration( + color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + ), + ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Stack( children: [ ClipRRect( - borderRadius: const BorderRadius.only(topLeft: Radius.circular(16), topRight: Radius.circular(16)), + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(16), + topRight: Radius.circular(16), + ), child: Stack( children: [ RestaurantImageView(vendorModel: vendorModel), @@ -308,7 +491,14 @@ class PopularRestaurant extends StatelessWidget { height: Responsive.height(20, context), width: Responsive.width(100, context), decoration: BoxDecoration( - gradient: LinearGradient(begin: const Alignment(-0.00, -1.00), end: const Alignment(0, 1), colors: [Colors.black.withOpacity(0), const Color(0xFF111827)]), + gradient: LinearGradient( + begin: const Alignment(-0.00, -1.00), + end: const Alignment(0, 1), + colors: [ + Colors.black.withOpacity(0), + const Color(0xFF111827), + ], + ), ), ), Positioned( @@ -316,21 +506,55 @@ class PopularRestaurant extends StatelessWidget { top: 10, child: InkWell( onTap: () async { - if (controller.favouriteList.where((p0) => p0.restaurantId == vendorModel.id).isNotEmpty) { - FavouriteModel favouriteModel = FavouriteModel(restaurantId: vendorModel.id, userId: FireStoreUtils.getCurrentUid()); - controller.favouriteList.removeWhere((item) => item.restaurantId == vendorModel.id); - await FireStoreUtils.removeFavouriteRestaurant(favouriteModel); + if (controller.favouriteList + .where( + (p0) => + p0.restaurantId == vendorModel.id, + ) + .isNotEmpty) { + FavouriteModel favouriteModel = + FavouriteModel( + restaurantId: vendorModel.id, + userId: + FireStoreUtils.getCurrentUid(), + ); + controller.favouriteList.removeWhere( + (item) => + item.restaurantId == vendorModel.id, + ); + await FireStoreUtils.removeFavouriteRestaurant( + favouriteModel, + ); } else { - FavouriteModel favouriteModel = FavouriteModel(restaurantId: vendorModel.id, userId: FireStoreUtils.getCurrentUid()); - controller.favouriteList.add(favouriteModel); - await FireStoreUtils.setFavouriteRestaurant(favouriteModel); + FavouriteModel favouriteModel = + FavouriteModel( + restaurantId: vendorModel.id, + userId: + FireStoreUtils.getCurrentUid(), + ); + controller.favouriteList.add( + favouriteModel, + ); + await FireStoreUtils.setFavouriteRestaurant( + favouriteModel, + ); } }, child: Obx( () => - controller.favouriteList.where((p0) => p0.restaurantId == vendorModel.id).isNotEmpty - ? SvgPicture.asset("assets/icons/ic_like_fill.svg") - : SvgPicture.asset("assets/icons/ic_like.svg"), + controller.favouriteList + .where( + (p0) => + p0.restaurantId == + vendorModel.id, + ) + .isNotEmpty + ? SvgPicture.asset( + "assets/icons/ic_like_fill.svg", + ) + : SvgPicture.asset( + "assets/icons/ic_like.svg", + ), ), ), ), @@ -338,22 +562,49 @@ class PopularRestaurant extends StatelessWidget { ), ), Transform.translate( - offset: Offset(Responsive.width(-3, context), Responsive.height(17.5, context)), + offset: Offset( + Responsive.width(-3, context), + Responsive.height(17.5, context), + ), child: Row( mainAxisAlignment: MainAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end, children: [ Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.primary600 : AppThemeData.primary50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.primary600 + : AppThemeData.primary50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(120), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 8, + ), child: Row( children: [ - SvgPicture.asset("assets/icons/ic_star.svg", colorFilter: ColorFilter.mode(AppThemeData.primary300, BlendMode.srcIn)), + SvgPicture.asset( + "assets/icons/ic_star.svg", + colorFilter: ColorFilter.mode( + AppThemeData.primary300, + BlendMode.srcIn, + ), + ), const SizedBox(width: 5), Text( "${Constant.calculateReview(reviewCount: vendorModel.reviewsCount!.toStringAsFixed(0), reviewSum: vendorModel.reviewsSum.toString())} (${vendorModel.reviewsCount!.toStringAsFixed(0)})", - style: TextStyle(color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600), + style: TextStyle( + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w600, + ), ), ], ), @@ -362,18 +613,39 @@ class PopularRestaurant extends StatelessWidget { const SizedBox(width: 10), Container( decoration: ShapeDecoration( - color: isDark ? AppThemeData.ecommerce600 : AppThemeData.ecommerce50, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120)), + color: + isDark + ? AppThemeData.ecommerce600 + : AppThemeData.ecommerce50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(120), + ), ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 8, + ), child: Row( children: [ - SvgPicture.asset("assets/icons/ic_map_distance.svg", colorFilter: ColorFilter.mode(AppThemeData.ecommerce300, BlendMode.srcIn)), + SvgPicture.asset( + "assets/icons/ic_map_distance.svg", + colorFilter: ColorFilter.mode( + AppThemeData.ecommerce300, + BlendMode.srcIn, + ), + ), const SizedBox(width: 5), Text( "${Constant.getDistance(lat1: vendorModel.latitude.toString(), lng1: vendorModel.longitude.toString(), lat2: Constant.selectedLocation.location!.latitude.toString(), lng2: Constant.selectedLocation.location!.longitude.toString())} ${Constant.distanceType}", - style: TextStyle(color: isDark ? AppThemeData.ecommerce300 : AppThemeData.ecommerce300, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600), + style: TextStyle( + color: + isDark + ? AppThemeData.ecommerce300 + : AppThemeData.ecommerce300, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w600, + ), ), ], ), @@ -394,13 +666,29 @@ class PopularRestaurant extends StatelessWidget { vendorModel.title.toString(), textAlign: TextAlign.start, maxLines: 1, - style: TextStyle(fontSize: 18, overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontSize: 18, + overflow: TextOverflow.ellipsis, + fontFamily: AppThemeData.semiBold, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), Text( vendorModel.location.toString(), textAlign: TextAlign.start, maxLines: 1, - style: TextStyle(overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500, color: isDark ? AppThemeData.grey400 : AppThemeData.grey400), + style: TextStyle( + overflow: TextOverflow.ellipsis, + fontFamily: AppThemeData.medium, + fontWeight: FontWeight.w500, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey400, + ), ), ], ), @@ -435,19 +723,30 @@ class AllRestaurant extends StatelessWidget { VendorModel vendorModel = controller.allNearestRestaurant[index]; return InkWell( onTap: () { - Get.to(const DineInDetailsScreen(), arguments: {"vendorModel": vendorModel}); + Get.to( + const DineInDetailsScreen(), + arguments: {"vendorModel": vendorModel}, + ); }, child: Padding( padding: const EdgeInsets.only(bottom: 20), child: Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16))), + decoration: ShapeDecoration( + color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + ), + ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Stack( children: [ ClipRRect( - borderRadius: const BorderRadius.only(topLeft: Radius.circular(16), topRight: Radius.circular(16)), + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(16), + topRight: Radius.circular(16), + ), child: Stack( children: [ RestaurantImageView(vendorModel: vendorModel), @@ -455,7 +754,14 @@ class AllRestaurant extends StatelessWidget { height: Responsive.height(20, context), width: Responsive.width(100, context), decoration: BoxDecoration( - gradient: LinearGradient(begin: const Alignment(-0.00, -1.00), end: const Alignment(0, 1), colors: [Colors.black.withOpacity(0), const Color(0xFF111827)]), + gradient: LinearGradient( + begin: const Alignment(-0.00, -1.00), + end: const Alignment(0, 1), + colors: [ + Colors.black.withOpacity(0), + const Color(0xFF111827), + ], + ), ), ), Positioned( @@ -463,21 +769,55 @@ class AllRestaurant extends StatelessWidget { top: 10, child: InkWell( onTap: () async { - if (controller.favouriteList.where((p0) => p0.restaurantId == vendorModel.id).isNotEmpty) { - FavouriteModel favouriteModel = FavouriteModel(restaurantId: vendorModel.id, userId: FireStoreUtils.getCurrentUid()); - controller.favouriteList.removeWhere((item) => item.restaurantId == vendorModel.id); - await FireStoreUtils.removeFavouriteRestaurant(favouriteModel); + if (controller.favouriteList + .where( + (p0) => + p0.restaurantId == vendorModel.id, + ) + .isNotEmpty) { + FavouriteModel favouriteModel = + FavouriteModel( + restaurantId: vendorModel.id, + userId: + FireStoreUtils.getCurrentUid(), + ); + controller.favouriteList.removeWhere( + (item) => + item.restaurantId == vendorModel.id, + ); + await FireStoreUtils.removeFavouriteRestaurant( + favouriteModel, + ); } else { - FavouriteModel favouriteModel = FavouriteModel(restaurantId: vendorModel.id, userId: FireStoreUtils.getCurrentUid()); - controller.favouriteList.add(favouriteModel); - await FireStoreUtils.setFavouriteRestaurant(favouriteModel); + FavouriteModel favouriteModel = + FavouriteModel( + restaurantId: vendorModel.id, + userId: + FireStoreUtils.getCurrentUid(), + ); + controller.favouriteList.add( + favouriteModel, + ); + await FireStoreUtils.setFavouriteRestaurant( + favouriteModel, + ); } }, child: Obx( () => - controller.favouriteList.where((p0) => p0.restaurantId == vendorModel.id).isNotEmpty - ? SvgPicture.asset("assets/icons/ic_like_fill.svg") - : SvgPicture.asset("assets/icons/ic_like.svg"), + controller.favouriteList + .where( + (p0) => + p0.restaurantId == + vendorModel.id, + ) + .isNotEmpty + ? SvgPicture.asset( + "assets/icons/ic_like_fill.svg", + ) + : SvgPicture.asset( + "assets/icons/ic_like.svg", + ), ), ), ), @@ -485,22 +825,49 @@ class AllRestaurant extends StatelessWidget { ), ), Transform.translate( - offset: Offset(Responsive.width(-3, context), Responsive.height(17.5, context)), + offset: Offset( + Responsive.width(-3, context), + Responsive.height(17.5, context), + ), child: Row( mainAxisAlignment: MainAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end, children: [ Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.primary600 : AppThemeData.primary50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.primary600 + : AppThemeData.primary50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(120), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 8, + ), child: Row( children: [ - SvgPicture.asset("assets/icons/ic_star.svg", colorFilter: ColorFilter.mode(AppThemeData.primary300, BlendMode.srcIn)), + SvgPicture.asset( + "assets/icons/ic_star.svg", + colorFilter: ColorFilter.mode( + AppThemeData.primary300, + BlendMode.srcIn, + ), + ), const SizedBox(width: 5), Text( "${Constant.calculateReview(reviewCount: vendorModel.reviewsCount.toString(), reviewSum: vendorModel.reviewsSum.toString())} (${vendorModel.reviewsCount!.toStringAsFixed(0)})", - style: TextStyle(color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600), + style: TextStyle( + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w600, + ), ), ], ), @@ -509,18 +876,39 @@ class AllRestaurant extends StatelessWidget { const SizedBox(width: 10), Container( decoration: ShapeDecoration( - color: isDark ? AppThemeData.ecommerce600 : AppThemeData.ecommerce50, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120)), + color: + isDark + ? AppThemeData.ecommerce600 + : AppThemeData.ecommerce50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(120), + ), ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 8, + ), child: Row( children: [ - SvgPicture.asset("assets/icons/ic_map_distance.svg", colorFilter: ColorFilter.mode(AppThemeData.ecommerce300, BlendMode.srcIn)), + SvgPicture.asset( + "assets/icons/ic_map_distance.svg", + colorFilter: ColorFilter.mode( + AppThemeData.ecommerce300, + BlendMode.srcIn, + ), + ), const SizedBox(width: 5), Text( "${Constant.getDistance(lat1: vendorModel.latitude.toString(), lng1: vendorModel.longitude.toString(), lat2: Constant.selectedLocation.location!.latitude.toString(), lng2: Constant.selectedLocation.location!.longitude.toString())} ${Constant.distanceType}", - style: TextStyle(color: isDark ? AppThemeData.ecommerce300 : AppThemeData.ecommerce300, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600), + style: TextStyle( + color: + isDark + ? AppThemeData.ecommerce300 + : AppThemeData.ecommerce300, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w600, + ), ), ], ), @@ -541,13 +929,29 @@ class AllRestaurant extends StatelessWidget { vendorModel.title.toString(), textAlign: TextAlign.start, maxLines: 1, - style: TextStyle(fontSize: 18, overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontSize: 18, + overflow: TextOverflow.ellipsis, + fontFamily: AppThemeData.semiBold, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), Text( vendorModel.location.toString(), textAlign: TextAlign.start, maxLines: 1, - style: TextStyle(overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500, color: isDark ? AppThemeData.grey400 : AppThemeData.grey400), + style: TextStyle( + overflow: TextOverflow.ellipsis, + fontFamily: AppThemeData.medium, + fontWeight: FontWeight.w500, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey400, + ), ), ], ), @@ -577,12 +981,18 @@ class NewArrival extends StatelessWidget { child: ListView.builder( physics: const BouncingScrollPhysics(), scrollDirection: Axis.horizontal, - itemCount: controller.newArrivalRestaurantList.length >= 10 ? 10 : controller.newArrivalRestaurantList.length, + itemCount: + controller.newArrivalRestaurantList.length >= 10 + ? 10 + : controller.newArrivalRestaurantList.length, itemBuilder: (BuildContext context, int index) { VendorModel vendorModel = controller.newArrivalRestaurantList[index]; return InkWell( onTap: () { - Get.to(const DineInDetailsScreen(), arguments: {"vendorModel": vendorModel}); + Get.to( + const DineInDetailsScreen(), + arguments: {"vendorModel": vendorModel}, + ); }, child: Padding( padding: const EdgeInsets.only(right: 10), @@ -593,13 +1003,27 @@ class NewArrival extends StatelessWidget { children: [ Expanded( child: ClipRRect( - borderRadius: const BorderRadius.all(Radius.circular(10)), + borderRadius: const BorderRadius.all( + Radius.circular(10), + ), child: Stack( children: [ - NetworkImageWidget(imageUrl: vendorModel.photo.toString(), fit: BoxFit.cover, height: Responsive.height(100, context), width: Responsive.width(100, context)), + NetworkImageWidget( + imageUrl: vendorModel.photo.toString(), + fit: BoxFit.cover, + height: Responsive.height(100, context), + width: Responsive.width(100, context), + ), Container( decoration: BoxDecoration( - gradient: LinearGradient(begin: const Alignment(0.00, 1.00), end: const Alignment(0, -1), colors: [Colors.black.withOpacity(0), AppThemeData.grey900]), + gradient: LinearGradient( + begin: const Alignment(0.00, 1.00), + end: const Alignment(0, -1), + colors: [ + Colors.black.withOpacity(0), + AppThemeData.grey900, + ], + ), ), ), Positioned( @@ -607,21 +1031,55 @@ class NewArrival extends StatelessWidget { top: 10, child: InkWell( onTap: () async { - if (controller.favouriteList.where((p0) => p0.restaurantId == vendorModel.id).isNotEmpty) { - FavouriteModel favouriteModel = FavouriteModel(restaurantId: vendorModel.id, userId: FireStoreUtils.getCurrentUid()); - controller.favouriteList.removeWhere((item) => item.restaurantId == vendorModel.id); - await FireStoreUtils.removeFavouriteRestaurant(favouriteModel); + if (controller.favouriteList + .where( + (p0) => + p0.restaurantId == vendorModel.id, + ) + .isNotEmpty) { + FavouriteModel favouriteModel = + FavouriteModel( + restaurantId: vendorModel.id, + userId: + FireStoreUtils.getCurrentUid(), + ); + controller.favouriteList.removeWhere( + (item) => + item.restaurantId == vendorModel.id, + ); + await FireStoreUtils.removeFavouriteRestaurant( + favouriteModel, + ); } else { - FavouriteModel favouriteModel = FavouriteModel(restaurantId: vendorModel.id, userId: FireStoreUtils.getCurrentUid()); - controller.favouriteList.add(favouriteModel); - await FireStoreUtils.setFavouriteRestaurant(favouriteModel); + FavouriteModel favouriteModel = + FavouriteModel( + restaurantId: vendorModel.id, + userId: + FireStoreUtils.getCurrentUid(), + ); + controller.favouriteList.add( + favouriteModel, + ); + await FireStoreUtils.setFavouriteRestaurant( + favouriteModel, + ); } }, child: Obx( () => - controller.favouriteList.where((p0) => p0.restaurantId == vendorModel.id).isNotEmpty - ? SvgPicture.asset("assets/icons/ic_like_fill.svg") - : SvgPicture.asset("assets/icons/ic_like.svg"), + controller.favouriteList + .where( + (p0) => + p0.restaurantId == + vendorModel.id, + ) + .isNotEmpty + ? SvgPicture.asset( + "assets/icons/ic_like_fill.svg", + ) + : SvgPicture.asset( + "assets/icons/ic_like.svg", + ), ), ), ), @@ -634,13 +1092,25 @@ class NewArrival extends StatelessWidget { vendorModel.title.toString(), textAlign: TextAlign.start, maxLines: 1, - style: TextStyle(fontSize: 16, overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.grey50 : AppThemeData.grey50), + style: TextStyle( + fontSize: 16, + overflow: TextOverflow.ellipsis, + fontFamily: AppThemeData.semiBold, + color: + isDark ? AppThemeData.grey50 : AppThemeData.grey50, + ), ), Row( children: [ Row( children: [ - SvgPicture.asset("assets/icons/ic_star.svg", colorFilter: ColorFilter.mode(AppThemeData.primary300, BlendMode.srcIn)), + SvgPicture.asset( + "assets/icons/ic_star.svg", + colorFilter: ColorFilter.mode( + AppThemeData.primary300, + BlendMode.srcIn, + ), + ), const SizedBox(width: 10), Text( "${Constant.calculateReview(reviewCount: vendorModel.reviewsCount.toString(), reviewSum: vendorModel.reviewsSum.toString())} (${vendorModel.reviewsCount!.toStringAsFixed(0)})", @@ -650,7 +1120,10 @@ class NewArrival extends StatelessWidget { overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500, - color: isDark ? AppThemeData.grey400 : AppThemeData.grey400, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey400, ), ), ], @@ -658,7 +1131,9 @@ class NewArrival extends StatelessWidget { const SizedBox(width: 20), Row( children: [ - SvgPicture.asset("assets/icons/ic_map_distance.svg"), + SvgPicture.asset( + "assets/icons/ic_map_distance.svg", + ), const SizedBox(width: 10), Text( "${Constant.getDistance(lat1: vendorModel.latitude.toString(), lng1: vendorModel.longitude.toString(), lat2: Constant.selectedLocation.location!.latitude.toString(), lng2: Constant.selectedLocation.location!.longitude.toString())} ${Constant.distanceType}", @@ -668,7 +1143,10 @@ class NewArrival extends StatelessWidget { overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500, - color: isDark ? AppThemeData.grey400 : AppThemeData.grey400, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey400, ), ), ], @@ -679,7 +1157,15 @@ class NewArrival extends StatelessWidget { vendorModel.location.toString(), textAlign: TextAlign.start, maxLines: 1, - style: TextStyle(overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500, color: isDark ? AppThemeData.grey400 : AppThemeData.grey400), + style: TextStyle( + overflow: TextOverflow.ellipsis, + fontFamily: AppThemeData.medium, + fontWeight: FontWeight.w500, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey400, + ), ), ], ), @@ -708,10 +1194,17 @@ class CategoryView extends StatelessWidget { padding: EdgeInsets.zero, itemCount: controller.vendorCategoryModel.length, itemBuilder: (context, index) { - VendorCategoryModel vendorCategoryModel = controller.vendorCategoryModel[index]; + VendorCategoryModel vendorCategoryModel = + controller.vendorCategoryModel[index]; return InkWell( onTap: () { - Get.to(const CategoryRestaurantScreen(), arguments: {"vendorCategoryModel": vendorCategoryModel, "dineIn": true}); + Get.to( + const CategoryRestaurantScreen(), + arguments: { + "vendorCategoryModel": vendorCategoryModel, + "dineIn": true, + }, + ); }, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 4), @@ -721,7 +1214,14 @@ class CategoryView extends StatelessWidget { decoration: ShapeDecoration( color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder( - side: BorderSide(width: 1, strokeAlign: BorderSide.strokeAlignOutside, color: isDark ? AppThemeData.grey800 : AppThemeData.grey100), + side: BorderSide( + width: 1, + strokeAlign: BorderSide.strokeAlignOutside, + color: + isDark + ? AppThemeData.grey800 + : AppThemeData.grey100, + ), borderRadius: BorderRadius.circular(100), ), ), @@ -729,14 +1229,32 @@ class CategoryView extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.center, children: [ - SizedBox(width: 60, height: 60, child: ClipOval(child: NetworkImageWidget(imageUrl: vendorCategoryModel.photo.toString(), fit: BoxFit.cover))), + SizedBox( + width: 60, + height: 60, + child: ClipOval( + child: NetworkImageWidget( + imageUrl: vendorCategoryModel.photo.toString(), + fit: BoxFit.cover, + ), + ), + ), Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 10, + ), child: Text( '${vendorCategoryModel.title}', textAlign: TextAlign.center, maxLines: 1, - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.medium), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.medium, + ), ), ), ], @@ -777,18 +1295,33 @@ class BannerBottomView extends StatelessWidget { return InkWell( onTap: () async { if (bannerModel.redirect_type == "store") { - ShowToastDialog.showLoader("Please wait...".tr); - VendorModel? vendorModel = await FireStoreUtils.getVendorById(bannerModel.redirect_id.toString()); + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); + VendorModel? vendorModel = + await FireStoreUtils.getVendorById( + bannerModel.redirect_id.toString(), + ); ShowToastDialog.closeLoader(); - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": vendorModel}); + Get.to( + const RestaurantDetailsScreen(), + arguments: {"vendorModel": vendorModel}, + ); } else if (bannerModel.redirect_type == "product") { - ShowToastDialog.showLoader("Please wait...".tr); - ProductModel? productModel = await FireStoreUtils.getProductById(bannerModel.redirect_id.toString()); - VendorModel? vendorModel = await FireStoreUtils.getVendorById(productModel!.vendorID.toString()); + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); + ProductModel? productModel = + await FireStoreUtils.getProductById( + bannerModel.redirect_id.toString(), + ); + VendorModel? vendorModel = + await FireStoreUtils.getVendorById( + productModel!.vendorID.toString(), + ); ShowToastDialog.closeLoader(); - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": vendorModel}); + Get.to( + const RestaurantDetailsScreen(), + arguments: {"vendorModel": vendorModel}, + ); } else if (bannerModel.redirect_type == "external_link") { final uri = Uri.parse(bannerModel.redirect_id.toString()); if (await canLaunchUrl(uri)) { @@ -800,7 +1333,13 @@ class BannerBottomView extends StatelessWidget { }, child: Padding( padding: const EdgeInsets.only(right: 14), - child: ClipRRect(borderRadius: const BorderRadius.all(Radius.circular(12)), child: NetworkImageWidget(imageUrl: bannerModel.photo.toString(), fit: BoxFit.cover)), + child: ClipRRect( + borderRadius: const BorderRadius.all(Radius.circular(12)), + child: NetworkImageWidget( + imageUrl: bannerModel.photo.toString(), + fit: BoxFit.cover, + ), + ), ), ); }, @@ -811,14 +1350,22 @@ class BannerBottomView extends StatelessWidget { child: Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, - children: List.generate(controller.bannerBottomModel.length, (index) { + children: List.generate(controller.bannerBottomModel.length, ( + index, + ) { return Obx( () => Container( margin: const EdgeInsets.only(right: 5), alignment: Alignment.centerLeft, height: 9, width: 9, - decoration: BoxDecoration(shape: BoxShape.circle, color: controller.currentBottomPage.value == index ? AppThemeData.primary300 : Colors.black12), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: + controller.currentBottomPage.value == index + ? AppThemeData.primary300 + : Colors.black12, + ), ), ); }), diff --git a/lib/screen_ui/multi_vendor_service/dine_in_screeen/view_all_category_dine_in_screen.dart b/lib/screen_ui/multi_vendor_service/dine_in_screeen/view_all_category_dine_in_screen.dart index 6d27058..538bb0d 100644 --- a/lib/screen_ui/multi_vendor_service/dine_in_screeen/view_all_category_dine_in_screen.dart +++ b/lib/screen_ui/multi_vendor_service/dine_in_screeen/view_all_category_dine_in_screen.dart @@ -3,9 +3,9 @@ import 'package:customer/controllers/view_all_category_controller.dart'; import 'package:customer/models/vendor_category_model.dart'; import 'package:customer/themes/app_them_data.dart'; import 'package:customer/utils/network_image_widget.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; - import '../../../controllers/theme_controller.dart'; import '../home_screen/category_restaurant_screen.dart'; @@ -17,55 +17,79 @@ class ViewAllCategoryDineInScreen extends StatelessWidget { final themeController = Get.find(); final isDark = themeController.isDark.value; return GetX( - init: ViewAllCategoryController(), - builder: (controller) { - return Scaffold( - appBar: AppBar( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, - centerTitle: false, - titleSpacing: 0, - title: Text( - "Categories".tr, - style: TextStyle( - fontSize: 16, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, - fontFamily: AppThemeData.medium, - fontWeight: FontWeight.w500, - ), + init: ViewAllCategoryController(), + builder: (controller) { + return Scaffold( + appBar: AppBar( + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + centerTitle: false, + titleSpacing: 0, + title: Text( + "Categories".tr, + style: TextStyle( + fontSize: 16, + color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + fontFamily: AppThemeData.medium, + fontWeight: FontWeight.w500, ), ), - body: controller.isLoading.value - ? Constant.loader() - : Padding( + ), + body: + controller.isLoading.value + ? Constant.loader() + : Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: GridView.builder( padding: EdgeInsets.zero, - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4, childAspectRatio: 3.5 / 6, crossAxisSpacing: 6), + gridDelegate: + const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 4, + childAspectRatio: 3.5 / 6, + crossAxisSpacing: 6, + ), itemCount: controller.vendorCategoryModel.length, physics: const NeverScrollableScrollPhysics(), shrinkWrap: true, itemBuilder: (context, index) { - VendorCategoryModel vendorCategoryModel = controller.vendorCategoryModel[index]; + VendorCategoryModel vendorCategoryModel = + controller.vendorCategoryModel[index]; return InkWell( onTap: () { - Get.to(const CategoryRestaurantScreen(), arguments: {"vendorCategoryModel": vendorCategoryModel, "dineIn": true}); + Get.to( + const CategoryRestaurantScreen(), + arguments: { + "vendorCategoryModel": vendorCategoryModel, + "dineIn": true, + }, + ); }, child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 6), + padding: const EdgeInsets.symmetric( + horizontal: 4, + vertical: 6, + ), child: Container( decoration: ShapeDecoration( - color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, shape: RoundedRectangleBorder( side: BorderSide( width: 1, strokeAlign: BorderSide.strokeAlignOutside, - color: isDark ? AppThemeData.grey800 : AppThemeData.grey100, + color: + isDark + ? AppThemeData.grey800 + : AppThemeData.grey100, ), borderRadius: BorderRadius.circular(100), ), ), child: Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.center, children: [ SizedBox( @@ -73,23 +97,31 @@ class ViewAllCategoryDineInScreen extends StatelessWidget { height: 60, child: ClipOval( child: NetworkImageWidget( - imageUrl: vendorCategoryModel.photo.toString(), + imageUrl: + vendorCategoryModel.photo + .toString(), fit: BoxFit.cover, ), ), ), Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 10, + ), child: Text( '${vendorCategoryModel.title}', textAlign: TextAlign.center, maxLines: 2, style: TextStyle( - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, fontFamily: AppThemeData.medium, ), ), - ) + ), ], ), ), @@ -98,7 +130,8 @@ class ViewAllCategoryDineInScreen extends StatelessWidget { }, ), ), - ); - }); + ); + }, + ); } } diff --git a/lib/screen_ui/multi_vendor_service/edit_profile_screen/edit_profile_screen.dart b/lib/screen_ui/multi_vendor_service/edit_profile_screen/edit_profile_screen.dart index 06a0df5..2af3d63 100644 --- a/lib/screen_ui/multi_vendor_service/edit_profile_screen/edit_profile_screen.dart +++ b/lib/screen_ui/multi_vendor_service/edit_profile_screen/edit_profile_screen.dart @@ -6,7 +6,9 @@ import 'package:customer/themes/responsive.dart'; import 'package:customer/themes/round_button_fill.dart'; import 'package:customer/themes/text_field_widget.dart'; import 'package:customer/utils/network_image_widget.dart'; + import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:get/get.dart'; import 'package:image_picker/image_picker.dart'; @@ -23,7 +25,12 @@ class EditProfileScreen extends StatelessWidget { init: EditProfileController(), builder: (controller) { return Scaffold( - appBar: AppBar(centerTitle: false, titleSpacing: 0, backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface), + appBar: AppBar( + centerTitle: false, + titleSpacing: 0, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + ), body: SingleChildScrollView( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 16), @@ -32,11 +39,24 @@ class EditProfileScreen extends StatelessWidget { children: [ Text( "Profile Information".tr, - style: TextStyle(fontSize: 24, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w500), + style: TextStyle( + fontSize: 24, + color: + isDark ? AppThemeData.grey50 : AppThemeData.grey900, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w500, + ), ), Text( - "View and update your personal details, contact information, and preferences.".tr, - style: TextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w400), + "View and update your personal details, contact information, and preferences." + .tr, + style: TextStyle( + fontSize: 16, + color: + isDark ? AppThemeData.grey50 : AppThemeData.grey900, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w400, + ), ), const SizedBox(height: 20), Center( @@ -45,12 +65,25 @@ class EditProfileScreen extends StatelessWidget { controller.profileImage.isEmpty ? ClipRRect( borderRadius: BorderRadius.circular(60), - child: Image.asset(Constant.userPlaceHolder, height: Responsive.width(24, context), width: Responsive.width(24, context), fit: BoxFit.cover), + child: Image.asset( + Constant.userPlaceHolder, + height: Responsive.width(24, context), + width: Responsive.width(24, context), + fit: BoxFit.cover, + ), ) - : Constant().hasValidUrl(controller.profileImage.value) == false + : Constant().hasValidUrl( + controller.profileImage.value, + ) == + false ? ClipRRect( borderRadius: BorderRadius.circular(60), - child: Image.file(File(controller.profileImage.value), height: Responsive.width(24, context), width: Responsive.width(24, context), fit: BoxFit.cover), + child: Image.file( + File(controller.profileImage.value), + height: Responsive.width(24, context), + width: Responsive.width(24, context), + fit: BoxFit.cover, + ), ) : ClipRRect( borderRadius: BorderRadius.circular(60), @@ -59,7 +92,12 @@ class EditProfileScreen extends StatelessWidget { imageUrl: controller.profileImage.value, height: Responsive.width(24, context), width: Responsive.width(24, context), - errorWidget: Image.asset(Constant.userPlaceHolder, fit: BoxFit.cover, height: Responsive.width(24, context), width: Responsive.width(24, context)), + errorWidget: Image.asset( + Constant.userPlaceHolder, + fit: BoxFit.cover, + height: Responsive.width(24, context), + width: Responsive.width(24, context), + ), ), ), Positioned( @@ -78,13 +116,37 @@ class EditProfileScreen extends StatelessWidget { const SizedBox(height: 20), Row( children: [ - Expanded(child: TextFieldWidget(title: 'First Name'.tr, controller: controller.firstNameController.value, hintText: 'First Name'.tr)), + Expanded( + child: TextFieldWidget( + title: 'First Name'.tr, + controller: controller.firstNameController.value, + hintText: 'First Name'.tr, + ), + ), const SizedBox(width: 10), - Expanded(child: TextFieldWidget(title: 'Last Name'.tr, controller: controller.lastNameController.value, hintText: 'Last Name'.tr)), + Expanded( + child: TextFieldWidget( + title: 'Last Name'.tr, + controller: controller.lastNameController.value, + hintText: 'Last Name'.tr, + ), + ), ], ), - TextFieldWidget(title: 'Email'.tr, textInputType: TextInputType.emailAddress, controller: controller.emailController.value, hintText: 'Email'.tr, enable: false), - TextFieldWidget(title: 'Phone Number'.tr, textInputType: TextInputType.emailAddress, controller: controller.phoneNumberController.value, hintText: 'Phone Number'.tr, enable: false), + TextFieldWidget( + title: 'Email'.tr, + textInputType: TextInputType.emailAddress, + controller: controller.emailController.value, + hintText: 'Email'.tr, + enable: false, + ), + TextFieldWidget( + title: 'Phone Number'.tr, + textInputType: TextInputType.emailAddress, + controller: controller.phoneNumberController.value, + hintText: 'Phone Number'.tr, + enable: false, + ), ], ), ), @@ -95,6 +157,7 @@ class EditProfileScreen extends StatelessWidget { child: Padding( padding: const EdgeInsets.only(bottom: 20), child: RoundedButtonFill( + borderRadius: 10.r, title: "Save Details".tr, height: 5.5, color: AppThemeData.primary300, @@ -111,7 +174,10 @@ class EditProfileScreen extends StatelessWidget { ); } - Future buildBottomSheet(BuildContext context, EditProfileController controller) { + Future buildBottomSheet( + BuildContext context, + EditProfileController controller, + ) { return showModalBottomSheet( context: context, builder: (context) { @@ -122,7 +188,16 @@ class EditProfileScreen extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ - Padding(padding: const EdgeInsets.only(top: 15), child: Text("please select".tr, style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600))), + Padding( + padding: const EdgeInsets.only(top: 15), + child: Text( + "please select".tr, + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + ), + ), + ), Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, @@ -132,8 +207,20 @@ class EditProfileScreen extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ - IconButton(onPressed: () => controller.pickFile(source: ImageSource.camera), icon: const Icon(Icons.camera_alt, size: 32)), - Padding(padding: const EdgeInsets.only(top: 3), child: Text("camera".tr, style: const TextStyle())), + IconButton( + onPressed: + () => controller.pickFile( + source: ImageSource.camera, + ), + icon: const Icon(Icons.camera_alt, size: 32), + ), + Padding( + padding: const EdgeInsets.only(top: 3), + child: Text( + "camera".tr, + style: const TextStyle(), + ), + ), ], ), ), @@ -143,8 +230,23 @@ class EditProfileScreen extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ - IconButton(onPressed: () => controller.pickFile(source: ImageSource.gallery), icon: const Icon(Icons.photo_library_sharp, size: 32)), - Padding(padding: const EdgeInsets.only(top: 3), child: Text("gallery".tr, style: const TextStyle())), + IconButton( + onPressed: + () => controller.pickFile( + source: ImageSource.gallery, + ), + icon: const Icon( + Icons.photo_library_sharp, + size: 32, + ), + ), + Padding( + padding: const EdgeInsets.only(top: 3), + child: Text( + "gallery".tr, + style: const TextStyle(), + ), + ), ], ), ), diff --git a/lib/screen_ui/multi_vendor_service/favourite_screens/favourite_screen.dart b/lib/screen_ui/multi_vendor_service/favourite_screens/favourite_screen.dart index 47a2d40..97cf5ba 100644 --- a/lib/screen_ui/multi_vendor_service/favourite_screens/favourite_screen.dart +++ b/lib/screen_ui/multi_vendor_service/favourite_screens/favourite_screen.dart @@ -7,6 +7,8 @@ import 'package:customer/models/vendor_model.dart'; import 'package:customer/themes/app_them_data.dart'; import 'package:customer/themes/responsive.dart'; import 'package:customer/themes/round_button_fill.dart'; +import 'package:customer/utils/app_router.dart'; + import '../../../controllers/theme_controller.dart'; import 'package:customer/utils/network_image_widget.dart'; import 'package:flutter/material.dart'; @@ -29,12 +31,15 @@ class FavouriteScreen extends StatelessWidget { init: FavouriteController(), builder: (controller) { return Scaffold( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, body: controller.isLoading.value ? Constant.loader() : Padding( - padding: EdgeInsets.only(top: MediaQuery.of(context).viewPadding.top), + padding: EdgeInsets.only( + top: MediaQuery.of(context).viewPadding.top, + ), child: Column( children: [ Padding( @@ -44,7 +49,15 @@ class FavouriteScreen extends StatelessWidget { Expanded( child: Text( "Your Favourites, All in One Place".tr, - style: TextStyle(fontSize: 24, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w500), + style: TextStyle( + fontSize: 24, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w500, + ), ), ), //SvgPicture.asset("assets/images/ic_favourite.svg"), @@ -56,22 +69,44 @@ class FavouriteScreen extends StatelessWidget { child: Constant.userModel == null ? Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), + padding: const EdgeInsets.symmetric( + horizontal: 16, + ), child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, children: [ - Image.asset("assets/images/login.gif", height: 120), + Image.asset( + "assets/images/login.gif", + height: 120, + ), const SizedBox(height: 12), Text( "Please Log In to Continue".tr, - style: TextStyle(color: isDark ? AppThemeData.grey100 : AppThemeData.grey800, fontSize: 22, fontFamily: AppThemeData.semiBold), + style: TextStyle( + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey800, + fontSize: 22, + fontFamily: AppThemeData.semiBold, + ), ), const SizedBox(height: 5), Text( - "You’re not logged in. Please sign in to access your account and explore all features.".tr, + "You’re not logged in. Please sign in to access your account and explore all features." + .tr, textAlign: TextAlign.center, - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey500, fontSize: 16, fontFamily: AppThemeData.bold), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey500, + fontSize: 16, + fontFamily: AppThemeData.bold, + ), ), const SizedBox(height: 20), RoundedButtonFill( @@ -90,11 +125,19 @@ class FavouriteScreen extends StatelessWidget { : Column( children: [ Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), + padding: const EdgeInsets.symmetric( + horizontal: 16, + ), child: Container( decoration: ShapeDecoration( - color: isDark ? AppThemeData.grey700 : AppThemeData.grey200, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120)), + color: + isDark + ? AppThemeData.grey700 + : AppThemeData.grey200, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(120), + ), ), child: Padding( padding: const EdgeInsets.all(8.0), @@ -103,19 +146,49 @@ class FavouriteScreen extends StatelessWidget { Expanded( child: InkWell( onTap: () { - controller.favouriteRestaurant.value = true; + controller + .favouriteRestaurant + .value = true; }, child: Container( decoration: - controller.favouriteRestaurant.value == false + controller + .favouriteRestaurant + .value == + false ? null - : ShapeDecoration(color: AppThemeData.grey900, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120))), + : ShapeDecoration( + color: + AppThemeData + .grey900, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 120, + ), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: + const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: Text( "Favourite Store".tr, - textAlign: TextAlign.center, - style: TextStyle(fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300), + textAlign: + TextAlign.center, + style: TextStyle( + fontFamily: + AppThemeData + .semiBold, + color: + isDark + ? AppThemeData + .primary300 + : AppThemeData + .primary300, + ), ), ), ), @@ -124,28 +197,57 @@ class FavouriteScreen extends StatelessWidget { Expanded( child: InkWell( onTap: () { - controller.favouriteRestaurant.value = false; + controller + .favouriteRestaurant + .value = false; }, child: Container( decoration: - controller.favouriteRestaurant.value == true + controller + .favouriteRestaurant + .value == + true ? null - : ShapeDecoration(color: AppThemeData.grey900, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120))), + : ShapeDecoration( + color: + AppThemeData + .grey900, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 120, + ), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: + const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: Text( "Favourite Item".tr, - textAlign: TextAlign.center, + textAlign: + TextAlign.center, style: TextStyle( - fontFamily: AppThemeData.semiBold, + fontFamily: + AppThemeData + .semiBold, color: - controller.favouriteRestaurant.value == true + controller + .favouriteRestaurant + .value == + true ? isDark - ? AppThemeData.grey400 - : AppThemeData.grey500 + ? AppThemeData + .grey400 + : AppThemeData + .grey500 : isDark - ? AppThemeData.primary300 - : AppThemeData.primary300, + ? AppThemeData + .primary300 + : AppThemeData + .primary300, ), ), ), @@ -160,79 +262,190 @@ class FavouriteScreen extends StatelessWidget { const SizedBox(height: 20), Expanded( child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 18), + padding: const EdgeInsets.symmetric( + horizontal: 18, + ), child: - controller.favouriteRestaurant.value - ? controller.favouriteVendorList.isEmpty - ? Constant.showEmptyView(message: "Favourite Store not found.".tr) + controller + .favouriteRestaurant + .value + ? controller + .favouriteVendorList + .isEmpty + ? Constant.showEmptyView( + message: + "Favourite Store not found." + .tr, + ) : ListView.builder( shrinkWrap: true, - padding: EdgeInsets.zero, - scrollDirection: Axis.vertical, - itemCount: controller.favouriteVendorList.length, - itemBuilder: (BuildContext context, int index) { - VendorModel vendorModel = controller.favouriteVendorList[index]; + padding: + EdgeInsets.zero, + scrollDirection: + Axis.vertical, + itemCount: + controller + .favouriteVendorList + .length, + itemBuilder: ( + BuildContext context, + int index, + ) { + VendorModel + vendorModel = + controller + .favouriteVendorList[index]; return InkWell( onTap: () { ShowToastDialog.closeLoader(); - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": vendorModel}); + Get.to( + const RestaurantDetailsScreen(), + arguments: { + "vendorModel": + vendorModel, + }, + ); // Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": vendorModel}); }, child: Padding( - padding: const EdgeInsets.only(bottom: 20), + padding: + const EdgeInsets.only( + bottom: 20, + ), child: Container( decoration: ShapeDecoration( - color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)), + color: + isDark + ? AppThemeData + .grey900 + : AppThemeData + .grey50, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 16, + ), + ), ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ Stack( children: [ ClipRRect( - borderRadius: const BorderRadius.only(topLeft: Radius.circular(16), topRight: Radius.circular(16)), + borderRadius: const BorderRadius.only( + topLeft: Radius.circular( + 16, + ), + topRight: Radius.circular( + 16, + ), + ), child: Stack( children: [ - RestaurantImageView(vendorModel: vendorModel), + RestaurantImageView( + vendorModel: + vendorModel, + ), Container( - height: Responsive.height(20, context), - width: Responsive.width(100, context), + height: Responsive.height( + 20, + context, + ), + width: Responsive.width( + 100, + context, + ), decoration: BoxDecoration( gradient: LinearGradient( - begin: const Alignment(-0.00, -1.00), - end: const Alignment(0, 1), - colors: [Colors.black.withOpacity(0), const Color(0xFF111827)], + begin: const Alignment( + -0.00, + -1.00, + ), + end: const Alignment( + 0, + 1, + ), + colors: [ + Colors.black.withOpacity( + 0, + ), + const Color( + 0xFF111827, + ), + ], ), ), ), Positioned( - right: 10, - top: 10, + right: + 10, + top: + 10, child: InkWell( onTap: () async { - if (controller.favouriteList.where((p0) => p0.restaurantId == vendorModel.id).isNotEmpty) { + if (controller.favouriteList + .where( + ( + p0, + ) => + p0.restaurantId == + vendorModel.id, + ) + .isNotEmpty) { FavouriteModel favouriteModel = FavouriteModel( - restaurantId: vendorModel.id, - userId: FireStoreUtils.getCurrentUid(), + restaurantId: + vendorModel.id, + userId: + FireStoreUtils.getCurrentUid(), + ); + controller.favouriteList.removeWhere( + ( + item, + ) => + item.restaurantId == + vendorModel.id, + ); + controller.favouriteVendorList.removeAt( + index, + ); + await FireStoreUtils.removeFavouriteRestaurant( + favouriteModel, ); - controller.favouriteList.removeWhere((item) => item.restaurantId == vendorModel.id); - controller.favouriteVendorList.removeAt(index); - await FireStoreUtils.removeFavouriteRestaurant(favouriteModel); } else { FavouriteModel favouriteModel = FavouriteModel( - restaurantId: vendorModel.id, - userId: FireStoreUtils.getCurrentUid(), + restaurantId: + vendorModel.id, + userId: + FireStoreUtils.getCurrentUid(), + ); + controller.favouriteList.add( + favouriteModel, + ); + await FireStoreUtils.setFavouriteRestaurant( + favouriteModel, ); - controller.favouriteList.add(favouriteModel); - await FireStoreUtils.setFavouriteRestaurant(favouriteModel); } }, child: Obx( () => - controller.favouriteList.where((p0) => p0.restaurantId == vendorModel.id).isNotEmpty - ? SvgPicture.asset("assets/icons/ic_like_fill.svg") - : SvgPicture.asset("assets/icons/ic_like.svg"), + controller.favouriteList + .where( + ( + p0, + ) => + p0.restaurantId == + vendorModel.id, + ) + .isNotEmpty + ? SvgPicture.asset( + "assets/icons/ic_like_fill.svg", + ) + : SvgPicture.asset( + "assets/icons/ic_like.svg", + ), ), ), ), @@ -240,86 +453,171 @@ class FavouriteScreen extends StatelessWidget { ), ), Transform.translate( - offset: Offset(Responsive.width(-3, context), Responsive.height(17.5, context)), + offset: Offset( + Responsive.width( + -3, + context, + ), + Responsive.height( + 17.5, + context, + ), + ), child: Row( - mainAxisAlignment: MainAxisAlignment.end, - crossAxisAlignment: CrossAxisAlignment.end, + mainAxisAlignment: + MainAxisAlignment.end, + crossAxisAlignment: + CrossAxisAlignment.end, children: [ Visibility( - visible: (vendorModel.isSelfDelivery == true && Constant.isSelfDeliveryFeature == true), + visible: + (vendorModel.isSelfDelivery == + true && + Constant.isSelfDeliveryFeature == + true), child: Row( children: [ Container( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 7), + padding: const EdgeInsets.symmetric( + horizontal: + 10, + vertical: + 7, + ), decoration: BoxDecoration( - color: AppThemeData.success300, - borderRadius: BorderRadius.circular(120), // Optional + color: + AppThemeData.success300, + borderRadius: BorderRadius.circular( + 120, + ), // Optional ), child: Row( children: [ - SvgPicture.asset("assets/icons/ic_free_delivery.svg"), - const SizedBox(width: 5), + SvgPicture.asset( + "assets/icons/ic_free_delivery.svg", + ), + const SizedBox( + width: + 5, + ), Text( "Free Delivery".tr, style: TextStyle( - fontSize: 14, - color: AppThemeData.success600, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + fontSize: + 14, + color: + AppThemeData.success600, + fontFamily: + AppThemeData.semiBold, + fontWeight: + FontWeight.w600, ), ), ], ), ), - const SizedBox(width: 6), + const SizedBox( + width: + 6, + ), ], ), ), Container( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 7), + padding: const EdgeInsets.symmetric( + horizontal: + 10, + vertical: + 7, + ), decoration: ShapeDecoration( - color: isDark ? AppThemeData.primary600 : AppThemeData.primary50, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120)), + color: + isDark + ? AppThemeData.primary600 + : AppThemeData.primary50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular( + 120, + ), + ), ), child: Row( children: [ SvgPicture.asset( "assets/icons/ic_star.svg", - colorFilter: ColorFilter.mode(AppThemeData.primary300, BlendMode.srcIn), + colorFilter: ColorFilter.mode( + AppThemeData.primary300, + BlendMode.srcIn, + ), + ), + const SizedBox( + width: + 5, ), - const SizedBox(width: 5), Text( "${Constant.calculateReview(reviewCount: vendorModel.reviewsCount!.toStringAsFixed(0), reviewSum: vendorModel.reviewsSum.toString())} (${vendorModel.reviewsCount!.toStringAsFixed(0)})", style: TextStyle( - color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + fontFamily: + AppThemeData.semiBold, + fontWeight: + FontWeight.w600, ), ), ], ), ), - const SizedBox(width: 6), + const SizedBox( + width: + 6, + ), Container( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 7), + padding: const EdgeInsets.symmetric( + horizontal: + 10, + vertical: + 7, + ), decoration: ShapeDecoration( - color: isDark ? AppThemeData.ecommerce600 : AppThemeData.ecommerce50, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120)), + color: + isDark + ? AppThemeData.ecommerce600 + : AppThemeData.ecommerce50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular( + 120, + ), + ), ), child: Row( children: [ SvgPicture.asset( "assets/icons/ic_map_distance.svg", - colorFilter: ColorFilter.mode(AppThemeData.ecommerce300, BlendMode.srcIn), + colorFilter: ColorFilter.mode( + AppThemeData.ecommerce300, + BlendMode.srcIn, + ), + ), + const SizedBox( + width: + 5, ), - const SizedBox(width: 5), Text( "${Constant.getDistance(lat1: vendorModel.latitude.toString(), lng1: vendorModel.longitude.toString(), lat2: Constant.selectedLocation.location!.latitude.toString(), lng2: Constant.selectedLocation.location!.longitude.toString())} ${Constant.distanceType}", style: TextStyle( - fontSize: 14, - color: isDark ? AppThemeData.ecommerce300 : AppThemeData.ecommerce300, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + fontSize: + 14, + color: + isDark + ? AppThemeData.ecommerce300 + : AppThemeData.ecommerce300, + fontFamily: + AppThemeData.semiBold, + fontWeight: + FontWeight.w600, ), ), ], @@ -330,38 +628,64 @@ class FavouriteScreen extends StatelessWidget { ), ], ), - const SizedBox(height: 15), + const SizedBox( + height: + 15, + ), Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), + padding: const EdgeInsets.symmetric( + horizontal: + 16, + ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( vendorModel.title.toString(), - textAlign: TextAlign.start, - maxLines: 1, + textAlign: + TextAlign.start, + maxLines: + 1, style: TextStyle( - fontSize: 18, - overflow: TextOverflow.ellipsis, - fontFamily: AppThemeData.semiBold, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + fontSize: + 18, + overflow: + TextOverflow.ellipsis, + fontFamily: + AppThemeData.semiBold, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, ), ), Text( vendorModel.location.toString(), - textAlign: TextAlign.start, - maxLines: 1, + textAlign: + TextAlign.start, + maxLines: + 1, style: TextStyle( - overflow: TextOverflow.ellipsis, - fontFamily: AppThemeData.medium, - fontWeight: FontWeight.w500, - color: isDark ? AppThemeData.grey400 : AppThemeData.grey400, + overflow: + TextOverflow.ellipsis, + fontFamily: + AppThemeData.medium, + fontWeight: + FontWeight.w500, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey400, ), ), ], ), ), - const SizedBox(height: 10), + const SizedBox( + height: + 10, + ), ], ), ), @@ -369,114 +693,249 @@ class FavouriteScreen extends StatelessWidget { ); }, ) - : controller.favouriteFoodList.isEmpty - ? Constant.showEmptyView(message: "Favourite Item not found.".tr) + : controller + .favouriteFoodList + .isEmpty + ? Constant.showEmptyView( + message: + "Favourite Item not found." + .tr, + ) : ListView.builder( - itemCount: controller.favouriteFoodList.length, + itemCount: + controller + .favouriteFoodList + .length, shrinkWrap: true, padding: EdgeInsets.zero, - itemBuilder: (context, index) { - ProductModel productModel = controller.favouriteFoodList[index]; + itemBuilder: ( + context, + index, + ) { + ProductModel + productModel = + controller + .favouriteFoodList[index]; return FutureBuilder( - future: getPrice(productModel), - builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { + future: getPrice( + productModel, + ), + builder: ( + context, + snapshot, + ) { + if (snapshot + .connectionState == + ConnectionState + .waiting) { return Constant.loader(); } else { - if (snapshot.hasError) { - return Center(child: Text('${"error".tr}: ${snapshot.error}')); - } else if (snapshot.data == null) { + if (snapshot + .hasError) { + return Center( + child: Text( + '${"error".tr}: ${snapshot.error}', + ), + ); + } else if (snapshot + .data == + null) { return const SizedBox(); } else { - Map map = snapshot.data!; - String price = map['price']; - String disPrice = map['disPrice']; + Map< + String, + dynamic + > + map = + snapshot + .data!; + String price = + map['price']; + String disPrice = + map['disPrice']; return InkWell( onTap: () async { - await FireStoreUtils.getVendorById(productModel.vendorID.toString()).then((value) { - if (value != null) { + await FireStoreUtils.getVendorById( + productModel + .vendorID + .toString(), + ).then(( + value, + ) { + if (value != + null) { ShowToastDialog.closeLoader(); - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": value}); + Get.to( + const RestaurantDetailsScreen(), + arguments: { + "vendorModel": + value, + }, + ); // Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": value}); } }); }, child: Padding( - padding: const EdgeInsets.symmetric(vertical: 5), + padding: + const EdgeInsets.symmetric( + vertical: + 5, + ), child: Container( decoration: ShapeDecoration( - color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)), + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 16, + ), + ), ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 14), + padding: const EdgeInsets.symmetric( + horizontal: + 14, + vertical: + 14, + ), child: Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Expanded( child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Row( children: [ - productModel.nonveg == true - ? SvgPicture.asset("assets/icons/ic_nonveg.svg") - : SvgPicture.asset("assets/icons/ic_veg.svg"), - const SizedBox(width: 5), + productModel.nonveg == + true + ? SvgPicture.asset( + "assets/icons/ic_nonveg.svg", + ) + : SvgPicture.asset( + "assets/icons/ic_veg.svg", + ), + const SizedBox( + width: + 5, + ), Text( - productModel.nonveg == true ? "Non Veg.".tr : "Pure veg.".tr, + productModel.nonveg == + true + ? "Non Veg.".tr + : "Pure veg.".tr, style: TextStyle( - color: productModel.nonveg == true ? AppThemeData.danger300 : AppThemeData.success400, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + color: + productModel.nonveg == + true + ? AppThemeData.danger300 + : AppThemeData.success400, + fontFamily: + AppThemeData.semiBold, + fontWeight: + FontWeight.w600, ), ), ], ), - const SizedBox(height: 5), + const SizedBox( + height: + 5, + ), Text( productModel.name.toString(), style: TextStyle( - fontSize: 18, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + fontSize: + 18, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: + AppThemeData.semiBold, + fontWeight: + FontWeight.w600, ), ), - double.parse(disPrice) <= 0 + double.parse( + disPrice, + ) <= + 0 ? Text( - Constant.amountShow(amount: price), + Constant.amountShow( + amount: + price, + ), style: TextStyle( - fontSize: 16, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + fontSize: + 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: + AppThemeData.semiBold, + fontWeight: + FontWeight.w600, ), ) : Row( children: [ Text( - Constant.amountShow(amount: disPrice), + Constant.amountShow( + amount: + disPrice, + ), style: TextStyle( - fontSize: 16, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + fontSize: + 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: + AppThemeData.semiBold, + fontWeight: + FontWeight.w600, ), ), - const SizedBox(width: 5), + const SizedBox( + width: + 5, + ), Text( - Constant.amountShow(amount: price), + Constant.amountShow( + amount: + price, + ), style: TextStyle( - fontSize: 14, - decoration: TextDecoration.lineThrough, - decorationColor: isDark ? AppThemeData.grey500 : AppThemeData.grey400, - color: isDark ? AppThemeData.grey500 : AppThemeData.grey400, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + fontSize: + 14, + decoration: + TextDecoration.lineThrough, + decorationColor: + isDark + ? AppThemeData.grey500 + : AppThemeData.grey400, + color: + isDark + ? AppThemeData.grey500 + : AppThemeData.grey400, + fontFamily: + AppThemeData.semiBold, + fontWeight: + FontWeight.w600, ), ), ], @@ -485,83 +944,177 @@ class FavouriteScreen extends StatelessWidget { children: [ SvgPicture.asset( "assets/icons/ic_star.svg", - colorFilter: const ColorFilter.mode(AppThemeData.warning300, BlendMode.srcIn), + colorFilter: const ColorFilter.mode( + AppThemeData.warning300, + BlendMode.srcIn, + ), + ), + const SizedBox( + width: + 5, ), - const SizedBox(width: 5), Text( "${Constant.calculateReview(reviewCount: productModel.reviewsCount!.toStringAsFixed(0), reviewSum: productModel.reviewsSum.toString())} (${productModel.reviewsCount!.toStringAsFixed(0)})", style: TextStyle( - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, - fontFamily: AppThemeData.regular, - fontWeight: FontWeight.w500, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: + AppThemeData.regular, + fontWeight: + FontWeight.w500, ), ), ], ), Text( "${productModel.description}", - maxLines: 2, + maxLines: + 2, style: TextStyle( - overflow: TextOverflow.ellipsis, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, - fontFamily: AppThemeData.regular, - fontWeight: FontWeight.w400, + overflow: + TextOverflow.ellipsis, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: + AppThemeData.regular, + fontWeight: + FontWeight.w400, ), ), ], ), ), - const SizedBox(width: 6), + const SizedBox( + width: + 6, + ), ClipRRect( - borderRadius: const BorderRadius.all(Radius.circular(16)), + borderRadius: const BorderRadius.all( + Radius.circular( + 16, + ), + ), child: Stack( children: [ NetworkImageWidget( - imageUrl: productModel.photo.toString(), - fit: BoxFit.cover, - height: Responsive.height(16, context), - width: Responsive.width(34, context), + imageUrl: + productModel.photo.toString(), + fit: + BoxFit.cover, + height: Responsive.height( + 16, + context, + ), + width: Responsive.width( + 34, + context, + ), ), Container( - height: Responsive.height(16, context), - width: Responsive.width(34, context), + height: Responsive.height( + 16, + context, + ), + width: Responsive.width( + 34, + context, + ), decoration: BoxDecoration( gradient: LinearGradient( - begin: const Alignment(-0.00, -1.00), - end: const Alignment(0, 1), - colors: [Colors.black.withOpacity(0), const Color(0xFF111827)], + begin: const Alignment( + -0.00, + -1.00, + ), + end: const Alignment( + 0, + 1, + ), + colors: [ + Colors.black.withOpacity( + 0, + ), + const Color( + 0xFF111827, + ), + ], ), ), ), Positioned( - right: 10, - top: 10, + right: + 10, + top: + 10, child: InkWell( onTap: () async { - if (controller.favouriteItemList.where((p0) => p0.productId == productModel.id).isNotEmpty) { + if (controller.favouriteItemList + .where( + ( + p0, + ) => + p0.productId == + productModel.id, + ) + .isNotEmpty) { FavouriteItemModel favouriteModel = FavouriteItemModel( - productId: productModel.id, - storeId: productModel.vendorID, - userId: FireStoreUtils.getCurrentUid(), + productId: + productModel.id, + storeId: + productModel.vendorID, + userId: + FireStoreUtils.getCurrentUid(), + ); + controller.favouriteItemList.removeWhere( + ( + item, + ) => + item.productId == + productModel.id, + ); + controller.favouriteFoodList.removeAt( + index, + ); + await FireStoreUtils.removeFavouriteItem( + favouriteModel, ); - controller.favouriteItemList.removeWhere((item) => item.productId == productModel.id); - controller.favouriteFoodList.removeAt(index); - await FireStoreUtils.removeFavouriteItem(favouriteModel); } else { FavouriteItemModel favouriteModel = FavouriteItemModel( - productId: productModel.id, - storeId: productModel.vendorID, - userId: FireStoreUtils.getCurrentUid(), + productId: + productModel.id, + storeId: + productModel.vendorID, + userId: + FireStoreUtils.getCurrentUid(), + ); + controller.favouriteItemList.add( + favouriteModel, + ); + await FireStoreUtils.setFavouriteItem( + favouriteModel, ); - controller.favouriteItemList.add(favouriteModel); - await FireStoreUtils.setFavouriteItem(favouriteModel); } }, child: Obx( () => - controller.favouriteItemList.where((p0) => p0.productId == productModel.id).isNotEmpty - ? SvgPicture.asset("assets/icons/ic_like_fill.svg") - : SvgPicture.asset("assets/icons/ic_like.svg"), + controller.favouriteItemList + .where( + ( + p0, + ) => + p0.productId == + productModel.id, + ) + .isNotEmpty + ? SvgPicture.asset( + "assets/icons/ic_like_fill.svg", + ) + : SvgPicture.asset( + "assets/icons/ic_like.svg", + ), ), ), ), @@ -604,24 +1157,56 @@ class FavouriteScreen extends StatelessWidget { print(productModel.price); print(productModel.disPrice); - VendorModel? vendorModel = await FireStoreUtils.getVendorById(productModel.vendorID.toString()); + VendorModel? vendorModel = await FireStoreUtils.getVendorById( + productModel.vendorID.toString(), + ); if (productModel.itemAttribute != null) { if (productModel.itemAttribute!.attributes!.isNotEmpty) { for (var element in productModel.itemAttribute!.attributes!) { if (element.attributeOptions!.isNotEmpty) { - selectedVariants.add(productModel.itemAttribute!.attributes![productModel.itemAttribute!.attributes!.indexOf(element)].attributeOptions![0].toString()); - selectedIndexVariants.add('${productModel.itemAttribute!.attributes!.indexOf(element)} _${productModel.itemAttribute!.attributes![0].attributeOptions![0].toString()}'); - selectedIndexArray.add('${productModel.itemAttribute!.attributes!.indexOf(element)}_0'); + selectedVariants.add( + productModel + .itemAttribute! + .attributes![productModel.itemAttribute!.attributes!.indexOf( + element, + )] + .attributeOptions![0] + .toString(), + ); + selectedIndexVariants.add( + '${productModel.itemAttribute!.attributes!.indexOf(element)} _${productModel.itemAttribute!.attributes![0].attributeOptions![0].toString()}', + ); + selectedIndexArray.add( + '${productModel.itemAttribute!.attributes!.indexOf(element)}_0', + ); } } } - if (productModel.itemAttribute!.variants!.where((element) => element.variantSku == selectedVariants.join('-')).isNotEmpty) { - price = Constant.productCommissionPrice(vendorModel!, productModel.itemAttribute!.variants!.where((element) => element.variantSku == selectedVariants.join('-')).first.variantPrice ?? '0'); + if (productModel.itemAttribute!.variants! + .where((element) => element.variantSku == selectedVariants.join('-')) + .isNotEmpty) { + price = Constant.productCommissionPrice( + vendorModel!, + productModel.itemAttribute!.variants! + .where( + (element) => + element.variantSku == selectedVariants.join('-'), + ) + .first + .variantPrice ?? + '0', + ); disPrice = Constant.productCommissionPrice(vendorModel, '0'); } } else { - price = Constant.productCommissionPrice(vendorModel!, productModel.price.toString()); - disPrice = Constant.productCommissionPrice(vendorModel, productModel.disPrice.toString()); + price = Constant.productCommissionPrice( + vendorModel!, + productModel.price.toString(), + ); + disPrice = Constant.productCommissionPrice( + vendorModel, + productModel.disPrice.toString(), + ); } return {'price': price, 'disPrice': disPrice}; diff --git a/lib/screen_ui/multi_vendor_service/forgot_password_screen/forgot_password_screen.dart b/lib/screen_ui/multi_vendor_service/forgot_password_screen/forgot_password_screen.dart index 52fa366..c09dad0 100644 --- a/lib/screen_ui/multi_vendor_service/forgot_password_screen/forgot_password_screen.dart +++ b/lib/screen_ui/multi_vendor_service/forgot_password_screen/forgot_password_screen.dart @@ -2,10 +2,10 @@ import 'package:customer/controllers/forgot_password_controller.dart'; import 'package:customer/themes/app_them_data.dart'; import 'package:customer/themes/round_button_fill.dart'; import 'package:customer/themes/text_field_widget.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:get/get.dart'; - import '../../../controllers/theme_controller.dart'; import '../../../themes/show_toast_dialog.dart'; @@ -20,14 +20,31 @@ class ForgotPasswordScreen extends StatelessWidget { init: ForgotPasswordController(), builder: (controller) { return Scaffold( - appBar: AppBar(backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface), + appBar: AppBar( + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + ), body: Padding( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("Forgot Password".tr, style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 22, fontFamily: AppThemeData.semiBold)), - Text("No worries!! We’ll send you reset instructions".tr, style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey500, fontSize: 16, fontFamily: AppThemeData.regular)), + Text( + "Forgot Password".tr, + style: TextStyle( + color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + fontSize: 22, + fontFamily: AppThemeData.semiBold, + ), + ), + Text( + "No worries!! We’ll send you reset instructions".tr, + style: TextStyle( + color: isDark ? AppThemeData.grey50 : AppThemeData.grey500, + fontSize: 16, + fontFamily: AppThemeData.regular, + ), + ), const SizedBox(height: 32), TextFieldWidget( title: 'Email Address'.tr, @@ -35,7 +52,13 @@ class ForgotPasswordScreen extends StatelessWidget { hintText: 'Enter email address'.tr, prefix: Padding( padding: const EdgeInsets.all(12), - child: SvgPicture.asset("assets/icons/ic_mail.svg", colorFilter: ColorFilter.mode(isDark ? AppThemeData.grey300 : AppThemeData.grey600, BlendMode.srcIn)), + child: SvgPicture.asset( + "assets/icons/ic_mail.svg", + colorFilter: ColorFilter.mode( + isDark ? AppThemeData.grey300 : AppThemeData.grey600, + BlendMode.srcIn, + ), + ), ), ), const SizedBox(height: 32), @@ -44,7 +67,9 @@ class ForgotPasswordScreen extends StatelessWidget { color: AppThemeData.primary300, textColor: AppThemeData.grey50, onPress: () async { - if (controller.emailEditingController.value.text.trim().isEmpty) { + if (controller.emailEditingController.value.text + .trim() + .isEmpty) { ShowToastDialog.showToast("Please enter valid email".tr); } else { controller.forgotPassword(); diff --git a/lib/screen_ui/multi_vendor_service/gift_card/gift_card_screen.dart b/lib/screen_ui/multi_vendor_service/gift_card/gift_card_screen.dart index 685fc0b..7476061 100644 --- a/lib/screen_ui/multi_vendor_service/gift_card/gift_card_screen.dart +++ b/lib/screen_ui/multi_vendor_service/gift_card/gift_card_screen.dart @@ -8,6 +8,7 @@ import 'package:customer/themes/responsive.dart'; import 'package:customer/themes/round_button_fill.dart'; import 'package:customer/themes/text_field_widget.dart'; import 'package:customer/utils/network_image_widget.dart'; + import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_svg/flutter_svg.dart'; @@ -28,13 +29,18 @@ class GiftCardScreen extends StatelessWidget { builder: (controller) { return Scaffold( appBar: AppBar( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, centerTitle: false, titleSpacing: 0, title: Text( "Customize Gift Card".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 16, + color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + ), ), actions: [ InkWell( @@ -68,26 +74,54 @@ class GiftCardScreen extends StatelessWidget { itemCount: controller.giftCardList.length, onPageChanged: (value) { controller.selectedPageIndex.value = value; - controller.selectedGiftCard.value = controller.giftCardList[controller.selectedPageIndex.value]; + controller.selectedGiftCard.value = + controller.giftCardList[controller + .selectedPageIndex + .value]; - controller.messageController.value.text = controller.giftCardList[controller.selectedPageIndex.value].message.toString(); + controller.messageController.value.text = + controller + .giftCardList[controller + .selectedPageIndex + .value] + .message + .toString(); }, scrollDirection: Axis.horizontal, controller: controller.pageController, itemBuilder: (context, index) { - GiftCardsModel giftCardModel = controller.giftCardList[index]; + GiftCardsModel giftCardModel = + controller.giftCardList[index]; return InkWell( onTap: () { - controller.selectedGiftCard.value = giftCardModel; - controller.messageController.value.text = controller.selectedGiftCard.value.message.toString(); + controller.selectedGiftCard.value = + giftCardModel; + controller.messageController.value.text = + controller + .selectedGiftCard + .value + .message + .toString(); }, child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10), + padding: const EdgeInsets.symmetric( + horizontal: 10, + ), child: Container( - decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), border: Border.all(color: AppThemeData.primary300)), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + border: Border.all( + color: AppThemeData.primary300, + ), + ), child: ClipRRect( borderRadius: BorderRadius.circular(10), - child: NetworkImageWidget(imageUrl: giftCardModel.image.toString(), width: Responsive.width(80, context), fit: BoxFit.cover), + child: NetworkImageWidget( + imageUrl: + giftCardModel.image.toString(), + width: Responsive.width(80, context), + fit: BoxFit.cover, + ), ), ), ), @@ -100,14 +134,32 @@ class GiftCardScreen extends StatelessWidget { title: 'Choose an amount'.tr, controller: controller.amountController.value, hintText: 'Enter gift card amount'.tr, - textInputType: const TextInputType.numberWithOptions(signed: true, decimal: true), + textInputType: + const TextInputType.numberWithOptions( + signed: true, + decimal: true, + ), textInputAction: TextInputAction.done, - inputFormatters: [FilteringTextInputFormatter.allow(RegExp('[0-9]'))], + inputFormatters: [ + FilteringTextInputFormatter.allow( + RegExp('[0-9]'), + ), + ], prefix: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 14, + ), child: Text( Constant.currencyModel!.symbol.tr, - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.semiBold, fontSize: 18), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.semiBold, + fontSize: 18, + ), ), ), onchange: (value) { @@ -125,17 +177,25 @@ class GiftCardScreen extends StatelessWidget { return Obx( () => InkWell( onTap: () { - controller.selectedAmount.value = controller.amountList[index]; - controller.amountController.value.text = controller.amountList[index]; + controller.selectedAmount.value = + controller.amountList[index]; + controller.amountController.value.text = + controller.amountList[index]; }, child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 5), + padding: const EdgeInsets.symmetric( + horizontal: 5, + ), child: Container( decoration: BoxDecoration( - borderRadius: const BorderRadius.all(Radius.circular(40)), + borderRadius: const BorderRadius.all( + Radius.circular(40), + ), border: Border.all( color: - controller.selectedAmount == controller.amountList[index] + controller.selectedAmount == + controller + .amountList[index] ? AppThemeData.primary300 : isDark ? AppThemeData.grey400 @@ -143,11 +203,24 @@ class GiftCardScreen extends StatelessWidget { ), ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10), + padding: const EdgeInsets.symmetric( + horizontal: 10, + ), child: Center( child: Text( - Constant.amountShow(amount: controller.amountList[index]), - style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 14, color: isDark ? AppThemeData.grey400 : AppThemeData.grey500), + Constant.amountShow( + amount: + controller + .amountList[index], + ), + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 14, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey500, + ), ), ), ), @@ -159,7 +232,12 @@ class GiftCardScreen extends StatelessWidget { ), ), const SizedBox(height: 40), - TextFieldWidget(title: 'Add Message (Optional)'.tr, controller: controller.messageController.value, hintText: 'Add message here....'.tr, maxLine: 6), + TextFieldWidget( + title: 'Add Message (Optional)'.tr, + controller: controller.messageController.value, + hintText: 'Add message here....'.tr, + maxLine: 6, + ), ], ), ), @@ -178,7 +256,10 @@ class GiftCardScreen extends StatelessWidget { onPress: () async { if (controller.amountController.value.text.isNotEmpty) { if (Constant.userModel == null) { - ShowToastDialog.showToast("Please log in to the application. You are not logged in.".tr); + ShowToastDialog.showToast( + "Please log in to the application. You are not logged in." + .tr, + ); } else { giftCardBottomSheet(context, controller); } @@ -194,12 +275,17 @@ class GiftCardScreen extends StatelessWidget { ); } - Future giftCardBottomSheet(BuildContext context, GiftCardController controller) { + Future giftCardBottomSheet( + BuildContext context, + GiftCardController controller, + ) { return showModalBottomSheet( context: context, isScrollControlled: true, isDismissible: true, - shape: const RoundedRectangleBorder(borderRadius: BorderRadius.vertical(top: Radius.circular(30))), + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.vertical(top: Radius.circular(30)), + ), clipBehavior: Clip.antiAliasWithSaveLayer, builder: (context) => FractionallySizedBox( @@ -212,7 +298,10 @@ class GiftCardScreen extends StatelessWidget { () => Scaffold( body: SingleChildScrollView( child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, @@ -220,17 +309,34 @@ class GiftCardScreen extends StatelessWidget { const SizedBox(height: 20), ClipRRect( borderRadius: BorderRadius.circular(10), - child: NetworkImageWidget(imageUrl: controller.selectedGiftCard.value.image.toString(), height: Responsive.height(20, context), width: Responsive.width(100, context)), + child: NetworkImageWidget( + imageUrl: + controller.selectedGiftCard.value.image + .toString(), + height: Responsive.height(20, context), + width: Responsive.width(100, context), + ), ), const SizedBox(height: 10), Padding( padding: const EdgeInsets.symmetric(vertical: 10), child: Container( padding: const EdgeInsets.all(8), - decoration: ShapeDecoration(color: AppThemeData.ecommerce50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12))), + decoration: ShapeDecoration( + color: AppThemeData.ecommerce50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + ), child: Text( - 'Complete payment and share this e-gift card with loved ones using any app'.tr, - style: TextStyle(color: AppThemeData.ecommerce300, fontSize: 14, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500), + 'Complete payment and share this e-gift card with loved ones using any app' + .tr, + style: TextStyle( + color: AppThemeData.ecommerce300, + fontSize: 14, + fontFamily: AppThemeData.medium, + fontWeight: FontWeight.w500, + ), ), ), ), @@ -240,48 +346,114 @@ class GiftCardScreen extends StatelessWidget { Text( "Bill Details".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 16, + ), ), const SizedBox(height: 10), Container( width: Responsive.width(100, context), - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 14), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 14, + ), child: Column( children: [ Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Expanded( child: Text( "Sub Total".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontSize: 16), + style: TextStyle( + fontFamily: + AppThemeData.regular, + color: + isDark + ? AppThemeData.grey300 + : AppThemeData + .grey600, + fontSize: 16, + ), ), ), Text( - Constant.amountShow(amount: controller.amountController.value.text), + Constant.amountShow( + amount: + controller + .amountController + .value + .text, + ), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + style: TextStyle( + fontFamily: + AppThemeData.regular, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 16, + ), ), ], ), const SizedBox(height: 10), Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Expanded( child: Text( "Grand Total".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontSize: 16), + style: TextStyle( + fontFamily: + AppThemeData.regular, + color: + isDark + ? AppThemeData.grey300 + : AppThemeData + .grey600, + fontSize: 16, + ), ), ), Text( - Constant.amountShow(amount: controller.amountController.value.text), + Constant.amountShow( + amount: + controller + .amountController + .value + .text, + ), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + style: TextStyle( + fontFamily: + AppThemeData.regular, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 16, + ), ), ], ), @@ -294,9 +466,17 @@ class GiftCardScreen extends StatelessWidget { const SizedBox(height: 20), Center( child: Text( - "${'Gift Card expire'.tr} ${controller.selectedGiftCard.value.expiryDay} ${'days after purchase'.tr}".tr, + "${'Gift Card expire'.tr} ${controller.selectedGiftCard.value.expiryDay} ${'days after purchase'.tr}" + .tr, textAlign: TextAlign.center, - style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 16, color: isDark ? AppThemeData.grey500 : AppThemeData.grey400), + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 16, + color: + isDark + ? AppThemeData.grey500 + : AppThemeData.grey400, + ), ), ), ], @@ -304,12 +484,17 @@ class GiftCardScreen extends StatelessWidget { ), ), bottomNavigationBar: Container( - color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20), + color: + isDark ? AppThemeData.grey900 : AppThemeData.grey50, + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 20, + ), child: Padding( padding: const EdgeInsets.only(bottom: 20), child: RoundedButtonFill( - title: "${'Pay'.tr} ${Constant.amountShow(amount: controller.amountController.value.text)}", + title: + "${'Pay'.tr} ${Constant.amountShow(amount: controller.amountController.value.text)}", height: 5.5, color: AppThemeData.primary300, textColor: AppThemeData.grey50, diff --git a/lib/screen_ui/multi_vendor_service/gift_card/history_gift_card.dart b/lib/screen_ui/multi_vendor_service/gift_card/history_gift_card.dart index 5a34585..9cc4e36 100644 --- a/lib/screen_ui/multi_vendor_service/gift_card/history_gift_card.dart +++ b/lib/screen_ui/multi_vendor_service/gift_card/history_gift_card.dart @@ -2,6 +2,7 @@ import 'package:customer/constant/constant.dart'; import 'package:customer/controllers/history_gift_card_controller.dart'; import 'package:customer/models/gift_cards_order_model.dart'; import 'package:customer/themes/app_them_data.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../../../controllers/theme_controller.dart'; @@ -18,7 +19,12 @@ class HistoryGiftCard extends StatelessWidget { init: HistoryGiftCardController(), builder: (controller) { return Scaffold( - appBar: AppBar(backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, centerTitle: false, titleSpacing: 0), + appBar: AppBar( + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + centerTitle: false, + titleSpacing: 0, + ), body: controller.isLoading.value ? Constant.loader() @@ -26,61 +32,114 @@ class HistoryGiftCard extends StatelessWidget { padding: const EdgeInsets.symmetric(horizontal: 16), child: controller.giftCardsOrderList.isEmpty - ? Constant.showEmptyView(message: "Purchased Gift card not found".tr) + ? Constant.showEmptyView( + message: "Purchased Gift card not found".tr, + ) : ListView.builder( itemCount: controller.giftCardsOrderList.length, shrinkWrap: true, itemBuilder: (context, index) { - GiftCardsOrderModel giftCardOrderModel = controller.giftCardsOrderList[index]; + GiftCardsOrderModel giftCardOrderModel = + controller.giftCardsOrderList[index]; return Container( - margin: const EdgeInsets.symmetric(vertical: 4), - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))), + margin: const EdgeInsets.symmetric( + vertical: 4, + ), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), child: Padding( padding: const EdgeInsets.all(10), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Row( children: [ Expanded( child: Text( - giftCardOrderModel.giftTitle.toString(), + giftCardOrderModel.giftTitle + .toString(), style: TextStyle( fontSize: 16, - color: isDark ? AppThemeData.ecommerce300 : AppThemeData.ecommerce300, - fontFamily: AppThemeData.semiBold, + color: + isDark + ? AppThemeData + .ecommerce300 + : AppThemeData + .ecommerce300, + fontFamily: + AppThemeData.semiBold, fontWeight: FontWeight.w500, ), ), ), Text( - Constant.amountShow(amount: giftCardOrderModel.price.toString()), + Constant.amountShow( + amount: + giftCardOrderModel.price + .toString(), + ), style: TextStyle( fontSize: 16, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, - fontFamily: AppThemeData.semiBold, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: + AppThemeData.semiBold, fontWeight: FontWeight.w500, ), ), ], ), const SizedBox(height: 10), - MySeparator(color: isDark ? AppThemeData.grey700 : AppThemeData.grey200), + MySeparator( + color: + isDark + ? AppThemeData.grey700 + : AppThemeData.grey200, + ), const SizedBox(height: 10), Row( children: [ Expanded( child: Text( "Gift Code".tr, - style: TextStyle(color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w500), + style: TextStyle( + color: + isDark + ? AppThemeData.grey300 + : AppThemeData + .grey600, + fontFamily: + AppThemeData.semiBold, + fontWeight: FontWeight.w500, + ), ), ), Text( - giftCardOrderModel.giftCode.toString().replaceAllMapped(RegExp(r".{4}"), (match) => "${match.group(0)} "), + giftCardOrderModel.giftCode + .toString() + .replaceAllMapped( + RegExp(r".{4}"), + (match) => + "${match.group(0)} ", + ), style: TextStyle( fontSize: 16, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, - fontFamily: AppThemeData.semiBold, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: + AppThemeData.semiBold, fontWeight: FontWeight.w500, ), ), @@ -92,16 +151,33 @@ class HistoryGiftCard extends StatelessWidget { Expanded( child: Text( "Gift Pin".tr, - style: TextStyle(color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w500), + style: TextStyle( + color: + isDark + ? AppThemeData.grey300 + : AppThemeData + .grey600, + fontFamily: + AppThemeData.semiBold, + fontWeight: FontWeight.w500, + ), ), ), - giftCardOrderModel.isPasswordShow == true + giftCardOrderModel.isPasswordShow == + true ? Text( - giftCardOrderModel.giftPin.toString(), + giftCardOrderModel.giftPin + .toString(), style: TextStyle( fontSize: 16, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, - fontFamily: AppThemeData.semiBold, + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, + fontFamily: + AppThemeData.semiBold, fontWeight: FontWeight.w500, ), ) @@ -109,60 +185,107 @@ class HistoryGiftCard extends StatelessWidget { "****", style: TextStyle( fontSize: 16, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, - fontFamily: AppThemeData.semiBold, + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, + fontFamily: + AppThemeData.semiBold, fontWeight: FontWeight.w500, ), ), const SizedBox(width: 10), - giftCardOrderModel.isPasswordShow == true + giftCardOrderModel.isPasswordShow == + true ? InkWell( onTap: () { - controller.updateList(index); + controller.updateList( + index, + ); controller.update(); }, - child: const Icon(Icons.visibility_off), + child: const Icon( + Icons.visibility_off, + ), ) : InkWell( onTap: () { - controller.updateList(index); + controller.updateList( + index, + ); controller.update(); }, - child: const Icon(Icons.remove_red_eye), + child: const Icon( + Icons.remove_red_eye, + ), ), ], ), const SizedBox(height: 10), - MySeparator(color: isDark ? AppThemeData.grey700 : AppThemeData.grey200), + MySeparator( + color: + isDark + ? AppThemeData.grey700 + : AppThemeData.grey200, + ), const SizedBox(height: 10), Row( children: [ InkWell( onTap: () { controller.share( - giftCardOrderModel.giftCode.toString(), - giftCardOrderModel.giftPin.toString(), - giftCardOrderModel.message.toString(), - giftCardOrderModel.price.toString(), - giftCardOrderModel.expireDate!, + giftCardOrderModel.giftCode + .toString(), + giftCardOrderModel.giftPin + .toString(), + giftCardOrderModel.message + .toString(), + giftCardOrderModel.price + .toString(), + giftCardOrderModel + .expireDate!, ); }, child: Container( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6), + padding: + const EdgeInsets.symmetric( + horizontal: 16, + vertical: 6, + ), decoration: ShapeDecoration( - color: isDark ? AppThemeData.grey700 : AppThemeData.grey200, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), + color: + isDark + ? AppThemeData.grey700 + : AppThemeData + .grey200, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 8, + ), + ), ), child: Row( - mainAxisSize: MainAxisSize.min, + mainAxisSize: + MainAxisSize.min, children: [ Text( 'Share'.tr, style: TextStyle( - color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, + color: + isDark + ? AppThemeData + .grey300 + : AppThemeData + .grey600, fontSize: 14, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + fontFamily: + AppThemeData + .semiBold, + fontWeight: + FontWeight.w600, height: 0.11, ), ), @@ -174,11 +297,20 @@ class HistoryGiftCard extends StatelessWidget { ), const Expanded(child: SizedBox()), Text( - giftCardOrderModel.redeem == true ? "Redeemed".tr : "Not Redeem".tr, + giftCardOrderModel.redeem == true + ? "Redeemed".tr + : "Not Redeem".tr, style: TextStyle( fontSize: 16, - color: giftCardOrderModel.redeem == true ? AppThemeData.success400 : AppThemeData.danger300, - fontFamily: AppThemeData.semiBold, + color: + giftCardOrderModel.redeem == + true + ? AppThemeData + .success400 + : AppThemeData + .danger300, + fontFamily: + AppThemeData.semiBold, fontWeight: FontWeight.w500, ), ), diff --git a/lib/screen_ui/multi_vendor_service/gift_card/redeem_gift_card_screen.dart b/lib/screen_ui/multi_vendor_service/gift_card/redeem_gift_card_screen.dart index a67bf7e..1998431 100644 --- a/lib/screen_ui/multi_vendor_service/gift_card/redeem_gift_card_screen.dart +++ b/lib/screen_ui/multi_vendor_service/gift_card/redeem_gift_card_screen.dart @@ -1,4 +1,5 @@ import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:customer/constant/const_texts.dart'; import 'package:customer/constant/constant.dart'; import 'package:customer/controllers/dash_board_controller.dart'; import 'package:customer/controllers/redeem_gift_card_controller.dart'; @@ -7,11 +8,12 @@ import 'package:customer/models/wallet_transaction_model.dart'; import 'package:customer/themes/app_them_data.dart'; import 'package:customer/themes/round_button_fill.dart'; import 'package:customer/themes/text_field_widget.dart'; +import 'package:customer/utils/app_router.dart'; + import '../../../controllers/theme_controller.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:get/get.dart'; - import '../../../service/fire_store_utils.dart'; import '../../../themes/show_toast_dialog.dart'; import '../dash_board_screens/dash_board_screen.dart'; @@ -27,7 +29,12 @@ class RedeemGiftCardScreen extends StatelessWidget { init: RedeemGiftCardController(), builder: (controller) { return Scaffold( - appBar: AppBar(backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, centerTitle: false, titleSpacing: 0), + appBar: AppBar( + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + centerTitle: false, + titleSpacing: 0, + ), body: InkWell( onTap: () { FocusScope.of(context).unfocus(); @@ -39,11 +46,24 @@ class RedeemGiftCardScreen extends StatelessWidget { children: [ Text( "Redeem Gift Card".tr, - style: TextStyle(fontSize: 24, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w500), + style: TextStyle( + fontSize: 24, + color: + isDark ? AppThemeData.grey50 : AppThemeData.grey900, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w500, + ), ), Text( - "Enter your gift card code to enjoy discounts and special offers on your orders.".tr, - style: TextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w400), + "Enter your gift card code to enjoy discounts and special offers on your orders." + .tr, + style: TextStyle( + fontSize: 16, + color: + isDark ? AppThemeData.grey50 : AppThemeData.grey900, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w400, + ), ), const SizedBox(height: 20), TextFieldWidget( @@ -51,14 +71,20 @@ class RedeemGiftCardScreen extends StatelessWidget { controller: controller.giftCodeController.value, hintText: 'Enter gift code'.tr, textInputType: TextInputType.number, - prefix: Padding(padding: const EdgeInsets.all(10), child: SvgPicture.asset("assets/icons/ic_gift_code.svg")), + prefix: Padding( + padding: const EdgeInsets.all(10), + child: SvgPicture.asset("assets/icons/ic_gift_code.svg"), + ), ), TextFieldWidget( title: 'Gift Pin'.tr, controller: controller.giftPinController.value, hintText: 'Enter gift pin'.tr, textInputType: TextInputType.number, - prefix: Padding(padding: const EdgeInsets.all(10), child: SvgPicture.asset("assets/icons/ic_gift_pin.svg")), + prefix: Padding( + padding: const EdgeInsets.all(10), + child: SvgPicture.asset("assets/icons/ic_gift_pin.svg"), + ), ), ], ), @@ -81,46 +107,74 @@ class RedeemGiftCardScreen extends StatelessWidget { } else if (controller.giftPinController.value.text.isEmpty) { ShowToastDialog.showToast("Please Enter Gift Pin".tr); } else { - ShowToastDialog.showLoader("Please wait...".tr); - await FireStoreUtils.checkRedeemCode(controller.giftCodeController.value.text.replaceAll(" ", "")).then((value) async { + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); + await FireStoreUtils.checkRedeemCode( + controller.giftCodeController.value.text.replaceAll( + " ", + "", + ), + ).then((value) async { if (value != null) { GiftCardsOrderModel giftCodeModel = value; if (giftCodeModel.redeem == true) { ShowToastDialog.closeLoader(); - ShowToastDialog.showToast("Gift voucher already redeemed".tr); - } else if (giftCodeModel.giftPin != controller.giftPinController.value.text) { + ShowToastDialog.showToast( + "Gift voucher already redeemed".tr, + ); + } else if (giftCodeModel.giftPin != + controller.giftPinController.value.text) { ShowToastDialog.closeLoader(); ShowToastDialog.showToast("Gift Pin Invalid".tr); - } else if (giftCodeModel.expireDate!.toDate().isBefore(DateTime.now())) { + } else if (giftCodeModel.expireDate!.toDate().isBefore( + DateTime.now(), + )) { ShowToastDialog.closeLoader(); ShowToastDialog.showToast("Gift Voucher expire".tr); } else { giftCodeModel.redeem = true; - WalletTransactionModel transactionModel = WalletTransactionModel( - id: Constant.getUuid(), - amount: double.parse(giftCodeModel.price.toString()), - date: Timestamp.now(), - paymentMethod: "Wallet", - transactionUser: "user", - userId: FireStoreUtils.getCurrentUid(), - isTopup: true, - note: "Gift Voucher", - paymentStatus: "success", - ); + WalletTransactionModel transactionModel = + WalletTransactionModel( + id: Constant.getUuid(), + amount: double.parse( + giftCodeModel.price.toString(), + ), + date: Timestamp.now(), + paymentMethod: "Wallet", + transactionUser: "user", + userId: FireStoreUtils.getCurrentUid(), + isTopup: true, + note: "Gift Voucher", + paymentStatus: "success", + ); - await FireStoreUtils.setWalletTransaction(transactionModel).then((value) async { + await FireStoreUtils.setWalletTransaction( + transactionModel, + ).then((value) async { if (value == true) { - await FireStoreUtils.updateUserWallet(amount: giftCodeModel.price.toString(), userId: FireStoreUtils.getCurrentUid()).then((value) async { - await FireStoreUtils.sendTopUpMail(paymentMethod: "Gift Voucher", amount: giftCodeModel.price.toString(), tractionId: transactionModel.id.toString()); - await FireStoreUtils.placeGiftCardOrder(giftCodeModel).then((value) { + await FireStoreUtils.updateUserWallet( + amount: giftCodeModel.price.toString(), + userId: FireStoreUtils.getCurrentUid(), + ).then((value) async { + await FireStoreUtils.sendTopUpMail( + paymentMethod: "Gift Voucher", + amount: giftCodeModel.price.toString(), + tractionId: transactionModel.id.toString(), + ); + await FireStoreUtils.placeGiftCardOrder( + giftCodeModel, + ).then((value) { ShowToastDialog.closeLoader(); if (Constant.walletSetting == true) { Get.offAll(const DashBoardScreen()); - DashBoardController controller = Get.put(DashBoardController()); + DashBoardController controller = Get.put( + DashBoardController(), + ); controller.selectedIndex.value = 2; } - ShowToastDialog.showToast("Voucher redeem successfully".tr); + ShowToastDialog.showToast( + "Voucher redeem successfully".tr, + ); }); }); } diff --git a/lib/screen_ui/multi_vendor_service/gift_card/select_gift_payment_screen.dart b/lib/screen_ui/multi_vendor_service/gift_card/select_gift_payment_screen.dart index bbcf508..01b6fc0 100644 --- a/lib/screen_ui/multi_vendor_service/gift_card/select_gift_payment_screen.dart +++ b/lib/screen_ui/multi_vendor_service/gift_card/select_gift_payment_screen.dart @@ -4,6 +4,7 @@ import 'package:customer/payment/createRazorPayOrderModel.dart'; import 'package:customer/payment/rozorpayConroller.dart'; import 'package:customer/themes/app_them_data.dart'; import 'package:customer/themes/round_button_fill.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../../../controllers/theme_controller.dart'; @@ -21,12 +22,22 @@ class SelectGiftPaymentScreen extends StatelessWidget { init: GiftCardController(), builder: (controller) { return Scaffold( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, appBar: AppBar( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, centerTitle: false, titleSpacing: 0, - title: Text("Payment Option".tr, textAlign: TextAlign.start, style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900)), + title: Text( + "Payment Option".tr, + textAlign: TextAlign.start, + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 16, + color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + ), + ), ), body: Padding( padding: const EdgeInsets.symmetric(horizontal: 16), @@ -37,7 +48,12 @@ class SelectGiftPaymentScreen extends StatelessWidget { Text( "Preferred Payment".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + fontSize: 16, + color: + isDark ? AppThemeData.grey50 : AppThemeData.grey900, + ), ), const SizedBox(height: 10), if (controller.walletSettingModel.value.isEnabled == true) @@ -46,17 +62,39 @@ class SelectGiftPaymentScreen extends StatelessWidget { children: [ Container( decoration: ShapeDecoration( - color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)), - shadows: const [BoxShadow(color: Color(0x07000000), blurRadius: 20, offset: Offset(0, 0), spreadRadius: 0)], + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + ), + shadows: const [ + BoxShadow( + color: Color(0x07000000), + blurRadius: 20, + offset: Offset(0, 0), + spreadRadius: 0, + ), + ], ), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ Visibility( - visible: controller.walletSettingModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.wallet, isDark, "assets/images/ic_wallet.png"), + visible: + controller + .walletSettingModel + .value + .isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.wallet, + isDark, + "assets/images/ic_wallet.png", + ), ), ], ), @@ -66,40 +104,143 @@ class SelectGiftPaymentScreen extends StatelessWidget { Text( "Other Payment Options".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), const SizedBox(height: 10), ], ), Container( decoration: ShapeDecoration( - color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)), - shadows: const [BoxShadow(color: Color(0x07000000), blurRadius: 20, offset: Offset(0, 0), spreadRadius: 0)], + color: + isDark ? AppThemeData.grey900 : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + ), + shadows: const [ + BoxShadow( + color: Color(0x07000000), + blurRadius: 20, + offset: Offset(0, 0), + spreadRadius: 0, + ), + ], ), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ - Visibility(visible: controller.flutterWaveModel.value.isEnable == true, child: cardDecoration(controller, PaymentGateway.stripe, isDark, "assets/images/stripe.png")), - Visibility(visible: controller.paytmModel.value.isEnabled == true, child: cardDecoration(controller, PaymentGateway.paypal, isDark, "assets/images/paypal.png")), - Visibility(visible: controller.payStackModel.value.isEnable == true, child: cardDecoration(controller, PaymentGateway.payStack, isDark, "assets/images/paystack.png")), Visibility( - visible: controller.mercadoPagoModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.mercadoPago, isDark, "assets/images/mercado-pago.png"), + visible: + controller.flutterWaveModel.value.isEnable == + true, + child: cardDecoration( + controller, + PaymentGateway.stripe, + isDark, + "assets/images/stripe.png", + ), ), Visibility( - visible: controller.flutterWaveModel.value.isEnable == true, - child: cardDecoration(controller, PaymentGateway.flutterWave, isDark, "assets/images/flutterwave_logo.png"), + visible: + controller.paytmModel.value.isEnabled == true, + child: cardDecoration( + controller, + PaymentGateway.paypal, + isDark, + "assets/images/paypal.png", + ), ), - Visibility(visible: controller.payFastModel.value.isEnable == true, child: cardDecoration(controller, PaymentGateway.payFast, isDark, "assets/images/payfast.png")), - Visibility(visible: controller.razorPayModel.value.isEnabled == true, child: cardDecoration(controller, PaymentGateway.razorpay, isDark, "assets/images/razorpay.png")), - Visibility(visible: controller.midTransModel.value.enable == true, child: cardDecoration(controller, PaymentGateway.midTrans, isDark, "assets/images/midtrans.png")), Visibility( - visible: controller.orangeMoneyModel.value.enable == true, - child: cardDecoration(controller, PaymentGateway.orangeMoney, isDark, "assets/images/orange_money.png"), + visible: + controller.payStackModel.value.isEnable == true, + child: cardDecoration( + controller, + PaymentGateway.payStack, + isDark, + "assets/images/paystack.png", + ), + ), + Visibility( + visible: + controller.mercadoPagoModel.value.isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.mercadoPago, + isDark, + "assets/images/mercado-pago.png", + ), + ), + Visibility( + visible: + controller.flutterWaveModel.value.isEnable == + true, + child: cardDecoration( + controller, + PaymentGateway.flutterWave, + isDark, + "assets/images/flutterwave_logo.png", + ), + ), + Visibility( + visible: + controller.payFastModel.value.isEnable == true, + child: cardDecoration( + controller, + PaymentGateway.payFast, + isDark, + "assets/images/payfast.png", + ), + ), + Visibility( + visible: + controller.razorPayModel.value.isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.razorpay, + isDark, + "assets/images/razorpay.png", + ), + ), + Visibility( + visible: + controller.midTransModel.value.enable == true, + child: cardDecoration( + controller, + PaymentGateway.midTrans, + isDark, + "assets/images/midtrans.png", + ), + ), + Visibility( + visible: + controller.orangeMoneyModel.value.enable == + true, + child: cardDecoration( + controller, + PaymentGateway.orangeMoney, + isDark, + "assets/images/orange_money.png", + ), + ), + Visibility( + visible: + controller.xenditModel.value.enable == true, + child: cardDecoration( + controller, + PaymentGateway.xendit, + isDark, + "assets/images/xendit.png", + ), ), - Visibility(visible: controller.xenditModel.value.enable == true, child: cardDecoration(controller, PaymentGateway.xendit, isDark, "assets/images/xendit.png")), ], ), ), @@ -109,7 +250,13 @@ class SelectGiftPaymentScreen extends StatelessWidget { ), ), bottomNavigationBar: Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, borderRadius: const BorderRadius.only(topLeft: Radius.circular(20), topRight: Radius.circular(20))), + decoration: BoxDecoration( + color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(20), + topRight: Radius.circular(20), + ), + ), padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20), child: Padding( padding: const EdgeInsets.only(bottom: 20), @@ -120,38 +267,88 @@ class SelectGiftPaymentScreen extends StatelessWidget { textColor: AppThemeData.grey50, fontSizes: 16, onPress: () async { - if (controller.selectedPaymentMethod.value == PaymentGateway.stripe.name) { - controller.stripeMakePayment(amount: controller.amountController.value.text); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.paypal.name) { - controller.paypalPaymentSheet(controller.amountController.value.text, context); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.payStack.name) { - controller.payStackPayment(controller.amountController.value.text); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.mercadoPago.name) { - controller.mercadoPagoMakePayment(context: context, amount: controller.amountController.value.text); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.flutterWave.name) { - controller.flutterWaveInitiatePayment(context: context, amount: controller.amountController.value.text); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.payFast.name) { - controller.payFastPayment(context: context, amount: controller.amountController.value.text); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.midTrans.name) { - controller.midtransMakePayment(context: context, amount: controller.amountController.value.text); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.orangeMoney.name) { - controller.orangeMakePayment(context: context, amount: controller.amountController.value.text); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.xendit.name) { - controller.xenditPayment(context, controller.amountController.value.text); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.wallet.name) { + if (controller.selectedPaymentMethod.value == + PaymentGateway.stripe.name) { + controller.stripeMakePayment( + amount: controller.amountController.value.text, + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.paypal.name) { + controller.paypalPaymentSheet( + controller.amountController.value.text, + context, + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.payStack.name) { + controller.payStackPayment( + controller.amountController.value.text, + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.mercadoPago.name) { + controller.mercadoPagoMakePayment( + context: context, + amount: controller.amountController.value.text, + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.flutterWave.name) { + controller.flutterWaveInitiatePayment( + context: context, + amount: controller.amountController.value.text, + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.payFast.name) { + controller.payFastPayment( + context: context, + amount: controller.amountController.value.text, + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.midTrans.name) { + controller.midtransMakePayment( + context: context, + amount: controller.amountController.value.text, + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.orangeMoney.name) { + controller.orangeMakePayment( + context: context, + amount: controller.amountController.value.text, + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.xendit.name) { + controller.xenditPayment( + context, + controller.amountController.value.text, + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.wallet.name) { controller.placeOrder(); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.razorpay.name) { - RazorPayController().createOrderRazorPay(amount: double.parse(controller.amountController.value.text), razorpayModel: controller.razorPayModel.value).then((value) { - if (value == null) { - Get.back(); - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); - } else { - CreateRazorPayOrderModel result = value; - controller.openCheckout(amount: controller.amountController.value.text, orderId: result.id); - } - }); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.razorpay.name) { + RazorPayController() + .createOrderRazorPay( + amount: double.parse( + controller.amountController.value.text, + ), + razorpayModel: controller.razorPayModel.value, + ) + .then((value) { + if (value == null) { + Get.back(); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); + } else { + CreateRazorPayOrderModel result = value; + controller.openCheckout( + amount: controller.amountController.value.text, + orderId: result.id, + ); + } + }); } else { - ShowToastDialog.showToast("Please select payment method".tr); + ShowToastDialog.showToast( + "Please select payment method".tr, + ); } }, ), @@ -162,7 +359,12 @@ class SelectGiftPaymentScreen extends StatelessWidget { ); } - Obx cardDecoration(GiftCardController controller, PaymentGateway value, isDark, String image) { + Obx cardDecoration( + GiftCardController controller, + PaymentGateway value, + isDark, + String image, + ) { return Obx( () => Padding( padding: const EdgeInsets.symmetric(vertical: 5), @@ -175,8 +377,16 @@ class SelectGiftPaymentScreen extends StatelessWidget { Container( width: 50, height: 50, - decoration: ShapeDecoration(shape: RoundedRectangleBorder(side: const BorderSide(width: 1, color: Color(0xFFE5E7EB)), borderRadius: BorderRadius.circular(8))), - child: Padding(padding: EdgeInsets.all(value.name == "payFast" ? 0 : 8.0), child: Image.asset(image)), + decoration: ShapeDecoration( + shape: RoundedRectangleBorder( + side: const BorderSide(width: 1, color: Color(0xFFE5E7EB)), + borderRadius: BorderRadius.circular(8), + ), + ), + child: Padding( + padding: EdgeInsets.all(value.name == "payFast" ? 0 : 8.0), + child: Image.asset(image), + ), ), const SizedBox(width: 10), value.name == "wallet" @@ -187,12 +397,32 @@ class SelectGiftPaymentScreen extends StatelessWidget { Text( value.name.capitalizeString(), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), Text( - Constant.amountShow(amount: controller.userModel.value.walletAmount == null ? '0.0' : controller.userModel.value.walletAmount.toString()), + Constant.amountShow( + amount: + controller.userModel.value.walletAmount == null + ? '0.0' + : controller.userModel.value.walletAmount + .toString(), + ), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + fontSize: 16, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + ), ), ], ), @@ -201,14 +431,20 @@ class SelectGiftPaymentScreen extends StatelessWidget { child: Text( value.name.capitalizeString(), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 16, + color: + isDark ? AppThemeData.grey50 : AppThemeData.grey900, + ), ), ), const Expanded(child: SizedBox()), Radio( value: value.name, groupValue: controller.selectedPaymentMethod.value, - activeColor: isDark ? AppThemeData.primary300 : AppThemeData.primary300, + activeColor: + isDark ? AppThemeData.primary300 : AppThemeData.primary300, onChanged: (value) { controller.selectedPaymentMethod.value = value.toString(); }, diff --git a/lib/screen_ui/multi_vendor_service/home_screen/category_restaurant_screen.dart b/lib/screen_ui/multi_vendor_service/home_screen/category_restaurant_screen.dart index a311418..a951228 100644 --- a/lib/screen_ui/multi_vendor_service/home_screen/category_restaurant_screen.dart +++ b/lib/screen_ui/multi_vendor_service/home_screen/category_restaurant_screen.dart @@ -3,6 +3,7 @@ import 'package:customer/controllers/category_restaurant_controller.dart'; import 'package:customer/models/vendor_model.dart'; import 'package:customer/themes/app_them_data.dart'; import 'package:customer/themes/responsive.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:get/get.dart'; @@ -21,7 +22,12 @@ class CategoryRestaurantScreen extends StatelessWidget { init: CategoryRestaurantController(), builder: (controller) { return Scaffold( - appBar: AppBar(backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, centerTitle: false, titleSpacing: 0), + appBar: AppBar( + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + centerTitle: false, + titleSpacing: 0, + ), body: controller.isLoading.value ? Constant.loader() @@ -33,33 +39,62 @@ class CategoryRestaurantScreen extends StatelessWidget { shrinkWrap: true, itemCount: controller.allNearestRestaurant.length, itemBuilder: (context, index) { - VendorModel vendorModel = controller.allNearestRestaurant[index]; + VendorModel vendorModel = + controller.allNearestRestaurant[index]; return InkWell( onTap: () { - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": vendorModel}); + Get.to( + const RestaurantDetailsScreen(), + arguments: {"vendorModel": vendorModel}, + ); }, child: Padding( padding: const EdgeInsets.only(bottom: 20), child: Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + ), + ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Stack( children: [ ClipRRect( - borderRadius: const BorderRadius.only(topLeft: Radius.circular(16), topRight: Radius.circular(16)), + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(16), + topRight: Radius.circular(16), + ), child: Stack( children: [ - RestaurantImageView(vendorModel: vendorModel), + RestaurantImageView( + vendorModel: vendorModel, + ), Container( - height: Responsive.height(20, context), - width: Responsive.width(100, context), + height: Responsive.height( + 20, + context, + ), + width: Responsive.width( + 100, + context, + ), decoration: BoxDecoration( gradient: LinearGradient( - begin: const Alignment(-0.00, -1.00), + begin: const Alignment( + -0.00, + -1.00, + ), end: const Alignment(0, 1), - colors: [Colors.black.withOpacity(0), const Color(0xFF111827)], + colors: [ + Colors.black.withOpacity(0), + const Color(0xFF111827), + ], ), ), ), @@ -67,28 +102,60 @@ class CategoryRestaurantScreen extends StatelessWidget { ), ), Transform.translate( - offset: Offset(Responsive.width(-3, context), Responsive.height(17.5, context)), + offset: Offset( + Responsive.width(-3, context), + Responsive.height(17.5, context), + ), child: Row( - mainAxisAlignment: MainAxisAlignment.end, - crossAxisAlignment: CrossAxisAlignment.end, + mainAxisAlignment: + MainAxisAlignment.end, + crossAxisAlignment: + CrossAxisAlignment.end, children: [ Visibility( - visible: (vendorModel.isSelfDelivery == true && Constant.isSelfDeliveryFeature == true), + visible: + (vendorModel.isSelfDelivery == + true && + Constant.isSelfDeliveryFeature == + true), child: Row( children: [ Container( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 7), + padding: + const EdgeInsets.symmetric( + horizontal: 10, + vertical: 7, + ), decoration: BoxDecoration( - color: AppThemeData.success300, - borderRadius: BorderRadius.circular(120), // Optional + color: + AppThemeData + .success300, + borderRadius: + BorderRadius.circular( + 120, + ), // Optional ), child: Row( children: [ - SvgPicture.asset("assets/icons/ic_free_delivery.svg"), - const SizedBox(width: 5), + SvgPicture.asset( + "assets/icons/ic_free_delivery.svg", + ), + const SizedBox( + width: 5, + ), Text( "Free Delivery".tr, - style: TextStyle(fontSize: 14, color: AppThemeData.success600, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600), + style: TextStyle( + fontSize: 14, + color: + AppThemeData + .success600, + fontFamily: + AppThemeData + .semiBold, + fontWeight: + FontWeight.w600, + ), ), ], ), @@ -99,22 +166,52 @@ class CategoryRestaurantScreen extends StatelessWidget { ), Container( decoration: ShapeDecoration( - color: isDark ? AppThemeData.primary600 : AppThemeData.primary50, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120)), + color: + isDark + ? AppThemeData + .primary600 + : AppThemeData + .primary50, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 120, + ), + ), ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 7), + padding: + const EdgeInsets.symmetric( + horizontal: 10, + vertical: 7, + ), child: Row( children: [ - SvgPicture.asset("assets/icons/ic_star.svg", colorFilter: ColorFilter.mode(AppThemeData.primary300, BlendMode.srcIn)), + SvgPicture.asset( + "assets/icons/ic_star.svg", + colorFilter: + ColorFilter.mode( + AppThemeData + .primary300, + BlendMode.srcIn, + ), + ), const SizedBox(width: 5), Text( "${Constant.calculateReview(reviewCount: vendorModel.reviewsCount!.toStringAsFixed(0), reviewSum: vendorModel.reviewsSum.toString())} (${vendorModel.reviewsCount!.toStringAsFixed(0)})", style: TextStyle( fontSize: 14, - color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + color: + isDark + ? AppThemeData + .primary300 + : AppThemeData + .primary300, + fontFamily: + AppThemeData + .semiBold, + fontWeight: + FontWeight.w600, ), ), ], @@ -124,22 +221,52 @@ class CategoryRestaurantScreen extends StatelessWidget { const SizedBox(width: 6), Container( decoration: ShapeDecoration( - color: isDark ? AppThemeData.ecommerce600 : AppThemeData.ecommerce50, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120)), + color: + isDark + ? AppThemeData + .ecommerce600 + : AppThemeData + .ecommerce50, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 120, + ), + ), ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 7), + padding: + const EdgeInsets.symmetric( + horizontal: 10, + vertical: 7, + ), child: Row( children: [ - SvgPicture.asset("assets/icons/ic_map_distance.svg", colorFilter: ColorFilter.mode(AppThemeData.ecommerce300, BlendMode.srcIn)), + SvgPicture.asset( + "assets/icons/ic_map_distance.svg", + colorFilter: + ColorFilter.mode( + AppThemeData + .ecommerce300, + BlendMode.srcIn, + ), + ), const SizedBox(width: 5), Text( "${Constant.getDistance(lat1: vendorModel.latitude.toString(), lng1: vendorModel.longitude.toString(), lat2: Constant.selectedLocation.location!.latitude.toString(), lng2: Constant.selectedLocation.location!.longitude.toString())} ${Constant.distanceType}", style: TextStyle( fontSize: 14, - color: isDark ? AppThemeData.ecommerce300 : AppThemeData.ecommerce300, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + color: + isDark + ? AppThemeData + .ecommerce300 + : AppThemeData + .ecommerce300, + fontFamily: + AppThemeData + .semiBold, + fontWeight: + FontWeight.w600, ), ), ], @@ -153,9 +280,12 @@ class CategoryRestaurantScreen extends StatelessWidget { ), const SizedBox(height: 15), Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), + padding: const EdgeInsets.symmetric( + horizontal: 16, + ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( vendorModel.title.toString(), @@ -165,7 +295,10 @@ class CategoryRestaurantScreen extends StatelessWidget { fontSize: 18, overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.semiBold, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, ), ), Text( @@ -176,7 +309,10 @@ class CategoryRestaurantScreen extends StatelessWidget { overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500, - color: isDark ? AppThemeData.grey400 : AppThemeData.grey400, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey400, ), ), ], diff --git a/lib/screen_ui/multi_vendor_service/home_screen/discount_restaurant_list_screen.dart b/lib/screen_ui/multi_vendor_service/home_screen/discount_restaurant_list_screen.dart index 52c3082..2416330 100644 --- a/lib/screen_ui/multi_vendor_service/home_screen/discount_restaurant_list_screen.dart +++ b/lib/screen_ui/multi_vendor_service/home_screen/discount_restaurant_list_screen.dart @@ -6,6 +6,7 @@ import 'package:customer/themes/app_them_data.dart'; import 'package:customer/themes/responsive.dart'; import 'package:customer/utils/network_image_widget.dart'; import 'package:dotted_border/dotted_border.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:get/get.dart'; @@ -24,13 +25,18 @@ class DiscountRestaurantListScreen extends StatelessWidget { builder: (controller) { return Scaffold( appBar: AppBar( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, centerTitle: false, titleSpacing: 0, title: Text( controller.title.value, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 16, + color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + ), ), ), body: @@ -46,24 +52,60 @@ class DiscountRestaurantListScreen extends StatelessWidget { CouponModel offerModel = controller.couponList[index]; return InkWell( onTap: () { - Get.to(RestaurantDetailsScreen(), arguments: {"vendorModel": vendorModel}); + Get.to( + RestaurantDetailsScreen(), + arguments: {"vendorModel": vendorModel}, + ); }, child: Padding( padding: const EdgeInsets.only(bottom: 20), child: Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + ), + ), child: Row( children: [ ClipRRect( - borderRadius: const BorderRadius.only(topLeft: Radius.circular(16), bottomLeft: Radius.circular(16)), + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(16), + bottomLeft: Radius.circular(16), + ), child: Stack( children: [ - NetworkImageWidget(imageUrl: vendorModel.photo.toString(), fit: BoxFit.cover, height: Responsive.height(16, context), width: Responsive.width(28, context)), + NetworkImageWidget( + imageUrl: + vendorModel.photo.toString(), + fit: BoxFit.cover, + height: Responsive.height( + 16, + context, + ), + width: Responsive.width(28, context), + ), Container( - height: Responsive.height(16, context), + height: Responsive.height( + 16, + context, + ), width: Responsive.width(28, context), decoration: BoxDecoration( - gradient: LinearGradient(begin: const Alignment(-0.00, -1.00), end: const Alignment(0, 1), colors: [Colors.black.withOpacity(0), const Color(0xFF111827)]), + gradient: LinearGradient( + begin: const Alignment( + -0.00, + -1.00, + ), + end: const Alignment(0, 1), + colors: [ + Colors.black.withOpacity(0), + const Color(0xFF111827), + ], + ), ), ), Positioned( @@ -71,16 +113,37 @@ class DiscountRestaurantListScreen extends StatelessWidget { left: 10, child: Container( decoration: ShapeDecoration( - color: isDark ? AppThemeData.ecommerce300 : AppThemeData.ecommerce300, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120)), + color: + isDark + ? AppThemeData + .ecommerce300 + : AppThemeData + .ecommerce300, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(120), + ), ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4), + padding: + const EdgeInsets.symmetric( + horizontal: 10, + vertical: 4, + ), child: Text( "${offerModel.discountType == "Fix Price" ? Constant.currencyModel!.symbol : ""}${offerModel.discount}${offerModel.discountType == "Percentage" ? "% off".toUpperCase().tr : " off".toUpperCase().tr}", textAlign: TextAlign.start, maxLines: 1, - style: TextStyle(overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.grey50 : AppThemeData.grey50), + style: TextStyle( + overflow: + TextOverflow.ellipsis, + fontFamily: + AppThemeData.semiBold, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey50, + ), ), ), ), @@ -90,9 +153,12 @@ class DiscountRestaurantListScreen extends StatelessWidget { ), Expanded( child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10), + padding: const EdgeInsets.symmetric( + horizontal: 10, + ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Row( children: [ @@ -103,19 +169,45 @@ class DiscountRestaurantListScreen extends StatelessWidget { maxLines: 1, style: TextStyle( fontSize: 18, - overflow: TextOverflow.ellipsis, - fontFamily: AppThemeData.semiBold, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + overflow: + TextOverflow.ellipsis, + fontFamily: + AppThemeData.semiBold, + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, ), ), ), Row( children: [ - SvgPicture.asset("assets/icons/ic_star.svg", colorFilter: ColorFilter.mode(AppThemeData.primary300, BlendMode.srcIn)), + SvgPicture.asset( + "assets/icons/ic_star.svg", + colorFilter: + ColorFilter.mode( + AppThemeData + .primary300, + BlendMode.srcIn, + ), + ), const SizedBox(width: 5), Text( "${Constant.calculateReview(reviewCount: vendorModel.reviewsCount!.toStringAsFixed(0), reviewSum: vendorModel.reviewsSum.toString())} (${vendorModel.reviewsCount!.toStringAsFixed(0)})", - style: TextStyle(color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600), + style: TextStyle( + color: + isDark + ? AppThemeData + .primary300 + : AppThemeData + .primary300, + fontFamily: + AppThemeData.semiBold, + fontWeight: + FontWeight.w600, + ), ), ], ), @@ -123,18 +215,33 @@ class DiscountRestaurantListScreen extends StatelessWidget { ), const SizedBox(height: 5), Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ - Icon(Icons.location_on, size: 18, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600), + Icon( + Icons.location_on, + size: 18, + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + ), const SizedBox(width: 5), Expanded( child: Text( - vendorModel.location.toString(), + vendorModel.location + .toString(), style: TextStyle( - fontFamily: AppThemeData.medium, + fontFamily: + AppThemeData.medium, fontWeight: FontWeight.w500, fontSize: 12, - color: isDark ? AppThemeData.grey400 : AppThemeData.grey400, + color: + isDark + ? AppThemeData + .grey400 + : AppThemeData + .grey400, ), ), ), @@ -142,19 +249,45 @@ class DiscountRestaurantListScreen extends StatelessWidget { ), const SizedBox(height: 5), Container( - color: isDark ? AppThemeData.primary600 : AppThemeData.primary50, + color: + isDark + ? AppThemeData.primary600 + : AppThemeData.primary50, child: DottedBorder( - options: RoundedRectDottedBorderOptions( - radius: const Radius.circular(6), - color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, - strokeWidth: 1, - ), + options: + RoundedRectDottedBorderOptions( + radius: + const Radius.circular( + 6, + ), + color: + isDark + ? AppThemeData + .primary300 + : AppThemeData + .primary300, + strokeWidth: 1, + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 2), + padding: + const EdgeInsets.symmetric( + horizontal: 10, + vertical: 2, + ), child: Text( "${offerModel.code}", textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300), + style: TextStyle( + fontFamily: + AppThemeData.semiBold, + fontSize: 16, + color: + isDark + ? AppThemeData + .primary300 + : AppThemeData + .primary300, + ), ), ), ), diff --git a/lib/screen_ui/multi_vendor_service/home_screen/home_screen.dart b/lib/screen_ui/multi_vendor_service/home_screen/home_screen.dart index 2d361f6..9764e2f 100644 --- a/lib/screen_ui/multi_vendor_service/home_screen/home_screen.dart +++ b/lib/screen_ui/multi_vendor_service/home_screen/home_screen.dart @@ -1,4 +1,5 @@ import 'package:badges/badges.dart' as badges; +import 'package:customer/constant/const_texts.dart'; import 'package:customer/constant/constant.dart'; import 'package:customer/controllers/map_view_controller.dart'; import 'package:customer/models/advertisement_model.dart'; @@ -13,17 +14,21 @@ import 'package:customer/screen_ui/location_enable_screens/location_permission_s import 'package:customer/screen_ui/multi_vendor_service/home_screen/restaurant_list_screen.dart'; import 'package:customer/screen_ui/multi_vendor_service/home_screen/story_view.dart'; import 'package:customer/screen_ui/multi_vendor_service/home_screen/view_all_category_screen.dart'; +import 'package:customer/screen_ui/service_home_screen/service_list_screen.dart'; import 'package:customer/themes/app_them_data.dart'; import 'package:customer/themes/custom_dialog_box.dart'; import 'package:customer/themes/responsive.dart'; import 'package:customer/themes/round_button_fill.dart'; +import 'package:customer/utils/app_router.dart'; import 'package:customer/utils/network_image_widget.dart'; import 'package:customer/utils/preferences.dart'; import 'package:customer/widget/osm_map/map_picker_page.dart'; import 'package:customer/widget/place_picker/location_picker_screen.dart'; import 'package:customer/widget/place_picker/selected_location_model.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart' as flutterMap; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:geocoding/geocoding.dart'; import 'package:geolocator/geolocator.dart'; @@ -67,28 +72,53 @@ class HomeScreen extends StatelessWidget { decoration: BoxDecoration( gradient: LinearGradient( begin: const Alignment(0.00, -3), - colors: [isDark ? AppThemeData.ecommerce300 : AppThemeData.ecommerce50, isDark ? AppThemeData.surfaceDark : AppThemeData.surface], + colors: [ + isDark ? AppThemeData.ecommerce300 : AppThemeData.ecommerce50, + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + ], end: const Alignment(0, 1), ), ), child: controller.isLoading.value ? Constant.loader() - : Constant.isZoneAvailable == false || controller.allNearestRestaurant.isEmpty + : Constant.isZoneAvailable == false || + controller.allNearestRestaurant.isEmpty ? Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Image.asset("assets/images/location.gif", height: 120), + Image.asset( + "assets/images/location.gif", + height: 120, + ), const SizedBox(height: 12), - Text("No Store Found in Your Area".tr, style: TextStyle(color: isDark ? AppThemeData.grey100 : AppThemeData.grey800, fontSize: 22, fontFamily: AppThemeData.semiBold)), + Text( + "No Store Found in Your Area".tr, + style: TextStyle( + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey800, + fontSize: 22, + fontFamily: AppThemeData.semiBold, + ), + ), const SizedBox(height: 5), Text( - "Currently, there are no available store in your zone. Try changing your location to find nearby options.".tr, + "Currently, there are no available store in your zone. Try changing your location to find nearby options." + .tr, textAlign: TextAlign.center, - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey500, fontSize: 16, fontFamily: AppThemeData.bold), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey500, + fontSize: 16, + fontFamily: AppThemeData.bold, + ), ), const SizedBox(height: 20), RoundedButtonFill( @@ -105,7 +135,9 @@ class HomeScreen extends StatelessWidget { ), ) : Padding( - padding: EdgeInsets.only(top: MediaQuery.of(context).viewPadding.top), + padding: EdgeInsets.only( + top: MediaQuery.of(context).viewPadding.top, + ), child: controller.isListView.value == false ? const MapView() @@ -114,7 +146,9 @@ class HomeScreen extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), + padding: const EdgeInsets.symmetric( + horizontal: 16, + ), child: Column( children: [ const SizedBox(height: 10), @@ -122,99 +156,210 @@ class HomeScreen extends StatelessWidget { children: [ InkWell( onTap: () { - Get.back(); + // Get.back(); + Get.offAll(ServiceListScreen()); }, - child: Icon(Icons.arrow_back, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, size: 20), + child: Icon( + Icons + .arrow_back_ios_new_rounded, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + size: 20.r, + ), ), const SizedBox(width: 10), Expanded( child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Constant.userModel == null ? InkWell( onTap: () { - Get.offAll(const LoginScreen()); + Get.offAll( + const LoginScreen(), + ); }, child: Text( - "Login".tr, - textAlign: TextAlign.center, - style: TextStyle(fontFamily: AppThemeData.medium, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 12), + "Login", + textAlign: + TextAlign.center, + style: TextStyle( + fontFamily: + AppThemeData + .medium, + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, + fontSize: 12.sp, + ), ), ) : Text( - Constant.userModel!.fullName(), - textAlign: TextAlign.center, - style: TextStyle(fontFamily: AppThemeData.medium, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 12), + "Еда и доставка", + style: + AppThemeData.boldTextStyle( + color: + AppThemeData + .darkGrey, + fontSize: 18.sp, + ), ), InkWell( onTap: () async { - if (Constant.userModel != null) { - Get.to(AddressListScreen())!.then((value) { + if (Constant.userModel != + null) { + Get.to( + AddressListScreen(), + )!.then((value) { if (value != null) { - ShippingAddress shippingAddress = value; - Constant.selectedLocation = shippingAddress; - controller.getData(); + ShippingAddress + shippingAddress = + value; + Constant.selectedLocation = + shippingAddress; + controller + .getData(); } }); } else { Constant.checkPermission( onTap: () async { - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader( + "Please wait..." + .tr, + ); // ✅ declare it once here! - ShippingAddress shippingAddress = ShippingAddress(); + ShippingAddress + shippingAddress = + ShippingAddress(); try { await Geolocator.requestPermission(); await Geolocator.getCurrentPosition(); ShowToastDialog.closeLoader(); - if (Constant.selectedMapType == 'osm') { - final result = await Get.to(() => MapPickerPage()); - if (result != null) { - final firstPlace = result; - final lat = firstPlace.coordinates.latitude; - final lng = firstPlace.coordinates.longitude; - final address = firstPlace.address; + if (Constant + .selectedMapType == + 'osm') { + final result = + await Get.to( + () => + MapPickerPage(), + ); + if (result != + null) { + final firstPlace = + result; + final lat = + firstPlace + .coordinates + .latitude; + final lng = + firstPlace + .coordinates + .longitude; + final address = + firstPlace + .address; - shippingAddress.addressAs = "Home"; - shippingAddress.locality = address.toString(); - shippingAddress.location = UserLocation(latitude: lat, longitude: lng); - Constant.selectedLocation = shippingAddress; - controller.getData(); + shippingAddress + .addressAs = + "Home"; + shippingAddress + .locality = + address + .toString(); + shippingAddress + .location = + UserLocation( + latitude: + lat, + longitude: + lng, + ); + Constant.selectedLocation = + shippingAddress; + controller + .getData(); Get.back(); } } else { - Get.to(LocationPickerScreen())!.then((value) async { - if (value != null) { - SelectedLocationModel selectedLocationModel = value; + Get.to( + LocationPickerScreen(), + )!.then(( + value, + ) async { + if (value != + null) { + SelectedLocationModel + selectedLocationModel = + value; - shippingAddress.addressAs = "Home"; - shippingAddress.location = UserLocation( - latitude: selectedLocationModel.latLng!.latitude, - longitude: selectedLocationModel.latLng!.longitude, + shippingAddress + .addressAs = + "Home"; + shippingAddress + .location = UserLocation( + latitude: + selectedLocationModel + .latLng! + .latitude, + longitude: + selectedLocationModel + .latLng! + .longitude, ); - shippingAddress.locality = "Picked from Map"; // You can reverse-geocode + shippingAddress + .locality = + "Picked from Map"; // You can reverse-geocode - Constant.selectedLocation = shippingAddress; - controller.getData(); + Constant.selectedLocation = + shippingAddress; + controller + .getData(); } }); } } catch (e) { - await placemarkFromCoordinates(19.228825, 72.854118).then((valuePlaceMaker) { - Placemark placeMark = valuePlaceMaker[0]; - shippingAddress.location = UserLocation(latitude: 19.228825, longitude: 72.854118); - String currentLocation = + await placemarkFromCoordinates( + 19.228825, + 72.854118, + ).then(( + valuePlaceMaker, + ) { + Placemark + placeMark = + valuePlaceMaker[0]; + shippingAddress + .location = + UserLocation( + latitude: + 19.228825, + longitude: + 72.854118, + ); + String + currentLocation = "${placeMark.name}, ${placeMark.subLocality}, ${placeMark.locality}, ${placeMark.administrativeArea}, ${placeMark.postalCode}, ${placeMark.country}"; - shippingAddress.locality = currentLocation; + shippingAddress + .locality = + currentLocation; }); - Constant.selectedLocation = shippingAddress; + Constant.selectedLocation = + shippingAddress; ShowToastDialog.closeLoader(); - controller.getData(); + controller + .getData(); } }, context: context, @@ -223,19 +368,36 @@ class HomeScreen extends StatelessWidget { }, child: Text.rich( maxLines: 1, - overflow: TextOverflow.ellipsis, + overflow: + TextOverflow.ellipsis, TextSpan( children: [ TextSpan( - text: Constant.selectedLocation.getFullAddress(), + text: + Constant + .selectedLocation + .getFullAddress(), style: TextStyle( - fontFamily: AppThemeData.medium, - overflow: TextOverflow.ellipsis, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + fontFamily: + AppThemeData + .medium, + overflow: + TextOverflow + .ellipsis, + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, fontSize: 14, ), ), - WidgetSpan(child: SvgPicture.asset("assets/icons/ic_down.svg")), + WidgetSpan( + child: SvgPicture.asset( + "assets/icons/ic_down.svg", + ), + ), ], ), ), @@ -246,21 +408,38 @@ class HomeScreen extends StatelessWidget { const SizedBox(width: 5), Obx( () => badges.Badge( - showBadge: cartItem.isEmpty ? false : true, + showBadge: + cartItem.isEmpty + ? false + : true, badgeContent: Text( "${cartItem.length}", style: TextStyle( fontSize: 14, - overflow: TextOverflow.ellipsis, - fontFamily: AppThemeData.semiBold, + overflow: + TextOverflow.ellipsis, + fontFamily: + AppThemeData.semiBold, fontWeight: FontWeight.w600, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey50, + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey50, ), ), - badgeStyle: badges.BadgeStyle(shape: badges.BadgeShape.circle, badgeColor: AppThemeData.ecommerce300), + badgeStyle: badges.BadgeStyle( + shape: + badges.BadgeShape.circle, + badgeColor: + AppThemeData.ecommerce300, + ), child: InkWell( onTap: () async { - (await Get.to(const CartScreen())); + (await Get.to( + const CartScreen(), + )); controller.getCartData(); }, child: ClipOval( @@ -269,15 +448,37 @@ class HomeScreen extends StatelessWidget { height: 42, decoration: ShapeDecoration( shape: RoundedRectangleBorder( - side: BorderSide(width: 1, color: isDark ? AppThemeData.grey700 : AppThemeData.grey200), - borderRadius: BorderRadius.circular(120), + side: BorderSide( + width: 1, + color: + isDark + ? AppThemeData + .grey700 + : AppThemeData + .grey200, + ), + borderRadius: + BorderRadius.circular( + 120, + ), ), ), child: Padding( - padding: const EdgeInsets.all(8.0), + padding: + const EdgeInsets.all( + 8.0, + ), child: SvgPicture.asset( "assets/icons/ic_shoping_cart.svg", - colorFilter: ColorFilter.mode(isDark ? AppThemeData.grey50 : AppThemeData.grey900, BlendMode.srcIn), + colorFilter: + ColorFilter.mode( + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, + BlendMode.srcIn, + ), ), ), ), @@ -287,106 +488,287 @@ class HomeScreen extends StatelessWidget { ), ], ), - const SizedBox(height: 10), + SizedBox(height: 25.h), InkWell( onTap: () { - Get.to(const SearchScreen(), arguments: {"vendorList": controller.allNearestRestaurant}); + Get.to( + const SearchScreen(), + arguments: { + "vendorList": + controller + .allNearestRestaurant, + }, + ); }, + // child: Container( + // height: 48.h, + // decoration: BoxDecoration( + // color: AppThemeData.cardColor, + // borderRadius: + // BorderRadius.circular(10.r), + // ), + // ), child: TextFieldWidget( + hintColor: AppThemeData.darkGrey, hintText: - Constant.sectionConstantModel?.name?.toLowerCase().contains('restaurants') == true - ? 'Search the restaurant, food and more...'.tr - : 'Search the store, item and more...'.tr, + Constant + .sectionConstantModel + ?.name + ?.toLowerCase() + .contains( + 'restaurants', + ) == + true + ? 'Искать что угодно' + : 'Search the store, item and more...' + .tr, controller: null, enable: false, - prefix: Padding(padding: const EdgeInsets.symmetric(horizontal: 16), child: SvgPicture.asset("assets/icons/ic_search.svg")), + backgroundColor: + AppThemeData.cardColor, + prefix: Padding( + padding: EdgeInsets.only( + left: 16.r, + right: 8.r, + ), + child: Icon( + Icons.search, + size: 24.r, + color: AppThemeData.darkGrey, + ), + ), ), ), - const SizedBox(height: 5), + SizedBox(height: 15.h), ], ), ), Expanded( child: SingleChildScrollView( child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ - controller.storyList.isEmpty || Constant.storyEnable == false - ? const SizedBox() - : Padding(padding: const EdgeInsets.symmetric(horizontal: 16), child: StoryView(controller: controller)), - SizedBox(height: controller.storyList.isEmpty ? 0 : 20), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - titleView(isDark, "Explore the Categories", () { - Get.to(const ViewAllCategoryScreen()); - }), - const SizedBox(height: 10), - CategoryView(controller: controller), - ], - ), + // controller.storyList.isEmpty || + // Constant.storyEnable == false + // ? const SizedBox() + // : Padding( + // padding: + // const EdgeInsets.symmetric( + // horizontal: 16, + // ), + // child: StoryView( + // controller: controller, + // ), + // ), + // SizedBox( + // height: + // controller.storyList.isEmpty + // ? 0 + // : 25.h, + // ), + Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + // titleView(isDark, "Explore the Categories", () { + // Get.to(const ViewAllCategoryScreen()); + // }), + Padding( + padding: EdgeInsets.symmetric( + horizontal: 16.r, + ), + child: Row( + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + "Категории", + style: + AppThemeData.boldTextStyle( + color: + AppThemeData + .darkGrey, + fontSize: 18.sp, + ), + ), + InkWell( + onTap: () { + Get.to( + const ViewAllCategoryScreen(), + ); + }, + child: Text( + "Все", + style: + AppThemeData.mediumTextStyle( + fontSize: 14.sp, + color: + AppThemeData + .mainColor, + ), + ), + ), + ], + ), + ), + const SizedBox(height: 10), + CategoryView( + controller: controller, + ), + ], ), const SizedBox(height: 32), - controller.bannerModel.isEmpty ? const SizedBox() : Padding(padding: const EdgeInsets.symmetric(horizontal: 16), child: BannerView(controller: controller)), - controller.couponRestaurantList.isEmpty + controller.bannerModel.isEmpty ? const SizedBox() : Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), + padding: + const EdgeInsets.symmetric( + horizontal: 16, + ), + child: BannerView( + controller: controller, + ), + ), + controller + .couponRestaurantList + .isEmpty + ? const SizedBox() + : Padding( + padding: + const EdgeInsets.symmetric( + horizontal: 16, + ), child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ - titleView(isDark, "Largest Discounts", () { - Get.to( - const DiscountRestaurantListScreen(), - arguments: {"vendorList": controller.couponRestaurantList, "couponList": controller.couponList, "title": "Discounts Restaurants"}, - ); - }), + titleView( + isDark, + ConstTexts.largestDiscounts.tr, + () { + Get.to( + const DiscountRestaurantListScreen(), + arguments: { + "vendorList": + controller + .couponRestaurantList, + "couponList": + controller + .couponList, + "title": + "Discounts Restaurants", + }, + ); + }, + ), const SizedBox(height: 16), - OfferView(controller: controller), + OfferView( + controller: controller, + ), ], ), ), const SizedBox(height: 28), - controller.newArrivalRestaurantList.isEmpty + controller + .newArrivalRestaurantList + .isEmpty ? const SizedBox() : Container( - decoration: const BoxDecoration(image: DecorationImage(image: AssetImage("assets/images/ic_new_arrival_bg.png"), fit: BoxFit.cover)), + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage( + "assets/images/ic_new_arrival_bg.png", + ), + fit: BoxFit.cover, + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16), + padding: + const EdgeInsets.symmetric( + horizontal: 16, + vertical: 16, + ), child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ Row( children: [ Expanded( child: Text( - "New Arrivals".tr, - textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey50), + ConstTexts.newArrival.tr, + textAlign: + TextAlign + .start, + style: TextStyle( + fontFamily: + AppThemeData + .semiBold, + fontSize: 16, + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey50, + ), ), ), InkWell( onTap: () { - Get.to(const RestaurantListScreen(), arguments: {"vendorList": controller.newArrivalRestaurantList, "title": "New Arrival"})?.then((v) { - controller.getFavouriteRestaurant(); + Get.to( + const RestaurantListScreen(), + arguments: { + "vendorList": + controller + .newArrivalRestaurantList, + "title": + "New Arrival", + }, + )?.then((v) { + controller + .getFavouriteRestaurant(); }); }, child: Text( - "View all".tr, - textAlign: TextAlign.center, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300), + ConstTexts.viewAll.tr, + textAlign: + TextAlign + .center, + style: TextStyle( + fontFamily: + AppThemeData + .regular, + color: + isDark + ? AppThemeData + .primary300 + : AppThemeData + .primary300, + ), ), ), ], ), - const SizedBox(height: 16), - NewArrival(controller: controller), + const SizedBox( + height: 16, + ), + NewArrival( + controller: controller, + ), ], ), ), @@ -394,54 +776,136 @@ class HomeScreen extends StatelessWidget { const SizedBox(height: 20), controller.bannerBottomModel.isEmpty ? const SizedBox() - : Padding(padding: const EdgeInsets.symmetric(horizontal: 16), child: BannerBottomView(controller: controller)), - Visibility(visible: (Constant.isEnableAdsFeature == true && controller.advertisementList.isNotEmpty), child: const SizedBox(height: 20)), + : Padding( + padding: + const EdgeInsets.symmetric( + horizontal: 16, + ), + child: BannerBottomView( + controller: controller, + ), + ), Visibility( - visible: Constant.isEnableAdsFeature == true, + visible: + (Constant.isEnableAdsFeature == + true && + controller + .advertisementList + .isNotEmpty), + child: const SizedBox(height: 20), + ), + Visibility( + visible: + Constant.isEnableAdsFeature == + true, child: - controller.advertisementList.isEmpty + controller + .advertisementList + .isEmpty ? const SizedBox() : Container( - color: AppThemeData.primary300.withAlpha(40), + color: AppThemeData + .primary300 + .withAlpha(40), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16), + padding: + const EdgeInsets.symmetric( + horizontal: 16, + vertical: 16, + ), child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment + .start, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ Row( children: [ Expanded( child: Text( - "Highlights for you".tr, - textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + ConstTexts.highlightsForU + .tr, + textAlign: + TextAlign + .start, + style: TextStyle( + fontFamily: + AppThemeData + .semiBold, + fontSize: + 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), ), InkWell( onTap: () { - Get.to(AllAdvertisementScreen())?.then((value) { - controller.getFavouriteRestaurant(); + Get.to( + AllAdvertisementScreen(), + )?.then(( + value, + ) { + controller + .getFavouriteRestaurant(); }); }, child: Text( - "View all".tr, - textAlign: TextAlign.center, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300), + ConstTexts.viewAll + .tr, + textAlign: + TextAlign + .center, + style: TextStyle( + fontFamily: + AppThemeData + .regular, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + ), ), ), ], ), - const SizedBox(height: 16), + const SizedBox( + height: 16, + ), SizedBox( height: 220, child: ListView.builder( - physics: const BouncingScrollPhysics(), - scrollDirection: Axis.horizontal, - itemCount: controller.advertisementList.length >= 10 ? 10 : controller.advertisementList.length, - padding: EdgeInsets.all(0), - itemBuilder: (BuildContext context, int index) { - return AdvertisementHomeCard(controller: controller, model: controller.advertisementList[index]); + physics: + const BouncingScrollPhysics(), + scrollDirection: + Axis.horizontal, + itemCount: + controller.advertisementList.length >= + 10 + ? 10 + : controller + .advertisementList + .length, + padding: + EdgeInsets.all( + 0, + ), + itemBuilder: ( + BuildContext + context, + int index, + ) { + return AdvertisementHomeCard( + controller: + controller, + model: + controller + .advertisementList[index], + ); }, ), ), @@ -452,32 +916,77 @@ class HomeScreen extends StatelessWidget { ), const SizedBox(height: 20), Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), + padding: const EdgeInsets.symmetric( + horizontal: 16, + ), child: Container( decoration: ShapeDecoration( - color: isDark ? AppThemeData.grey700 : AppThemeData.grey200, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120)), + color: + isDark + ? AppThemeData.grey700 + : AppThemeData.grey200, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 120, + ), + ), ), child: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all( + 8.0, + ), child: Row( children: [ Expanded( child: InkWell( onTap: () { - controller.isPopular.value = true; + controller + .isPopular + .value = true; }, child: Container( decoration: - controller.isPopular.value == false + controller + .isPopular + .value == + false ? null - : ShapeDecoration(color: AppThemeData.grey900, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120))), + : ShapeDecoration( + color: + AppThemeData + .grey900, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 120, + ), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: + const EdgeInsets.symmetric( + horizontal: + 16, + vertical: 10, + ), child: Text( - "Popular Stores".tr, - textAlign: TextAlign.center, - style: TextStyle(fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300), + ConstTexts.popularStores + .tr, + textAlign: + TextAlign + .center, + style: TextStyle( + fontFamily: + AppThemeData + .semiBold, + color: + isDark + ? AppThemeData + .primary300 + : AppThemeData + .primary300, + ), ), ), ), @@ -486,28 +995,55 @@ class HomeScreen extends StatelessWidget { Expanded( child: InkWell( onTap: () { - controller.isPopular.value = false; + controller + .isPopular + .value = false; }, child: Container( decoration: - controller.isPopular.value == true + controller + .isPopular + .value == + true ? null - : ShapeDecoration(color: AppThemeData.grey900, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120))), + : ShapeDecoration( + color: + AppThemeData + .grey900, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 120, + ), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: + const EdgeInsets.symmetric( + horizontal: + 16, + vertical: 10, + ), child: Text( - "All Stores".tr, - textAlign: TextAlign.center, + ConstTexts.allStores.tr, + textAlign: + TextAlign + .center, style: TextStyle( - fontFamily: AppThemeData.semiBold, + fontFamily: + AppThemeData + .semiBold, color: - controller.isPopular.value == true + controller.isPopular.value == + true ? isDark ? AppThemeData.grey400 : AppThemeData.grey500 : isDark - ? AppThemeData.primary300 - : AppThemeData.primary300, + ? AppThemeData + .primary300 + : AppThemeData + .primary300, ), ), ), @@ -520,8 +1056,18 @@ class HomeScreen extends StatelessWidget { ), ), Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20), - child: controller.isPopular.value ? PopularRestaurant(controller: controller) : AllRestaurant(controller: controller), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 20, + ), + child: + controller.isPopular.value + ? PopularRestaurant( + controller: controller, + ) + : AllRestaurant( + controller: controller, + ), ), // controller.isPopular.value // ? PopularRestaurant( @@ -538,18 +1084,29 @@ class HomeScreen extends StatelessWidget { ), ), ), - floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, + floatingActionButtonLocation: + FloatingActionButtonLocation.centerFloat, floatingActionButton: Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.grey800 : AppThemeData.grey100, borderRadius: const BorderRadius.all(Radius.circular(30))), + decoration: BoxDecoration( + color: isDark ? AppThemeData.grey800 : AppThemeData.grey100, + borderRadius: const BorderRadius.all(Radius.circular(30)), + ), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6), child: Row( mainAxisSize: MainAxisSize.min, children: [ Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, borderRadius: const BorderRadius.all(Radius.circular(30))), + decoration: BoxDecoration( + color: + isDark ? AppThemeData.grey900 : AppThemeData.grey50, + borderRadius: const BorderRadius.all(Radius.circular(30)), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 5, + ), child: Row( children: [ InkWell( @@ -558,12 +1115,22 @@ class HomeScreen extends StatelessWidget { }, child: ClipOval( child: Container( - decoration: BoxDecoration(color: controller.isListView.value ? AppThemeData.primary300 : null), + decoration: BoxDecoration( + color: + controller.isListView.value + ? AppThemeData.primary300 + : null, + ), child: Padding( padding: const EdgeInsets.all(8.0), child: SvgPicture.asset( "assets/icons/ic_view_grid_list.svg", - colorFilter: ColorFilter.mode(controller.isListView.value ? AppThemeData.grey50 : AppThemeData.grey500, BlendMode.srcIn), + colorFilter: ColorFilter.mode( + controller.isListView.value + ? AppThemeData.grey50 + : AppThemeData.grey500, + BlendMode.srcIn, + ), ), ), ), @@ -577,12 +1144,22 @@ class HomeScreen extends StatelessWidget { }, child: ClipOval( child: Container( - decoration: BoxDecoration(color: controller.isListView.value == false ? AppThemeData.primary300 : null), + decoration: BoxDecoration( + color: + controller.isListView.value == false + ? AppThemeData.primary300 + : null, + ), child: Padding( padding: const EdgeInsets.all(8.0), child: SvgPicture.asset( "assets/icons/ic_map_draw.svg", - colorFilter: ColorFilter.mode(controller.isListView.value == false ? AppThemeData.grey50 : AppThemeData.grey500, BlendMode.srcIn), + colorFilter: ColorFilter.mode( + controller.isListView.value == false + ? AppThemeData.grey50 + : AppThemeData.grey500, + BlendMode.srcIn, + ), ), ), ), @@ -599,10 +1176,23 @@ class HomeScreen extends StatelessWidget { }, child: ClipOval( child: Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50), + decoration: BoxDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + ), child: Padding( padding: const EdgeInsets.all(10), - child: SvgPicture.asset("assets/icons/ic_scan_code.svg", colorFilter: ColorFilter.mode(isDark ? AppThemeData.grey400 : AppThemeData.grey500, BlendMode.srcIn)), + child: SvgPicture.asset( + "assets/icons/ic_scan_code.svg", + colorFilter: ColorFilter.mode( + isDark + ? AppThemeData.grey400 + : AppThemeData.grey500, + BlendMode.srcIn, + ), + ), ), ), ), @@ -610,24 +1200,46 @@ class HomeScreen extends StatelessWidget { const SizedBox(width: 14), Theme( data: Theme.of(context).copyWith( - canvasColor: isDark ? AppThemeData.greyDark100 : AppThemeData.grey100, // background when dropdown opens + canvasColor: + isDark + ? AppThemeData.greyDark100 + : AppThemeData + .grey100, // background when dropdown opens ), child: DropdownButton( isDense: false, underline: const SizedBox(), - dropdownColor: isDark ? AppThemeData.greyDark100 : AppThemeData.grey100, + dropdownColor: + isDark + ? AppThemeData.greyDark100 + : AppThemeData.grey100, value: controller.selectedOrderTypeValue.value.tr, icon: const Icon(Icons.keyboard_arrow_down), items: - ['Delivery'.tr, 'TakeAway'.tr].map((String value) { + [ConstTexts.delivery.tr, ConstTexts.takeAway.tr].map(( + String value, + ) { return DropdownMenuItem( value: value, - child: Text(value.tr, style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900)), + child: Text( + value.tr, + style: TextStyle( + fontFamily: AppThemeData.semiBold, + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), + ), ); }).toList(), onChanged: (value) async { if (cartItem.isEmpty) { - await Preferences.setString(Preferences.foodDeliveryType, value!); + await Preferences.setString( + Preferences.foodDeliveryType, + value!, + ); controller.selectedOrderTypeValue.value = value; controller.getData(); } else { @@ -635,15 +1247,22 @@ class HomeScreen extends StatelessWidget { context: context, builder: (BuildContext context) { return CustomDialogBox( - title: "Alert".tr, - descriptions: "Do you really want to change the delivery option? Your cart will be empty.".tr, - positiveString: "Ok".tr, - negativeString: "Cancel".tr, + title: ConstTexts.alert.tr, + descriptions:"", + // ConstTexts.doYouWantChangeTheDeliverOption + // .tr, + positiveString: ConstTexts.ok.tr, + negativeString: ConstTexts.cancel.tr, positiveClick: () async { - await Preferences.setString(Preferences.foodDeliveryType, value!); - controller.selectedOrderTypeValue.value = value; + await Preferences.setString( + Preferences.foodDeliveryType, + value!, + ); + controller.selectedOrderTypeValue.value = + value; controller.getData(); - DatabaseHelper.instance.deleteAllCartProducts(); + DatabaseHelper.instance + .deleteAllCartProducts(); controller.cartProvider.clearDatabase(); controller.getCartData(); Get.back(); @@ -671,12 +1290,28 @@ class HomeScreen extends StatelessWidget { Row titleView(isDark, String name, Function()? onPress) { return Row( children: [ - Expanded(child: Text(name.tr, textAlign: TextAlign.start, style: TextStyle(fontFamily: AppThemeData.bold, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900))), + Expanded( + child: Text( + name.tr, + textAlign: TextAlign.start, + style: TextStyle( + fontFamily: AppThemeData.bold, + color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + ), + ), + ), InkWell( onTap: () { onPress!(); }, - child: Text("View all".tr, textAlign: TextAlign.center, style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300)), + child: Text( + ConstTexts.viewAll.tr, + textAlign: TextAlign.center, + style: TextStyle( + fontFamily: AppThemeData.regular, + color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, + ), + ), ), ], ); @@ -702,21 +1337,37 @@ class PopularRestaurant extends StatelessWidget { VendorModel vendorModel = controller.popularRestaurantList[index]; return InkWell( onTap: () { - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": vendorModel})?.then((v) { + Get.to( + const RestaurantDetailsScreen(), + arguments: {"vendorModel": vendorModel}, + )?.then((v) { controller.getFavouriteRestaurant(); }); }, child: Padding( - padding: EdgeInsets.only(bottom: controller.popularRestaurantList.length - 1 == index ? 60 : 20), + padding: EdgeInsets.only( + bottom: + controller.popularRestaurantList.length - 1 == index + ? 60 + : 20, + ), child: Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16))), + decoration: ShapeDecoration( + color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + ), + ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Stack( children: [ ClipRRect( - borderRadius: const BorderRadius.only(topLeft: Radius.circular(16), topRight: Radius.circular(16)), + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(16), + topRight: Radius.circular(16), + ), child: Stack( children: [ RestaurantImageView(vendorModel: vendorModel), @@ -724,7 +1375,14 @@ class PopularRestaurant extends StatelessWidget { height: Responsive.height(20, context), width: Responsive.width(100, context), decoration: BoxDecoration( - gradient: LinearGradient(begin: const Alignment(-0.00, -1.00), end: const Alignment(0, 1), colors: [Colors.black.withOpacity(0), const Color(0xFF111827)]), + gradient: LinearGradient( + begin: const Alignment(-0.00, -1.00), + end: const Alignment(0, 1), + colors: [ + Colors.black.withOpacity(0), + const Color(0xFF111827), + ], + ), ), ), @@ -733,21 +1391,55 @@ class PopularRestaurant extends StatelessWidget { top: 10, child: InkWell( onTap: () async { - if (controller.favouriteList.where((p0) => p0.restaurantId == vendorModel.id).isNotEmpty) { - FavouriteModel favouriteModel = FavouriteModel(restaurantId: vendorModel.id, userId: FireStoreUtils.getCurrentUid()); - controller.favouriteList.removeWhere((item) => item.restaurantId == vendorModel.id); - await FireStoreUtils.removeFavouriteRestaurant(favouriteModel); + if (controller.favouriteList + .where( + (p0) => + p0.restaurantId == vendorModel.id, + ) + .isNotEmpty) { + FavouriteModel favouriteModel = + FavouriteModel( + restaurantId: vendorModel.id, + userId: + FireStoreUtils.getCurrentUid(), + ); + controller.favouriteList.removeWhere( + (item) => + item.restaurantId == vendorModel.id, + ); + await FireStoreUtils.removeFavouriteRestaurant( + favouriteModel, + ); } else { - FavouriteModel favouriteModel = FavouriteModel(restaurantId: vendorModel.id, userId: FireStoreUtils.getCurrentUid()); - controller.favouriteList.add(favouriteModel); - await FireStoreUtils.setFavouriteRestaurant(favouriteModel); + FavouriteModel favouriteModel = + FavouriteModel( + restaurantId: vendorModel.id, + userId: + FireStoreUtils.getCurrentUid(), + ); + controller.favouriteList.add( + favouriteModel, + ); + await FireStoreUtils.setFavouriteRestaurant( + favouriteModel, + ); } }, child: Obx( () => - controller.favouriteList.where((p0) => p0.restaurantId == vendorModel.id).isNotEmpty - ? SvgPicture.asset("assets/icons/ic_like_fill.svg") - : SvgPicture.asset("assets/icons/ic_like.svg"), + controller.favouriteList + .where( + (p0) => + p0.restaurantId == + vendorModel.id, + ) + .isNotEmpty + ? SvgPicture.asset( + "assets/icons/ic_like_fill.svg", + ) + : SvgPicture.asset( + "assets/icons/ic_like.svg", + ), ), ), ), @@ -755,26 +1447,46 @@ class PopularRestaurant extends StatelessWidget { ), ), Transform.translate( - offset: Offset(Responsive.width(-3, context), Responsive.height(17.5, context)), + offset: Offset( + Responsive.width(-3, context), + Responsive.height(17.5, context), + ), child: Row( mainAxisAlignment: MainAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end, children: [ Visibility( - visible: (vendorModel.isSelfDelivery == true && Constant.isSelfDeliveryFeature == true), + visible: + (vendorModel.isSelfDelivery == true && + Constant.isSelfDeliveryFeature == true), child: Row( children: [ Container( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 7), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 7, + ), decoration: BoxDecoration( color: AppThemeData.success300, - borderRadius: BorderRadius.circular(120), // Optional + borderRadius: BorderRadius.circular( + 120, + ), // Optional ), child: Row( children: [ - SvgPicture.asset("assets/icons/ic_free_delivery.svg"), + SvgPicture.asset( + "assets/icons/ic_free_delivery.svg", + ), const SizedBox(width: 5), - Text("Free Delivery".tr, style: TextStyle(fontSize: 14, color: AppThemeData.carRent600, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600)), + Text( + ConstTexts.freeDelivery.tr, + style: TextStyle( + fontSize: 14, + color: AppThemeData.carRent600, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w600, + ), + ), ], ), ), @@ -783,35 +1495,77 @@ class PopularRestaurant extends StatelessWidget { ), ), Container( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 7), - decoration: ShapeDecoration(color: isDark ? AppThemeData.primary600 : AppThemeData.primary50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120))), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 7, + ), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.primary600 + : AppThemeData.primary50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(120), + ), + ), child: Row( children: [ - SvgPicture.asset("assets/icons/ic_star.svg", colorFilter: ColorFilter.mode(AppThemeData.primary300, BlendMode.srcIn)), + SvgPicture.asset( + "assets/icons/ic_star.svg", + colorFilter: ColorFilter.mode( + AppThemeData.primary300, + BlendMode.srcIn, + ), + ), const SizedBox(width: 5), Text( "${Constant.calculateReview(reviewCount: vendorModel.reviewsCount!.toStringAsFixed(0), reviewSum: vendorModel.reviewsSum.toString())} (${vendorModel.reviewsCount!.toStringAsFixed(0)})", - style: TextStyle(fontSize: 14, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600), + style: TextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w600, + ), ), ], ), ), const SizedBox(width: 6), Container( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 7), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 7, + ), decoration: ShapeDecoration( - color: isDark ? AppThemeData.ecommerce600 : AppThemeData.ecommerce50, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120)), + color: + isDark + ? AppThemeData.ecommerce600 + : AppThemeData.ecommerce50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(120), + ), ), child: Row( children: [ - SvgPicture.asset("assets/icons/ic_map_distance.svg", colorFilter: ColorFilter.mode(AppThemeData.ecommerce300, BlendMode.srcIn)), + SvgPicture.asset( + "assets/icons/ic_map_distance.svg", + colorFilter: ColorFilter.mode( + AppThemeData.ecommerce300, + BlendMode.srcIn, + ), + ), const SizedBox(width: 5), Text( "${Constant.getDistance(lat1: vendorModel.latitude.toString(), lng1: vendorModel.longitude.toString(), lat2: Constant.selectedLocation.location!.latitude.toString(), lng2: Constant.selectedLocation.location!.longitude.toString())} ${Constant.distanceType}", style: TextStyle( fontSize: 14, - color: isDark ? AppThemeData.ecommerce300 : AppThemeData.ecommerce300, + color: + isDark + ? AppThemeData.ecommerce300 + : AppThemeData.ecommerce300, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600, ), @@ -834,13 +1588,29 @@ class PopularRestaurant extends StatelessWidget { vendorModel.title.toString(), textAlign: TextAlign.start, maxLines: 1, - style: TextStyle(fontSize: 18, overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontSize: 18, + overflow: TextOverflow.ellipsis, + fontFamily: AppThemeData.semiBold, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), Text( vendorModel.location.toString(), textAlign: TextAlign.start, maxLines: 1, - style: TextStyle(overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500, color: isDark ? AppThemeData.grey400 : AppThemeData.grey400), + style: TextStyle( + overflow: TextOverflow.ellipsis, + fontFamily: AppThemeData.medium, + fontWeight: FontWeight.w500, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey400, + ), ), ], ), @@ -875,21 +1645,35 @@ class AllRestaurant extends StatelessWidget { VendorModel vendorModel = controller.allNearestRestaurant[index]; return InkWell( onTap: () { - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": vendorModel})?.then((v) { + Get.to( + const RestaurantDetailsScreen(), + arguments: {"vendorModel": vendorModel}, + )?.then((v) { controller.getFavouriteRestaurant(); }); }, child: Padding( - padding: EdgeInsets.only(bottom: controller.allNearestRestaurant.length - 1 == index ? 60 : 20), + padding: EdgeInsets.only( + bottom: + controller.allNearestRestaurant.length - 1 == index ? 60 : 20, + ), child: Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16))), + decoration: ShapeDecoration( + color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + ), + ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Stack( children: [ ClipRRect( - borderRadius: const BorderRadius.only(topLeft: Radius.circular(16), topRight: Radius.circular(16)), + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(16), + topRight: Radius.circular(16), + ), child: Stack( children: [ RestaurantImageView(vendorModel: vendorModel), @@ -897,7 +1681,14 @@ class AllRestaurant extends StatelessWidget { height: Responsive.height(20, context), width: Responsive.width(100, context), decoration: BoxDecoration( - gradient: LinearGradient(begin: const Alignment(-0.00, -1.00), end: const Alignment(0, 1), colors: [Colors.black.withOpacity(0), const Color(0xFF111827)]), + gradient: LinearGradient( + begin: const Alignment(-0.00, -1.00), + end: const Alignment(0, 1), + colors: [ + Colors.black.withValues(alpha: 0), + const Color(0xFF111827), + ], + ), ), ), Positioned( @@ -905,21 +1696,55 @@ class AllRestaurant extends StatelessWidget { top: 10, child: InkWell( onTap: () async { - if (controller.favouriteList.where((p0) => p0.restaurantId == vendorModel.id).isNotEmpty) { - FavouriteModel favouriteModel = FavouriteModel(restaurantId: vendorModel.id, userId: FireStoreUtils.getCurrentUid()); - controller.favouriteList.removeWhere((item) => item.restaurantId == vendorModel.id); - await FireStoreUtils.removeFavouriteRestaurant(favouriteModel); + if (controller.favouriteList + .where( + (p0) => + p0.restaurantId == vendorModel.id, + ) + .isNotEmpty) { + FavouriteModel favouriteModel = + FavouriteModel( + restaurantId: vendorModel.id, + userId: + FireStoreUtils.getCurrentUid(), + ); + controller.favouriteList.removeWhere( + (item) => + item.restaurantId == vendorModel.id, + ); + await FireStoreUtils.removeFavouriteRestaurant( + favouriteModel, + ); } else { - FavouriteModel favouriteModel = FavouriteModel(restaurantId: vendorModel.id, userId: FireStoreUtils.getCurrentUid()); - controller.favouriteList.add(favouriteModel); - await FireStoreUtils.setFavouriteRestaurant(favouriteModel); + FavouriteModel favouriteModel = + FavouriteModel( + restaurantId: vendorModel.id, + userId: + FireStoreUtils.getCurrentUid(), + ); + controller.favouriteList.add( + favouriteModel, + ); + await FireStoreUtils.setFavouriteRestaurant( + favouriteModel, + ); } }, child: Obx( () => - controller.favouriteList.where((p0) => p0.restaurantId == vendorModel.id).isNotEmpty - ? SvgPicture.asset("assets/icons/ic_like_fill.svg") - : SvgPicture.asset("assets/icons/ic_like.svg"), + controller.favouriteList + .where( + (p0) => + p0.restaurantId == + vendorModel.id, + ) + .isNotEmpty + ? SvgPicture.asset( + "assets/icons/ic_like_fill.svg", + ) + : SvgPicture.asset( + "assets/icons/ic_like.svg", + ), ), ), ), @@ -927,26 +1752,46 @@ class AllRestaurant extends StatelessWidget { ), ), Transform.translate( - offset: Offset(Responsive.width(-3, context), Responsive.height(17.5, context)), + offset: Offset( + Responsive.width(-3, context), + Responsive.height(17.5, context), + ), child: Row( mainAxisAlignment: MainAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end, children: [ Visibility( - visible: (vendorModel.isSelfDelivery == true && Constant.isSelfDeliveryFeature == true), + visible: + (vendorModel.isSelfDelivery == true && + Constant.isSelfDeliveryFeature == true), child: Row( children: [ Container( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 7), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 7, + ), decoration: BoxDecoration( color: AppThemeData.carRent300, - borderRadius: BorderRadius.circular(120), // Optional + borderRadius: BorderRadius.circular( + 120, + ), // Optional ), child: Row( children: [ - SvgPicture.asset("assets/icons/ic_free_delivery.svg"), + SvgPicture.asset( + "assets/icons/ic_free_delivery.svg", + ), const SizedBox(width: 5), - Text("Free Delivery".tr, style: TextStyle(fontSize: 14, color: AppThemeData.carRent600, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600)), + Text( + ConstTexts.freeDelivery.tr, + style: TextStyle( + fontSize: 14, + color: AppThemeData.carRent600, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w600, + ), + ), ], ), ), @@ -955,35 +1800,77 @@ class AllRestaurant extends StatelessWidget { ), ), Container( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 7), - decoration: ShapeDecoration(color: isDark ? AppThemeData.primary600 : AppThemeData.primary50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120))), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 7, + ), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.primary600 + : AppThemeData.primary50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(120), + ), + ), child: Row( children: [ - SvgPicture.asset("assets/icons/ic_star.svg", colorFilter: ColorFilter.mode(AppThemeData.primary300, BlendMode.srcIn)), + SvgPicture.asset( + "assets/icons/ic_star.svg", + colorFilter: ColorFilter.mode( + AppThemeData.primary300, + BlendMode.srcIn, + ), + ), const SizedBox(width: 5), Text( "${Constant.calculateReview(reviewCount: vendorModel.reviewsCount.toString(), reviewSum: vendorModel.reviewsSum.toString())} (${vendorModel.reviewsCount!.toStringAsFixed(0)})", - style: TextStyle(fontSize: 14, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600), + style: TextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w600, + ), ), ], ), ), const SizedBox(width: 6), Container( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 7), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 7, + ), decoration: ShapeDecoration( - color: isDark ? AppThemeData.ecommerce600 : AppThemeData.ecommerce50, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120)), + color: + isDark + ? AppThemeData.ecommerce600 + : AppThemeData.ecommerce50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(120), + ), ), child: Row( children: [ - SvgPicture.asset("assets/icons/ic_map_distance.svg", colorFilter: ColorFilter.mode(AppThemeData.ecommerce300, BlendMode.srcIn)), + SvgPicture.asset( + "assets/icons/ic_map_distance.svg", + colorFilter: ColorFilter.mode( + AppThemeData.ecommerce300, + BlendMode.srcIn, + ), + ), const SizedBox(width: 5), Text( "${Constant.getDistance(lat1: vendorModel.latitude.toString(), lng1: vendorModel.longitude.toString(), lat2: Constant.selectedLocation.location!.latitude.toString(), lng2: Constant.selectedLocation.location!.longitude.toString())} ${Constant.distanceType}", style: TextStyle( fontSize: 14, - color: isDark ? AppThemeData.ecommerce300 : AppThemeData.ecommerce300, + color: + isDark + ? AppThemeData.ecommerce300 + : AppThemeData.ecommerce300, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600, ), @@ -1006,13 +1893,29 @@ class AllRestaurant extends StatelessWidget { vendorModel.title.toString(), textAlign: TextAlign.start, maxLines: 1, - style: TextStyle(fontSize: 18, overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontSize: 18, + overflow: TextOverflow.ellipsis, + fontFamily: AppThemeData.semiBold, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), Text( vendorModel.location.toString(), textAlign: TextAlign.start, maxLines: 1, - style: TextStyle(overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500, color: isDark ? AppThemeData.grey400 : AppThemeData.grey400), + style: TextStyle( + overflow: TextOverflow.ellipsis, + fontFamily: AppThemeData.medium, + fontWeight: FontWeight.w500, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey400, + ), ), ], ), @@ -1042,12 +1945,18 @@ class NewArrival extends StatelessWidget { child: ListView.builder( physics: const BouncingScrollPhysics(), scrollDirection: Axis.horizontal, - itemCount: controller.newArrivalRestaurantList.length >= 10 ? 10 : controller.newArrivalRestaurantList.length, + itemCount: + controller.newArrivalRestaurantList.length >= 10 + ? 10 + : controller.newArrivalRestaurantList.length, itemBuilder: (BuildContext context, int index) { VendorModel vendorModel = controller.newArrivalRestaurantList[index]; return InkWell( onTap: () { - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": vendorModel})?.then((v) { + Get.to( + const RestaurantDetailsScreen(), + arguments: {"vendorModel": vendorModel}, + )?.then((v) { controller.getFavouriteRestaurant(); }); }, @@ -1060,13 +1969,27 @@ class NewArrival extends StatelessWidget { children: [ Expanded( child: ClipRRect( - borderRadius: const BorderRadius.all(Radius.circular(10)), + borderRadius: const BorderRadius.all( + Radius.circular(10), + ), child: Stack( children: [ - NetworkImageWidget(imageUrl: vendorModel.photo.toString(), fit: BoxFit.cover, height: Responsive.height(100, context), width: Responsive.width(100, context)), + NetworkImageWidget( + imageUrl: vendorModel.photo.toString(), + fit: BoxFit.cover, + height: Responsive.height(100, context), + width: Responsive.width(100, context), + ), Container( decoration: BoxDecoration( - gradient: LinearGradient(begin: const Alignment(0.00, 1.00), end: const Alignment(0, -1), colors: [Colors.black.withOpacity(0), AppThemeData.grey900]), + gradient: LinearGradient( + begin: const Alignment(0.00, 1.00), + end: const Alignment(0, -1), + colors: [ + Colors.black.withOpacity(0), + AppThemeData.grey900, + ], + ), ), ), Positioned( @@ -1074,21 +1997,55 @@ class NewArrival extends StatelessWidget { top: 10, child: InkWell( onTap: () async { - if (controller.favouriteList.where((p0) => p0.restaurantId == vendorModel.id).isNotEmpty) { - FavouriteModel favouriteModel = FavouriteModel(restaurantId: vendorModel.id, userId: FireStoreUtils.getCurrentUid()); - controller.favouriteList.removeWhere((item) => item.restaurantId == vendorModel.id); - await FireStoreUtils.removeFavouriteRestaurant(favouriteModel); + if (controller.favouriteList + .where( + (p0) => + p0.restaurantId == vendorModel.id, + ) + .isNotEmpty) { + FavouriteModel favouriteModel = + FavouriteModel( + restaurantId: vendorModel.id, + userId: + FireStoreUtils.getCurrentUid(), + ); + controller.favouriteList.removeWhere( + (item) => + item.restaurantId == vendorModel.id, + ); + await FireStoreUtils.removeFavouriteRestaurant( + favouriteModel, + ); } else { - FavouriteModel favouriteModel = FavouriteModel(restaurantId: vendorModel.id, userId: FireStoreUtils.getCurrentUid()); - controller.favouriteList.add(favouriteModel); - await FireStoreUtils.setFavouriteRestaurant(favouriteModel); + FavouriteModel favouriteModel = + FavouriteModel( + restaurantId: vendorModel.id, + userId: + FireStoreUtils.getCurrentUid(), + ); + controller.favouriteList.add( + favouriteModel, + ); + await FireStoreUtils.setFavouriteRestaurant( + favouriteModel, + ); } }, child: Obx( () => - controller.favouriteList.where((p0) => p0.restaurantId == vendorModel.id).isNotEmpty - ? SvgPicture.asset("assets/icons/ic_like_fill.svg") - : SvgPicture.asset("assets/icons/ic_like.svg"), + controller.favouriteList + .where( + (p0) => + p0.restaurantId == + vendorModel.id, + ) + .isNotEmpty + ? SvgPicture.asset( + "assets/icons/ic_like_fill.svg", + ) + : SvgPicture.asset( + "assets/icons/ic_like.svg", + ), ), ), ), @@ -1101,27 +2058,40 @@ class NewArrival extends StatelessWidget { vendorModel.title.toString(), textAlign: TextAlign.start, maxLines: 1, - style: TextStyle(fontSize: 16, overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.grey50 : AppThemeData.grey50), + style: TextStyle( + fontSize: 16, + overflow: TextOverflow.ellipsis, + fontFamily: AppThemeData.semiBold, + color: + isDark ? AppThemeData.grey50 : AppThemeData.grey50, + ), ), SingleChildScrollView( scrollDirection: Axis.horizontal, child: Row( children: [ Visibility( - visible: (vendorModel.isSelfDelivery == true && Constant.isSelfDeliveryFeature == true), + visible: + (vendorModel.isSelfDelivery == true && + Constant.isSelfDeliveryFeature == true), child: Row( children: [ - SvgPicture.asset("assets/icons/ic_free_delivery.svg"), + SvgPicture.asset( + "assets/icons/ic_free_delivery.svg", + ), const SizedBox(width: 4), Text( - "Free Delivery".tr, + ConstTexts.freeDelivery.tr, textAlign: TextAlign.start, maxLines: 1, style: TextStyle( overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500, - color: isDark ? AppThemeData.grey400 : AppThemeData.grey400, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey400, ), ), const SizedBox(width: 8), @@ -1130,7 +2100,13 @@ class NewArrival extends StatelessWidget { ), Row( children: [ - SvgPicture.asset("assets/icons/ic_star.svg", colorFilter: ColorFilter.mode(AppThemeData.primary300, BlendMode.srcIn)), + SvgPicture.asset( + "assets/icons/ic_star.svg", + colorFilter: ColorFilter.mode( + AppThemeData.primary300, + BlendMode.srcIn, + ), + ), const SizedBox(width: 4), Text( "${Constant.calculateReview(reviewCount: vendorModel.reviewsCount.toString(), reviewSum: vendorModel.reviewsSum.toString())} (${vendorModel.reviewsCount!.toStringAsFixed(0)})", @@ -1140,7 +2116,10 @@ class NewArrival extends StatelessWidget { overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500, - color: isDark ? AppThemeData.grey400 : AppThemeData.grey400, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey400, ), ), ], @@ -1148,7 +2127,9 @@ class NewArrival extends StatelessWidget { const SizedBox(width: 8), Row( children: [ - SvgPicture.asset("assets/icons/ic_map_distance.svg"), + SvgPicture.asset( + "assets/icons/ic_map_distance.svg", + ), const SizedBox(width: 4), Text( "${Constant.getDistance(lat1: vendorModel.latitude.toString(), lng1: vendorModel.longitude.toString(), lat2: Constant.selectedLocation.location!.latitude.toString(), lng2: Constant.selectedLocation.location!.longitude.toString())} ${Constant.distanceType}", @@ -1158,7 +2139,10 @@ class NewArrival extends StatelessWidget { overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500, - color: isDark ? AppThemeData.grey400 : AppThemeData.grey400, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey400, ), ), ], @@ -1170,7 +2154,15 @@ class NewArrival extends StatelessWidget { vendorModel.location.toString(), textAlign: TextAlign.start, maxLines: 1, - style: TextStyle(overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500, color: isDark ? AppThemeData.grey400 : AppThemeData.grey400), + style: TextStyle( + overflow: TextOverflow.ellipsis, + fontFamily: AppThemeData.medium, + fontWeight: FontWeight.w500, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey400, + ), ), ], ), @@ -1187,7 +2179,11 @@ class AdvertisementHomeCard extends StatelessWidget { final AdvertisementModel model; final FoodHomeController controller; - const AdvertisementHomeCard({super.key, required this.controller, required this.model}); + const AdvertisementHomeCard({ + super.key, + required this.controller, + required this.model, + }); @override Widget build(BuildContext context) { @@ -1195,10 +2191,15 @@ class AdvertisementHomeCard extends StatelessWidget { final isDark = themeController.isDark.value; return InkWell( onTap: () async { - ShowToastDialog.showLoader("Please wait...".tr); - VendorModel? vendorModel = await FireStoreUtils.getVendorById(model.vendorId!); + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); + VendorModel? vendorModel = await FireStoreUtils.getVendorById( + model.vendorId!, + ); ShowToastDialog.closeLoader(); - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": vendorModel}); + Get.to( + const RestaurantDetailsScreen(), + arguments: {"vendorModel": vendorModel}, + ); }, child: Container( margin: EdgeInsets.only(right: 16), @@ -1206,7 +2207,14 @@ class AdvertisementHomeCard extends StatelessWidget { decoration: BoxDecoration( color: isDark ? AppThemeData.info600 : AppThemeData.surface, borderRadius: BorderRadius.circular(16), - boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.1), blurRadius: isDark ? 6 : 2, spreadRadius: 0, offset: Offset(0, isDark ? 3 : 1))], + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.1), + blurRadius: isDark ? 6 : 2, + spreadRadius: 0, + offset: Offset(0, isDark ? 3 : 1), + ), + ], ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -1215,18 +2223,32 @@ class AdvertisementHomeCard extends StatelessWidget { children: [ model.type == 'restaurant_promotion' ? ClipRRect( - borderRadius: BorderRadius.vertical(top: Radius.circular(16)), - child: NetworkImageWidget(imageUrl: model.coverImage ?? '', height: 135, width: double.infinity, fit: BoxFit.cover), + borderRadius: BorderRadius.vertical( + top: Radius.circular(16), + ), + child: NetworkImageWidget( + imageUrl: model.coverImage ?? '', + height: 135, + width: double.infinity, + fit: BoxFit.cover, + ), ) - : VideoAdvWidget(url: model.video ?? '', height: 135, width: double.infinity), - if (model.type != 'video_promotion' && model.vendorId != null && (model.showRating == true || model.showReview == true)) + : VideoAdvWidget( + url: model.video ?? '', + height: 135, + width: double.infinity, + ), + if (model.type != 'video_promotion' && + model.vendorId != null && + (model.showRating == true || model.showReview == true)) Positioned( bottom: 8, right: 8, child: FutureBuilder( future: FireStoreUtils.getVendorById(model.vendorId!), builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { + if (snapshot.connectionState == + ConnectionState.waiting) { return const SizedBox(); } else { if (snapshot.hasError) { @@ -1236,16 +2258,43 @@ class AdvertisementHomeCard extends StatelessWidget { } else { VendorModel vendorModel = snapshot.data!; return Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.primary600 : AppThemeData.primary50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.primary600 + : AppThemeData.primary50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(120), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 8, + ), child: Row( children: [ - if (model.showRating == true) SvgPicture.asset("assets/icons/ic_star.svg", colorFilter: ColorFilter.mode(AppThemeData.primary300, BlendMode.srcIn)), - if (model.showRating == true) const SizedBox(width: 5), + if (model.showRating == true) + SvgPicture.asset( + "assets/icons/ic_star.svg", + colorFilter: ColorFilter.mode( + AppThemeData.primary300, + BlendMode.srcIn, + ), + ), + if (model.showRating == true) + const SizedBox(width: 5), Text( "${model.showRating == true ? Constant.calculateReview(reviewCount: vendorModel.reviewsCount!.toStringAsFixed(0), reviewSum: vendorModel.reviewsSum.toString()) : ''} ${model.showReview == true ? '(${vendorModel.reviewsCount!.toStringAsFixed(0)})' : ''}", - style: TextStyle(fontSize: 14, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600), + style: TextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w600, + ), ), ], ), @@ -1264,7 +2313,15 @@ class AdvertisementHomeCard extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ if (model.type == 'restaurant_promotion') - ClipRRect(borderRadius: BorderRadius.circular(30), child: NetworkImageWidget(imageUrl: model.profileImage ?? '', height: 50, width: 50, fit: BoxFit.cover)), + ClipRRect( + borderRadius: BorderRadius.circular(30), + child: NetworkImageWidget( + imageUrl: model.profileImage ?? '', + height: 50, + width: 50, + fit: BoxFit.cover, + ), + ), SizedBox(width: 8), Expanded( child: Column( @@ -1272,12 +2329,26 @@ class AdvertisementHomeCard extends StatelessWidget { children: [ Text( model.title ?? '', - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 14, fontWeight: FontWeight.bold), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 14, + fontWeight: FontWeight.bold, + ), overflow: TextOverflow.ellipsis, ), Text( model.description ?? '', - style: TextStyle(fontSize: 12, fontFamily: AppThemeData.medium, color: isDark ? AppThemeData.grey400 : AppThemeData.grey600), + style: TextStyle( + fontSize: 12, + fontFamily: AppThemeData.medium, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey600, + ), overflow: TextOverflow.ellipsis, maxLines: 2, ), @@ -1288,26 +2359,73 @@ class AdvertisementHomeCard extends StatelessWidget { ? IconButton( icon: Obx( () => - controller.favouriteList.where((p0) => p0.restaurantId == model.vendorId).isNotEmpty - ? SvgPicture.asset("assets/icons/ic_like_fill.svg") - : SvgPicture.asset("assets/icons/ic_like.svg", colorFilter: ColorFilter.mode(isDark ? AppThemeData.grey400 : AppThemeData.grey600, BlendMode.srcIn)), + controller.favouriteList + .where( + (p0) => + p0.restaurantId == model.vendorId, + ) + .isNotEmpty + ? SvgPicture.asset( + "assets/icons/ic_like_fill.svg", + ) + : SvgPicture.asset( + "assets/icons/ic_like.svg", + colorFilter: ColorFilter.mode( + isDark + ? AppThemeData.grey400 + : AppThemeData.grey600, + BlendMode.srcIn, + ), + ), ), onPressed: () async { - if (controller.favouriteList.where((p0) => p0.restaurantId == model.vendorId).isNotEmpty) { - FavouriteModel favouriteModel = FavouriteModel(restaurantId: model.vendorId, userId: FireStoreUtils.getCurrentUid()); - controller.favouriteList.removeWhere((item) => item.restaurantId == model.vendorId); - await FireStoreUtils.removeFavouriteRestaurant(favouriteModel); + if (controller.favouriteList + .where((p0) => p0.restaurantId == model.vendorId) + .isNotEmpty) { + FavouriteModel favouriteModel = FavouriteModel( + restaurantId: model.vendorId, + userId: FireStoreUtils.getCurrentUid(), + ); + controller.favouriteList.removeWhere( + (item) => item.restaurantId == model.vendorId, + ); + await FireStoreUtils.removeFavouriteRestaurant( + favouriteModel, + ); } else { - FavouriteModel favouriteModel = FavouriteModel(restaurantId: model.vendorId, userId: FireStoreUtils.getCurrentUid()); + FavouriteModel favouriteModel = FavouriteModel( + restaurantId: model.vendorId, + userId: FireStoreUtils.getCurrentUid(), + ); controller.favouriteList.add(favouriteModel); - await FireStoreUtils.setFavouriteRestaurant(favouriteModel); + await FireStoreUtils.setFavouriteRestaurant( + favouriteModel, + ); } controller.update(); }, ) : Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.primary600 : AppThemeData.primary50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5))), - child: Padding(padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4), child: Icon(Icons.arrow_forward, size: 20, color: AppThemeData.primary300)), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.primary600 + : AppThemeData.primary50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), + ), + ), + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 4, + ), + child: Icon( + Icons.arrow_forward, + size: 20, + color: AppThemeData.primary300, + ), + ), ), ], ), @@ -1333,13 +2451,19 @@ class OfferView extends StatelessWidget { child: ListView.builder( physics: const BouncingScrollPhysics(), scrollDirection: Axis.horizontal, - itemCount: controller.couponRestaurantList.length >= 15 ? 15 : controller.couponRestaurantList.length, + itemCount: + controller.couponRestaurantList.length >= 15 + ? 15 + : controller.couponRestaurantList.length, itemBuilder: (BuildContext context, int index) { VendorModel vendorModel = controller.couponRestaurantList[index]; CouponModel offerModel = controller.couponList[index]; return InkWell( onTap: () { - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": vendorModel}); + Get.to( + const RestaurantDetailsScreen(), + arguments: {"vendorModel": vendorModel}, + ); }, child: Padding( padding: const EdgeInsets.only(right: 10), @@ -1350,13 +2474,27 @@ class OfferView extends StatelessWidget { children: [ Expanded( child: ClipRRect( - borderRadius: const BorderRadius.all(Radius.circular(10)), + borderRadius: const BorderRadius.all( + Radius.circular(10), + ), child: Stack( children: [ - NetworkImageWidget(imageUrl: vendorModel.photo.toString(), fit: BoxFit.cover, height: Responsive.height(100, context), width: Responsive.width(100, context)), + NetworkImageWidget( + imageUrl: vendorModel.photo.toString(), + fit: BoxFit.cover, + height: Responsive.height(100, context), + width: Responsive.width(100, context), + ), Container( decoration: BoxDecoration( - gradient: LinearGradient(begin: const Alignment(-0.00, -1.00), end: const Alignment(0, 1), colors: [Colors.black.withOpacity(0), AppThemeData.grey900]), + gradient: LinearGradient( + begin: const Alignment(-0.00, -1.00), + end: const Alignment(0, 1), + colors: [ + Colors.black.withValues(alpha: 0), + AppThemeData.grey900, + ], + ), ), ), Positioned( @@ -1366,7 +2504,7 @@ class OfferView extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "Upto".tr, + ConstTexts.upto.tr, textAlign: TextAlign.start, maxLines: 1, style: TextStyle( @@ -1374,14 +2512,24 @@ class OfferView extends StatelessWidget { overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w900, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey50, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey50, ), ), Text( "${offerModel.discountType == "Fix Price" ? Constant.currencyModel!.symbol : ""}${offerModel.discount}${offerModel.discountType == "Percentage" ? "% off".tr : "off".tr}", textAlign: TextAlign.start, maxLines: 1, - style: TextStyle(overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.grey50 : AppThemeData.grey50), + style: TextStyle( + overflow: TextOverflow.ellipsis, + fontFamily: AppThemeData.semiBold, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey50, + ), ), ], ), @@ -1395,28 +2543,41 @@ class OfferView extends StatelessWidget { vendorModel.title.toString(), textAlign: TextAlign.start, maxLines: 1, - style: TextStyle(fontSize: 16, overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontSize: 16, + overflow: TextOverflow.ellipsis, + fontFamily: AppThemeData.semiBold, + color: + isDark ? AppThemeData.grey50 : AppThemeData.grey900, + ), ), SingleChildScrollView( scrollDirection: Axis.horizontal, child: Row( children: [ Visibility( - visible: (vendorModel.isSelfDelivery == true && Constant.isSelfDeliveryFeature == true), + visible: + (vendorModel.isSelfDelivery == true && + Constant.isSelfDeliveryFeature == true), child: Row( children: [ Row( children: [ - SvgPicture.asset("assets/icons/ic_free_delivery.svg"), + SvgPicture.asset( + "assets/icons/ic_free_delivery.svg", + ), const SizedBox(width: 5), Text( - "Free Delivery".tr, + ConstTexts.freeDelivery.tr, style: TextStyle( fontSize: 12, overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500, - color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, ), ), ], @@ -1427,7 +2588,13 @@ class OfferView extends StatelessWidget { ), Row( children: [ - SvgPicture.asset("assets/icons/ic_star.svg", colorFilter: ColorFilter.mode(AppThemeData.primary300, BlendMode.srcIn)), + SvgPicture.asset( + "assets/icons/ic_star.svg", + colorFilter: ColorFilter.mode( + AppThemeData.primary300, + BlendMode.srcIn, + ), + ), const SizedBox(width: 10), Text( "${Constant.calculateReview(reviewCount: vendorModel.reviewsCount.toString(), reviewSum: vendorModel.reviewsSum.toString())} (${vendorModel.reviewsCount!.toStringAsFixed(0)})", @@ -1438,7 +2605,10 @@ class OfferView extends StatelessWidget { overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500, - color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, ), ), ], @@ -1484,18 +2654,33 @@ class BannerView extends StatelessWidget { return InkWell( onTap: () async { if (bannerModel.redirect_type == "store") { - ShowToastDialog.showLoader("Please wait...".tr); - VendorModel? vendorModel = await FireStoreUtils.getVendorById(bannerModel.redirect_id.toString()); + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); + VendorModel? vendorModel = + await FireStoreUtils.getVendorById( + bannerModel.redirect_id.toString(), + ); ShowToastDialog.closeLoader(); - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": vendorModel}); + Get.to( + const RestaurantDetailsScreen(), + arguments: {"vendorModel": vendorModel}, + ); } else if (bannerModel.redirect_type == "product") { - ShowToastDialog.showLoader("Please wait...".tr); - ProductModel? productModel = await FireStoreUtils.getProductById(bannerModel.redirect_id.toString()); - VendorModel? vendorModel = await FireStoreUtils.getVendorById(productModel!.vendorID.toString()); + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); + ProductModel? productModel = + await FireStoreUtils.getProductById( + bannerModel.redirect_id.toString(), + ); + VendorModel? vendorModel = + await FireStoreUtils.getVendorById( + productModel!.vendorID.toString(), + ); ShowToastDialog.closeLoader(); - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": vendorModel}); + Get.to( + const RestaurantDetailsScreen(), + arguments: {"vendorModel": vendorModel}, + ); } else if (bannerModel.redirect_type == "external_link") { final uri = Uri.parse(bannerModel.redirect_id.toString()); if (await canLaunchUrl(uri)) { @@ -1507,7 +2692,13 @@ class BannerView extends StatelessWidget { }, child: Padding( padding: const EdgeInsets.only(right: 14), - child: ClipRRect(borderRadius: const BorderRadius.all(Radius.circular(12)), child: NetworkImageWidget(imageUrl: bannerModel.photo.toString(), fit: BoxFit.cover)), + child: ClipRRect( + borderRadius: const BorderRadius.all(Radius.circular(12)), + child: NetworkImageWidget( + imageUrl: bannerModel.photo.toString(), + fit: BoxFit.cover, + ), + ), ), ); }, @@ -1525,7 +2716,13 @@ class BannerView extends StatelessWidget { alignment: Alignment.centerLeft, height: 9, width: 9, - decoration: BoxDecoration(shape: BoxShape.circle, color: controller.currentPage.value == index ? AppThemeData.primary300 : Colors.black12), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: + controller.currentPage.value == index + ? AppThemeData.primary300 + : Colors.black12, + ), ), ); }), @@ -1563,18 +2760,33 @@ class BannerBottomView extends StatelessWidget { return InkWell( onTap: () async { if (bannerModel.redirect_type == "store") { - ShowToastDialog.showLoader("Please wait...".tr); - VendorModel? vendorModel = await FireStoreUtils.getVendorById(bannerModel.redirect_id.toString()); + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); + VendorModel? vendorModel = + await FireStoreUtils.getVendorById( + bannerModel.redirect_id.toString(), + ); ShowToastDialog.closeLoader(); - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": vendorModel}); + Get.to( + const RestaurantDetailsScreen(), + arguments: {"vendorModel": vendorModel}, + ); } else if (bannerModel.redirect_type == "product") { - ShowToastDialog.showLoader("Please wait...".tr); - ProductModel? productModel = await FireStoreUtils.getProductById(bannerModel.redirect_id.toString()); - VendorModel? vendorModel = await FireStoreUtils.getVendorById(productModel!.vendorID.toString()); + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); + ProductModel? productModel = + await FireStoreUtils.getProductById( + bannerModel.redirect_id.toString(), + ); + VendorModel? vendorModel = + await FireStoreUtils.getVendorById( + productModel!.vendorID.toString(), + ); ShowToastDialog.closeLoader(); - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": vendorModel}); + Get.to( + const RestaurantDetailsScreen(), + arguments: {"vendorModel": vendorModel}, + ); } else if (bannerModel.redirect_type == "external_link") { final uri = Uri.parse(bannerModel.redirect_id.toString()); if (await canLaunchUrl(uri)) { @@ -1586,7 +2798,13 @@ class BannerBottomView extends StatelessWidget { }, child: Padding( padding: const EdgeInsets.only(right: 14), - child: ClipRRect(borderRadius: const BorderRadius.all(Radius.circular(12)), child: NetworkImageWidget(imageUrl: bannerModel.photo.toString(), fit: BoxFit.cover)), + child: ClipRRect( + borderRadius: const BorderRadius.all(Radius.circular(12)), + child: NetworkImageWidget( + imageUrl: bannerModel.photo.toString(), + fit: BoxFit.cover, + ), + ), ), ); }, @@ -1597,14 +2815,22 @@ class BannerBottomView extends StatelessWidget { child: Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, - children: List.generate(controller.bannerBottomModel.length, (index) { + children: List.generate(controller.bannerBottomModel.length, ( + index, + ) { return Obx( () => Container( margin: const EdgeInsets.only(right: 5), alignment: Alignment.centerLeft, height: 9, width: 9, - decoration: BoxDecoration(shape: BoxShape.circle, color: controller.currentBottomPage.value == index ? AppThemeData.primary300 : Colors.black12), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: + controller.currentBottomPage.value == index + ? AppThemeData.primary300 + : Colors.black12, + ), ), ); }), @@ -1625,46 +2851,63 @@ class CategoryView extends StatelessWidget { final themeController = Get.find(); final isDark = themeController.isDark.value; return SizedBox( - height: 124, + height: 100.h, child: ListView.builder( scrollDirection: Axis.horizontal, padding: EdgeInsets.zero, itemCount: controller.vendorCategoryModel.length, itemBuilder: (context, index) { - VendorCategoryModel vendorCategoryModel = controller.vendorCategoryModel[index]; + VendorCategoryModel vendorCategoryModel = + controller.vendorCategoryModel[index]; return InkWell( onTap: () { - Get.to(const CategoryRestaurantScreen(), arguments: {"vendorCategoryModel": vendorCategoryModel, "dineIn": false}); + Get.to( + const CategoryRestaurantScreen(), + arguments: { + "vendorCategoryModel": vendorCategoryModel, + "dineIn": false, + }, + ); }, - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 2), - child: SizedBox( - width: 78, - child: Container( - decoration: ShapeDecoration( - color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, - shape: RoundedRectangleBorder( - side: BorderSide(width: 1, strokeAlign: BorderSide.strokeAlignOutside, color: isDark ? AppThemeData.grey800 : AppThemeData.grey100), - borderRadius: BorderRadius.circular(100), + child: Container( + width: 100.r, + height: 100.r, + margin: + index == 0 + ? EdgeInsets.only(left: 16.r, right: 10.r) + : index == controller.vendorCategoryModel.length - 1 + ? EdgeInsets.only(right: 16.r) + : EdgeInsets.only(right: 10.r), + decoration: BoxDecoration( + color: isDark ? AppThemeData.grey900 : AppThemeData.cardColor, + borderRadius: BorderRadius.circular(12.r), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: EdgeInsets.all(10.r), + child: Text( + '${vendorCategoryModel.title}', + textAlign: TextAlign.center, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: AppThemeData.boldTextStyle( + color: AppThemeData.darkGrey, + fontSize: 13.3.sp, + ), ), ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - SizedBox(width: 60, height: 60, child: ClipOval(child: NetworkImageWidget(imageUrl: vendorCategoryModel.photo.toString(), fit: BoxFit.cover))), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10), - child: Text( - '${vendorCategoryModel.title}', - textAlign: TextAlign.center, - maxLines: 1, - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.medium), - ), + Expanded( + child: ClipOval( + child: NetworkImageWidget( + imageUrl: vendorCategoryModel.photo.toString(), + fit: BoxFit.cover, ), - ], + ), ), - ), + ], ), ), ); @@ -1693,7 +2936,15 @@ class StoryView extends StatelessWidget { padding: const EdgeInsets.only(right: 10), child: InkWell( onTap: () { - Navigator.of(context).push(MaterialPageRoute(builder: (context) => MoreStories(storyList: controller.storyList, index: index))); + Navigator.of(context).push( + MaterialPageRoute( + builder: + (context) => MoreStories( + storyList: controller.storyList, + index: index, + ), + ), + ); }, child: SizedBox( width: 134, @@ -1701,18 +2952,33 @@ class StoryView extends StatelessWidget { borderRadius: const BorderRadius.all(Radius.circular(10)), child: Stack( children: [ - NetworkImageWidget(imageUrl: storyModel.videoThumbnail.toString(), fit: BoxFit.cover, height: Responsive.height(100, context), width: Responsive.width(100, context)), + NetworkImageWidget( + imageUrl: storyModel.videoThumbnail.toString(), + fit: BoxFit.cover, + height: Responsive.height(100, context), + width: Responsive.width(100, context), + ), Container(color: Colors.black.withOpacity(0.30)), Padding( - padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 8), + padding: const EdgeInsets.symmetric( + horizontal: 5, + vertical: 8, + ), child: FutureBuilder( - future: FireStoreUtils.getVendorById(storyModel.vendorID.toString()), + future: FireStoreUtils.getVendorById( + storyModel.vendorID.toString(), + ), builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { + if (snapshot.connectionState == + ConnectionState.waiting) { return Constant.loader(); } else { if (snapshot.hasError) { - return Center(child: Text('${"Error".tr}: ${snapshot.error}')); + return Center( + child: Text( + '${"Error".tr}: ${snapshot.error}', + ), + ); } else if (snapshot.data == null) { return const SizedBox(); } else { @@ -1721,28 +2987,51 @@ class StoryView extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - ClipOval(child: NetworkImageWidget(imageUrl: vendorModel.photo.toString(), width: 30, height: 30, fit: BoxFit.cover)), + ClipOval( + child: NetworkImageWidget( + imageUrl: vendorModel.photo.toString(), + width: 30, + height: 30, + fit: BoxFit.cover, + ), + ), const SizedBox(width: 4), Expanded( child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( vendorModel.title.toString(), textAlign: TextAlign.center, maxLines: 1, - style: const TextStyle(color: Colors.white, fontSize: 12, overflow: TextOverflow.ellipsis, fontWeight: FontWeight.w700), + style: const TextStyle( + color: Colors.white, + fontSize: 12, + overflow: TextOverflow.ellipsis, + fontWeight: FontWeight.w700, + ), ), Row( children: [ - SvgPicture.asset("assets/icons/ic_star.svg"), + SvgPicture.asset( + "assets/icons/ic_star.svg", + ), const SizedBox(width: 5), Text( "${Constant.calculateReview(reviewCount: vendorModel.reviewsCount.toString(), reviewSum: vendorModel.reviewsSum!.toStringAsFixed(0))} reviews", textAlign: TextAlign.center, maxLines: 1, - style: const TextStyle(color: AppThemeData.warning300, fontSize: 10, overflow: TextOverflow.ellipsis, fontWeight: FontWeight.w700), + style: const TextStyle( + color: + AppThemeData.warning300, + fontSize: 10, + overflow: + TextOverflow.ellipsis, + fontWeight: FontWeight.w700, + ), ), ], ), @@ -1784,11 +3073,18 @@ class MapView extends StatelessWidget { ? flutterMap.FlutterMap( mapController: controller.osmMapController, options: flutterMap.MapOptions( - initialCenter: location.LatLng(Constant.selectedLocation.location!.latitude ?? 0.0, Constant.selectedLocation.location!.longitude ?? 0.0), + initialCenter: location.LatLng( + Constant.selectedLocation.location!.latitude ?? 0.0, + Constant.selectedLocation.location!.longitude ?? 0.0, + ), initialZoom: 10, ), children: [ - flutterMap.TileLayer(urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', userAgentPackageName: 'com.emart.app'), + flutterMap.TileLayer( + urlTemplate: + 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', + userAgentPackageName: 'com.emart.app', + ), flutterMap.MarkerLayer(markers: controller.osmMarker), ], ) @@ -1806,8 +3102,26 @@ class MapView extends StatelessWidget { zoom: 18, target: controller.homeController.allNearestRestaurant.isEmpty - ? LatLng(Constant.selectedLocation.location!.latitude ?? 45.521563, Constant.selectedLocation.location!.longitude ?? -122.677433) - : LatLng(controller.homeController.allNearestRestaurant.first.latitude ?? 45.521563, controller.homeController.allNearestRestaurant.first.longitude ?? -122.677433), + ? LatLng( + Constant.selectedLocation.location!.latitude ?? + 45.521563, + Constant.selectedLocation.location!.longitude ?? + -122.677433, + ) + : LatLng( + controller + .homeController + .allNearestRestaurant + .first + .latitude ?? + 45.521563, + controller + .homeController + .allNearestRestaurant + .first + .longitude ?? + -122.677433, + ), ), ), controller.homeController.allNearestRestaurant.isEmpty @@ -1824,60 +3138,141 @@ class MapView extends StatelessWidget { Expanded( child: PageView.builder( pageSnapping: true, - controller: PageController(viewportFraction: 0.88), + controller: PageController( + viewportFraction: 0.88, + ), onPageChanged: (value) async { if (Constant.selectedMapType == "osm") { controller.osmMapController.move( - location.LatLng(controller.homeController.allNearestRestaurant[value].latitude!, controller.homeController.allNearestRestaurant[value].longitude!), + location.LatLng( + controller + .homeController + .allNearestRestaurant[value] + .latitude!, + controller + .homeController + .allNearestRestaurant[value] + .longitude!, + ), 16, ); } else { - CameraUpdate cameraUpdate = CameraUpdate.newCameraPosition( - CameraPosition( - zoom: 18, - target: LatLng(controller.homeController.allNearestRestaurant[value].latitude!, controller.homeController.allNearestRestaurant[value].longitude!), - ), + CameraUpdate cameraUpdate = + CameraUpdate.newCameraPosition( + CameraPosition( + zoom: 18, + target: LatLng( + controller + .homeController + .allNearestRestaurant[value] + .latitude!, + controller + .homeController + .allNearestRestaurant[value] + .longitude!, + ), + ), + ); + controller.mapController!.animateCamera( + cameraUpdate, ); - controller.mapController!.animateCamera(cameraUpdate); } }, - itemCount: controller.homeController.allNearestRestaurant.length, + itemCount: + controller + .homeController + .allNearestRestaurant + .length, scrollDirection: Axis.horizontal, itemBuilder: (context, index) { - VendorModel vendorModel = controller.homeController.allNearestRestaurant[index]; + VendorModel vendorModel = + controller + .homeController + .allNearestRestaurant[index]; return InkWell( onTap: () { - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": vendorModel})?.then((v) { - controller.homeController.getFavouriteRestaurant(); + Get.to( + const RestaurantDetailsScreen(), + arguments: {"vendorModel": vendorModel}, + )?.then((v) { + controller.homeController + .getFavouriteRestaurant(); }); }, child: Padding( - padding: EdgeInsets.symmetric(vertical: 10, horizontal: index == 0 ? 0 : 10), + padding: EdgeInsets.symmetric( + vertical: 10, + horizontal: index == 0 ? 0 : 10, + ), child: Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, borderRadius: const BorderRadius.all(Radius.circular(16))), + decoration: BoxDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + borderRadius: const BorderRadius.all( + Radius.circular(16), + ), + ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Stack( children: [ ClipRRect( - borderRadius: const BorderRadius.only(topLeft: Radius.circular(16), topRight: Radius.circular(16)), + borderRadius: + const BorderRadius.only( + topLeft: Radius.circular( + 16, + ), + topRight: Radius.circular( + 16, + ), + ), child: Stack( children: [ NetworkImageWidget( - imageUrl: vendorModel.photo.toString(), + imageUrl: + vendorModel.photo + .toString(), fit: BoxFit.cover, - height: Responsive.height(14, context), - width: Responsive.width(100, context), + height: Responsive.height( + 14, + context, + ), + width: Responsive.width( + 100, + context, + ), ), Container( - height: Responsive.height(14, context), - width: Responsive.width(100, context), + height: Responsive.height( + 14, + context, + ), + width: Responsive.width( + 100, + context, + ), decoration: BoxDecoration( gradient: LinearGradient( - begin: const Alignment(-0.00, -1.00), - end: const Alignment(0, 1), - colors: [Colors.black.withOpacity(0), const Color(0xFF111827)], + begin: + const Alignment( + -0.00, + -1.00, + ), + end: const Alignment( + 0, + 1, + ), + colors: [ + Colors.black + .withValues(alpha: 0), + const Color( + 0xFF111827, + ), + ], ), ), ), @@ -1886,21 +3281,75 @@ class MapView extends StatelessWidget { top: 10, child: InkWell( onTap: () async { - if (controller.homeController.favouriteList.where((p0) => p0.restaurantId == vendorModel.id).isNotEmpty) { - FavouriteModel favouriteModel = FavouriteModel(restaurantId: vendorModel.id, userId: FireStoreUtils.getCurrentUid()); - controller.homeController.favouriteList.removeWhere((item) => item.restaurantId == vendorModel.id); - await FireStoreUtils.removeFavouriteRestaurant(favouriteModel); + if (controller + .homeController + .favouriteList + .where( + (p0) => + p0.restaurantId == + vendorModel + .id, + ) + .isNotEmpty) { + FavouriteModel + favouriteModel = + FavouriteModel( + restaurantId: + vendorModel + .id, + userId: + FireStoreUtils.getCurrentUid(), + ); + controller + .homeController + .favouriteList + .removeWhere( + (item) => + item.restaurantId == + vendorModel + .id, + ); + await FireStoreUtils.removeFavouriteRestaurant( + favouriteModel, + ); } else { - FavouriteModel favouriteModel = FavouriteModel(restaurantId: vendorModel.id, userId: FireStoreUtils.getCurrentUid()); - controller.homeController.favouriteList.add(favouriteModel); - await FireStoreUtils.setFavouriteRestaurant(favouriteModel); + FavouriteModel + favouriteModel = + FavouriteModel( + restaurantId: + vendorModel + .id, + userId: + FireStoreUtils.getCurrentUid(), + ); + controller + .homeController + .favouriteList + .add( + favouriteModel, + ); + await FireStoreUtils.setFavouriteRestaurant( + favouriteModel, + ); } }, child: Obx( () => - controller.homeController.favouriteList.where((p0) => p0.restaurantId == vendorModel.id).isNotEmpty - ? SvgPicture.asset("assets/icons/ic_like_fill.svg") - : SvgPicture.asset("assets/icons/ic_like.svg"), + controller + .homeController + .favouriteList + .where( + (p0) => + p0.restaurantId == + vendorModel.id, + ) + .isNotEmpty + ? SvgPicture.asset( + "assets/icons/ic_like_fill.svg", + ) + : SvgPicture.asset( + "assets/icons/ic_like.svg", + ), ), ), ), @@ -1908,53 +3357,128 @@ class MapView extends StatelessWidget { ), ), Transform.translate( - offset: Offset(Responsive.width(-3, context), Responsive.height(11, context)), + offset: Offset( + Responsive.width(-3, context), + Responsive.height( + 11, + context, + ), + ), child: Row( - mainAxisAlignment: MainAxisAlignment.end, - crossAxisAlignment: CrossAxisAlignment.end, + mainAxisAlignment: + MainAxisAlignment.end, + crossAxisAlignment: + CrossAxisAlignment.end, children: [ Visibility( - visible: (vendorModel.isSelfDelivery == true && Constant.isSelfDeliveryFeature == true), + visible: + (vendorModel.isSelfDelivery == + true && + Constant.isSelfDeliveryFeature == + true), child: Row( children: [ Container( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 7), + padding: + const EdgeInsets.symmetric( + horizontal: + 10, + vertical: 7, + ), decoration: BoxDecoration( - color: AppThemeData.carRent300, - borderRadius: BorderRadius.circular(120), // Optional + color: + AppThemeData + .carRent300, + borderRadius: + BorderRadius.circular( + 120, + ), // Optional ), child: Row( children: [ - SvgPicture.asset("assets/icons/ic_free_delivery.svg"), - const SizedBox(width: 5), + SvgPicture.asset( + "assets/icons/ic_free_delivery.svg", + ), + const SizedBox( + width: 5, + ), Text( - "Free Delivery".tr, - style: TextStyle(fontSize: 14, color: AppThemeData.success600, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600), + ConstTexts.freeDelivery + .tr, + style: TextStyle( + fontSize: + 14, + color: + AppThemeData + .success600, + fontFamily: + AppThemeData + .semiBold, + fontWeight: + FontWeight + .w600, + ), ), ], ), ), - const SizedBox(width: 6), + const SizedBox( + width: 6, + ), ], ), ), Container( decoration: ShapeDecoration( - color: isDark ? AppThemeData.primary600 : AppThemeData.primary50, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120)), + color: + isDark + ? AppThemeData + .primary600 + : AppThemeData + .primary50, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 120, + ), + ), ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), + padding: + const EdgeInsets.symmetric( + horizontal: 12, + vertical: 8, + ), child: Row( children: [ - SvgPicture.asset("assets/icons/ic_star.svg", colorFilter: ColorFilter.mode(AppThemeData.primary300, BlendMode.srcIn)), - const SizedBox(width: 5), + SvgPicture.asset( + "assets/icons/ic_star.svg", + colorFilter: + ColorFilter.mode( + AppThemeData + .primary300, + BlendMode + .srcIn, + ), + ), + const SizedBox( + width: 5, + ), Text( "${Constant.calculateReview(reviewCount: vendorModel.reviewsCount.toString(), reviewSum: vendorModel.reviewsSum.toString())} (${vendorModel.reviewsCount!.toStringAsFixed(0)})", style: TextStyle( - color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + color: + isDark + ? AppThemeData + .primary300 + : AppThemeData + .primary300, + fontFamily: + AppThemeData + .semiBold, + fontWeight: + FontWeight + .w600, ), ), ], @@ -1964,21 +3488,55 @@ class MapView extends StatelessWidget { const SizedBox(width: 10), Container( decoration: ShapeDecoration( - color: isDark ? AppThemeData.ecommerce600 : AppThemeData.ecommerce50, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120)), + color: + isDark + ? AppThemeData + .ecommerce600 + : AppThemeData + .ecommerce50, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 120, + ), + ), ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), + padding: + const EdgeInsets.symmetric( + horizontal: 12, + vertical: 8, + ), child: Row( children: [ - SvgPicture.asset("assets/icons/ic_map_distance.svg", colorFilter: ColorFilter.mode(AppThemeData.ecommerce300, BlendMode.srcIn)), - const SizedBox(width: 5), + SvgPicture.asset( + "assets/icons/ic_map_distance.svg", + colorFilter: + ColorFilter.mode( + AppThemeData + .ecommerce300, + BlendMode + .srcIn, + ), + ), + const SizedBox( + width: 5, + ), Text( "${Constant.getDistance(lat1: vendorModel.latitude.toString(), lng1: vendorModel.longitude.toString(), lat2: Constant.selectedLocation.location!.latitude.toString(), lng2: Constant.selectedLocation.location!.longitude.toString())} ${Constant.distanceType}", style: TextStyle( - color: isDark ? AppThemeData.ecommerce300 : AppThemeData.ecommerce300, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + color: + isDark + ? AppThemeData + .ecommerce300 + : AppThemeData + .ecommerce300, + fontFamily: + AppThemeData + .semiBold, + fontWeight: + FontWeight + .w600, ), ), ], @@ -1992,9 +3550,12 @@ class MapView extends StatelessWidget { ), const SizedBox(height: 15), Padding( - padding: const EdgeInsets.symmetric(horizontal: 10), + padding: const EdgeInsets.symmetric( + horizontal: 10, + ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( vendorModel.title.toString(), @@ -2002,20 +3563,35 @@ class MapView extends StatelessWidget { maxLines: 1, style: TextStyle( fontSize: 18, - overflow: TextOverflow.ellipsis, - fontFamily: AppThemeData.semiBold, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + overflow: + TextOverflow.ellipsis, + fontFamily: + AppThemeData.semiBold, + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, ), ), Text( - vendorModel.location.toString(), + vendorModel.location + .toString(), textAlign: TextAlign.start, maxLines: 1, style: TextStyle( - overflow: TextOverflow.ellipsis, - fontFamily: AppThemeData.medium, + overflow: + TextOverflow.ellipsis, + fontFamily: + AppThemeData.medium, fontWeight: FontWeight.w500, - color: isDark ? AppThemeData.grey400 : AppThemeData.grey400, + color: + isDark + ? AppThemeData + .grey400 + : AppThemeData + .grey400, ), ), ], diff --git a/lib/screen_ui/multi_vendor_service/home_screen/home_screen_two.dart b/lib/screen_ui/multi_vendor_service/home_screen/home_screen_two.dart index ef0cfed..3c35f0d 100644 --- a/lib/screen_ui/multi_vendor_service/home_screen/home_screen_two.dart +++ b/lib/screen_ui/multi_vendor_service/home_screen/home_screen_two.dart @@ -1,5 +1,6 @@ import 'dart:math'; +import 'package:customer/constant/const_texts.dart'; import 'package:customer/constant/constant.dart'; import 'package:customer/controllers/food_home_controller.dart'; import 'package:customer/models/coupon_model.dart'; @@ -18,11 +19,13 @@ import 'package:customer/themes/custom_dialog_box.dart'; import 'package:customer/themes/responsive.dart'; import 'package:customer/themes/round_button_fill.dart'; import 'package:customer/themes/text_field_widget.dart'; +import 'package:customer/utils/app_router.dart'; import 'package:customer/utils/network_image_widget.dart'; import 'package:customer/utils/preferences.dart'; import 'package:customer/widget/osm_map/map_picker_page.dart'; import 'package:customer/widget/place_picker/location_picker_screen.dart'; import 'package:customer/widget/place_picker/selected_location_model.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:geocoding/geocoding.dart'; @@ -56,11 +59,12 @@ class HomeScreenTwo extends StatelessWidget { init: FoodHomeController(), builder: (controller) { return Scaffold( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + backgroundColor: AppThemeData.mainColor, body: controller.isLoading.value ? Constant.loader() - : Constant.isZoneAvailable == false || controller.allNearestRestaurant.isEmpty + : Constant.isZoneAvailable == false || + controller.allNearestRestaurant.isEmpty ? Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: Column( @@ -69,12 +73,30 @@ class HomeScreenTwo extends StatelessWidget { children: [ Image.asset("assets/images/location.gif", height: 120), const SizedBox(height: 12), - Text("No Store Found in Your Area".tr, style: TextStyle(color: isDark ? AppThemeData.grey100 : AppThemeData.grey800, fontSize: 22, fontFamily: AppThemeData.semiBold)), + Text( + "No Store Found in Your Area".tr, + style: TextStyle( + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey800, + fontSize: 22, + fontFamily: AppThemeData.semiBold, + ), + ), const SizedBox(height: 5), Text( - "Currently, there are no available store in your zone. Try changing your location to find nearby options.".tr, + "Currently, there are no available store in your zone. Try changing your location to find nearby options." + .tr, textAlign: TextAlign.center, - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey500, fontSize: 16, fontFamily: AppThemeData.bold), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey500, + fontSize: 16, + fontFamily: AppThemeData.bold, + ), ), const SizedBox(height: 20), RoundedButtonFill( @@ -91,16 +113,21 @@ class HomeScreenTwo extends StatelessWidget { ), ) : Padding( - padding: EdgeInsets.only(top: MediaQuery.of(context).viewPadding.top), + padding: EdgeInsets.only( + top: MediaQuery.of(context).viewPadding.top, + ), child: controller.isListView.value == false ? const MapView() : Column( children: [ Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), + padding: const EdgeInsets.symmetric( + horizontal: 16, + ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Row( children: [ @@ -108,98 +135,216 @@ class HomeScreenTwo extends StatelessWidget { onTap: () { Get.back(); }, - child: Icon(Icons.arrow_back, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, size: 20), + child: Icon( + Icons.arrow_back, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + size: 20, + ), ), const SizedBox(width: 10), Expanded( child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Constant.userModel == null ? InkWell( onTap: () { - Get.offAll(const LoginScreen()); + Get.offAll( + const LoginScreen(), + ); }, child: Text( "Login".tr, - textAlign: TextAlign.center, - style: TextStyle(fontFamily: AppThemeData.medium, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 12), + textAlign: + TextAlign.center, + style: TextStyle( + fontFamily: + AppThemeData + .medium, + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, + fontSize: 12, + ), ), ) : Text( - Constant.userModel!.fullName(), - textAlign: TextAlign.center, - style: TextStyle(fontFamily: AppThemeData.medium, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 12), + Constant.userModel! + .fullName(), + textAlign: + TextAlign.center, + style: TextStyle( + fontFamily: + AppThemeData.medium, + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, + fontSize: 12, + ), ), InkWell( onTap: () async { - if (Constant.userModel != null) { - Get.to(AddressListScreen())!.then((value) { + if (Constant.userModel != + null) { + Get.to( + AddressListScreen(), + )!.then((value) { if (value != null) { - ShippingAddress shippingAddress = value; - Constant.selectedLocation = shippingAddress; + ShippingAddress + shippingAddress = + value; + Constant.selectedLocation = + shippingAddress; controller.getData(); } }); } else { Constant.checkPermission( onTap: () async { - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader( + ConstTexts + .pleaseWait + .tr, + ); // ✅ declare once for whole method - ShippingAddress shippingAddress = ShippingAddress(); + ShippingAddress + shippingAddress = + ShippingAddress(); try { await Geolocator.requestPermission(); await Geolocator.getCurrentPosition(); ShowToastDialog.closeLoader(); - if (Constant.selectedMapType == 'osm') { - final result = await Get.to(() => MapPickerPage()); - if (result != null) { - final firstPlace = result; - final lat = firstPlace.coordinates.latitude; - final lng = firstPlace.coordinates.longitude; - final address = firstPlace.address; + if (Constant + .selectedMapType == + 'osm') { + final result = + await Get.to( + () => + MapPickerPage(), + ); + if (result != + null) { + final firstPlace = + result; + final lat = + firstPlace + .coordinates + .latitude; + final lng = + firstPlace + .coordinates + .longitude; + final address = + firstPlace + .address; - shippingAddress.addressAs = "Home"; - shippingAddress.locality = address.toString(); - shippingAddress.location = UserLocation(latitude: lat, longitude: lng); - Constant.selectedLocation = shippingAddress; - controller.getData(); + shippingAddress + .addressAs = + "Home"; + shippingAddress + .locality = + address + .toString(); + shippingAddress + .location = + UserLocation( + latitude: + lat, + longitude: + lng, + ); + Constant.selectedLocation = + shippingAddress; + controller + .getData(); Get.back(); } } else { - Get.to(LocationPickerScreen())!.then((value) async { - if (value != null) { - SelectedLocationModel selectedLocationModel = value; + Get.to( + LocationPickerScreen(), + )!.then(( + value, + ) async { + if (value != + null) { + SelectedLocationModel + selectedLocationModel = + value; - shippingAddress.addressAs = "Home"; - shippingAddress.location = UserLocation( - latitude: selectedLocationModel.latLng!.latitude, - longitude: selectedLocationModel.latLng!.longitude, + shippingAddress + .addressAs = + "Home"; + shippingAddress + .location = UserLocation( + latitude: + selectedLocationModel + .latLng! + .latitude, + longitude: + selectedLocationModel + .latLng! + .longitude, ); - shippingAddress.locality = "Picked from Map"; // You can reverse-geocode + shippingAddress + .locality = + "Picked from Map"; // You can reverse-geocode - Constant.selectedLocation = shippingAddress; - controller.getData(); + Constant.selectedLocation = + shippingAddress; + controller + .getData(); } }); } } catch (e) { - await placemarkFromCoordinates(19.228825, 72.854118).then((valuePlaceMaker) { - Placemark placeMark = valuePlaceMaker[0]; - shippingAddress.addressAs = "Home"; - shippingAddress.location = UserLocation(latitude: 19.228825, longitude: 72.854118); - String currentLocation = + await placemarkFromCoordinates( + 19.228825, + 72.854118, + ).then(( + valuePlaceMaker, + ) { + Placemark + placeMark = + valuePlaceMaker[0]; + shippingAddress + .addressAs = + "Home"; + shippingAddress + .location = + UserLocation( + latitude: + 19.228825, + longitude: + 72.854118, + ); + String + currentLocation = "${placeMark.name}, ${placeMark.subLocality}, ${placeMark.locality}, ${placeMark.administrativeArea}, ${placeMark.postalCode}, ${placeMark.country}"; - shippingAddress.locality = currentLocation; + shippingAddress + .locality = + currentLocation; }); - Constant.selectedLocation = shippingAddress; + Constant.selectedLocation = + shippingAddress; ShowToastDialog.closeLoader(); - controller.getData(); + controller + .getData(); } }, context: context, @@ -208,19 +353,36 @@ class HomeScreenTwo extends StatelessWidget { }, child: Text.rich( maxLines: 1, - overflow: TextOverflow.ellipsis, + overflow: + TextOverflow.ellipsis, TextSpan( children: [ TextSpan( - text: Constant.selectedLocation.getFullAddress(), + text: + Constant + .selectedLocation + .getFullAddress(), style: TextStyle( - fontFamily: AppThemeData.medium, - overflow: TextOverflow.ellipsis, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + fontFamily: + AppThemeData + .medium, + overflow: + TextOverflow + .ellipsis, + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, fontSize: 14, ), ), - WidgetSpan(child: SvgPicture.asset("assets/icons/ic_down.svg")), + WidgetSpan( + child: SvgPicture.asset( + "assets/icons/ic_down.svg", + ), + ), ], ), ), @@ -231,16 +393,28 @@ class HomeScreenTwo extends StatelessWidget { const SizedBox(width: 5), InkWell( onTap: () async { - (await Get.to(const CartScreen())); + (await Get.to( + const CartScreen(), + )); controller.getCartData(); }, child: ClipOval( child: Container( - padding: const EdgeInsets.all(8.0), - color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, + padding: const EdgeInsets.all( + 8.0, + ), + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, child: SvgPicture.asset( "assets/icons/ic_shoping_cart.svg", - colorFilter: ColorFilter.mode(isDark ? AppThemeData.grey50 : AppThemeData.grey900, BlendMode.srcIn), + colorFilter: ColorFilter.mode( + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + BlendMode.srcIn, + ), ), ), ), @@ -250,16 +424,39 @@ class HomeScreenTwo extends StatelessWidget { const SizedBox(height: 10), InkWell( onTap: () { - Get.to(const SearchScreen(), arguments: {"vendorList": controller.allNearestRestaurant}); + Get.to( + const SearchScreen(), + arguments: { + "vendorList": + controller + .allNearestRestaurant, + }, + ); }, child: TextFieldWidget( hintText: - Constant.sectionConstantModel?.name?.toLowerCase().contains('restaurants') == true - ? 'Search the dish, foo and more...'.tr - : 'Search the store, item and more...'.tr, + Constant + .sectionConstantModel + ?.name + ?.toLowerCase() + .contains( + 'restaurants', + ) == + true + ? 'Search the dish, foo and more...' + .tr + : 'Search the store, item and more...' + .tr, controller: null, enable: false, - prefix: Padding(padding: const EdgeInsets.symmetric(horizontal: 16), child: SvgPicture.asset("assets/icons/ic_search.svg")), + prefix: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 16, + ), + child: SvgPicture.asset( + "assets/icons/ic_search.svg", + ), + ), ), ), const SizedBox(height: 5), @@ -270,64 +467,185 @@ class HomeScreenTwo extends StatelessWidget { child: SingleChildScrollView( child: Column( children: [ - controller.bannerModel.isEmpty ? const SizedBox() : Padding(padding: const EdgeInsets.symmetric(horizontal: 16), child: BannerView(controller: controller)), + controller.bannerModel.isEmpty + ? const SizedBox() + : Padding( + padding: + const EdgeInsets.symmetric( + horizontal: 16, + ), + child: BannerView( + controller: controller, + ), + ), const SizedBox(height: 20), - Padding(padding: const EdgeInsets.symmetric(horizontal: 16), child: CategoryView(controller: controller)), + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 16, + ), + child: CategoryView( + controller: controller, + ), + ), controller.couponRestaurantList.isEmpty ? const SizedBox() - : Padding(padding: const EdgeInsets.symmetric(horizontal: 16), child: Column(children: [const SizedBox(height: 20), OfferView(controller: controller)])), - controller.storyList.isEmpty || Constant.storyEnable == false + : Padding( + padding: + const EdgeInsets.symmetric( + horizontal: 16, + ), + child: Column( + children: [ + const SizedBox(height: 20), + OfferView( + controller: controller, + ), + ], + ), + ), + controller.storyList.isEmpty || + Constant.storyEnable == false ? const SizedBox() - : Padding(padding: const EdgeInsets.symmetric(horizontal: 16), child: Column(children: [const SizedBox(height: 20), StoryView(controller: controller)])), + : Padding( + padding: + const EdgeInsets.symmetric( + horizontal: 16, + ), + child: Column( + children: [ + const SizedBox(height: 20), + StoryView( + controller: controller, + ), + ], + ), + ), Visibility( - visible: Constant.isEnableAdsFeature == true, + visible: + Constant.isEnableAdsFeature == + true, child: - controller.advertisementList.isEmpty + controller + .advertisementList + .isEmpty ? const SizedBox() : Column( children: [ - const SizedBox(height: 20), + const SizedBox( + height: 20, + ), Container( - margin: const EdgeInsets.symmetric(horizontal: 16), - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16), - decoration: BoxDecoration(borderRadius: BorderRadius.circular(20), color: AppThemeData.primary300.withAlpha(40)), + margin: + const EdgeInsets.symmetric( + horizontal: 16, + ), + padding: + const EdgeInsets.symmetric( + horizontal: 16, + vertical: 16, + ), + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular( + 20, + ), + color: AppThemeData + .primary300 + .withAlpha(40), + ), child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment + .start, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ Row( children: [ Expanded( child: Text( - "Highlights for you".tr, - textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + "Highlights for you" + .tr, + textAlign: + TextAlign + .start, + style: TextStyle( + fontFamily: + AppThemeData + .semiBold, + fontSize: + 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), ), InkWell( onTap: () { - Get.to(AllAdvertisementScreen())?.then((value) { - controller.getFavouriteRestaurant(); + Get.to( + AllAdvertisementScreen(), + )?.then(( + value, + ) { + controller + .getFavouriteRestaurant(); }); }, child: Text( - "See all".tr, - textAlign: TextAlign.center, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300), + "See all" + .tr, + textAlign: + TextAlign + .center, + style: TextStyle( + fontFamily: + AppThemeData + .regular, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + ), ), ), ], ), - const SizedBox(height: 16), + const SizedBox( + height: 16, + ), SizedBox( height: 220, child: ListView.builder( - physics: const BouncingScrollPhysics(), - scrollDirection: Axis.horizontal, - itemCount: controller.advertisementList.length >= 10 ? 10 : controller.advertisementList.length, - padding: EdgeInsets.all(0), - itemBuilder: (BuildContext context, int index) { - return AdvertisementHomeCard(controller: controller, model: controller.advertisementList[index]); + physics: + const BouncingScrollPhysics(), + scrollDirection: + Axis.horizontal, + itemCount: + controller.advertisementList.length >= + 10 + ? 10 + : controller + .advertisementList + .length, + padding: + EdgeInsets.all( + 0, + ), + itemBuilder: ( + BuildContext + context, + int index, + ) { + return AdvertisementHomeCard( + controller: + controller, + model: + controller + .advertisementList[index], + ); }, ), ), @@ -337,7 +655,16 @@ class HomeScreenTwo extends StatelessWidget { ], ), ), - controller.allNearestRestaurant.isEmpty ? const SizedBox() : Column(children: [const SizedBox(height: 20), RestaurantView(controller: controller)]), + controller.allNearestRestaurant.isEmpty + ? const SizedBox() + : Column( + children: [ + const SizedBox(height: 20), + RestaurantView( + controller: controller, + ), + ], + ), ], ), ), @@ -345,18 +672,29 @@ class HomeScreenTwo extends StatelessWidget { ], ), ), - floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, + floatingActionButtonLocation: + FloatingActionButtonLocation.centerFloat, floatingActionButton: Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.grey800 : AppThemeData.grey100, borderRadius: const BorderRadius.all(Radius.circular(30))), + decoration: BoxDecoration( + color: isDark ? AppThemeData.grey800 : AppThemeData.grey100, + borderRadius: const BorderRadius.all(Radius.circular(30)), + ), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6), child: Row( mainAxisSize: MainAxisSize.min, children: [ Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, borderRadius: const BorderRadius.all(Radius.circular(30))), + decoration: BoxDecoration( + color: + isDark ? AppThemeData.grey900 : AppThemeData.grey50, + borderRadius: const BorderRadius.all(Radius.circular(30)), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 5, + ), child: Row( children: [ InkWell( @@ -365,12 +703,22 @@ class HomeScreenTwo extends StatelessWidget { }, child: ClipOval( child: Container( - decoration: BoxDecoration(color: controller.isListView.value ? AppThemeData.primary300 : null), + decoration: BoxDecoration( + color: + controller.isListView.value + ? AppThemeData.primary300 + : null, + ), child: Padding( padding: const EdgeInsets.all(8.0), child: SvgPicture.asset( "assets/icons/ic_view_grid_list.svg", - colorFilter: ColorFilter.mode(controller.isListView.value ? AppThemeData.grey50 : AppThemeData.grey500, BlendMode.srcIn), + colorFilter: ColorFilter.mode( + controller.isListView.value + ? AppThemeData.grey50 + : AppThemeData.grey500, + BlendMode.srcIn, + ), ), ), ), @@ -383,12 +731,22 @@ class HomeScreenTwo extends StatelessWidget { }, child: ClipOval( child: Container( - decoration: BoxDecoration(color: controller.isListView.value == false ? AppThemeData.primary300 : null), + decoration: BoxDecoration( + color: + controller.isListView.value == false + ? AppThemeData.primary300 + : null, + ), child: Padding( padding: const EdgeInsets.all(8.0), child: SvgPicture.asset( "assets/icons/ic_map_draw.svg", - colorFilter: ColorFilter.mode(controller.isListView.value == false ? AppThemeData.grey50 : AppThemeData.grey500, BlendMode.srcIn), + colorFilter: ColorFilter.mode( + controller.isListView.value == false + ? AppThemeData.grey50 + : AppThemeData.grey500, + BlendMode.srcIn, + ), ), ), ), @@ -405,10 +763,23 @@ class HomeScreenTwo extends StatelessWidget { }, child: ClipOval( child: Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50), + decoration: BoxDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + ), child: Padding( padding: const EdgeInsets.all(10), - child: SvgPicture.asset("assets/icons/ic_scan_code.svg", colorFilter: ColorFilter.mode(isDark ? AppThemeData.grey400 : AppThemeData.grey500, BlendMode.srcIn)), + child: SvgPicture.asset( + "assets/icons/ic_scan_code.svg", + colorFilter: ColorFilter.mode( + isDark + ? AppThemeData.grey400 + : AppThemeData.grey500, + BlendMode.srcIn, + ), + ), ), ), ), @@ -420,15 +791,30 @@ class HomeScreenTwo extends StatelessWidget { value: controller.selectedOrderTypeValue.value.tr, icon: const Icon(Icons.keyboard_arrow_down), items: - ['Delivery'.tr, 'TakeAway'.tr].map((String value) { + ['Delivery'.tr, 'TakeAway'.tr].map(( + String value, + ) { return DropdownMenuItem( value: value, - child: Text(value.tr, style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900)), + child: Text( + value.tr, + style: TextStyle( + fontFamily: AppThemeData.semiBold, + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), + ), ); }).toList(), onChanged: (value) async { if (cartItem.isEmpty) { - await Preferences.setString(Preferences.foodDeliveryType, value!); + await Preferences.setString( + Preferences.foodDeliveryType, + value!, + ); controller.selectedOrderTypeValue.value = value; controller.getData(); } else { @@ -437,11 +823,16 @@ class HomeScreenTwo extends StatelessWidget { builder: (BuildContext context) { return CustomDialogBox( title: "Alert".tr, - descriptions: "Do you really want to change the delivery option? Your cart will be empty.".tr, + descriptions: + "Do you really want to change the delivery option? Your cart will be empty." + .tr, positiveString: "Ok".tr, negativeString: "Cancel".tr, positiveClick: () async { - await Preferences.setString(Preferences.foodDeliveryType, value!); + await Preferences.setString( + Preferences.foodDeliveryType, + value!, + ); controller.selectedOrderTypeValue.value = value; controller.getData(); DatabaseHelper.instance.deleteAllCartProducts(); @@ -479,7 +870,10 @@ class CategoryView extends StatelessWidget { final themeController = Get.find(); final isDark = themeController.isDark.value; return Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24))), + decoration: ShapeDecoration( + color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)), + ), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 10), child: Column( @@ -493,7 +887,19 @@ class CategoryView extends StatelessWidget { children: [ Row( children: [ - Expanded(child: Text("Our Categories".tr, style: TextStyle(fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 18))), + Expanded( + child: Text( + "Our Categories".tr, + style: TextStyle( + fontFamily: AppThemeData.semiBold, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 18, + ), + ), + ), InkWell( onTap: () { Get.to(const ViewAllCategoryScreen()); @@ -501,15 +907,28 @@ class CategoryView extends StatelessWidget { child: Text( "See all".tr, textAlign: TextAlign.center, - style: TextStyle(fontFamily: AppThemeData.medium, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, fontSize: 14), + style: TextStyle( + fontFamily: AppThemeData.medium, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + fontSize: 14, + ), ), ), ], ), GradientText( 'Best Servings Food'.tr, - style: TextStyle(fontSize: 24, fontFamily: 'Inter Tight', fontWeight: FontWeight.w800), - gradient: LinearGradient(colors: [Color(0xFF3961F1), Color(0xFF11D0EA)]), + style: TextStyle( + fontSize: 24, + fontFamily: 'Inter Tight', + fontWeight: FontWeight.w800, + ), + gradient: LinearGradient( + colors: [Color(0xFF3961F1), Color(0xFF11D0EA)], + ), ), ], ), @@ -517,23 +936,52 @@ class CategoryView extends StatelessWidget { const SizedBox(height: 10), GridView.builder( padding: EdgeInsets.zero, - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4, childAspectRatio: 5 / 6), - itemCount: controller.vendorCategoryModel.length >= 8 ? 8 : controller.vendorCategoryModel.length, + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 4, + childAspectRatio: 5 / 6, + ), + itemCount: + controller.vendorCategoryModel.length >= 8 + ? 8 + : controller.vendorCategoryModel.length, physics: const NeverScrollableScrollPhysics(), shrinkWrap: true, itemBuilder: (context, index) { - VendorCategoryModel vendorCategoryModel = controller.vendorCategoryModel[index]; + VendorCategoryModel vendorCategoryModel = + controller.vendorCategoryModel[index]; return InkWell( onTap: () { - Get.to(const CategoryRestaurantScreen(), arguments: {"vendorCategoryModel": vendorCategoryModel, "dineIn": false}); + Get.to( + const CategoryRestaurantScreen(), + arguments: { + "vendorCategoryModel": vendorCategoryModel, + "dineIn": false, + }, + ); }, child: Column( children: [ - ClipOval(child: SizedBox(width: 60, height: 60, child: NetworkImageWidget(imageUrl: vendorCategoryModel.photo.toString(), fit: BoxFit.cover))), + ClipOval( + child: SizedBox( + width: 60, + height: 60, + child: NetworkImageWidget( + imageUrl: vendorCategoryModel.photo.toString(), + fit: BoxFit.cover, + ), + ), + ), Text( "${vendorCategoryModel.title}", textAlign: TextAlign.center, - style: TextStyle(fontFamily: AppThemeData.medium, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 12), + style: TextStyle( + fontFamily: AppThemeData.medium, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 12, + ), ), ], ), @@ -557,7 +1005,10 @@ class OfferView extends StatelessWidget { final themeController = Get.find(); final isDark = themeController.isDark.value; return Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24))), + decoration: ShapeDecoration( + color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)), + ), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 10), child: Column( @@ -571,26 +1022,55 @@ class OfferView extends StatelessWidget { children: [ Row( children: [ - Expanded(child: Text("Large Discounts".tr, style: TextStyle(fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 18))), + Expanded( + child: Text( + "Large Discounts".tr, + style: TextStyle( + fontFamily: AppThemeData.semiBold, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 18, + ), + ), + ), InkWell( onTap: () { Get.to( const DiscountRestaurantListScreen(), - arguments: {"vendorList": controller.couponRestaurantList, "couponList": controller.couponList, "title": "Discounts Restaurants"}, + arguments: { + "vendorList": controller.couponRestaurantList, + "couponList": controller.couponList, + "title": "Discounts Restaurants", + }, ); }, child: Text( "See all".tr, textAlign: TextAlign.center, - style: TextStyle(fontFamily: AppThemeData.medium, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, fontSize: 14), + style: TextStyle( + fontFamily: AppThemeData.medium, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + fontSize: 14, + ), ), ), ], ), GradientText( 'Save Upto 50% Off'.tr, - style: TextStyle(fontSize: 24, fontFamily: 'Inter Tight', fontWeight: FontWeight.w800), - gradient: LinearGradient(colors: [Color(0xFF39F1C5), Color(0xFF97EA11)]), + style: TextStyle( + fontSize: 24, + fontFamily: 'Inter Tight', + fontWeight: FontWeight.w800, + ), + gradient: LinearGradient( + colors: [Color(0xFF39F1C5), Color(0xFF97EA11)], + ), ), ], ), @@ -603,47 +1083,82 @@ class OfferView extends StatelessWidget { shrinkWrap: true, scrollDirection: Axis.horizontal, physics: const BouncingScrollPhysics(), - itemCount: controller.couponRestaurantList.length >= 15 ? 15 : controller.couponRestaurantList.length, + itemCount: + controller.couponRestaurantList.length >= 15 + ? 15 + : controller.couponRestaurantList.length, itemBuilder: (context, index) { - VendorModel vendorModel = controller.couponRestaurantList[index]; + VendorModel vendorModel = + controller.couponRestaurantList[index]; CouponModel offerModel = controller.couponList[index]; return InkWell( onTap: () { - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": vendorModel}); + Get.to( + const RestaurantDetailsScreen(), + arguments: {"vendorModel": vendorModel}, + ); }, child: Padding( padding: const EdgeInsets.only(right: 10), child: SizedBox( width: Responsive.width(34, context), child: ClipRRect( - borderRadius: const BorderRadius.all(Radius.circular(10)), + borderRadius: const BorderRadius.all( + Radius.circular(10), + ), child: Stack( children: [ - NetworkImageWidget(imageUrl: vendorModel.photo.toString(), fit: BoxFit.cover, height: Responsive.height(100, context), width: Responsive.width(100, context)), + NetworkImageWidget( + imageUrl: vendorModel.photo.toString(), + fit: BoxFit.cover, + height: Responsive.height(100, context), + width: Responsive.width(100, context), + ), Container( decoration: BoxDecoration( - gradient: LinearGradient(begin: const Alignment(-0.00, -1.00), end: const Alignment(0, 1), colors: [Colors.black.withOpacity(0), AppThemeData.grey900]), + gradient: LinearGradient( + begin: const Alignment(-0.00, -1.00), + end: const Alignment(0, 1), + colors: [ + Colors.black.withOpacity(0), + AppThemeData.grey900, + ], + ), ), ), Align( alignment: Alignment.bottomCenter, child: Padding( - padding: const EdgeInsets.symmetric(vertical: 10), + padding: const EdgeInsets.symmetric( + vertical: 10, + ), child: Column( mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, children: [ Text( vendorModel.title.toString(), textAlign: TextAlign.start, maxLines: 1, - style: TextStyle(fontSize: 18, overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.grey50 : AppThemeData.grey50), + style: TextStyle( + fontSize: 18, + overflow: TextOverflow.ellipsis, + fontFamily: AppThemeData.semiBold, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey50, + ), ), const SizedBox(height: 5), RoundedButtonFill( title: "${offerModel.discountType == "Fix Price" ? Constant.currencyModel!.symbol : ""}${offerModel.discount}${offerModel.discountType == "Percentage" ? "% off".tr : "off".tr}", - color: Colors.primaries[Random().nextInt(Colors.primaries.length)], + color: + Colors.primaries[Random().nextInt( + Colors.primaries.length, + )], textColor: AppThemeData.grey50, width: 20, height: 3.5, @@ -694,18 +1209,31 @@ class BannerView extends StatelessWidget { return InkWell( onTap: () async { if (bannerModel.redirect_type == "store") { - ShowToastDialog.showLoader("Please wait...".tr); - VendorModel? vendorModel = await FireStoreUtils.getVendorById(bannerModel.redirect_id.toString()); + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); + VendorModel? vendorModel = await FireStoreUtils.getVendorById( + bannerModel.redirect_id.toString(), + ); ShowToastDialog.closeLoader(); - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": vendorModel}); + Get.to( + const RestaurantDetailsScreen(), + arguments: {"vendorModel": vendorModel}, + ); } else if (bannerModel.redirect_type == "product") { - ShowToastDialog.showLoader("Please wait...".tr); - ProductModel? productModel = await FireStoreUtils.getProductById(bannerModel.redirect_id.toString()); - VendorModel? vendorModel = await FireStoreUtils.getVendorById(productModel!.vendorID.toString()); + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); + ProductModel? productModel = + await FireStoreUtils.getProductById( + bannerModel.redirect_id.toString(), + ); + VendorModel? vendorModel = await FireStoreUtils.getVendorById( + productModel!.vendorID.toString(), + ); ShowToastDialog.closeLoader(); - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": vendorModel}); + Get.to( + const RestaurantDetailsScreen(), + arguments: {"vendorModel": vendorModel}, + ); } else if (bannerModel.redirect_type == "external_link") { final uri = Uri.parse(bannerModel.redirect_id.toString()); if (await canLaunchUrl(uri)) { @@ -717,7 +1245,13 @@ class BannerView extends StatelessWidget { }, child: Padding( padding: const EdgeInsets.only(right: 14), - child: ClipRRect(borderRadius: const BorderRadius.all(Radius.circular(12)), child: NetworkImageWidget(imageUrl: bannerModel.photo.toString(), fit: BoxFit.cover)), + child: ClipRRect( + borderRadius: const BorderRadius.all(Radius.circular(12)), + child: NetworkImageWidget( + imageUrl: bannerModel.photo.toString(), + fit: BoxFit.cover, + ), + ), ), ); }, @@ -737,7 +1271,13 @@ class StoryView extends StatelessWidget { final isDark = themeController.isDark.value; return Container( height: Responsive.height(32, context), - decoration: const BoxDecoration(borderRadius: BorderRadius.all(Radius.circular(20)), image: DecorationImage(image: AssetImage("assets/images/story_bg.png"), fit: BoxFit.cover)), + decoration: const BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(20)), + image: DecorationImage( + image: AssetImage("assets/images/story_bg.png"), + fit: BoxFit.cover, + ), + ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -746,11 +1286,33 @@ class StoryView extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row(children: [Expanded(child: Text("Stories".tr, style: TextStyle(fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.grey50 : AppThemeData.grey50, fontSize: 18)))]), + Row( + children: [ + Expanded( + child: Text( + "Stories".tr, + style: TextStyle( + fontFamily: AppThemeData.semiBold, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey50, + fontSize: 18, + ), + ), + ), + ], + ), GradientText( 'Best Food Stories Ever'.tr, - style: TextStyle(fontSize: 24, fontFamily: 'Inter Tight', fontWeight: FontWeight.w800), - gradient: LinearGradient(colors: [Color(0xFFF1C839), Color(0xFFEA1111)]), + style: TextStyle( + fontSize: 24, + fontFamily: 'Inter Tight', + fontWeight: FontWeight.w800, + ), + gradient: LinearGradient( + colors: [Color(0xFFF1C839), Color(0xFFEA1111)], + ), ), ], ), @@ -768,56 +1330,116 @@ class StoryView extends StatelessWidget { padding: const EdgeInsets.only(right: 10), child: InkWell( onTap: () { - Navigator.of(context).push(MaterialPageRoute(builder: (context) => MoreStories(storyList: controller.storyList, index: index))); + Navigator.of(context).push( + MaterialPageRoute( + builder: + (context) => MoreStories( + storyList: controller.storyList, + index: index, + ), + ), + ); }, child: SizedBox( width: 134, child: ClipRRect( - borderRadius: const BorderRadius.all(Radius.circular(10)), + borderRadius: const BorderRadius.all( + Radius.circular(10), + ), child: Stack( children: [ - NetworkImageWidget(imageUrl: storyModel.videoThumbnail.toString(), fit: BoxFit.cover, height: Responsive.height(100, context), width: Responsive.width(100, context)), + NetworkImageWidget( + imageUrl: storyModel.videoThumbnail.toString(), + fit: BoxFit.cover, + height: Responsive.height(100, context), + width: Responsive.width(100, context), + ), Container(color: Colors.black.withOpacity(0.30)), Padding( - padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 8), + padding: const EdgeInsets.symmetric( + horizontal: 5, + vertical: 8, + ), child: FutureBuilder( - future: FireStoreUtils.getVendorById(storyModel.vendorID.toString()), + future: FireStoreUtils.getVendorById( + storyModel.vendorID.toString(), + ), builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { + if (snapshot.connectionState == + ConnectionState.waiting) { return Constant.loader(); } else { if (snapshot.hasError) { - return Center(child: Text('${"Error".tr}: ${snapshot.error}')); + return Center( + child: Text( + '${"Error".tr}: ${snapshot.error}', + ), + ); } else if (snapshot.data == null) { return const SizedBox(); } else { - VendorModel vendorModel = snapshot.data!; + VendorModel vendorModel = + snapshot.data!; return Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ - ClipOval(child: NetworkImageWidget(imageUrl: vendorModel.photo.toString(), width: 30, height: 30, fit: BoxFit.cover)), + ClipOval( + child: NetworkImageWidget( + imageUrl: + vendorModel.photo + .toString(), + width: 30, + height: 30, + fit: BoxFit.cover, + ), + ), const SizedBox(width: 4), Expanded( child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( - vendorModel.title.toString(), + vendorModel.title + .toString(), textAlign: TextAlign.center, maxLines: 1, - style: const TextStyle(color: Colors.white, fontSize: 12, overflow: TextOverflow.ellipsis, fontWeight: FontWeight.w700), + style: const TextStyle( + color: Colors.white, + fontSize: 12, + overflow: + TextOverflow.ellipsis, + fontWeight: + FontWeight.w700, + ), ), Row( children: [ - SvgPicture.asset("assets/icons/ic_star.svg"), + SvgPicture.asset( + "assets/icons/ic_star.svg", + ), const SizedBox(width: 5), Text( "${Constant.calculateReview(reviewCount: vendorModel.reviewsCount.toString(), reviewSum: vendorModel.reviewsSum!.toStringAsFixed(0))} ${'reviews'.tr}", - textAlign: TextAlign.center, + textAlign: + TextAlign.center, maxLines: 1, - style: const TextStyle(color: AppThemeData.warning300, fontSize: 10, overflow: TextOverflow.ellipsis, fontWeight: FontWeight.w700), + style: const TextStyle( + color: + AppThemeData + .warning300, + fontSize: 10, + overflow: + TextOverflow + .ellipsis, + fontWeight: + FontWeight.w700, + ), ), ], ), @@ -869,15 +1491,38 @@ class RestaurantView extends StatelessWidget { padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4), child: Row( children: [ - Expanded(child: Text("Best Restaurants".tr, style: TextStyle(fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 18))), + Expanded( + child: Text( + "Best Restaurants".tr, + style: TextStyle( + fontFamily: AppThemeData.semiBold, + color: + isDark ? AppThemeData.grey50 : AppThemeData.grey900, + fontSize: 18, + ), + ), + ), InkWell( onTap: () { - Get.to(const RestaurantListScreen(), arguments: {"vendorList": controller.allNearestRestaurant, "title": "Best Restaurants"}); + Get.to( + const RestaurantListScreen(), + arguments: { + "vendorList": controller.allNearestRestaurant, + "title": "Best Restaurants", + }, + ); }, child: Text( "See all".tr, textAlign: TextAlign.center, - style: TextStyle(fontFamily: AppThemeData.medium, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, fontSize: 14), + style: TextStyle( + fontFamily: AppThemeData.medium, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + fontSize: 14, + ), ), ), ], @@ -893,36 +1538,65 @@ class RestaurantView extends StatelessWidget { scrollDirection: Axis.vertical, itemCount: controller.allNearestRestaurant.length, itemBuilder: (BuildContext context, int index) { - VendorModel vendorModel = controller.allNearestRestaurant[index]; + VendorModel vendorModel = + controller.allNearestRestaurant[index]; List tempList = []; List discountAmountTempList = []; for (var element in controller.couponList) { - if (vendorModel.id == element.vendorID && element.expiresAt!.toDate().isAfter(DateTime.now())) { + if (vendorModel.id == element.vendorID && + element.expiresAt!.toDate().isAfter(DateTime.now())) { tempList.add(element); - discountAmountTempList.add(double.parse(element.discount.toString())); + discountAmountTempList.add( + double.parse(element.discount.toString()), + ); } } return InkWell( onTap: () { - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": vendorModel}); + Get.to( + const RestaurantDetailsScreen(), + arguments: {"vendorModel": vendorModel}, + ); }, child: Padding( padding: const EdgeInsets.only(bottom: 20), child: Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + ), + ), child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ ClipRRect( - borderRadius: const BorderRadius.all(Radius.circular(16)), + borderRadius: const BorderRadius.all( + Radius.circular(16), + ), child: Stack( children: [ - NetworkImageWidget(height: Responsive.height(14, context), width: Responsive.width(30, context), imageUrl: vendorModel.photo.toString(), fit: BoxFit.cover), + NetworkImageWidget( + height: Responsive.height(14, context), + width: Responsive.width(30, context), + imageUrl: vendorModel.photo.toString(), + fit: BoxFit.cover, + ), Container( height: Responsive.height(14, context), width: Responsive.width(30, context), decoration: BoxDecoration( - gradient: LinearGradient(begin: const Alignment(-0.00, -1.00), end: const Alignment(0, 1), colors: [Colors.black.withOpacity(0), const Color(0xFF111827)]), + gradient: LinearGradient( + begin: const Alignment(-0.00, -1.00), + end: const Alignment(0, 1), + colors: [ + Colors.black.withOpacity(0), + const Color(0xFF111827), + ], + ), ), ), discountAmountTempList.isEmpty @@ -932,31 +1606,47 @@ class RestaurantView extends StatelessWidget { left: 0, right: 0, child: Padding( - padding: const EdgeInsets.only(bottom: 10), + padding: const EdgeInsets.only( + bottom: 10, + ), child: Column( mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, children: [ Text( "Upto".tr, textAlign: TextAlign.center, maxLines: 1, style: TextStyle( - overflow: TextOverflow.ellipsis, - fontFamily: AppThemeData.regular, + overflow: + TextOverflow.ellipsis, + fontFamily: + AppThemeData.regular, fontWeight: FontWeight.w900, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey50, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey50, ), ), Text( - discountAmountTempList.reduce(min).toString() + "% OFF".tr, + discountAmountTempList + .reduce(min) + .toString() + + "% OFF".tr, textAlign: TextAlign.center, maxLines: 1, style: TextStyle( fontSize: 18, - overflow: TextOverflow.ellipsis, - fontFamily: AppThemeData.semiBold, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey50, + overflow: + TextOverflow.ellipsis, + fontFamily: + AppThemeData.semiBold, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey50, ), ), ], @@ -976,7 +1666,15 @@ class RestaurantView extends StatelessWidget { vendorModel.title.toString(), textAlign: TextAlign.start, maxLines: 1, - style: TextStyle(fontSize: 18, overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontSize: 18, + overflow: TextOverflow.ellipsis, + fontFamily: AppThemeData.semiBold, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), Text( vendorModel.location.toString(), @@ -986,7 +1684,10 @@ class RestaurantView extends StatelessWidget { overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500, - color: isDark ? AppThemeData.grey400 : AppThemeData.grey400, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey400, ), ), const SizedBox(height: 5), @@ -995,18 +1696,31 @@ class RestaurantView extends StatelessWidget { child: Row( children: [ Visibility( - visible: (vendorModel.isSelfDelivery == true && Constant.isSelfDeliveryFeature == true), + visible: + (vendorModel.isSelfDelivery == + true && + Constant.isSelfDeliveryFeature == + true), child: Row( children: [ - SvgPicture.asset("assets/icons/ic_free_delivery.svg", width: 18), + SvgPicture.asset( + "assets/icons/ic_free_delivery.svg", + width: 18, + ), const SizedBox(width: 5), Text( "Free Delivery".tr, style: TextStyle( - overflow: TextOverflow.ellipsis, - fontFamily: AppThemeData.medium, + overflow: + TextOverflow.ellipsis, + fontFamily: + AppThemeData.medium, fontWeight: FontWeight.w500, - color: isDark ? AppThemeData.grey400 : AppThemeData.grey400, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData + .grey400, ), ), const SizedBox(width: 10), @@ -1016,8 +1730,18 @@ class RestaurantView extends StatelessWidget { Row( children: [ Padding( - padding: const EdgeInsets.symmetric(horizontal: 10), - child: SvgPicture.asset("assets/icons/ic_star.svg", width: 18, colorFilter: ColorFilter.mode(AppThemeData.primary300, BlendMode.srcIn)), + padding: + const EdgeInsets.symmetric( + horizontal: 10, + ), + child: SvgPicture.asset( + "assets/icons/ic_star.svg", + width: 18, + colorFilter: ColorFilter.mode( + AppThemeData.primary300, + BlendMode.srcIn, + ), + ), ), Text( "${Constant.calculateReview(reviewCount: vendorModel.reviewsCount.toString(), reviewSum: vendorModel.reviewsSum.toString())} (${vendorModel.reviewsCount!.toStringAsFixed(0)})", @@ -1027,7 +1751,10 @@ class RestaurantView extends StatelessWidget { overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500, - color: isDark ? AppThemeData.grey400 : AppThemeData.grey400, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey400, ), ), ], @@ -1035,8 +1762,18 @@ class RestaurantView extends StatelessWidget { Row( children: [ Padding( - padding: const EdgeInsets.symmetric(horizontal: 10), - child: Icon(Icons.circle, size: 5, color: isDark ? AppThemeData.grey400 : AppThemeData.grey500), + padding: + const EdgeInsets.symmetric( + horizontal: 10, + ), + child: Icon( + Icons.circle, + size: 5, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey500, + ), ), Text( "${Constant.getDistance(lat1: vendorModel.latitude.toString(), lng1: vendorModel.longitude.toString(), lat2: Constant.selectedLocation.location!.latitude.toString(), lng2: Constant.selectedLocation.location!.longitude.toString())} ${Constant.distanceType}", @@ -1046,7 +1783,10 @@ class RestaurantView extends StatelessWidget { overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500, - color: isDark ? AppThemeData.grey400 : AppThemeData.grey400, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey400, ), ), ], diff --git a/lib/screen_ui/multi_vendor_service/home_screen/restaurant_list_screen.dart b/lib/screen_ui/multi_vendor_service/home_screen/restaurant_list_screen.dart index 7e5c18f..706f226 100644 --- a/lib/screen_ui/multi_vendor_service/home_screen/restaurant_list_screen.dart +++ b/lib/screen_ui/multi_vendor_service/home_screen/restaurant_list_screen.dart @@ -4,11 +4,11 @@ import 'package:customer/models/favourite_model.dart'; import 'package:customer/models/vendor_model.dart'; import 'package:customer/themes/app_them_data.dart'; import 'package:customer/themes/responsive.dart'; + import '../../../controllers/theme_controller.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:get/get.dart'; - import '../../../service/fire_store_utils.dart'; import '../../../widget/restaurant_image_view.dart'; import '../restaurant_details_screen/restaurant_details_screen.dart'; @@ -25,13 +25,18 @@ class RestaurantListScreen extends StatelessWidget { builder: (controller) { return Scaffold( appBar: AppBar( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, centerTitle: false, titleSpacing: 0, title: Text( controller.title.value, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 16, + color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + ), ), ), body: @@ -43,35 +48,64 @@ class RestaurantListScreen extends StatelessWidget { shrinkWrap: true, itemCount: controller.vendorSearchList.length, itemBuilder: (context, index) { - VendorModel vendorModel = controller.vendorSearchList[index]; + VendorModel vendorModel = + controller.vendorSearchList[index]; return InkWell( onTap: () { - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": vendorModel})?.then((v) { + Get.to( + const RestaurantDetailsScreen(), + arguments: {"vendorModel": vendorModel}, + )?.then((v) { controller.getFavouriteRestaurant(); }); }, child: Padding( padding: const EdgeInsets.only(bottom: 20), child: Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + ), + ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Stack( children: [ ClipRRect( - borderRadius: const BorderRadius.only(topLeft: Radius.circular(16), topRight: Radius.circular(16)), + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(16), + topRight: Radius.circular(16), + ), child: Stack( children: [ - RestaurantImageView(vendorModel: vendorModel), + RestaurantImageView( + vendorModel: vendorModel, + ), Container( - height: Responsive.height(20, context), - width: Responsive.width(100, context), + height: Responsive.height( + 20, + context, + ), + width: Responsive.width( + 100, + context, + ), decoration: BoxDecoration( gradient: LinearGradient( - begin: const Alignment(-0.00, -1.00), + begin: const Alignment( + -0.00, + -1.00, + ), end: const Alignment(0, 1), - colors: [Colors.black.withOpacity(0), const Color(0xFF111827)], + colors: [ + Colors.black.withOpacity(0), + const Color(0xFF111827), + ], ), ), ), @@ -80,21 +114,60 @@ class RestaurantListScreen extends StatelessWidget { top: 10, child: InkWell( onTap: () async { - if (controller.favouriteList.where((p0) => p0.restaurantId == vendorModel.id).isNotEmpty) { - FavouriteModel favouriteModel = FavouriteModel(restaurantId: vendorModel.id, userId: FireStoreUtils.getCurrentUid()); - controller.favouriteList.removeWhere((item) => item.restaurantId == vendorModel.id); - await FireStoreUtils.removeFavouriteRestaurant(favouriteModel); + if (controller.favouriteList + .where( + (p0) => + p0.restaurantId == + vendorModel.id, + ) + .isNotEmpty) { + FavouriteModel + favouriteModel = FavouriteModel( + restaurantId: + vendorModel.id, + userId: + FireStoreUtils.getCurrentUid(), + ); + controller.favouriteList + .removeWhere( + (item) => + item.restaurantId == + vendorModel.id, + ); + await FireStoreUtils.removeFavouriteRestaurant( + favouriteModel, + ); } else { - FavouriteModel favouriteModel = FavouriteModel(restaurantId: vendorModel.id, userId: FireStoreUtils.getCurrentUid()); - controller.favouriteList.add(favouriteModel); - await FireStoreUtils.setFavouriteRestaurant(favouriteModel); + FavouriteModel + favouriteModel = FavouriteModel( + restaurantId: + vendorModel.id, + userId: + FireStoreUtils.getCurrentUid(), + ); + controller.favouriteList + .add(favouriteModel); + await FireStoreUtils.setFavouriteRestaurant( + favouriteModel, + ); } }, child: Obx( () => - controller.favouriteList.where((p0) => p0.restaurantId == vendorModel.id).isNotEmpty - ? SvgPicture.asset("assets/icons/ic_like_fill.svg") - : SvgPicture.asset("assets/icons/ic_like.svg"), + controller.favouriteList + .where( + (p0) => + p0.restaurantId == + vendorModel + .id, + ) + .isNotEmpty + ? SvgPicture.asset( + "assets/icons/ic_like_fill.svg", + ) + : SvgPicture.asset( + "assets/icons/ic_like.svg", + ), ), ), ), @@ -102,28 +175,60 @@ class RestaurantListScreen extends StatelessWidget { ), ), Transform.translate( - offset: Offset(Responsive.width(-3, context), Responsive.height(17.5, context)), + offset: Offset( + Responsive.width(-3, context), + Responsive.height(17.5, context), + ), child: Row( - mainAxisAlignment: MainAxisAlignment.end, - crossAxisAlignment: CrossAxisAlignment.end, + mainAxisAlignment: + MainAxisAlignment.end, + crossAxisAlignment: + CrossAxisAlignment.end, children: [ Visibility( - visible: (vendorModel.isSelfDelivery == true && Constant.isSelfDeliveryFeature == true), + visible: + (vendorModel.isSelfDelivery == + true && + Constant.isSelfDeliveryFeature == + true), child: Row( children: [ Container( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 7), + padding: + const EdgeInsets.symmetric( + horizontal: 10, + vertical: 7, + ), decoration: BoxDecoration( - color: AppThemeData.success300, - borderRadius: BorderRadius.circular(120), // Optional + color: + AppThemeData + .success300, + borderRadius: + BorderRadius.circular( + 120, + ), // Optional ), child: Row( children: [ - SvgPicture.asset("assets/icons/ic_free_delivery.svg"), - const SizedBox(width: 5), + SvgPicture.asset( + "assets/icons/ic_free_delivery.svg", + ), + const SizedBox( + width: 5, + ), Text( "Free Delivery".tr, - style: TextStyle(fontSize: 14, color: AppThemeData.carRent600, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600), + style: TextStyle( + fontSize: 14, + color: + AppThemeData + .carRent600, + fontFamily: + AppThemeData + .semiBold, + fontWeight: + FontWeight.w600, + ), ), ], ), @@ -133,22 +238,51 @@ class RestaurantListScreen extends StatelessWidget { ), ), Container( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 7), + padding: + const EdgeInsets.symmetric( + horizontal: 10, + vertical: 7, + ), decoration: ShapeDecoration( - color: isDark ? AppThemeData.primary600 : AppThemeData.primary50, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120)), + color: + isDark + ? AppThemeData + .primary600 + : AppThemeData + .primary50, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 120, + ), + ), ), child: Row( children: [ - SvgPicture.asset("assets/icons/ic_star.svg", colorFilter: ColorFilter.mode(AppThemeData.primary300, BlendMode.srcIn)), + SvgPicture.asset( + "assets/icons/ic_star.svg", + colorFilter: + ColorFilter.mode( + AppThemeData + .primary300, + BlendMode.srcIn, + ), + ), const SizedBox(width: 5), Text( "${Constant.calculateReview(reviewCount: vendorModel.reviewsCount!.toStringAsFixed(0), reviewSum: vendorModel.reviewsSum.toString())} (${vendorModel.reviewsCount!.toStringAsFixed(0)})", style: TextStyle( fontSize: 14, - color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + color: + isDark + ? AppThemeData + .primary300 + : AppThemeData + .primary300, + fontFamily: + AppThemeData.semiBold, + fontWeight: + FontWeight.w600, ), ), ], @@ -156,22 +290,51 @@ class RestaurantListScreen extends StatelessWidget { ), const SizedBox(width: 6), Container( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 7), + padding: + const EdgeInsets.symmetric( + horizontal: 10, + vertical: 7, + ), decoration: ShapeDecoration( - color: isDark ? AppThemeData.ecommerce600 : AppThemeData.ecommerce50, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120)), + color: + isDark + ? AppThemeData + .ecommerce600 + : AppThemeData + .ecommerce50, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 120, + ), + ), ), child: Row( children: [ - SvgPicture.asset("assets/icons/ic_map_distance.svg", colorFilter: ColorFilter.mode(AppThemeData.ecommerce300, BlendMode.srcIn)), + SvgPicture.asset( + "assets/icons/ic_map_distance.svg", + colorFilter: + ColorFilter.mode( + AppThemeData + .ecommerce300, + BlendMode.srcIn, + ), + ), const SizedBox(width: 5), Text( "${Constant.getDistance(lat1: vendorModel.latitude.toString(), lng1: vendorModel.longitude.toString(), lat2: Constant.selectedLocation.location!.latitude.toString(), lng2: Constant.selectedLocation.location!.longitude.toString())} ${Constant.distanceType}", style: TextStyle( fontSize: 14, - color: isDark ? AppThemeData.ecommerce300 : AppThemeData.ecommerce300, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + color: + isDark + ? AppThemeData + .ecommerce300 + : AppThemeData + .ecommerce300, + fontFamily: + AppThemeData.semiBold, + fontWeight: + FontWeight.w600, ), ), ], @@ -184,9 +347,12 @@ class RestaurantListScreen extends StatelessWidget { ), const SizedBox(height: 15), Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), + padding: const EdgeInsets.symmetric( + horizontal: 16, + ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( vendorModel.title.toString(), @@ -196,7 +362,10 @@ class RestaurantListScreen extends StatelessWidget { fontSize: 18, overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.semiBold, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, ), ), Text( @@ -207,7 +376,10 @@ class RestaurantListScreen extends StatelessWidget { overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500, - color: isDark ? AppThemeData.grey400 : AppThemeData.grey400, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey400, ), ), ], diff --git a/lib/screen_ui/multi_vendor_service/home_screen/story_view.dart b/lib/screen_ui/multi_vendor_service/home_screen/story_view.dart index 3b9d6b2..8374167 100644 --- a/lib/screen_ui/multi_vendor_service/home_screen/story_view.dart +++ b/lib/screen_ui/multi_vendor_service/home_screen/story_view.dart @@ -5,6 +5,7 @@ import 'package:customer/themes/app_them_data.dart'; import 'package:customer/utils/network_image_widget.dart'; import 'package:customer/widget/story_view/controller/story_controller.dart'; import 'package:customer/widget/story_view/utils.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:get/get.dart'; @@ -70,9 +71,15 @@ class MoreStoriesState extends State { StoryView( key: ValueKey(widget.index), storyItems: - List.generate(widget.storyList[widget.index].videoUrl.length, (i) { - return StoryItem.pageVideo(widget.storyList[widget.index].videoUrl[i], controller: storyController); - }).toList(), + List.generate( + widget.storyList[widget.index].videoUrl.length, + (i) { + return StoryItem.pageVideo( + widget.storyList[widget.index].videoUrl[i], + controller: storyController, + ); + }, + ).toList(), onComplete: () { debugPrint("--------->"); debugPrint(widget.storyList.length.toString()); @@ -95,15 +102,23 @@ class MoreStoriesState extends State { }, ), Padding( - padding: EdgeInsets.only(top: MediaQuery.of(context).viewPadding.top + 30, left: 16, right: 16), + padding: EdgeInsets.only( + top: MediaQuery.of(context).viewPadding.top + 30, + left: 16, + right: 16, + ), child: FutureBuilder( - future: FireStoreUtils.getVendorById(widget.storyList[widget.index].vendorID.toString()), + future: FireStoreUtils.getVendorById( + widget.storyList[widget.index].vendorID.toString(), + ), builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return SizedBox(); } else { if (snapshot.hasError) { - return Center(child: Text('${"Error".tr}: ${snapshot.error}')); + return Center( + child: Text('${"Error".tr}: ${snapshot.error}'), + ); return Center(child: Text('Error: ${snapshot.error}')); } else if (snapshot.data == null) { return const SizedBox(); @@ -111,13 +126,23 @@ class MoreStoriesState extends State { VendorModel vendorModel = snapshot.data!; return InkWell( onTap: () { - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": vendorModel}); + Get.to( + const RestaurantDetailsScreen(), + arguments: {"vendorModel": vendorModel}, + ); }, child: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - ClipOval(child: NetworkImageWidget(imageUrl: vendorModel.photo.toString(), width: 50, height: 50, fit: BoxFit.cover)), + ClipOval( + child: NetworkImageWidget( + imageUrl: vendorModel.photo.toString(), + width: 50, + height: 50, + fit: BoxFit.cover, + ), + ), const SizedBox(width: 10), Expanded( child: Column( @@ -128,17 +153,29 @@ class MoreStoriesState extends State { vendorModel.title.toString(), textAlign: TextAlign.center, maxLines: 1, - style: const TextStyle(color: Colors.white, fontSize: 16, overflow: TextOverflow.ellipsis, fontWeight: FontWeight.w700), + style: const TextStyle( + color: Colors.white, + fontSize: 16, + overflow: TextOverflow.ellipsis, + fontWeight: FontWeight.w700, + ), ), Row( children: [ - SvgPicture.asset("assets/icons/ic_star.svg"), + SvgPicture.asset( + "assets/icons/ic_star.svg", + ), const SizedBox(width: 5), Text( "${Constant.calculateReview(reviewCount: vendorModel.reviewsCount.toString(), reviewSum: vendorModel.reviewsSum.toString())} ${'reviews'.tr}", textAlign: TextAlign.center, maxLines: 1, - style: const TextStyle(color: AppThemeData.warning300, fontSize: 12, overflow: TextOverflow.ellipsis, fontWeight: FontWeight.w700), + style: const TextStyle( + color: AppThemeData.warning300, + fontSize: 12, + overflow: TextOverflow.ellipsis, + fontWeight: FontWeight.w700, + ), ), ], ), @@ -151,8 +188,17 @@ class MoreStoriesState extends State { }, child: Container( padding: const EdgeInsets.all(10.0), - decoration: BoxDecoration(borderRadius: BorderRadius.circular(30), color: Colors.grey), - child: SvgPicture.asset("assets/icons/ic_close.svg", colorFilter: ColorFilter.mode(AppThemeData.grey800, BlendMode.srcIn)), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(30), + color: Colors.grey, + ), + child: SvgPicture.asset( + "assets/icons/ic_close.svg", + colorFilter: ColorFilter.mode( + AppThemeData.grey800, + BlendMode.srcIn, + ), + ), ), ), ], diff --git a/lib/screen_ui/multi_vendor_service/home_screen/view_all_category_screen.dart b/lib/screen_ui/multi_vendor_service/home_screen/view_all_category_screen.dart index 49cc84a..f0ddbab 100644 --- a/lib/screen_ui/multi_vendor_service/home_screen/view_all_category_screen.dart +++ b/lib/screen_ui/multi_vendor_service/home_screen/view_all_category_screen.dart @@ -3,9 +3,9 @@ import 'package:customer/controllers/view_all_category_controller.dart'; import 'package:customer/models/vendor_category_model.dart'; import 'package:customer/themes/app_them_data.dart'; import 'package:customer/utils/network_image_widget.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; - import '../../../controllers/theme_controller.dart'; import 'category_restaurant_screen.dart'; @@ -21,10 +21,19 @@ class ViewAllCategoryScreen extends StatelessWidget { builder: (controller) { return Scaffold( appBar: AppBar( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, centerTitle: false, titleSpacing: 0, - title: Text("Categories".tr, style: TextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500)), + title: Text( + "Categories".tr, + style: TextStyle( + fontSize: 16, + color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + fontFamily: AppThemeData.medium, + fontWeight: FontWeight.w500, + ), + ), ), body: controller.isLoading.value @@ -33,38 +42,84 @@ class ViewAllCategoryScreen extends StatelessWidget { padding: const EdgeInsets.symmetric(horizontal: 16), child: GridView.builder( padding: EdgeInsets.zero, - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4, childAspectRatio: 3.5 / 6, crossAxisSpacing: 6), + gridDelegate: + const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 4, + childAspectRatio: 3.5 / 6, + crossAxisSpacing: 6, + ), itemCount: controller.vendorCategoryModel.length, physics: const NeverScrollableScrollPhysics(), shrinkWrap: true, itemBuilder: (context, index) { - VendorCategoryModel vendorCategoryModel = controller.vendorCategoryModel[index]; + VendorCategoryModel vendorCategoryModel = + controller.vendorCategoryModel[index]; return InkWell( onTap: () { - Get.to(const CategoryRestaurantScreen(), arguments: {"vendorCategoryModel": vendorCategoryModel, "dineIn": false}); + Get.to( + const CategoryRestaurantScreen(), + arguments: { + "vendorCategoryModel": vendorCategoryModel, + "dineIn": false, + }, + ); }, child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 6), + padding: const EdgeInsets.symmetric( + horizontal: 4, + vertical: 6, + ), child: Container( decoration: ShapeDecoration( - color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, shape: RoundedRectangleBorder( - side: BorderSide(width: 1, strokeAlign: BorderSide.strokeAlignOutside, color: isDark ? AppThemeData.grey800 : AppThemeData.grey100), + side: BorderSide( + width: 1, + strokeAlign: BorderSide.strokeAlignOutside, + color: + isDark + ? AppThemeData.grey800 + : AppThemeData.grey100, + ), borderRadius: BorderRadius.circular(100), ), ), child: Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.center, children: [ - SizedBox(width: 60, height: 60, child: ClipOval(child: NetworkImageWidget(imageUrl: vendorCategoryModel.photo.toString(), fit: BoxFit.cover))), + SizedBox( + width: 60, + height: 60, + child: ClipOval( + child: NetworkImageWidget( + imageUrl: + vendorCategoryModel.photo + .toString(), + fit: BoxFit.cover, + ), + ), + ), Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 10, + ), child: Text( '${vendorCategoryModel.title}', textAlign: TextAlign.center, maxLines: 2, - style: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 12), + style: AppThemeData.mediumTextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 12, + ), ), ), ], diff --git a/lib/screen_ui/multi_vendor_service/order_list_screen/live_tracking_screen.dart b/lib/screen_ui/multi_vendor_service/order_list_screen/live_tracking_screen.dart index 0e2a4a8..8ea6cf4 100644 --- a/lib/screen_ui/multi_vendor_service/order_list_screen/live_tracking_screen.dart +++ b/lib/screen_ui/multi_vendor_service/order_list_screen/live_tracking_screen.dart @@ -1,6 +1,7 @@ import 'package:customer/constant/constant.dart'; import 'package:customer/controllers/live_tracking_controller.dart'; import 'package:customer/themes/app_them_data.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart' as flutterMap; import 'package:get/get.dart'; @@ -23,17 +24,44 @@ class LiveTrackingScreen extends StatelessWidget { } return Scaffold( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, - appBar: AppBar(backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, title: Text("Live Tracking".tr), centerTitle: false), + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + appBar: AppBar( + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + title: Text("Live Tracking".tr), + centerTitle: false, + ), body: Constant.selectedMapType == 'osm' ? flutterMap.FlutterMap( mapController: controller.osmMapController, - options: flutterMap.MapOptions(initialCenter: controller.driverCurrent.value, initialZoom: 14), + options: flutterMap.MapOptions( + initialCenter: controller.driverCurrent.value, + initialZoom: 14, + ), children: [ - flutterMap.TileLayer(urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', userAgentPackageName: 'com.emart.customer'), - if (controller.routePoints.isNotEmpty) flutterMap.PolylineLayer(polylines: [flutterMap.Polyline(points: controller.routePoints, strokeWidth: 5.0, color: Colors.blue)]), - flutterMap.MarkerLayer(markers: controller.orderModel.value.id == null ? [] : controller.osmMarkers), + flutterMap.TileLayer( + urlTemplate: + 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', + userAgentPackageName: 'felix.fondex.uz', + ), + if (controller.routePoints.isNotEmpty) + flutterMap.PolylineLayer( + polylines: [ + flutterMap.Polyline( + points: controller.routePoints, + strokeWidth: 5.0, + color: Colors.blue, + ), + ], + ), + flutterMap.MarkerLayer( + markers: + controller.orderModel.value.id == null + ? [] + : controller.osmMarkers, + ), ], ) : gmap.GoogleMap( @@ -42,11 +70,18 @@ class LiveTrackingScreen extends StatelessWidget { }, myLocationEnabled: true, zoomControlsEnabled: false, - polylines: Set.of(controller.polyLines.values), + polylines: Set.of( + controller.polyLines.values, + ), markers: Set.of(controller.markers.values), initialCameraPosition: gmap.CameraPosition( zoom: 14, - target: gmap.LatLng(controller.driverUserModel.value.location?.latitude ?? 0.0, controller.driverUserModel.value.location?.longitude ?? 0.0), + target: gmap.LatLng( + controller.driverUserModel.value.location?.latitude ?? + 0.0, + controller.driverUserModel.value.location?.longitude ?? + 0.0, + ), ), ), ); diff --git a/lib/screen_ui/multi_vendor_service/order_list_screen/order_details_screen.dart b/lib/screen_ui/multi_vendor_service/order_list_screen/order_details_screen.dart index 0434d25..10ab8e3 100644 --- a/lib/screen_ui/multi_vendor_service/order_list_screen/order_details_screen.dart +++ b/lib/screen_ui/multi_vendor_service/order_list_screen/order_details_screen.dart @@ -1,3 +1,4 @@ +import 'package:customer/constant/const_texts.dart'; import 'package:customer/constant/constant.dart'; import 'package:customer/controllers/order_details_controller.dart'; import 'package:customer/models/cart_product_model.dart'; @@ -8,6 +9,7 @@ import 'package:customer/themes/app_them_data.dart'; import 'package:customer/themes/responsive.dart'; import 'package:customer/themes/round_button_fill.dart'; import 'package:customer/utils/network_image_widget.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:get/get.dart'; @@ -32,12 +34,22 @@ class OrderDetailsScreen extends StatelessWidget { init: OrderDetailsController(), builder: (controller) { return Scaffold( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, appBar: AppBar( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, centerTitle: false, titleSpacing: 0, - title: Text("Order Details".tr, textAlign: TextAlign.start, style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900)), + title: Text( + "Order Details".tr, + textAlign: TextAlign.start, + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 16, + color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + ), + ), ), body: controller.isLoading.value @@ -56,19 +68,38 @@ class OrderDetailsScreen extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "${'Order'.tr} ${Constant.orderId(orderId: controller.orderModel.value.id.toString())}".tr, + "${'Order'.tr} ${Constant.orderId(orderId: controller.orderModel.value.id.toString())}" + .tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 18, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + fontSize: 18, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), ], ), ), RoundedButtonFill( - title: controller.orderModel.value.status.toString().tr, - color: Constant.statusColor(status: controller.orderModel.value.status.toString()), + title: + controller.orderModel.value.status + .toString() + .tr, + color: Constant.statusColor( + status: + controller.orderModel.value.status + .toString(), + ), width: 32, height: 4.5, - textColor: Constant.statusText(status: controller.orderModel.value.status.toString()), + textColor: Constant.statusText( + status: + controller.orderModel.value.status + .toString(), + ), onPress: () async {}, ), ], @@ -76,73 +107,177 @@ class OrderDetailsScreen extends StatelessWidget { const SizedBox(height: 14), controller.orderModel.value.takeAway == true ? Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: Row( children: [ Expanded( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( "${controller.orderModel.value.vendor!.title}", textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300), + style: TextStyle( + fontFamily: + AppThemeData.semiBold, + fontSize: 16, + color: + isDark + ? AppThemeData + .primary300 + : AppThemeData + .primary300, + ), ), Text( "${controller.orderModel.value.vendor!.location}", textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 14, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600), + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 14, + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + ), ), ], ), ), - controller.orderModel.value.status == Constant.orderPlaced || - controller.orderModel.value.status == Constant.orderRejected || - controller.orderModel.value.status == Constant.orderCompleted + controller.orderModel.value.status == + Constant.orderPlaced || + controller + .orderModel + .value + .status == + Constant.orderRejected || + controller + .orderModel + .value + .status == + Constant.orderCompleted ? const SizedBox() : InkWell( onTap: () { - Constant.makePhoneCall(controller.orderModel.value.vendor!.phonenumber.toString()); + Constant.makePhoneCall( + controller + .orderModel + .value + .vendor! + .phonenumber + .toString(), + ); }, child: Container( width: 42, height: 42, decoration: ShapeDecoration( shape: RoundedRectangleBorder( - side: BorderSide(width: 1, color: isDark ? AppThemeData.grey700 : AppThemeData.grey200), - borderRadius: BorderRadius.circular(120), + side: BorderSide( + width: 1, + color: + isDark + ? AppThemeData + .grey700 + : AppThemeData + .grey200, + ), + borderRadius: + BorderRadius.circular( + 120, + ), + ), + ), + child: Padding( + padding: const EdgeInsets.all( + 8.0, + ), + child: SvgPicture.asset( + "assets/icons/ic_phone_call.svg", ), ), - child: Padding(padding: const EdgeInsets.all(8.0), child: SvgPicture.asset("assets/icons/ic_phone_call.svg")), ), ), const SizedBox(width: 10), - controller.orderModel.value.status == Constant.orderPlaced || - controller.orderModel.value.status == Constant.orderRejected || - controller.orderModel.value.status == Constant.orderCompleted + controller.orderModel.value.status == + Constant.orderPlaced || + controller + .orderModel + .value + .status == + Constant.orderRejected || + controller + .orderModel + .value + .status == + Constant.orderCompleted ? const SizedBox() : InkWell( onTap: () async { - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader( + ConstTexts.pleaseWait.tr, + ); - UserModel? customer = await FireStoreUtils.getUserProfile(controller.orderModel.value.authorID.toString()); - UserModel? restaurantUser = await FireStoreUtils.getUserProfile(controller.orderModel.value.vendor!.author.toString()); - VendorModel? vendorModel = await FireStoreUtils.getVendorById(restaurantUser!.vendorID.toString()); + UserModel? customer = + await FireStoreUtils.getUserProfile( + controller + .orderModel + .value + .authorID + .toString(), + ); + UserModel? restaurantUser = + await FireStoreUtils.getUserProfile( + controller + .orderModel + .value + .vendor! + .author + .toString(), + ); + VendorModel? vendorModel = + await FireStoreUtils.getVendorById( + restaurantUser!.vendorID + .toString(), + ); ShowToastDialog.closeLoader(); Get.to( const ChatScreen(), arguments: { - "customerName": customer!.fullName(), - "restaurantName": vendorModel!.title, - "orderId": controller.orderModel.value.id, - "restaurantId": restaurantUser.id, + "customerName": + customer!.fullName(), + "restaurantName": + vendorModel!.title, + "orderId": + controller + .orderModel + .value + .id, + "restaurantId": + restaurantUser.id, "customerId": customer.id, - "customerProfileImage": customer.profilePictureURL, - "restaurantProfileImage": vendorModel.photo, - "token": restaurantUser.fcmToken, + "customerProfileImage": + customer + .profilePictureURL, + "restaurantProfileImage": + vendorModel.photo, + "token": + restaurantUser.fcmToken, "chatType": "restaurant", }, ); @@ -152,11 +287,29 @@ class OrderDetailsScreen extends StatelessWidget { height: 42, decoration: ShapeDecoration( shape: RoundedRectangleBorder( - side: BorderSide(width: 1, color: isDark ? AppThemeData.grey700 : AppThemeData.grey200), - borderRadius: BorderRadius.circular(120), + side: BorderSide( + width: 1, + color: + isDark + ? AppThemeData + .grey700 + : AppThemeData + .grey200, + ), + borderRadius: + BorderRadius.circular( + 120, + ), + ), + ), + child: Padding( + padding: const EdgeInsets.all( + 8.0, + ), + child: SvgPicture.asset( + "assets/icons/ic_wechat.svg", ), ), - child: Padding(padding: const EdgeInsets.all(8.0), child: SvgPicture.asset("assets/icons/ic_wechat.svg")), ), ), ], @@ -164,15 +317,26 @@ class OrderDetailsScreen extends StatelessWidget { ), ) : Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), + padding: const EdgeInsets.symmetric( + horizontal: 16, + ), child: Column( children: [ Timeline.tileBuilder( shrinkWrap: true, padding: EdgeInsets.zero, - physics: const NeverScrollableScrollPhysics(), + physics: + const NeverScrollableScrollPhysics(), theme: TimelineThemeData( nodePosition: 0, // indicatorPosition: 0, @@ -180,81 +344,219 @@ class OrderDetailsScreen extends StatelessWidget { builder: TimelineTileBuilder.connected( contentsAlign: ContentsAlign.basic, indicatorBuilder: (context, index) { - return SvgPicture.asset("assets/icons/ic_location.svg"); + return SvgPicture.asset( + "assets/icons/ic_location.svg", + ); }, - connectorBuilder: (context, index, connectorType) { - return const DashedLineConnector(color: AppThemeData.grey300, gap: 3); + connectorBuilder: ( + context, + index, + connectorType, + ) { + return const DashedLineConnector( + color: AppThemeData.grey300, + gap: 3, + ); }, contentsBuilder: (context, index) { return Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10), + padding: + const EdgeInsets.symmetric( + horizontal: 10, + vertical: 10, + ), child: index == 0 ? Row( children: [ Expanded( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ Text( "${controller.orderModel.value.vendor!.title}", - textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300), + textAlign: + TextAlign + .start, + style: TextStyle( + fontFamily: + AppThemeData + .semiBold, + fontSize: + 16, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + ), ), Text( "${controller.orderModel.value.vendor!.location}", - textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 14, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600), + textAlign: + TextAlign + .start, + style: TextStyle( + fontFamily: + AppThemeData + .medium, + fontSize: + 14, + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + ), ), ], ), ), - controller.orderModel.value.status == Constant.orderPlaced || - controller.orderModel.value.status == Constant.orderRejected || - controller.orderModel.value.status == Constant.orderCompleted + controller + .orderModel + .value + .status == + Constant + .orderPlaced || + controller + .orderModel + .value + .status == + Constant + .orderRejected || + controller + .orderModel + .value + .status == + Constant + .orderCompleted ? const SizedBox() : InkWell( onTap: () { - Constant.makePhoneCall(controller.orderModel.value.vendor!.phonenumber.toString()); + Constant.makePhoneCall( + controller + .orderModel + .value + .vendor! + .phonenumber + .toString(), + ); }, child: Container( width: 42, height: 42, decoration: ShapeDecoration( shape: RoundedRectangleBorder( - side: BorderSide(width: 1, color: isDark ? AppThemeData.grey700 : AppThemeData.grey200), - borderRadius: BorderRadius.circular(120), + side: BorderSide( + width: + 1, + color: + isDark + ? AppThemeData.grey700 + : AppThemeData.grey200, + ), + borderRadius: + BorderRadius.circular( + 120, + ), + ), + ), + child: Padding( + padding: + const EdgeInsets.all( + 8.0, + ), + child: SvgPicture.asset( + "assets/icons/ic_phone_call.svg", ), ), - child: Padding(padding: const EdgeInsets.all(8.0), child: SvgPicture.asset("assets/icons/ic_phone_call.svg")), ), ), - const SizedBox(width: 10), - controller.orderModel.value.status == Constant.orderPlaced || - controller.orderModel.value.status == Constant.orderRejected || - controller.orderModel.value.status == Constant.orderCompleted + const SizedBox( + width: 10, + ), + controller + .orderModel + .value + .status == + Constant + .orderPlaced || + controller + .orderModel + .value + .status == + Constant + .orderRejected || + controller + .orderModel + .value + .status == + Constant + .orderCompleted ? const SizedBox() : InkWell( onTap: () async { - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader( + "Please wait..." + .tr, + ); - UserModel? customer = await FireStoreUtils.getUserProfile(controller.orderModel.value.authorID.toString()); - UserModel? restaurantUser = await FireStoreUtils.getUserProfile(controller.orderModel.value.vendor!.author.toString()); - VendorModel? vendorModel = await FireStoreUtils.getVendorById(restaurantUser!.vendorID.toString()); + UserModel? + customer = await FireStoreUtils.getUserProfile( + controller + .orderModel + .value + .authorID + .toString(), + ); + UserModel? + restaurantUser = await FireStoreUtils.getUserProfile( + controller + .orderModel + .value + .vendor! + .author + .toString(), + ); + VendorModel? + vendorModel = await FireStoreUtils.getVendorById( + restaurantUser! + .vendorID + .toString(), + ); ShowToastDialog.closeLoader(); Get.to( const ChatScreen(), arguments: { - "customerName": customer!.fullName(), - "restaurantName": vendorModel!.title, - "orderId": controller.orderModel.value.id, - "restaurantId": restaurantUser.id, - "customerId": customer.id, - "customerProfileImage": customer.profilePictureURL, - "restaurantProfileImage": vendorModel.photo, - "token": restaurantUser.fcmToken, - "chatType": "restaurant", + "customerName": + customer! + .fullName(), + "restaurantName": + vendorModel! + .title, + "orderId": + controller + .orderModel + .value + .id, + "restaurantId": + restaurantUser + .id, + "customerId": + customer + .id, + "customerProfileImage": + customer + .profilePictureURL, + "restaurantProfileImage": + vendorModel + .photo, + "token": + restaurantUser + .fcmToken, + "chatType": + "restaurant", }, ); }, @@ -263,27 +565,75 @@ class OrderDetailsScreen extends StatelessWidget { height: 42, decoration: ShapeDecoration( shape: RoundedRectangleBorder( - side: BorderSide(width: 1, color: isDark ? AppThemeData.grey700 : AppThemeData.grey200), - borderRadius: BorderRadius.circular(120), + side: BorderSide( + width: + 1, + color: + isDark + ? AppThemeData.grey700 + : AppThemeData.grey200, + ), + borderRadius: + BorderRadius.circular( + 120, + ), + ), + ), + child: Padding( + padding: + const EdgeInsets.all( + 8.0, + ), + child: SvgPicture.asset( + "assets/icons/ic_wechat.svg", ), ), - child: Padding(padding: const EdgeInsets.all(8.0), child: SvgPicture.asset("assets/icons/ic_wechat.svg")), ), ), ], ) : Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ Text( "${controller.orderModel.value.address!.addressAs}", - textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300), + textAlign: + TextAlign.start, + style: TextStyle( + fontFamily: + AppThemeData + .semiBold, + fontSize: 16, + color: + isDark + ? AppThemeData + .primary300 + : AppThemeData + .primary300, + ), ), Text( - controller.orderModel.value.address!.getFullAddress(), - textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 14, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600), + controller + .orderModel + .value + .address! + .getFullAddress(), + textAlign: + TextAlign.start, + style: TextStyle( + fontFamily: + AppThemeData + .medium, + fontSize: 14, + color: + isDark + ? AppThemeData + .grey300 + : AppThemeData + .grey600, + ), ), ], ), @@ -292,93 +642,215 @@ class OrderDetailsScreen extends StatelessWidget { itemCount: 2, ), ), - controller.orderModel.value.status == Constant.orderRejected + controller.orderModel.value.status == + Constant.orderRejected ? const SizedBox() : Column( children: [ - Padding(padding: const EdgeInsets.symmetric(vertical: 10), child: MySeparator(color: isDark ? AppThemeData.grey700 : AppThemeData.grey200)), - controller.orderModel.value.status == Constant.orderCompleted && controller.orderModel.value.driver != null + Padding( + padding: + const EdgeInsets.symmetric( + vertical: 10, + ), + child: MySeparator( + color: + isDark + ? AppThemeData.grey700 + : AppThemeData + .grey200, + ), + ), + controller + .orderModel + .value + .status == + Constant + .orderCompleted && + controller + .orderModel + .value + .driver != + null ? Row( children: [ - SvgPicture.asset("assets/icons/ic_check_small.svg"), + SvgPicture.asset( + "assets/icons/ic_check_small.svg", + ), const SizedBox(width: 5), Text( - controller.orderModel.value.driver!.fullName(), - textAlign: TextAlign.right, + controller + .orderModel + .value + .driver! + .fullName(), + textAlign: + TextAlign.right, style: TextStyle( - color: isDark ? AppThemeData.grey100 : AppThemeData.grey800, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w500, + color: + isDark + ? AppThemeData + .grey100 + : AppThemeData + .grey800, + fontFamily: + AppThemeData + .semiBold, + fontWeight: + FontWeight.w500, fontSize: 14, ), ), const SizedBox(width: 5), Text( "Order Delivered.".tr, - textAlign: TextAlign.right, + textAlign: + TextAlign.right, style: TextStyle( - color: isDark ? AppThemeData.grey100 : AppThemeData.grey800, - fontFamily: AppThemeData.regular, - fontWeight: FontWeight.w500, + color: + isDark + ? AppThemeData + .grey100 + : AppThemeData + .grey800, + fontFamily: + AppThemeData + .regular, + fontWeight: + FontWeight.w500, fontSize: 14, ), ), ], ) - : controller.orderModel.value.status == Constant.orderAccepted || controller.orderModel.value.status == Constant.driverPending + : controller + .orderModel + .value + .status == + Constant + .orderAccepted || + controller + .orderModel + .value + .status == + Constant.driverPending ? Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ - SvgPicture.asset("assets/icons/ic_timer.svg"), + SvgPicture.asset( + "assets/icons/ic_timer.svg", + ), const SizedBox(width: 5), Expanded( child: Text( "${'Your Order has been Preparing and assign to the driver'.tr}\n${'Preparation Time'.tr} ${controller.orderModel.value.estimatedTimeToPrepare}" .tr, - textAlign: TextAlign.start, + textAlign: + TextAlign.start, style: TextStyle( - color: isDark ? AppThemeData.warning400 : AppThemeData.warning400, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w500, + color: + isDark + ? AppThemeData + .warning400 + : AppThemeData + .warning400, + fontFamily: + AppThemeData + .semiBold, + fontWeight: + FontWeight.w500, fontSize: 14, ), ), ), ], ) - : controller.orderModel.value.driver != null + : controller + .orderModel + .value + .driver != + null ? Row( children: [ ClipOval( child: NetworkImageWidget( - imageUrl: controller.orderModel.value.author!.profilePictureURL.toString(), + imageUrl: + controller + .orderModel + .value + .author! + .profilePictureURL + .toString(), fit: BoxFit.cover, - height: Responsive.height(5, context), - width: Responsive.width(10, context), + height: + Responsive.height( + 5, + context, + ), + width: + Responsive.width( + 10, + context, + ), ), ), const SizedBox(width: 10), Expanded( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ Text( - controller.orderModel.value.driver!.fullName().toString(), - textAlign: TextAlign.start, + controller + .orderModel + .value + .driver! + .fullName() + .toString(), + textAlign: + TextAlign + .start, style: TextStyle( - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, + fontFamily: + AppThemeData + .semiBold, + fontWeight: + FontWeight + .w600, fontSize: 16, ), ), Text( - controller.orderModel.value.driver!.email.toString(), - textAlign: TextAlign.start, + controller + .orderModel + .value + .driver! + .email + .toString(), + textAlign: + TextAlign + .start, style: TextStyle( - color: isDark ? AppThemeData.success400 : AppThemeData.success400, - fontFamily: AppThemeData.regular, - fontWeight: FontWeight.w400, + color: + isDark + ? AppThemeData + .success400 + : AppThemeData + .success400, + fontFamily: + AppThemeData + .regular, + fontWeight: + FontWeight + .w400, fontSize: 12, ), ), @@ -387,42 +859,105 @@ class OrderDetailsScreen extends StatelessWidget { ), InkWell( onTap: () { - Constant.makePhoneCall(controller.orderModel.value.driver!.phoneNumber.toString()); + Constant.makePhoneCall( + controller + .orderModel + .value + .driver! + .phoneNumber + .toString(), + ); }, child: Container( width: 42, height: 42, decoration: ShapeDecoration( shape: RoundedRectangleBorder( - side: BorderSide(width: 1, color: isDark ? AppThemeData.grey700 : AppThemeData.grey200), - borderRadius: BorderRadius.circular(120), + side: BorderSide( + width: 1, + color: + isDark + ? AppThemeData + .grey700 + : AppThemeData + .grey200, + ), + borderRadius: + BorderRadius.circular( + 120, + ), + ), + ), + child: Padding( + padding: + const EdgeInsets.all( + 8.0, + ), + child: SvgPicture.asset( + "assets/icons/ic_phone_call.svg", ), ), - child: Padding(padding: const EdgeInsets.all(8.0), child: SvgPicture.asset("assets/icons/ic_phone_call.svg")), ), ), const SizedBox(width: 10), InkWell( onTap: () async { - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader( + ConstTexts + .pleaseWait + .tr, + ); - UserModel? customer = await FireStoreUtils.getUserProfile(controller.orderModel.value.authorID.toString()); - UserModel? restaurantUser = await FireStoreUtils.getUserProfile(controller.orderModel.value.driverID.toString()); + UserModel? customer = + await FireStoreUtils.getUserProfile( + controller + .orderModel + .value + .authorID + .toString(), + ); + UserModel? + restaurantUser = + await FireStoreUtils.getUserProfile( + controller + .orderModel + .value + .driverID + .toString(), + ); ShowToastDialog.closeLoader(); Get.to( const ChatScreen(), arguments: { - "customerName": customer!.fullName(), - "restaurantName": restaurantUser!.fullName(), - "orderId": controller.orderModel.value.id, - "restaurantId": restaurantUser.id, - "customerId": customer.id, - "customerProfileImage": customer.profilePictureURL, - "restaurantProfileImage": restaurantUser.profilePictureURL, - "token": restaurantUser.fcmToken, - "chatType": "Driver", + "customerName": + customer! + .fullName(), + "restaurantName": + restaurantUser! + .fullName(), + "orderId": + controller + .orderModel + .value + .id, + "restaurantId": + restaurantUser + .id, + "customerId": + customer.id, + "customerProfileImage": + customer + .profilePictureURL, + "restaurantProfileImage": + restaurantUser + .profilePictureURL, + "token": + restaurantUser + .fcmToken, + "chatType": + "Driver", }, ); }, @@ -431,11 +966,30 @@ class OrderDetailsScreen extends StatelessWidget { height: 42, decoration: ShapeDecoration( shape: RoundedRectangleBorder( - side: BorderSide(width: 1, color: isDark ? AppThemeData.grey700 : AppThemeData.grey200), - borderRadius: BorderRadius.circular(120), + side: BorderSide( + width: 1, + color: + isDark + ? AppThemeData + .grey700 + : AppThemeData + .grey200, + ), + borderRadius: + BorderRadius.circular( + 120, + ), + ), + ), + child: Padding( + padding: + const EdgeInsets.all( + 8.0, + ), + child: SvgPicture.asset( + "assets/icons/ic_wechat.svg", ), ), - child: Padding(padding: const EdgeInsets.all(8.0), child: SvgPicture.asset("assets/icons/ic_wechat.svg")), ), ), ], @@ -452,44 +1006,100 @@ class OrderDetailsScreen extends StatelessWidget { Text( "Your Order".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), const SizedBox(height: 10), Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: ListView.separated( shrinkWrap: true, padding: EdgeInsets.zero, - itemCount: controller.orderModel.value.products!.length, + itemCount: + controller + .orderModel + .value + .products! + .length, physics: const NeverScrollableScrollPhysics(), itemBuilder: (context, index) { - CartProductModel cartProductModel = controller.orderModel.value.products![index]; + CartProductModel cartProductModel = + controller + .orderModel + .value + .products![index]; return Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Row( - crossAxisAlignment: CrossAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, children: [ ClipRRect( - borderRadius: const BorderRadius.all(Radius.circular(14)), + borderRadius: + const BorderRadius.all( + Radius.circular(14), + ), child: Stack( children: [ NetworkImageWidget( - imageUrl: cartProductModel.photo.toString(), - height: Responsive.height(8, context), - width: Responsive.width(16, context), + imageUrl: + cartProductModel.photo + .toString(), + height: Responsive.height( + 8, + context, + ), + width: Responsive.width( + 16, + context, + ), fit: BoxFit.cover, ), Container( - height: Responsive.height(8, context), - width: Responsive.width(16, context), + height: Responsive.height( + 8, + context, + ), + width: Responsive.width( + 16, + context, + ), decoration: BoxDecoration( gradient: LinearGradient( - begin: const Alignment(-0.00, -1.00), - end: const Alignment(0, 1), - colors: [Colors.black.withOpacity(0), const Color(0xFF111827)], + begin: const Alignment( + -0.00, + -1.00, + ), + end: const Alignment( + 0, + 1, + ), + colors: [ + Colors.black + .withOpacity(0), + const Color(0xFF111827), + ], ), ), ), @@ -499,69 +1109,173 @@ class OrderDetailsScreen extends StatelessWidget { const SizedBox(width: 10), Expanded( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Row( children: [ Expanded( child: Text( "${cartProductModel.name}", - textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + textAlign: + TextAlign.start, + style: TextStyle( + fontFamily: + AppThemeData + .regular, + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, + fontSize: 16, + ), ), ), Text( "x ${cartProductModel.quantity}", - textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + textAlign: + TextAlign.start, + style: TextStyle( + fontFamily: + AppThemeData + .regular, + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, + fontSize: 16, + ), ), ], ), - double.parse(cartProductModel.discountPrice == null || cartProductModel.discountPrice!.isEmpty ? "0.0" : cartProductModel.discountPrice.toString()) <= 0 + double.parse( + cartProductModel.discountPrice == + null || + cartProductModel + .discountPrice! + .isEmpty + ? "0.0" + : cartProductModel + .discountPrice + .toString(), + ) <= + 0 ? Text( - Constant.amountShow(amount: cartProductModel.price), + Constant.amountShow( + amount: + cartProductModel + .price, + ), style: TextStyle( fontSize: 16, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, + fontFamily: + AppThemeData + .semiBold, + fontWeight: + FontWeight.w600, ), ) : Row( children: [ Text( - Constant.amountShow(amount: cartProductModel.discountPrice.toString()), + Constant.amountShow( + amount: + cartProductModel + .discountPrice + .toString(), + ), style: TextStyle( fontSize: 16, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, + fontFamily: + AppThemeData + .semiBold, + fontWeight: + FontWeight.w600, ), ), - const SizedBox(width: 5), + const SizedBox( + width: 5, + ), Text( - Constant.amountShow(amount: cartProductModel.price), + Constant.amountShow( + amount: + cartProductModel + .price, + ), style: TextStyle( fontSize: 14, - decoration: TextDecoration.lineThrough, - decorationColor: isDark ? AppThemeData.grey500 : AppThemeData.grey400, - color: isDark ? AppThemeData.grey500 : AppThemeData.grey400, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + decoration: + TextDecoration + .lineThrough, + decorationColor: + isDark + ? AppThemeData + .grey500 + : AppThemeData + .grey400, + color: + isDark + ? AppThemeData + .grey500 + : AppThemeData + .grey400, + fontFamily: + AppThemeData + .semiBold, + fontWeight: + FontWeight.w600, ), ), ], ), Align( - alignment: Alignment.centerRight, + alignment: + Alignment.centerRight, child: RoundedButtonFill( title: "Rate us".tr, height: 3.8, width: 20, - color: isDark ? AppThemeData.warning300 : AppThemeData.warning300, - textColor: isDark ? AppThemeData.grey100 : AppThemeData.grey800, + color: + isDark + ? AppThemeData + .warning300 + : AppThemeData + .warning300, + textColor: + isDark + ? AppThemeData + .grey100 + : AppThemeData + .grey800, onPress: () async { - Get.to(const RateProductScreen(), arguments: {"orderModel": controller.orderModel.value, "productId": cartProductModel.id}); + Get.to( + const RateProductScreen(), + arguments: { + "orderModel": + controller + .orderModel + .value, + "productId": + cartProductModel + .id, + }, + ); }, ), ), @@ -570,63 +1284,149 @@ class OrderDetailsScreen extends StatelessWidget { ), ], ), - cartProductModel.variantInfo == null || cartProductModel.variantInfo!.variantOptions!.isEmpty + cartProductModel.variantInfo == null || + cartProductModel + .variantInfo! + .variantOptions! + .isEmpty ? Container() : Padding( - padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 5, + vertical: 10, + ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( "Variants".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontSize: 16), + style: TextStyle( + fontFamily: + AppThemeData.semiBold, + color: + isDark + ? AppThemeData + .grey300 + : AppThemeData + .grey600, + fontSize: 16, + ), ), const SizedBox(height: 5), Wrap( spacing: 6.0, runSpacing: 6.0, children: - List.generate(cartProductModel.variantInfo!.variantOptions!.length, (i) { - return Container( - decoration: ShapeDecoration( - color: isDark ? AppThemeData.grey800 : AppThemeData.grey100, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), - ), - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 5), - child: Text( - "${cartProductModel.variantInfo!.variantOptions!.keys.elementAt(i)} : ${cartProductModel.variantInfo!.variantOptions![cartProductModel.variantInfo!.variantOptions!.keys.elementAt(i)]}", - textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, color: isDark ? AppThemeData.grey500 : AppThemeData.grey400), + List.generate( + cartProductModel + .variantInfo! + .variantOptions! + .length, + (i) { + return Container( + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData + .grey800 + : AppThemeData + .grey100, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 8, + ), + ), ), - ), - ); - }).toList(), + child: Padding( + padding: + const EdgeInsets.symmetric( + horizontal: + 16, + vertical: 5, + ), + child: Text( + "${cartProductModel.variantInfo!.variantOptions!.keys.elementAt(i)} : ${cartProductModel.variantInfo!.variantOptions![cartProductModel.variantInfo!.variantOptions!.keys.elementAt(i)]}", + textAlign: + TextAlign + .start, + style: TextStyle( + fontFamily: + AppThemeData + .medium, + color: + isDark + ? AppThemeData + .grey500 + : AppThemeData + .grey400, + ), + ), + ), + ); + }, + ).toList(), ), ], ), ), - cartProductModel.extras == null || cartProductModel.extras!.isEmpty + cartProductModel.extras == null || + cartProductModel.extras!.isEmpty ? const SizedBox() : Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Row( children: [ Expanded( child: Text( "Addons".tr, - textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontSize: 16), + textAlign: + TextAlign.start, + style: TextStyle( + fontFamily: + AppThemeData + .semiBold, + color: + isDark + ? AppThemeData + .grey300 + : AppThemeData + .grey600, + fontSize: 16, + ), ), ), Text( Constant.amountShow( - amount: (double.parse(cartProductModel.extrasPrice.toString()) * double.parse(cartProductModel.quantity.toString())).toString(), + amount: + (double.parse( + cartProductModel + .extrasPrice + .toString(), + ) * + double.parse( + cartProductModel + .quantity + .toString(), + )) + .toString(), ), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, fontSize: 16), + style: TextStyle( + fontFamily: + AppThemeData.semiBold, + color: + isDark + ? AppThemeData + .primary300 + : AppThemeData + .primary300, + fontSize: 16, + ), ), ], ), @@ -634,22 +1434,56 @@ class OrderDetailsScreen extends StatelessWidget { spacing: 6.0, runSpacing: 6.0, children: - List.generate(cartProductModel.extras!.length, (i) { - return Container( - decoration: ShapeDecoration( - color: isDark ? AppThemeData.grey800 : AppThemeData.grey100, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), - ), - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 5), - child: Text( - cartProductModel.extras![i].toString(), - textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, color: isDark ? AppThemeData.grey500 : AppThemeData.grey400), + List.generate( + cartProductModel + .extras! + .length, + (i) { + return Container( + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData + .grey800 + : AppThemeData + .grey100, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 8, + ), + ), ), - ), - ); - }).toList(), + child: Padding( + padding: + const EdgeInsets.symmetric( + horizontal: + 16, + vertical: 5, + ), + child: Text( + cartProductModel + .extras![i] + .toString(), + textAlign: + TextAlign + .start, + style: TextStyle( + fontFamily: + AppThemeData + .medium, + color: + isDark + ? AppThemeData + .grey500 + : AppThemeData + .grey400, + ), + ), + ), + ); + }, + ).toList(), ), ], ), @@ -657,7 +1491,17 @@ class OrderDetailsScreen extends StatelessWidget { ); }, separatorBuilder: (context, index) { - return Padding(padding: const EdgeInsets.symmetric(vertical: 10), child: MySeparator(color: isDark ? AppThemeData.grey700 : AppThemeData.grey200)); + return Padding( + padding: const EdgeInsets.symmetric( + vertical: 10, + ), + child: MySeparator( + color: + isDark + ? AppThemeData.grey700 + : AppThemeData.grey200, + ), + ); }, ), ), @@ -691,30 +1535,67 @@ class OrderDetailsScreen extends StatelessWidget { Text( "Bill Details".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), const SizedBox(height: 10), Container( width: Responsive.width(100, context), - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 14), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 14, + ), child: Column( children: [ Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Expanded( child: Text( "Item totals".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.regular, + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + fontSize: 16, + ), ), ), Text( - Constant.amountShow(amount: controller.subTotal.value.toString()), + Constant.amountShow( + amount: + controller.subTotal.value + .toString(), + ), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.regular, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 16, + ), ), ], ), @@ -722,67 +1603,160 @@ class OrderDetailsScreen extends StatelessWidget { controller.orderModel.value.takeAway == true ? const SizedBox() : Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Expanded( child: Text( "Delivery Fee".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontSize: 16), + style: TextStyle( + fontFamily: + AppThemeData.regular, + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + fontSize: 16, + ), ), ), - (controller.orderModel.value.vendor?.isSelfDelivery == true) - ? Text('Free Delivery'.tr, textAlign: TextAlign.start, style: TextStyle(fontFamily: AppThemeData.regular, color: AppThemeData.success400, fontSize: 16)) + (controller + .orderModel + .value + .vendor + ?.isSelfDelivery == + true) + ? Text( + 'Free Delivery'.tr, + textAlign: TextAlign.start, + style: TextStyle( + fontFamily: + AppThemeData.regular, + color: + AppThemeData.success400, + fontSize: 16, + ), + ) : Text( Constant.amountShow( amount: - controller.orderModel.value.deliveryCharge == null || controller.orderModel.value.deliveryCharge!.isEmpty + controller + .orderModel + .value + .deliveryCharge == + null || + controller + .orderModel + .value + .deliveryCharge! + .isEmpty ? "0.0" - : controller.orderModel.value.deliveryCharge.toString(), + : controller + .orderModel + .value + .deliveryCharge + .toString(), ), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + style: TextStyle( + fontFamily: + AppThemeData.regular, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData + .grey900, + fontSize: 16, + ), ), ], ), const SizedBox(height: 10), - MySeparator(color: isDark ? AppThemeData.grey700 : AppThemeData.grey200), + MySeparator( + color: + isDark + ? AppThemeData.grey700 + : AppThemeData.grey200, + ), const SizedBox(height: 10), Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Expanded( child: Text( "Coupon Discount".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.regular, + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + fontSize: 16, + ), ), ), Text( "- (${Constant.amountShow(amount: controller.orderModel.value.discount.toString())})", textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.danger300 : AppThemeData.danger300, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.regular, + color: + isDark + ? AppThemeData.danger300 + : AppThemeData.danger300, + fontSize: 16, + ), ), ], ), - controller.orderModel.value.specialDiscount != null && controller.orderModel.value.specialDiscount!['special_discount'] != null + controller.orderModel.value.specialDiscount != + null && + controller + .orderModel + .value + .specialDiscount!['special_discount'] != + null ? Column( children: [ const SizedBox(height: 10), Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Expanded( child: Text( "Special Discount".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontSize: 16), + style: TextStyle( + fontFamily: + AppThemeData.regular, + color: + isDark + ? AppThemeData + .grey300 + : AppThemeData + .grey600, + fontSize: 16, + ), ), ), Text( "- (${Constant.amountShow(amount: controller.specialDiscountAmount.value.toString())})", textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.danger300 : AppThemeData.danger300, fontSize: 16), + style: TextStyle( + fontFamily: + AppThemeData.regular, + color: + isDark + ? AppThemeData + .danger300 + : AppThemeData + .danger300, + fontSize: 16, + ), ), ], ), @@ -790,50 +1764,110 @@ class OrderDetailsScreen extends StatelessWidget { ) : const SizedBox(), const SizedBox(height: 10), - controller.orderModel.value.takeAway == true || controller.orderModel.value.vendor?.isSelfDelivery == true + controller.orderModel.value.takeAway == + true || + controller + .orderModel + .value + .vendor + ?.isSelfDelivery == + true ? const SizedBox() : Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Expanded( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( "Delivery Tips".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontSize: 16), + style: TextStyle( + fontFamily: + AppThemeData.regular, + color: + isDark + ? AppThemeData + .grey300 + : AppThemeData + .grey600, + fontSize: 16, + ), ), ], ), ), Text( - Constant.amountShow(amount: controller.orderModel.value.tipAmount.toString()), + Constant.amountShow( + amount: + controller + .orderModel + .value + .tipAmount + .toString(), + ), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.regular, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 16, + ), ), ], ), const SizedBox(height: 10), - MySeparator(color: isDark ? AppThemeData.grey700 : AppThemeData.grey200), + MySeparator( + color: + isDark + ? AppThemeData.grey700 + : AppThemeData.grey200, + ), const SizedBox(height: 10), ListView.builder( - itemCount: controller.orderModel.value.taxSetting!.length, + itemCount: + controller + .orderModel + .value + .taxSetting! + .length, shrinkWrap: true, padding: EdgeInsets.zero, - physics: const NeverScrollableScrollPhysics(), + physics: + const NeverScrollableScrollPhysics(), itemBuilder: (context, index) { - TaxModel taxModel = controller.orderModel.value.taxSetting![index]; + TaxModel taxModel = + controller + .orderModel + .value + .taxSetting![index]; return Padding( - padding: const EdgeInsets.symmetric(vertical: 5), + padding: const EdgeInsets.symmetric( + vertical: 5, + ), child: Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Expanded( child: Text( "${taxModel.title.toString()} (${taxModel.type == "fix" ? Constant.amountShow(amount: taxModel.tax) : "${taxModel.tax}%"})", textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontSize: 16), + style: TextStyle( + fontFamily: + AppThemeData.regular, + color: + isDark + ? AppThemeData.grey300 + : AppThemeData + .grey600, + fontSize: 16, + ), ), ), Text( @@ -841,13 +1875,33 @@ class OrderDetailsScreen extends StatelessWidget { amount: Constant.calculateTax( amount: - (controller.subTotal.value - double.parse(controller.orderModel.value.discount.toString()) - controller.specialDiscountAmount.value) + (controller + .subTotal + .value - + double.parse( + controller + .orderModel + .value + .discount + .toString(), + ) - + controller + .specialDiscountAmount + .value) .toString(), taxModel: taxModel, ).toString(), ), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + style: TextStyle( + fontFamily: + AppThemeData.regular, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 16, + ), ), ], ), @@ -856,19 +1910,38 @@ class OrderDetailsScreen extends StatelessWidget { ), const SizedBox(height: 10), Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Expanded( child: Text( "To Pay".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.regular, + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + fontSize: 16, + ), ), ), Text( - Constant.amountShow(amount: controller.totalAmount.value.toString()), + Constant.amountShow( + amount: + controller.totalAmount.value + .toString(), + ), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.regular, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 16, + ), ), ], ), @@ -880,37 +1953,72 @@ class OrderDetailsScreen extends StatelessWidget { Text( "Order Details".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), const SizedBox(height: 10), Container( width: Responsive.width(100, context), - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 14), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 14, + ), child: Column( children: [ Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Expanded( child: Text( "Delivery type".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.regular, + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + fontSize: 16, + ), ), ), Text( - controller.orderModel.value.takeAway == true + controller.orderModel.value.takeAway == + true ? "TakeAway".tr - : controller.orderModel.value.scheduleTime == null + : controller + .orderModel + .value + .scheduleTime == + null ? "Standard".tr : "Schedule".tr, textAlign: TextAlign.start, style: TextStyle( fontFamily: AppThemeData.medium, color: - controller.orderModel.value.scheduleTime != null + controller + .orderModel + .value + .scheduleTime != + null ? AppThemeData.primary300 : isDark ? AppThemeData.grey50 @@ -922,60 +2030,121 @@ class OrderDetailsScreen extends StatelessWidget { ), const SizedBox(height: 10), Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Expanded( child: Text( "Payment Method".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.regular, + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + fontSize: 16, + ), ), ), Text( - controller.orderModel.value.paymentMethod.toString(), + controller + .orderModel + .value + .paymentMethod + .toString(), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.regular, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 16, + ), ), ], ), const SizedBox(height: 10), Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Expanded( child: Text( "Date and Time".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.regular, + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + fontSize: 16, + ), ), ), Text( - Constant.timestampToDateTime(controller.orderModel.value.createdAt!), + Constant.timestampToDateTime( + controller + .orderModel + .value + .createdAt!, + ), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.regular, + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + fontSize: 16, + ), ), ], ), const SizedBox(height: 10), Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Expanded( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( "Phone Number".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontSize: 16), + style: TextStyle( + fontFamily: + AppThemeData.regular, + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + fontSize: 16, + ), ), ], ), ), Text( - controller.orderModel.value.author!.phoneNumber.toString(), + controller + .orderModel + .value + .author! + .phoneNumber + .toString(), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.regular, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 16, + ), ), ], ), @@ -985,7 +2154,8 @@ class OrderDetailsScreen extends StatelessWidget { ), ), const SizedBox(height: 20), - controller.orderModel.value.notes == null || controller.orderModel.value.notes!.isEmpty + controller.orderModel.value.notes == null || + controller.orderModel.value.notes!.isEmpty ? const SizedBox() : Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -993,18 +2163,44 @@ class OrderDetailsScreen extends StatelessWidget { Text( "Remarks".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), const SizedBox(height: 10), Container( width: Responsive.width(100, context), - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 14), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 14, + ), child: Text( - controller.orderModel.value.notes.toString(), + controller.orderModel.value.notes + .toString(), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.regular, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 16, + ), ), ), ), @@ -1016,22 +2212,35 @@ class OrderDetailsScreen extends StatelessWidget { ), bottomNavigationBar: controller.orderModel.value.status == Constant.orderShipped || - controller.orderModel.value.status == Constant.orderInTransit || - controller.orderModel.value.status == Constant.orderCompleted + controller.orderModel.value.status == + Constant.orderInTransit || + controller.orderModel.value.status == + Constant.orderCompleted ? Container( color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 20, + ), child: Padding( padding: const EdgeInsets.only(bottom: 20), child: - controller.orderModel.value.status == Constant.orderShipped || controller.orderModel.value.status == Constant.orderInTransit + controller.orderModel.value.status == + Constant.orderShipped || + controller.orderModel.value.status == + Constant.orderInTransit ? RoundedButtonFill( title: "Track Order".tr, height: 5.5, color: AppThemeData.warning300, textColor: AppThemeData.grey900, onPress: () async { - Get.to(const LiveTrackingScreen(), arguments: {"orderModel": controller.orderModel.value}); + Get.to( + const LiveTrackingScreen(), + arguments: { + "orderModel": controller.orderModel.value, + }, + ); }, ) : RoundedButtonFill( @@ -1040,9 +2249,17 @@ class OrderDetailsScreen extends StatelessWidget { color: AppThemeData.primary300, textColor: AppThemeData.grey50, onPress: () async { - for (var element in controller.orderModel.value.products!) { - controller.addToCart(cartProductModel: element); - ShowToastDialog.showToast("Item Added In a cart".tr); + for (var element + in controller + .orderModel + .value + .products!) { + controller.addToCart( + cartProductModel: element, + ); + ShowToastDialog.showToast( + "Item Added In a cart".tr, + ); } }, ), diff --git a/lib/screen_ui/multi_vendor_service/order_list_screen/order_screen.dart b/lib/screen_ui/multi_vendor_service/order_list_screen/order_screen.dart index 3cacd3a..3e3cdaa 100644 --- a/lib/screen_ui/multi_vendor_service/order_list_screen/order_screen.dart +++ b/lib/screen_ui/multi_vendor_service/order_list_screen/order_screen.dart @@ -5,7 +5,9 @@ import 'package:customer/models/order_model.dart'; import 'package:customer/themes/app_them_data.dart'; import 'package:customer/themes/responsive.dart'; import 'package:customer/themes/round_button_fill.dart'; +import 'package:customer/utils/app_router.dart'; import 'package:customer/utils/network_image_widget.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../../../controllers/theme_controller.dart'; @@ -27,7 +29,9 @@ class OrderScreen extends StatelessWidget { builder: (controller) { return Scaffold( body: Padding( - padding: EdgeInsets.only(top: MediaQuery.of(context).viewPadding.top), + padding: EdgeInsets.only( + top: MediaQuery.of(context).viewPadding.top, + ), child: controller.isLoading.value ? Constant.loader() @@ -40,12 +44,30 @@ class OrderScreen extends StatelessWidget { children: [ Image.asset("assets/images/login.gif", height: 120), const SizedBox(height: 12), - Text("Please Log In to Continue".tr, style: TextStyle(color: isDark ? AppThemeData.grey100 : AppThemeData.grey800, fontSize: 22, fontFamily: AppThemeData.semiBold)), + Text( + "Please Log In to Continue".tr, + style: TextStyle( + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey800, + fontSize: 22, + fontFamily: AppThemeData.semiBold, + ), + ), const SizedBox(height: 5), Text( - "You’re not logged in. Please sign in to access your account and explore all features.".tr, + "You’re not logged in. Please sign in to access your account and explore all features." + .tr, textAlign: TextAlign.center, - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey500, fontSize: 16, fontFamily: AppThemeData.bold), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey500, + fontSize: 16, + fontFamily: AppThemeData.bold, + ), ), const SizedBox(height: 20), RoundedButtonFill( @@ -71,15 +93,32 @@ class OrderScreen extends StatelessWidget { children: [ Expanded( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( "My Order".tr, - style: TextStyle(fontSize: 24, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w500), + style: TextStyle( + fontSize: 24, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w500, + ), ), Text( - "Keep track your delivered, In Progress and Rejected item all in just one place.".tr, - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w400), + "Keep track your delivered, In Progress and Rejected item all in just one place." + .tr, + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w400, + ), ), ], ), @@ -90,26 +129,51 @@ class OrderScreen extends StatelessWidget { const SizedBox(height: 10), Expanded( child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), + padding: const EdgeInsets.symmetric( + horizontal: 16, + ), child: Column( children: [ Container( - padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 10), - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey800 : AppThemeData.grey100, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120))), + padding: const EdgeInsets.symmetric( + vertical: 6, + horizontal: 10, + ), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey800 + : AppThemeData.grey100, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular( + 120, + ), + ), + ), child: TabBar( indicator: BoxDecoration( - borderRadius: BorderRadius.circular(50), // Creates border + borderRadius: BorderRadius.circular( + 50, + ), // Creates border color: AppThemeData.primary300, ), labelColor: AppThemeData.grey50, isScrollable: true, tabAlignment: TabAlignment.start, indicatorWeight: 0.5, - unselectedLabelColor: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + unselectedLabelColor: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, dividerColor: Colors.transparent, indicatorSize: TabBarIndicatorSize.tab, tabs: [ - Padding(padding: const EdgeInsets.symmetric(horizontal: 18), child: Tab(text: 'All'.tr)), + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 18, + ), + child: Tab(text: 'All'.tr), + ), Tab(text: 'In Progress'.tr), Tab(text: 'Delivered'.tr), Tab(text: 'Cancelled'.tr), @@ -122,72 +186,134 @@ class OrderScreen extends StatelessWidget { child: TabBarView( children: [ controller.allList.isEmpty - ? Constant.showEmptyView(message: "Order Not Found".tr) + ? Constant.showEmptyView( + message: "Order Not Found".tr, + ) : RefreshIndicator( - onRefresh: () => controller.getOrder(), + onRefresh: + () => controller.getOrder(), child: ListView.builder( - itemCount: controller.allList.length, + itemCount: + controller.allList.length, shrinkWrap: true, padding: EdgeInsets.zero, itemBuilder: (context, index) { - OrderModel orderModel = controller.allList[index]; - return itemView(isDark, context, orderModel, controller); + OrderModel orderModel = + controller.allList[index]; + return itemView( + isDark, + context, + orderModel, + controller, + ); }, ), ), controller.inProgressList.isEmpty - ? Constant.showEmptyView(message: "Order Not Found".tr) + ? Constant.showEmptyView( + message: "Order Not Found".tr, + ) : RefreshIndicator( - onRefresh: () => controller.getOrder(), + onRefresh: + () => controller.getOrder(), child: ListView.builder( - itemCount: controller.inProgressList.length, + itemCount: + controller + .inProgressList + .length, shrinkWrap: true, padding: EdgeInsets.zero, itemBuilder: (context, index) { - OrderModel orderModel = controller.inProgressList[index]; - return itemView(isDark, context, orderModel, controller); + OrderModel orderModel = + controller + .inProgressList[index]; + return itemView( + isDark, + context, + orderModel, + controller, + ); }, ), ), controller.deliveredList.isEmpty - ? Constant.showEmptyView(message: "Order Not Found".tr) + ? Constant.showEmptyView( + message: "Order Not Found".tr, + ) : RefreshIndicator( - onRefresh: () => controller.getOrder(), + onRefresh: + () => controller.getOrder(), child: ListView.builder( - itemCount: controller.deliveredList.length, + itemCount: + controller + .deliveredList + .length, shrinkWrap: true, padding: EdgeInsets.zero, itemBuilder: (context, index) { - OrderModel orderModel = controller.deliveredList[index]; - return itemView(isDark, context, orderModel, controller); + OrderModel orderModel = + controller + .deliveredList[index]; + return itemView( + isDark, + context, + orderModel, + controller, + ); }, ), ), controller.cancelledList.isEmpty - ? Constant.showEmptyView(message: "Order Not Found".tr) + ? Constant.showEmptyView( + message: "Order Not Found".tr, + ) : RefreshIndicator( - onRefresh: () => controller.getOrder(), + onRefresh: + () => controller.getOrder(), child: ListView.builder( - itemCount: controller.cancelledList.length, + itemCount: + controller + .cancelledList + .length, shrinkWrap: true, padding: EdgeInsets.zero, itemBuilder: (context, index) { - OrderModel orderModel = controller.cancelledList[index]; - return itemView(isDark, context, orderModel, controller); + OrderModel orderModel = + controller + .cancelledList[index]; + return itemView( + isDark, + context, + orderModel, + controller, + ); }, ), ), controller.rejectedList.isEmpty - ? Constant.showEmptyView(message: "Order Not Found".tr) + ? Constant.showEmptyView( + message: "Order Not Found".tr, + ) : RefreshIndicator( - onRefresh: () => controller.getOrder(), + onRefresh: + () => controller.getOrder(), child: ListView.builder( - itemCount: controller.rejectedList.length, + itemCount: + controller + .rejectedList + .length, shrinkWrap: true, padding: EdgeInsets.zero, itemBuilder: (context, index) { - OrderModel orderModel = controller.rejectedList[index]; - return itemView(isDark, context, orderModel, controller); + OrderModel orderModel = + controller + .rejectedList[index]; + return itemView( + isDark, + context, + orderModel, + controller, + ); }, ), ), @@ -207,11 +333,21 @@ class OrderScreen extends StatelessWidget { ); } - Padding itemView(isDark, BuildContext context, OrderModel orderModel, OrderController controller) { + Padding itemView( + isDark, + BuildContext context, + OrderModel orderModel, + OrderController controller, + ) { return Padding( padding: const EdgeInsets.symmetric(vertical: 5), child: Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12))), + decoration: ShapeDecoration( + color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + ), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( @@ -222,12 +358,24 @@ class OrderScreen extends StatelessWidget { borderRadius: const BorderRadius.all(Radius.circular(16)), child: Stack( children: [ - NetworkImageWidget(imageUrl: orderModel.vendor!.photo.toString(), fit: BoxFit.cover, height: Responsive.height(10, context), width: Responsive.width(20, context)), + NetworkImageWidget( + imageUrl: orderModel.vendor!.photo.toString(), + fit: BoxFit.cover, + height: Responsive.height(10, context), + width: Responsive.width(20, context), + ), Container( height: Responsive.height(10, context), width: Responsive.width(20, context), decoration: BoxDecoration( - gradient: LinearGradient(begin: const Alignment(0.00, 1.00), end: const Alignment(0, -1), colors: [Colors.black.withOpacity(0), AppThemeData.grey900]), + gradient: LinearGradient( + begin: const Alignment(0.00, 1.00), + end: const Alignment(0, -1), + colors: [ + Colors.black.withOpacity(0), + AppThemeData.grey900, + ], + ), ), ), ], @@ -241,17 +389,39 @@ class OrderScreen extends StatelessWidget { Text( orderModel.status.toString(), textAlign: TextAlign.right, - style: TextStyle(color: Constant.statusColor(status: orderModel.status.toString()), fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w500, fontSize: 12), + style: TextStyle( + color: Constant.statusColor( + status: orderModel.status.toString(), + ), + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w500, + fontSize: 12, + ), ), const SizedBox(height: 5), Text( orderModel.vendor!.title.toString(), - style: TextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w400), + style: TextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.medium, + fontWeight: FontWeight.w400, + ), ), const SizedBox(height: 5), Text( Constant.timestampToDateTime(orderModel.createdAt!), - style: TextStyle(color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500), + style: TextStyle( + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + fontFamily: AppThemeData.medium, + fontWeight: FontWeight.w500, + ), ), ], ), @@ -271,23 +441,55 @@ class OrderScreen extends StatelessWidget { Expanded( child: Text( "${cartProduct.quantity} x ${cartProduct.name.toString()}", - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w400), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w400, + ), ), ), Text( Constant.amountShow( amount: - double.parse(cartProduct.discountPrice.toString()) <= 0 - ? (double.parse('${cartProduct.price ?? 0}') * double.parse('${cartProduct.quantity ?? 0}')).toString() - : (double.parse('${cartProduct.discountPrice ?? 0}') * double.parse('${cartProduct.quantity ?? 0}')).toString(), + double.parse( + cartProduct.discountPrice.toString(), + ) <= + 0 + ? (double.parse('${cartProduct.price ?? 0}') * + double.parse( + '${cartProduct.quantity ?? 0}', + )) + .toString() + : (double.parse( + '${cartProduct.discountPrice ?? 0}', + ) * + double.parse( + '${cartProduct.quantity ?? 0}', + )) + .toString(), + ), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w500, ), - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w500), ), ], ); }, ), - Padding(padding: const EdgeInsets.symmetric(vertical: 14), child: MySeparator(color: isDark ? AppThemeData.grey700 : AppThemeData.grey200)), + Padding( + padding: const EdgeInsets.symmetric(vertical: 14), + child: MySeparator( + color: isDark ? AppThemeData.grey700 : AppThemeData.grey200, + ), + ), Row( children: [ orderModel.status == Constant.orderCompleted @@ -296,26 +498,48 @@ class OrderScreen extends StatelessWidget { onTap: () { for (var element in orderModel.products!) { controller.addToCart(cartProductModel: element); - ShowToastDialog.showToast("Item Added In a cart".tr); + ShowToastDialog.showToast( + "Item Added In a cart".tr, + ); } }, child: Text( "Reorder".tr, textAlign: TextAlign.center, - style: TextStyle(color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600, fontSize: 16), + style: TextStyle( + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w600, + fontSize: 16, + ), ), ), ) - : orderModel.status == Constant.orderShipped || orderModel.status == Constant.orderInTransit + : orderModel.status == Constant.orderShipped || + orderModel.status == Constant.orderInTransit ? Expanded( child: InkWell( onTap: () { - Get.to(const LiveTrackingScreen(), arguments: {"orderModel": orderModel}); + Get.to( + const LiveTrackingScreen(), + arguments: {"orderModel": orderModel}, + ); }, child: Text( "Track Order".tr, textAlign: TextAlign.center, - style: TextStyle(color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600, fontSize: 16), + style: TextStyle( + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w600, + fontSize: 16, + ), ), ), ) @@ -323,13 +547,24 @@ class OrderScreen extends StatelessWidget { Expanded( child: InkWell( onTap: () { - Get.to(const OrderDetailsScreen(), arguments: {"orderModel": orderModel}); + Get.to( + const OrderDetailsScreen(), + arguments: {"orderModel": orderModel}, + ); // Get.off(const OrderPlacingScreen(), arguments: {"orderModel": orderModel}); }, child: Text( "View Details".tr, textAlign: TextAlign.center, - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600, fontSize: 16), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w600, + fontSize: 16, + ), ), ), ), diff --git a/lib/screen_ui/multi_vendor_service/profile_screen/profile_screen.dart b/lib/screen_ui/multi_vendor_service/profile_screen/profile_screen.dart index 12f17fc..5f1b3b3 100644 --- a/lib/screen_ui/multi_vendor_service/profile_screen/profile_screen.dart +++ b/lib/screen_ui/multi_vendor_service/profile_screen/profile_screen.dart @@ -1,3 +1,4 @@ +import 'package:customer/constant/const_texts.dart'; import 'package:customer/constant/constant.dart'; import 'package:customer/controllers/my_profile_controller.dart'; import 'package:customer/screen_ui/on_demand_service/provider_inbox_screen.dart'; @@ -5,6 +6,8 @@ import 'package:customer/screen_ui/on_demand_service/worker_inbox_screen.dart'; import 'package:customer/themes/app_them_data.dart'; import 'package:customer/themes/custom_dialog_box.dart'; import 'package:customer/themes/responsive.dart'; +import 'package:customer/utils/app_router.dart'; + import 'package:in_app_review/in_app_review.dart'; import '../../../controllers/theme_controller.dart'; import '../../../service/fire_store_utils.dart'; @@ -43,7 +46,9 @@ class ProfileScreen extends StatelessWidget { return controller.isLoading.value ? Constant.loader() : Padding( - padding: EdgeInsets.only(top: MediaQuery.of(context).viewPadding.top), + padding: EdgeInsets.only( + top: MediaQuery.of(context).viewPadding.top, + ), child: SingleChildScrollView( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 16), @@ -52,41 +57,106 @@ class ProfileScreen extends StatelessWidget { children: [ Text( "My Profile".tr, - style: TextStyle(fontSize: 24, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w500), + style: TextStyle( + fontSize: 24, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w500, + ), ), Text( - "Manage your personal information, preferences, and settings all in one place.".tr, - style: TextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w400), + "Manage your personal information, preferences, and settings all in one place." + .tr, + style: TextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w400, + ), ), const SizedBox(height: 20), Text( "General Information".tr, - style: TextStyle(fontSize: 12, color: isDark ? AppThemeData.grey400 : AppThemeData.grey500, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w500), + style: TextStyle( + fontSize: 12, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey500, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w500, + ), ), const SizedBox(height: 10), Container( width: Responsive.width(100, context), - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 8, + ), child: Column( children: [ Constant.userModel == null ? const SizedBox() - : cardDecoration(isDark, controller, "assets/images/ic_profile.svg", "Profile Information".tr, () { - Get.to(const EditProfileScreen()); - }), - if (Constant.sectionConstantModel!.dineInActive == true) - cardDecoration(isDark, controller, "assets/images/ic_dinin.svg", "Dine-In".tr, () { - Get.to(const DineInScreen()); - }), - cardDecoration(isDark, controller, "assets/images/ic_gift.svg", "Gift Card".tr, () { - Get.to(const GiftCardScreen()); - }), + : cardDecoration( + isDark, + controller, + "assets/images/ic_profile.svg", + "Profile Information".tr, + () { + Get.to(const EditProfileScreen()); + }, + ), + if (Constant + .sectionConstantModel! + .dineInActive == + true) + cardDecoration( + isDark, + controller, + "assets/images/ic_dinin.svg", + "Dine-In".tr, + () { + Get.to(const DineInScreen()); + }, + ), + cardDecoration( + isDark, + controller, + "assets/images/ic_gift.svg", + "Gift Card".tr, + () { + Get.to(const GiftCardScreen()); + }, + ), if (Constant.isCashbackActive == true) - cardDecoration(isDark, controller, "assets/icons/ic_cashback_Offer.svg", "Cashback Offers".tr, () { - Get.to(const CashbackOffersListScreen()); - }), + cardDecoration( + isDark, + controller, + "assets/icons/ic_cashback_Offer.svg", + "Cashback Offers".tr, + () { + Get.to( + const CashbackOffersListScreen(), + ); + }, + ), ], ), ), @@ -98,19 +168,46 @@ class ProfileScreen extends StatelessWidget { children: [ Text( "Bookings Information".tr, - style: TextStyle(fontSize: 12, color: isDark ? AppThemeData.grey400 : AppThemeData.grey500, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w500), + style: TextStyle( + fontSize: 12, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey500, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w500, + ), ), const SizedBox(height: 10), Container( width: Responsive.width(100, context), - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 5, + ), child: Column( children: [ - cardDecoration(isDark, controller, "assets/icons/ic_dinin_order.svg", "Dine-In Booking".tr, () { - Get.to(const DineInBookingScreen()); - }), + cardDecoration( + isDark, + controller, + "assets/icons/ic_dinin_order.svg", + "Dine-In Booking".tr, + () { + Get.to( + const DineInBookingScreen(), + ); + }, + ), ], ), ), @@ -121,20 +218,51 @@ class ProfileScreen extends StatelessWidget { const SizedBox(height: 10), Text( "Preferences".tr, - style: TextStyle(fontSize: 12, color: isDark ? AppThemeData.grey400 : AppThemeData.grey500, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w500), + style: TextStyle( + fontSize: 12, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey500, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w500, + ), ), const SizedBox(height: 10), Container( width: Responsive.width(100, context), - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 8, + ), child: Column( children: [ - cardDecoration(isDark, controller, "assets/icons/ic_change_language.svg", "Change Language".tr, () { - Get.to(const ChangeLanguageScreen()); - }), - cardDecoration(isDark, controller, "assets/icons/ic_light_dark.svg", "Dark Mode".tr, () {}), + cardDecoration( + isDark, + controller, + "assets/icons/ic_change_language.svg", + "Change Language".tr, + () { + Get.to(const ChangeLanguageScreen()); + }, + ), + cardDecoration( + isDark, + controller, + "assets/icons/ic_light_dark.svg", + "Dark Mode".tr, + () {}, + ), ], ), ), @@ -142,31 +270,69 @@ class ProfileScreen extends StatelessWidget { const SizedBox(height: 10), Text( "Social".tr, - style: TextStyle(fontSize: 12, color: isDark ? AppThemeData.grey400 : AppThemeData.grey500, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w500), + style: TextStyle( + fontSize: 12, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey500, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w500, + ), ), const SizedBox(height: 10), Container( width: Responsive.width(100, context), - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 8, + ), child: Column( children: [ Constant.userModel == null ? const SizedBox() - : cardDecoration(isDark, controller, "assets/icons/ic_refer.svg", "Refer a Friend".tr, () { - Get.to(const ReferFriendScreen()); - }), - cardDecoration(isDark, controller, "assets/icons/ic_share.svg", "Share app".tr, () { - Share.share( - '${'Check out Foodie, your ultimate food delivery application!'.tr} \n\n${'Google Play:'.tr} ${Constant.googlePlayLink} \n\n${'App Store:'.tr} ${Constant.appStoreLink}', - subject: 'Look what I made!'.tr, - ); - }), - cardDecoration(isDark, controller, "assets/icons/ic_rate.svg", "Rate the app".tr, () { - final InAppReview inAppReview = InAppReview.instance; - inAppReview.requestReview(); - }), + : cardDecoration( + isDark, + controller, + "assets/icons/ic_refer.svg", + "Refer a Friend".tr, + () { + Get.to(const ReferFriendScreen()); + }, + ), + cardDecoration( + isDark, + controller, + "assets/icons/ic_share.svg", + "Share app".tr, + () { + Share.share( + '${'Check out Foodie, your ultimate food delivery application!'.tr} \n\n${'Google Play:'.tr} ${Constant.googlePlayLink} \n\n${'App Store:'.tr} ${Constant.appStoreLink}', + subject: 'Look what I made!'.tr, + ); + }, + ), + cardDecoration( + isDark, + controller, + "assets/icons/ic_rate.svg", + "Rate the app".tr, + () { + final InAppReview inAppReview = + InAppReview.instance; + inAppReview.requestReview(); + }, + ), ], ), ), @@ -179,28 +345,75 @@ class ProfileScreen extends StatelessWidget { children: [ Text( "Communication".tr, - style: TextStyle(fontSize: 12, color: isDark ? AppThemeData.grey400 : AppThemeData.grey500, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w500), + style: TextStyle( + fontSize: 12, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey500, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w500, + ), ), const SizedBox(height: 10), Container( width: Responsive.width(100, context), - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 8, + ), child: Column( children: [ - cardDecoration(isDark, controller, "assets/icons/ic_restaurant_chat.svg", "Store Inbox".tr, () { - Get.to(const RestaurantInboxScreen()); - }), - cardDecoration(isDark, controller, "assets/icons/ic_restaurant_driver.svg", "Driver Inbox".tr, () { - Get.to(const DriverInboxScreen()); - }), - cardDecoration(isDark, controller, "assets/icons/ic_restaurant_chat.svg", "Provider Inbox".tr, () { - Get.to(const ProviderInboxScreen()); - }), - cardDecoration(isDark, controller, "assets/icons/ic_restaurant_driver.svg", "Worker Inbox".tr, () { - Get.to(const WorkerInboxScreen()); - }), + cardDecoration( + isDark, + controller, + "assets/icons/ic_restaurant_chat.svg", + "Store Inbox".tr, + () { + Get.to( + const RestaurantInboxScreen(), + ); + }, + ), + cardDecoration( + isDark, + controller, + "assets/icons/ic_restaurant_driver.svg", + "Driver Inbox".tr, + () { + Get.to(const DriverInboxScreen()); + }, + ), + cardDecoration( + isDark, + controller, + "assets/icons/ic_restaurant_chat.svg", + "Provider Inbox".tr, + () { + Get.to( + const ProviderInboxScreen(), + ); + }, + ), + cardDecoration( + isDark, + controller, + "assets/icons/ic_restaurant_driver.svg", + "Worker Inbox".tr, + () { + Get.to(const WorkerInboxScreen()); + }, + ), ], ), ), @@ -208,21 +421,63 @@ class ProfileScreen extends StatelessWidget { const SizedBox(height: 10), ], ), - Text("Legal".tr, style: TextStyle(fontSize: 12, color: isDark ? AppThemeData.grey400 : AppThemeData.grey500, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w500)), + Text( + "Legal".tr, + style: TextStyle( + fontSize: 12, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey500, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w500, + ), + ), const SizedBox(height: 10), Container( width: Responsive.width(100, context), - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 8, + ), child: Column( children: [ - cardDecoration(isDark, controller, "assets/icons/ic_privacy_policy.svg", "Privacy Policy".tr, () { - Get.to(const TermsAndConditionScreen(type: "privacy")); - }), - cardDecoration(isDark, controller, "assets/icons/ic_tearm_condition.svg", "Terms and Conditions".tr, () { - Get.to(const TermsAndConditionScreen(type: "termAndCondition")); - }), + cardDecoration( + isDark, + controller, + "assets/icons/ic_privacy_policy.svg", + "Privacy Policy".tr, + () { + Get.to( + const TermsAndConditionScreen( + type: "privacy", + ), + ); + }, + ), + cardDecoration( + isDark, + controller, + "assets/icons/ic_tearm_condition.svg", + "Terms and Conditions".tr, + () { + Get.to( + const TermsAndConditionScreen( + type: "termAndCondition", + ), + ); + }, + ), ], ), ), @@ -231,39 +486,74 @@ class ProfileScreen extends StatelessWidget { const SizedBox(height: 10), Container( width: Responsive.width(100, context), - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 6, + ), child: Column( children: [ Constant.userModel == null - ? cardDecoration(isDark, controller, "assets/icons/ic_logout.svg", "Log In".tr, () { - Get.offAll(const LoginScreen()); - }) - : cardDecoration(isDark, controller, "assets/icons/ic_logout.svg", "Log out".tr, () { - showDialog( - context: context, - builder: (BuildContext context) { - return CustomDialogBox( - title: "Log out".tr, - descriptions: "Are you sure you want to log out? You will need to enter your credentials to log back in.".tr, - positiveString: "Log out".tr, - negativeString: "Cancel".tr, - positiveClick: () async { - Constant.userModel!.fcmToken = ""; - await FireStoreUtils.updateUser(Constant.userModel!); - Constant.userModel = null; - await FirebaseAuth.instance.signOut(); - Get.offAll(const LoginScreen()); - }, - negativeClick: () { - Get.back(); - }, - img: Image.asset('assets/images/ic_logout.gif', height: 50, width: 50), - ); - }, - ); - }), + ? cardDecoration( + isDark, + controller, + "assets/icons/ic_logout.svg", + "Log In".tr, + () { + Get.offAll(const LoginScreen()); + }, + ) + : cardDecoration( + isDark, + controller, + "assets/icons/ic_logout.svg", + "Log out".tr, + () { + showDialog( + context: context, + builder: (BuildContext context) { + return CustomDialogBox( + title: "Log out".tr, + descriptions: + "Are you sure you want to log out? You will need to enter your credentials to log back in." + .tr, + positiveString: "Log out".tr, + negativeString: "Cancel".tr, + positiveClick: () async { + Constant.userModel!.fcmToken = + ""; + await FireStoreUtils.updateUser( + Constant.userModel!, + ); + Constant.userModel = null; + await FirebaseAuth.instance + .signOut(); + Get.offAll( + const LoginScreen(), + ); + }, + negativeClick: () { + Get.back(); + }, + img: Image.asset( + 'assets/images/ic_logout.gif', + height: 50, + width: 50, + ), + ); + }, + ); + }, + ), ], ), ), @@ -272,7 +562,9 @@ class ProfileScreen extends StatelessWidget { Constant.userModel == null ? const SizedBox() : Padding( - padding: const EdgeInsets.symmetric(vertical: 20), + padding: const EdgeInsets.symmetric( + vertical: 20, + ), child: InkWell( onTap: () { showDialog( @@ -280,40 +572,66 @@ class ProfileScreen extends StatelessWidget { builder: (BuildContext context) { return CustomDialogBox( title: "Delete Account".tr, - descriptions: "Are you sure you want to delete your account? This action is irreversible and will permanently remove all your data.".tr, + descriptions: + "Are you sure you want to delete your account? This action is irreversible and will permanently remove all your data." + .tr, positiveString: "Delete".tr, negativeString: "Cancel".tr, positiveClick: () async { - ShowToastDialog.showLoader("Please wait...".tr); - await controller.deleteUserFromServer(); - await FireStoreUtils.deleteUser().then((value) { + ShowToastDialog.showLoader( + ConstTexts.pleaseWait.tr, + ); + await controller + .deleteUserFromServer(); + await FireStoreUtils.deleteUser().then(( + value, + ) { ShowToastDialog.closeLoader(); if (value == true) { - ShowToastDialog.showToast("Account deleted successfully".tr); + ShowToastDialog.showToast( + "Account deleted successfully" + .tr, + ); Get.offAll(const LoginScreen()); } else { - ShowToastDialog.showToast("Contact Administrator".tr); + ShowToastDialog.showToast( + "Contact Administrator".tr, + ); } }); }, negativeClick: () { Get.back(); }, - img: Image.asset('assets/icons/delete_dialog.gif', height: 50, width: 50), + img: Image.asset( + 'assets/icons/delete_dialog.gif', + height: 50, + width: 50, + ), ); }, ); }, child: Row( mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, children: [ - SvgPicture.asset("assets/icons/ic_delete.svg"), + SvgPicture.asset( + "assets/icons/ic_delete.svg", + ), const SizedBox(width: 10), Text( "Delete Account".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 16, color: isDark ? AppThemeData.danger300 : AppThemeData.danger300), + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 16, + color: + isDark + ? AppThemeData.danger300 + : AppThemeData.danger300, + ), ), ], ), @@ -323,7 +641,14 @@ class ProfileScreen extends StatelessWidget { child: Text( "V : ${Constant.appVersion}", textAlign: TextAlign.center, - style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 14, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 14, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), ), ], @@ -337,7 +662,13 @@ class ProfileScreen extends StatelessWidget { ); } - Padding cardDecoration(bool isDark, MyProfileController controller, String image, String title, Function()? onPress) { + Padding cardDecoration( + bool isDark, + MyProfileController controller, + String image, + String title, + Function()? onPress, + ) { return Padding( padding: const EdgeInsets.symmetric(vertical: 10), child: InkWell( @@ -347,7 +678,18 @@ class ProfileScreen extends StatelessWidget { }, child: Row( children: [ - SvgPicture.asset(image, colorFilter: title == "Log In".tr || title == "Cashbacks".tr ? const ColorFilter.mode(AppThemeData.success500, BlendMode.srcIn) : null, height: 24, width: 24), + SvgPicture.asset( + image, + colorFilter: + title == "Log In".tr || title == "Cashbacks".tr + ? const ColorFilter.mode( + AppThemeData.success500, + BlendMode.srcIn, + ) + : null, + height: 24, + width: 24, + ), const SizedBox(width: 10), Expanded( child: Text( @@ -361,16 +703,28 @@ class ProfileScreen extends StatelessWidget { ? AppThemeData.danger300 : title == "Log In".tr ? AppThemeData.success500 - : (isDark ? AppThemeData.grey100 : AppThemeData.grey800), + : (isDark + ? AppThemeData.grey100 + : AppThemeData.grey800), ), ), ), title == "Dark Mode".tr ? Transform.scale( scale: 0.8, - child: Obx(() => CupertinoSwitch(value: controller.isDarkModeSwitch.value, activeTrackColor: AppThemeData.primary300, onChanged: controller.toggleDarkMode)), + child: Obx( + () => CupertinoSwitch( + value: controller.isDarkModeSwitch.value, + activeTrackColor: AppThemeData.primary300, + onChanged: controller.toggleDarkMode, + ), + ), ) - : Icon(Icons.keyboard_arrow_right, color: isDark ? AppThemeData.greyDark700 : AppThemeData.grey700), + : Icon( + Icons.keyboard_arrow_right, + color: + isDark ? AppThemeData.greyDark700 : AppThemeData.grey700, + ), ], ), ), diff --git a/lib/screen_ui/multi_vendor_service/rate_us_screen/rate_product_screen.dart b/lib/screen_ui/multi_vendor_service/rate_us_screen/rate_product_screen.dart index 14f1542..5902970 100644 --- a/lib/screen_ui/multi_vendor_service/rate_us_screen/rate_product_screen.dart +++ b/lib/screen_ui/multi_vendor_service/rate_us_screen/rate_product_screen.dart @@ -6,6 +6,7 @@ import 'package:customer/themes/responsive.dart'; import 'package:customer/themes/round_button_fill.dart'; import 'package:customer/utils/network_image_widget.dart'; import 'package:dotted_border/dotted_border.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:flutter_svg/flutter_svg.dart'; @@ -26,33 +27,74 @@ class RateProductScreen extends StatelessWidget { init: RateProductController(), builder: (controller) { return Scaffold( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, appBar: AppBar( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, centerTitle: false, titleSpacing: 0, - title: Text("Rate the item".tr, textAlign: TextAlign.start, style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900)), + title: Text( + "Rate the item".tr, + textAlign: TextAlign.start, + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 16, + color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + ), + ), ), body: controller.isLoading.value ? Constant.loader() : Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: SingleChildScrollView( child: Column( children: [ Container( width: Responsive.width(100, context), - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 20), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 20, + ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("Rate for".tr, style: TextStyle(color: isDark ? AppThemeData.grey400 : AppThemeData.grey500, fontSize: 16, fontFamily: AppThemeData.medium)), + Text( + "Rate for".tr, + style: TextStyle( + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey500, + fontSize: 16, + fontFamily: AppThemeData.medium, + ), + ), Text( "${controller.productModel.value.name}".tr, - style: TextStyle(color: isDark ? AppThemeData.grey100 : AppThemeData.grey800, fontSize: 18, fontFamily: AppThemeData.semiBold), + style: TextStyle( + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey800, + fontSize: 18, + fontFamily: AppThemeData.semiBold, + ), ), const SizedBox(height: 10), RatingBar.builder( @@ -61,42 +103,109 @@ class RateProductScreen extends StatelessWidget { direction: Axis.horizontal, itemCount: 5, itemSize: 26, - unratedColor: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, - itemPadding: const EdgeInsets.symmetric(horizontal: 6.0), - itemBuilder: (context, _) => const Icon(Icons.star, color: AppThemeData.warning300), + unratedColor: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + itemPadding: const EdgeInsets.symmetric( + horizontal: 6.0, + ), + itemBuilder: + (context, _) => const Icon( + Icons.star, + color: AppThemeData.warning300, + ), onRatingUpdate: (double rate) { controller.ratings.value = rate; }, ), - Padding(padding: const EdgeInsets.symmetric(vertical: 20), child: MySeparator(color: isDark ? AppThemeData.grey700 : AppThemeData.grey200)), + Padding( + padding: const EdgeInsets.symmetric( + vertical: 20, + ), + child: MySeparator( + color: + isDark + ? AppThemeData.grey700 + : AppThemeData.grey200, + ), + ), ListView.builder( - itemCount: controller.reviewAttributeList.length, + itemCount: + controller.reviewAttributeList.length, shrinkWrap: true, - physics: const NeverScrollableScrollPhysics(), + physics: + const NeverScrollableScrollPhysics(), padding: EdgeInsets.zero, itemBuilder: (context, index) { return Padding( - padding: const EdgeInsets.symmetric(vertical: 2), + padding: const EdgeInsets.symmetric( + vertical: 2, + ), child: Row( children: [ Expanded( child: Text( - controller.reviewAttributeList[index].title.toString(), - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16, fontFamily: AppThemeData.semiBold), + controller + .reviewAttributeList[index] + .title + .toString(), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData + .grey900, + fontSize: 16, + fontFamily: + AppThemeData.semiBold, + ), ), ), RatingBar.builder( initialRating: - controller.ratingModel.value.id == null ? 0.0 : controller.ratingModel.value.reviewAttributes?[controller.reviewAttributeList[index].id] ?? 0.0, + controller + .ratingModel + .value + .id == + null + ? 0.0 + : controller + .ratingModel + .value + .reviewAttributes?[controller + .reviewAttributeList[index] + .id] ?? + 0.0, minRating: 1, direction: Axis.horizontal, itemCount: 5, itemSize: 18, - unratedColor: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, - itemPadding: const EdgeInsets.symmetric(horizontal: 2.0), - itemBuilder: (context, _) => const Icon(Icons.star, color: AppThemeData.warning300), + unratedColor: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + itemPadding: + const EdgeInsets.symmetric( + horizontal: 2.0, + ), + itemBuilder: + (context, _) => const Icon( + Icons.star, + color: + AppThemeData.warning300, + ), onRatingUpdate: (double rate) { - controller.reviewAttribute.addEntries([MapEntry(controller.reviewAttributeList[index].id.toString(), rate)]); + controller.reviewAttribute + .addEntries([ + MapEntry( + controller + .reviewAttributeList[index] + .id + .toString(), + rate, + ), + ]); }, ), ], @@ -109,34 +218,72 @@ class RateProductScreen extends StatelessWidget { options: RoundedRectDottedBorderOptions( radius: const Radius.circular(12), dashPattern: const [6, 6, 6, 6], - color: isDark ? AppThemeData.grey700 : AppThemeData.grey200, + color: + isDark + ? AppThemeData.grey700 + : AppThemeData.grey200, ), child: Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, borderRadius: const BorderRadius.all(Radius.circular(12))), + decoration: BoxDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + borderRadius: const BorderRadius.all( + Radius.circular(12), + ), + ), child: SizedBox( height: Responsive.height(20, context), width: Responsive.width(90, context), child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment.center, children: [ - SvgPicture.asset('assets/icons/ic_folder.svg'), + SvgPicture.asset( + 'assets/icons/ic_folder.svg', + ), const SizedBox(height: 10), Text( - "Choose a image and upload here".tr, - style: TextStyle(color: isDark ? AppThemeData.grey100 : AppThemeData.grey800, fontFamily: AppThemeData.medium, fontSize: 16), + "Choose a image and upload here" + .tr, + style: TextStyle( + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey800, + fontFamily: AppThemeData.medium, + fontSize: 16, + ), ), const SizedBox(height: 5), - Text("JPEG, PNG".tr, style: TextStyle(fontSize: 12, color: isDark ? AppThemeData.grey200 : AppThemeData.grey700, fontFamily: AppThemeData.regular)), + Text( + "JPEG, PNG".tr, + style: TextStyle( + fontSize: 12, + color: + isDark + ? AppThemeData.grey200 + : AppThemeData.grey700, + fontFamily: + AppThemeData.regular, + ), + ), const SizedBox(height: 10), RoundedButtonFill( title: "Brows Image".tr, color: AppThemeData.primary50, width: 30, height: 5, - textColor: AppThemeData.primary300, + textColor: + AppThemeData.primary300, onPress: () async { - buildBottomSheet(context, controller); + buildBottomSheet( + context, + controller, + ); }, ), ], @@ -153,21 +300,54 @@ class RateProductScreen extends StatelessWidget { children: [ Expanded( child: ListView.builder( - itemCount: controller.images.length, + itemCount: + controller.images.length, shrinkWrap: true, - scrollDirection: Axis.horizontal, + scrollDirection: + Axis.horizontal, // physics: const NeverScrollableScrollPhysics(), itemBuilder: (context, index) { return Padding( - padding: const EdgeInsets.symmetric(horizontal: 5), + padding: + const EdgeInsets.symmetric( + horizontal: 5, + ), child: Stack( children: [ ClipRRect( - borderRadius: const BorderRadius.all(Radius.circular(10)), + borderRadius: + const BorderRadius.all( + Radius.circular( + 10, + ), + ), child: - (controller.images[index] is XFile) - ? Image.file(File((controller.images[index] as XFile).path), fit: BoxFit.cover, width: 80, height: 80) - : NetworkImageWidget(imageUrl: controller.images[index]?.toString() ?? '', fit: BoxFit.cover, width: 80, height: 80), + (controller.images[index] + is XFile) + ? Image.file( + File( + (controller.images[index] + as XFile) + .path, + ), + fit: + BoxFit + .cover, + width: 80, + height: 80, + ) + : NetworkImageWidget( + imageUrl: + controller + .images[index] + ?.toString() ?? + '', + fit: + BoxFit + .cover, + width: 80, + height: 80, + ), // controller.images[index].runtimeType == XFile // ? Image.file(File(controller.images[index].path), fit: BoxFit.cover, width: 80, height: 80) // : NetworkImageWidget(imageUrl: controller.images[index], fit: BoxFit.cover, width: 80, height: 80), @@ -179,9 +359,19 @@ class RateProductScreen extends StatelessWidget { right: 0, child: InkWell( onTap: () { - controller.images.removeAt(index); + controller.images + .removeAt( + index, + ); }, - child: const Icon(Icons.remove_circle, size: 28, color: AppThemeData.danger300), + child: const Icon( + Icons + .remove_circle, + size: 28, + color: + AppThemeData + .danger300, + ), ), ), ], @@ -198,26 +388,49 @@ class RateProductScreen extends StatelessWidget { options: RoundedRectDottedBorderOptions( radius: const Radius.circular(12), dashPattern: const [6, 6, 6, 6], - color: isDark ? AppThemeData.grey700 : AppThemeData.grey200, + color: + isDark + ? AppThemeData.grey700 + : AppThemeData.grey200, ), child: TextFormField( keyboardType: TextInputType.text, - textCapitalization: TextCapitalization.sentences, - controller: controller.commentController.value, + textCapitalization: + TextCapitalization.sentences, + controller: + controller.commentController.value, maxLines: 4, textInputAction: TextInputAction.done, - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.medium), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.medium, + ), decoration: InputDecoration( - errorStyle: const TextStyle(color: Colors.red), + errorStyle: const TextStyle( + color: Colors.red, + ), filled: true, - fillColor: isDark ? AppThemeData.grey900 : AppThemeData.grey50, + fillColor: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, disabledBorder: InputBorder.none, focusedBorder: InputBorder.none, enabledBorder: InputBorder.none, errorBorder: InputBorder.none, border: InputBorder.none, hintText: "Type comment".tr, - hintStyle: TextStyle(fontSize: 14, color: isDark ? AppThemeData.grey600 : AppThemeData.grey400, fontFamily: AppThemeData.regular), + hintStyle: TextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.grey600 + : AppThemeData.grey400, + fontFamily: AppThemeData.regular, + ), ), ), ), @@ -250,7 +463,10 @@ class RateProductScreen extends StatelessWidget { ); } - Future buildBottomSheet(BuildContext context, RateProductController controller) { + Future buildBottomSheet( + BuildContext context, + RateProductController controller, + ) { return showModalBottomSheet( context: context, builder: (context) { @@ -265,7 +481,15 @@ class RateProductScreen extends StatelessWidget { children: [ Padding( padding: const EdgeInsets.only(top: 15), - child: Text("Please Select".tr, style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.bold, fontSize: 16)), + child: Text( + "Please Select".tr, + style: TextStyle( + color: + isDark ? AppThemeData.grey50 : AppThemeData.grey900, + fontFamily: AppThemeData.bold, + fontSize: 16, + ), + ), ), Row( mainAxisAlignment: MainAxisAlignment.center, @@ -276,8 +500,17 @@ class RateProductScreen extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ - IconButton(onPressed: () => controller.pickFile(source: ImageSource.camera), icon: const Icon(Icons.camera_alt, size: 32)), - Padding(padding: const EdgeInsets.only(top: 3), child: Text("Camera".tr)), + IconButton( + onPressed: + () => controller.pickFile( + source: ImageSource.camera, + ), + icon: const Icon(Icons.camera_alt, size: 32), + ), + Padding( + padding: const EdgeInsets.only(top: 3), + child: Text("Camera".tr), + ), ], ), ), @@ -287,8 +520,20 @@ class RateProductScreen extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ - IconButton(onPressed: () => controller.pickFile(source: ImageSource.gallery), icon: const Icon(Icons.photo_library_sharp, size: 32)), - Padding(padding: const EdgeInsets.only(top: 3), child: Text("Gallery".tr)), + IconButton( + onPressed: + () => controller.pickFile( + source: ImageSource.gallery, + ), + icon: const Icon( + Icons.photo_library_sharp, + size: 32, + ), + ), + Padding( + padding: const EdgeInsets.only(top: 3), + child: Text("Gallery".tr), + ), ], ), ), diff --git a/lib/screen_ui/multi_vendor_service/refer_friend_screen/refer_friend_screen.dart b/lib/screen_ui/multi_vendor_service/refer_friend_screen/refer_friend_screen.dart index f2f6c03..f2ce0e2 100644 --- a/lib/screen_ui/multi_vendor_service/refer_friend_screen/refer_friend_screen.dart +++ b/lib/screen_ui/multi_vendor_service/refer_friend_screen/refer_friend_screen.dart @@ -3,6 +3,7 @@ import 'package:customer/controllers/refer_friend_controller.dart'; import 'package:customer/themes/app_them_data.dart'; import 'package:customer/themes/responsive.dart'; import 'package:customer/themes/round_button_fill.dart'; + import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_svg/flutter_svg.dart'; @@ -29,9 +30,16 @@ class ReferFriendScreen extends StatelessWidget { : Container( width: Responsive.width(100, context), height: Responsive.height(100, context), - decoration: const BoxDecoration(image: DecorationImage(image: AssetImage("assets/images/refer_friend.png"), fit: BoxFit.fill)), + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage("assets/images/refer_friend.png"), + fit: BoxFit.fill, + ), + ), child: Padding( - padding: EdgeInsets.only(top: MediaQuery.of(context).viewPadding.top), + padding: EdgeInsets.only( + top: MediaQuery.of(context).viewPadding.top, + ), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: Column( @@ -41,30 +49,56 @@ class ReferFriendScreen extends StatelessWidget { onTap: () { Get.back(); }, - child: const Icon(Icons.arrow_back, color: AppThemeData.grey50), + child: const Icon( + Icons.arrow_back, + color: AppThemeData.grey50, + ), ), Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ const SizedBox(height: 60), - Center(child: SvgPicture.asset("assets/images/referal_top.svg")), + Center( + child: SvgPicture.asset( + "assets/images/referal_top.svg", + ), + ), const SizedBox(height: 10), Text( "Refer your friend and earn".tr, - style: TextStyle(fontSize: 22, color: isDark ? AppThemeData.grey50 : AppThemeData.grey50, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w500), + style: TextStyle( + fontSize: 22, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey50, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w500, + ), ), const SizedBox(width: 4), Text( "${Constant.amountShow(amount: Constant.sectionConstantModel!.referralAmount)} ${'Each🎉'.tr}", - style: TextStyle(fontSize: 24, color: isDark ? AppThemeData.grey50 : AppThemeData.grey50, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w500), + style: TextStyle( + fontSize: 24, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey50, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w500, + ), ), const SizedBox(height: 32), Text( "Invite Friends & Businesses".tr, style: TextStyle( fontSize: 16, - color: isDark ? AppThemeData.ecommerce100 : AppThemeData.ecommerceDark100, + color: + isDark + ? AppThemeData.ecommerce100 + : AppThemeData.ecommerceDark100, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w500, ), @@ -74,25 +108,60 @@ class ReferFriendScreen extends StatelessWidget { "${'Invite your friends to sign up with Foodie using your code, and you’ll earn'.tr} ${Constant.amountShow(amount: Constant.sectionConstantModel!.referralAmount)} ${'after their Success the first order! 💸🍔'.tr}" .tr, textAlign: TextAlign.center, - style: TextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey50, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w500), + style: TextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey50, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w500, + ), ), const SizedBox(height: 40), Container( decoration: ShapeDecoration( - gradient: const LinearGradient(begin: Alignment(0.00, -1.00), end: Alignment(0, 1), colors: [Color(0xFF271366), Color(0xFF4826B2)]), - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120)), - shadows: const [BoxShadow(color: Color(0x14FFFFFF), blurRadius: 120, offset: Offset(0, 0), spreadRadius: 0)], + gradient: const LinearGradient( + begin: Alignment(0.00, -1.00), + end: Alignment(0, 1), + colors: [ + Color(0xFF271366), + Color(0xFF4826B2), + ], + ), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(120), + ), + shadows: const [ + BoxShadow( + color: Color(0x14FFFFFF), + blurRadius: 120, + offset: Offset(0, 0), + spreadRadius: 0, + ), + ], ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 80, vertical: 16), + padding: const EdgeInsets.symmetric( + horizontal: 80, + vertical: 16, + ), child: Row( mainAxisSize: MainAxisSize.min, children: [ Text( - controller.referralModel.value.referralCode.toString(), + controller + .referralModel + .value + .referralCode + .toString(), style: TextStyle( fontSize: 16, - color: isDark ? AppThemeData.ecommerce100 : AppThemeData.ecommerceDark100, + color: + isDark + ? AppThemeData.ecommerce100 + : AppThemeData + .ecommerceDark100, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w500, ), @@ -100,34 +169,74 @@ class ReferFriendScreen extends StatelessWidget { const SizedBox(width: 10), InkWell( onTap: () { - Clipboard.setData(ClipboardData(text: controller.referralModel.value.referralCode.toString())); - ShowToastDialog.showToast("Copied".tr); + Clipboard.setData( + ClipboardData( + text: + controller + .referralModel + .value + .referralCode + .toString(), + ), + ); + ShowToastDialog.showToast( + "Copied".tr, + ); }, - child: const Icon(Icons.copy, color: AppThemeData.ecommerce100), + child: const Icon( + Icons.copy, + color: AppThemeData.ecommerce100, + ), ), ], ), ), ), Padding( - padding: const EdgeInsets.symmetric(horizontal: 40), + padding: const EdgeInsets.symmetric( + horizontal: 40, + ), child: Row( children: [ - Expanded(child: Divider(thickness: 1, color: isDark ? AppThemeData.ecommerce100 : AppThemeData.ecommerceDark100)), + Expanded( + child: Divider( + thickness: 1, + color: + isDark + ? AppThemeData.ecommerce100 + : AppThemeData + .ecommerceDark100, + ), + ), Padding( - padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 30), + padding: const EdgeInsets.symmetric( + horizontal: 20, + vertical: 30, + ), child: Text( "or".tr, textAlign: TextAlign.center, style: TextStyle( - color: isDark ? AppThemeData.ecommerce100 : AppThemeData.ecommerceDark100, + color: + isDark + ? AppThemeData.ecommerce100 + : AppThemeData + .ecommerceDark100, fontSize: 12, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500, ), ), ), - Expanded(child: Divider(color: isDark ? AppThemeData.ecommerce100 : AppThemeData.ecommerceDark100)), + Expanded( + child: Divider( + color: + isDark + ? AppThemeData.ecommerce100 + : AppThemeData + .ecommerceDark100, + ), + ), ], ), ), diff --git a/lib/screen_ui/multi_vendor_service/restaurant_details_screen/restaurant_details_screen.dart b/lib/screen_ui/multi_vendor_service/restaurant_details_screen/restaurant_details_screen.dart index 690a53e..cce2b6e 100644 --- a/lib/screen_ui/multi_vendor_service/restaurant_details_screen/restaurant_details_screen.dart +++ b/lib/screen_ui/multi_vendor_service/restaurant_details_screen/restaurant_details_screen.dart @@ -1,4 +1,7 @@ +import 'dart:developer'; + import 'package:badges/badges.dart' as badges; +import 'package:customer/constant/const_texts.dart'; import 'package:customer/constant/constant.dart'; import 'package:customer/controllers/restaurant_details_controller.dart'; import 'package:customer/models/cart_product_model.dart'; @@ -13,11 +16,11 @@ import 'package:customer/themes/responsive.dart'; import 'package:customer/themes/round_button_fill.dart'; import 'package:customer/themes/text_field_widget.dart'; import 'package:customer/utils/network_image_widget.dart'; + import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:get/get.dart'; - import '../../../controllers/theme_controller.dart'; import '../../../service/fire_store_utils.dart'; import '../../../themes/show_toast_dialog.dart'; @@ -51,14 +54,32 @@ class RestaurantDetailsScreen extends StatelessWidget { child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text('${cartItem.length} ${"items".tr}', style: TextStyle(fontFamily: AppThemeData.medium, color: AppThemeData.grey50, fontSize: 16)), - Text('View Cart'.tr, style: TextStyle(fontFamily: AppThemeData.semiBold, color: AppThemeData.grey50, fontSize: 16, fontWeight: FontWeight.bold)), + Text( + '${cartItem.length} ${"items".tr}', + style: TextStyle( + fontFamily: AppThemeData.medium, + color: AppThemeData.grey50, + fontSize: 16, + ), + ), + Text( + ConstTexts.viewCart.tr, + style: TextStyle( + fontFamily: AppThemeData.semiBold, + color: AppThemeData.grey50, + fontSize: 16, + fontWeight: FontWeight.bold, + ), + ), ], ), ), ), body: NestedScrollView( - headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { + headerSliverBuilder: ( + BuildContext context, + bool innerBoxIsScrolled, + ) { return [ SliverAppBar( expandedHeight: Responsive.height(30, context), @@ -72,24 +93,48 @@ class RestaurantDetailsScreen extends StatelessWidget { onTap: () { Get.back(); }, - child: Icon(Icons.arrow_back, color: isDark ? AppThemeData.grey50 : AppThemeData.grey50), + child: Icon( + Icons.arrow_back, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey50, + ), ), const Expanded(child: SizedBox()), Visibility( - visible: (controller.vendorModel.value.isSelfDelivery == true && Constant.isSelfDeliveryFeature == true), + visible: + (controller.vendorModel.value.isSelfDelivery == + true && + Constant.isSelfDeliveryFeature == true), child: Row( children: [ Container( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 7), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 7, + ), decoration: BoxDecoration( color: AppThemeData.primary300, - borderRadius: BorderRadius.circular(120), // Optional + borderRadius: BorderRadius.circular( + 120, + ), // Optional ), child: Row( children: [ - SvgPicture.asset("assets/icons/ic_free_delivery.svg"), + SvgPicture.asset( + "assets/icons/ic_free_delivery.svg", + ), const SizedBox(width: 5), - Text("Free Delivery".tr, style: TextStyle(fontSize: 14, color: AppThemeData.carRent600, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600)), + Text( + ConstTexts.freeDelivery.tr, + style: TextStyle( + fontSize: 14, + color: AppThemeData.carRent600, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w600, + ), + ), ], ), ), @@ -99,21 +144,55 @@ class RestaurantDetailsScreen extends StatelessWidget { ), InkWell( onTap: () async { - if (controller.favouriteList.where((p0) => p0.restaurantId == controller.vendorModel.value.id).isNotEmpty) { - FavouriteModel favouriteModel = FavouriteModel(restaurantId: controller.vendorModel.value.id, userId: FireStoreUtils.getCurrentUid()); - controller.favouriteList.removeWhere((item) => item.restaurantId == controller.vendorModel.value.id); - await FireStoreUtils.removeFavouriteRestaurant(favouriteModel); + if (controller.favouriteList + .where( + (p0) => + p0.restaurantId == + controller.vendorModel.value.id, + ) + .isNotEmpty) { + FavouriteModel favouriteModel = FavouriteModel( + restaurantId: controller.vendorModel.value.id, + userId: FireStoreUtils.getCurrentUid(), + ); + controller.favouriteList.removeWhere( + (item) => + item.restaurantId == + controller.vendorModel.value.id, + ); + await FireStoreUtils.removeFavouriteRestaurant( + favouriteModel, + ); } else { - FavouriteModel favouriteModel = FavouriteModel(restaurantId: controller.vendorModel.value.id, userId: FireStoreUtils.getCurrentUid()); + FavouriteModel favouriteModel = FavouriteModel( + restaurantId: controller.vendorModel.value.id, + userId: FireStoreUtils.getCurrentUid(), + ); controller.favouriteList.add(favouriteModel); - await FireStoreUtils.setFavouriteRestaurant(favouriteModel); + await FireStoreUtils.setFavouriteRestaurant( + favouriteModel, + ); } }, child: Obx( () => - controller.favouriteList.where((p0) => p0.restaurantId == controller.vendorModel.value.id).isNotEmpty - ? SvgPicture.asset("assets/icons/ic_like_fill.svg", colorFilter: const ColorFilter.mode(AppThemeData.grey50, BlendMode.srcIn)) - : SvgPicture.asset("assets/icons/ic_like.svg"), + controller.favouriteList + .where( + (p0) => + p0.restaurantId == + controller.vendorModel.value.id, + ) + .isNotEmpty + ? SvgPicture.asset( + "assets/icons/ic_like_fill.svg", + colorFilter: const ColorFilter.mode( + AppThemeData.grey50, + BlendMode.srcIn, + ), + ) + : SvgPicture.asset( + "assets/icons/ic_like.svg", + ), ), ), const SizedBox(width: 10), @@ -127,16 +206,30 @@ class RestaurantDetailsScreen extends StatelessWidget { overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey50, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey50, ), ), - badgeStyle: badges.BadgeStyle(shape: badges.BadgeShape.circle, badgeColor: AppThemeData.ecommerce300), + badgeStyle: badges.BadgeStyle( + shape: badges.BadgeShape.circle, + badgeColor: AppThemeData.ecommerce300, + ), child: InkWell( onTap: () { Get.to(const CartScreen()); }, child: ClipOval( - child: SvgPicture.asset("assets/icons/ic_shoping_cart.svg", width: 24, height: 24, colorFilter: const ColorFilter.mode(AppThemeData.grey50, BlendMode.srcIn)), + child: SvgPicture.asset( + "assets/icons/ic_shoping_cart.svg", + width: 24, + height: 24, + colorFilter: const ColorFilter.mode( + AppThemeData.grey50, + BlendMode.srcIn, + ), + ), ), ), ), @@ -146,18 +239,28 @@ class RestaurantDetailsScreen extends StatelessWidget { flexibleSpace: FlexibleSpaceBar( background: Stack( children: [ - controller.vendorModel.value.photos == null || controller.vendorModel.value.photos!.isEmpty + controller.vendorModel.value.photos == null || + controller.vendorModel.value.photos!.isEmpty ? Stack( children: [ NetworkImageWidget( - imageUrl: controller.vendorModel.value.photo.toString(), + imageUrl: + controller.vendorModel.value.photo + .toString(), fit: BoxFit.cover, width: Responsive.width(100, context), height: Responsive.height(40, context), ), Container( decoration: BoxDecoration( - gradient: LinearGradient(begin: const Alignment(0.00, -1.00), end: const Alignment(0, 1), colors: [Colors.black.withOpacity(0), Colors.black]), + gradient: LinearGradient( + begin: const Alignment(0.00, -1.00), + end: const Alignment(0, 1), + colors: [ + Colors.black.withValues(alpha: 0), + Colors.black, + ], + ), ), ), ], @@ -166,18 +269,32 @@ class RestaurantDetailsScreen extends StatelessWidget { physics: const BouncingScrollPhysics(), controller: controller.pageController.value, scrollDirection: Axis.horizontal, - itemCount: controller.vendorModel.value.photos!.length, + itemCount: + controller.vendorModel.value.photos!.length, padEnds: false, pageSnapping: true, allowImplicitScrolling: true, itemBuilder: (BuildContext context, int index) { - String image = controller.vendorModel.value.photos![index]; + String image = + controller.vendorModel.value.photos![index]; return Stack( children: [ - NetworkImageWidget(imageUrl: image.toString(), fit: BoxFit.cover, width: Responsive.width(100, context), height: Responsive.height(40, context)), + NetworkImageWidget( + imageUrl: image.toString(), + fit: BoxFit.cover, + width: Responsive.width(100, context), + height: Responsive.height(40, context), + ), Container( decoration: BoxDecoration( - gradient: LinearGradient(begin: const Alignment(0.00, -1.00), end: const Alignment(0, 1), colors: [Colors.black.withOpacity(0), Colors.black]), + gradient: LinearGradient( + begin: const Alignment(0.00, -1.00), + end: const Alignment(0, 1), + colors: [ + Colors.black.withValues(alpha: 0), + Colors.black, + ], + ), ), ), ], @@ -191,17 +308,26 @@ class RestaurantDetailsScreen extends StatelessWidget { child: Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, - children: List.generate(controller.vendorModel.value.photos!.length, (index) { - return Obx( - () => Container( - margin: const EdgeInsets.only(right: 5), - alignment: Alignment.centerLeft, - height: 9, - width: 9, - decoration: BoxDecoration(shape: BoxShape.circle, color: controller.currentPage.value == index ? AppThemeData.primary300 : AppThemeData.grey300), - ), - ); - }), + children: List.generate( + controller.vendorModel.value.photos!.length, + (index) { + return Obx( + () => Container( + margin: const EdgeInsets.only(right: 5), + alignment: Alignment.centerLeft, + height: 9, + width: 9, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: + controller.currentPage.value == index + ? AppThemeData.primary300 + : AppThemeData.grey300, + ), + ), + ); + }, + ), ), ), ], @@ -222,38 +348,64 @@ class RestaurantDetailsScreen extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), + padding: const EdgeInsets.symmetric( + horizontal: 16, + ), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Expanded( child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( - controller.vendorModel.value.title.toString(), + controller.vendorModel.value.title + .toString(), textAlign: TextAlign.start, maxLines: 1, style: TextStyle( fontSize: 22, overflow: TextOverflow.ellipsis, - fontFamily: AppThemeData.semiBold, + fontFamily: + AppThemeData.semiBold, fontWeight: FontWeight.w600, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, ), ), SizedBox( - width: Responsive.width(78, context), + width: Responsive.width( + 78, + context, + ), child: Text( - controller.vendorModel.value.location.toString(), + controller + .vendorModel + .value + .location + .toString(), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500, color: isDark ? AppThemeData.grey400 : AppThemeData.grey400), + style: TextStyle( + fontFamily: + AppThemeData.medium, + fontWeight: FontWeight.w500, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData + .grey400, + ), ), ), ], @@ -263,21 +415,60 @@ class RestaurantDetailsScreen extends StatelessWidget { children: [ Container( decoration: ShapeDecoration( - color: isDark ? AppThemeData.primary600 : AppThemeData.primary50, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120)), + color: + isDark + ? AppThemeData.primary600 + : AppThemeData.primary50, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(120), + ), ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4), + padding: + const EdgeInsets.symmetric( + horizontal: 12, + vertical: 4, + ), child: Row( children: [ - SvgPicture.asset("assets/icons/ic_star.svg", colorFilter: ColorFilter.mode(AppThemeData.primary300, BlendMode.srcIn)), + SvgPicture.asset( + "assets/icons/ic_star.svg", + colorFilter: + ColorFilter.mode( + AppThemeData + .primary300, + BlendMode.srcIn, + ), + ), const SizedBox(width: 5), Text( Constant.calculateReview( - reviewCount: controller.vendorModel.value.reviewsCount.toString(), - reviewSum: controller.vendorModel.value.reviewsSum.toString(), + reviewCount: + controller + .vendorModel + .value + .reviewsCount + .toString(), + reviewSum: + controller + .vendorModel + .value + .reviewsSum + .toString(), + ), + style: TextStyle( + color: + isDark + ? AppThemeData + .primary300 + : AppThemeData + .primary300, + fontFamily: + AppThemeData.semiBold, + fontWeight: + FontWeight.w600, ), - style: TextStyle(color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600), ), ], ), @@ -285,23 +476,45 @@ class RestaurantDetailsScreen extends StatelessWidget { ), InkWell( onTap: () { - Get.to(const ReviewListScreen(), arguments: {"vendorModel": controller.vendorModel.value}); + Get.to( + const ReviewListScreen(), + arguments: { + "vendorModel": + controller + .vendorModel + .value, + }, + ); }, child: Text( "${controller.vendorModel.value.reviewsCount} ${'Ratings'.tr}", - style: TextStyle(decoration: TextDecoration.underline, color: isDark ? AppThemeData.grey200 : AppThemeData.grey700, fontFamily: AppThemeData.regular), + style: TextStyle( + decoration: + TextDecoration.underline, + color: + isDark + ? AppThemeData.grey200 + : AppThemeData.grey700, + fontFamily: + AppThemeData.regular, + ), ), ), ], ), ], ), - Constant.sectionConstantModel!.serviceTypeFlag == "ecommerce-service" + Constant + .sectionConstantModel! + .serviceTypeFlag == + "ecommerce-service" ? SizedBox() : Row( children: [ Text( - controller.isOpen.value ? "Open".tr : "Close".tr, + controller.isOpen.value + ? "Open".tr + : "Close".tr, textAlign: TextAlign.start, maxLines: 1, style: TextStyle( @@ -309,42 +522,88 @@ class RestaurantDetailsScreen extends StatelessWidget { overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600, - color: controller.isOpen.value ? AppThemeData.success400 : AppThemeData.danger300, + color: + controller.isOpen.value + ? AppThemeData.success400 + : AppThemeData.danger300, + ), + ), + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 10, + ), + child: Icon( + Icons.circle, + size: 5, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey500, ), ), - Padding(padding: const EdgeInsets.symmetric(horizontal: 10), child: Icon(Icons.circle, size: 5, color: isDark ? AppThemeData.grey400 : AppThemeData.grey500)), InkWell( onTap: () { - if (controller.vendorModel.value.workingHours!.isEmpty) { - ShowToastDialog.showToast("Timing is not added by store".tr); + if (controller + .vendorModel + .value + .workingHours! + .isEmpty) { + ShowToastDialog.showToast( + ConstTexts.timingIsNotAdded + .tr, + ); } else { - timeShowBottomSheet(context, controller); + timeShowBottomSheet( + context, + controller, + ); } }, child: Text( - "View Timings".tr, + ConstTexts.viewTimings.tr, textAlign: TextAlign.start, maxLines: 1, style: TextStyle( fontSize: 14, - decoration: TextDecoration.underline, - decorationColor: AppThemeData.ecommerce300, + decoration: + TextDecoration.underline, + decorationColor: + AppThemeData.ecommerce300, overflow: TextOverflow.ellipsis, - fontFamily: AppThemeData.semiBold, + fontFamily: + AppThemeData.semiBold, fontWeight: FontWeight.w600, - color: isDark ? AppThemeData.ecommerce300 : AppThemeData.ecommerce300, + color: + isDark + ? AppThemeData + .ecommerce300 + : AppThemeData + .ecommerce300, ), ), ), ], ), - controller.vendorModel.value.dineInActive == true || (controller.vendorModel.value.openDineTime != null && controller.vendorModel.value.openDineTime!.isNotEmpty) + controller.vendorModel.value.dineInActive == + true || + (controller + .vendorModel + .value + .openDineTime != + null && + controller + .vendorModel + .value + .openDineTime! + .isNotEmpty) ? Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ const SizedBox(height: 20), Text( - "Also applicable on table booking".tr, + ConstTexts.alsoApplicableOnTable + .tr, textAlign: TextAlign.start, maxLines: 1, style: TextStyle( @@ -352,52 +611,105 @@ class RestaurantDetailsScreen extends StatelessWidget { overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, ), ), const SizedBox(height: 10), InkWell( onTap: () { - Get.to(const DineInDetailsScreen(), arguments: {"vendorModel": controller.vendorModel.value}); + Get.to( + const DineInDetailsScreen(), + arguments: { + "vendorModel": + controller + .vendorModel + .value, + }, + ); }, child: Container( height: 80, clipBehavior: Clip.antiAlias, decoration: ShapeDecoration( - color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, shape: RoundedRectangleBorder( - side: BorderSide(width: 1, color: isDark ? AppThemeData.grey900 : AppThemeData.grey50), - borderRadius: BorderRadius.circular(16), + side: BorderSide( + width: 1, + color: + isDark + ? AppThemeData + .grey900 + : AppThemeData + .grey50, + ), + borderRadius: + BorderRadius.circular(16), ), ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: + const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: Row( - crossAxisAlignment: CrossAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, children: [ - Image.asset("assets/images/ic_table.gif"), + Image.asset( + "assets/images/ic_table.gif", + ), const SizedBox(width: 10), Expanded( child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ Text( - "Table Booking".tr, + ConstTexts.tableBooking.tr, style: TextStyle( fontSize: 16, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, + fontFamily: + AppThemeData + .semiBold, + fontWeight: + FontWeight + .w600, ), ), Text( - "Quick Conformations".tr, + ConstTexts.quickConformations + .tr, style: TextStyle( fontSize: 12, - color: isDark ? AppThemeData.grey400 : AppThemeData.grey500, - fontFamily: AppThemeData.medium, - fontWeight: FontWeight.w500, + color: + isDark + ? AppThemeData + .grey400 + : AppThemeData + .grey500, + fontFamily: + AppThemeData + .medium, + fontWeight: + FontWeight + .w500, ), ), ], @@ -414,11 +726,12 @@ class RestaurantDetailsScreen extends StatelessWidget { controller.couponList.isEmpty ? const SizedBox() : Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ const SizedBox(height: 20), Text( - "Additional Offers".tr, + ConstTexts.additionlOffers.tr, textAlign: TextAlign.start, maxLines: 1, style: TextStyle( @@ -426,16 +739,21 @@ class RestaurantDetailsScreen extends StatelessWidget { overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, ), ), const SizedBox(height: 10), - CouponListView(controller: controller), + CouponListView( + controller: controller, + ), ], ), const SizedBox(height: 20), Text( - "Menu".tr, + ConstTexts.menu.tr, textAlign: TextAlign.start, maxLines: 1, style: TextStyle( @@ -443,26 +761,41 @@ class RestaurantDetailsScreen extends StatelessWidget { overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, ), ), const SizedBox(height: 10), TextFieldWidget( - controller: controller.searchEditingController.value, - hintText: 'Search the item and more...'.tr, + controller: + controller + .searchEditingController + .value, + hintText: ConstTexts.searchAndMore.tr, onchange: (value) { controller.searchProduct(value); }, - prefix: Padding(padding: const EdgeInsets.all(12), child: SvgPicture.asset("assets/icons/ic_search.svg")), + prefix: Padding( + padding: const EdgeInsets.all(12), + child: SvgPicture.asset( + "assets/icons/ic_search.svg", + ), + ), ), const SizedBox(height: 10), - Constant.sectionConstantModel!.isProductDetails == false + Constant + .sectionConstantModel! + .isProductDetails == + false ? SizedBox() : Row( children: [ InkWell( onTap: () { - if (controller.isVag.value == true) { + if (controller.isVag.value == + true) { controller.isVag.value = false; } else { controller.isVag.value = true; @@ -470,30 +803,83 @@ class RestaurantDetailsScreen extends StatelessWidget { controller.filterRecord(); }, child: Container( - padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), + padding: + const EdgeInsets.symmetric( + horizontal: 12, + vertical: 8, + ), decoration: controller.isVag.value ? ShapeDecoration( - color: isDark ? AppThemeData.primary600 : AppThemeData.primary50, - shape: RoundedRectangleBorder(side: BorderSide(width: 1, color: AppThemeData.primary300), borderRadius: BorderRadius.circular(120)), + color: + isDark + ? AppThemeData + .primary600 + : AppThemeData + .primary50, + shape: RoundedRectangleBorder( + side: BorderSide( + width: 1, + color: + AppThemeData + .primary300, + ), + borderRadius: + BorderRadius.circular( + 120, + ), + ), ) : ShapeDecoration( - color: isDark ? AppThemeData.grey800 : AppThemeData.grey100, + color: + isDark + ? AppThemeData + .grey800 + : AppThemeData + .grey100, shape: RoundedRectangleBorder( - side: BorderSide(width: 1, color: isDark ? AppThemeData.grey700 : AppThemeData.grey200), - borderRadius: BorderRadius.circular(120), + side: BorderSide( + width: 1, + color: + isDark + ? AppThemeData + .grey700 + : AppThemeData + .grey200, + ), + borderRadius: + BorderRadius.circular( + 120, + ), ), ), child: Row( mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.center, children: [ - SvgPicture.asset("assets/icons/ic_veg.svg", height: 20, width: 20), + SvgPicture.asset( + "assets/icons/ic_veg.svg", + height: 20, + width: 20, + ), const SizedBox(width: 8), Text( - 'Veg'.tr, - style: TextStyle(color: isDark ? AppThemeData.grey100 : AppThemeData.grey800, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600), + ConstTexts.veg.tr, + style: TextStyle( + color: + isDark + ? AppThemeData + .grey100 + : AppThemeData + .grey800, + fontFamily: + AppThemeData.semiBold, + fontWeight: + FontWeight.w600, + ), ), ], ), @@ -502,38 +888,94 @@ class RestaurantDetailsScreen extends StatelessWidget { const SizedBox(width: 10), InkWell( onTap: () { - if (controller.isNonVag.value == true) { - controller.isNonVag.value = false; + if (controller.isNonVag.value == + true) { + controller.isNonVag.value = + false; } else { - controller.isNonVag.value = true; + controller.isNonVag.value = + true; } controller.filterRecord(); }, child: Container( - padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), + padding: + const EdgeInsets.symmetric( + horizontal: 12, + vertical: 8, + ), decoration: controller.isNonVag.value ? ShapeDecoration( - color: isDark ? AppThemeData.primary600 : AppThemeData.primary50, - shape: RoundedRectangleBorder(side: BorderSide(width: 1, color: AppThemeData.primary300), borderRadius: BorderRadius.circular(120)), + color: + isDark + ? AppThemeData + .primary600 + : AppThemeData + .primary50, + shape: RoundedRectangleBorder( + side: BorderSide( + width: 1, + color: + AppThemeData + .primary300, + ), + borderRadius: + BorderRadius.circular( + 120, + ), + ), ) : ShapeDecoration( - color: isDark ? AppThemeData.grey800 : AppThemeData.grey100, + color: + isDark + ? AppThemeData + .grey800 + : AppThemeData + .grey100, shape: RoundedRectangleBorder( - side: BorderSide(width: 1, color: isDark ? AppThemeData.grey700 : AppThemeData.grey200), - borderRadius: BorderRadius.circular(120), + side: BorderSide( + width: 1, + color: + isDark + ? AppThemeData + .grey700 + : AppThemeData + .grey200, + ), + borderRadius: + BorderRadius.circular( + 120, + ), ), ), child: Row( mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.center, children: [ - SvgPicture.asset("assets/icons/ic_nonveg.svg", height: 20, width: 20), + SvgPicture.asset( + "assets/icons/ic_nonveg.svg", + height: 20, + width: 20, + ), const SizedBox(width: 8), Text( - 'Non Veg'.tr, - style: TextStyle(color: isDark ? AppThemeData.grey100 : AppThemeData.grey800, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600), + ConstTexts.nonVeg.tr, + style: TextStyle( + color: + isDark + ? AppThemeData + .grey100 + : AppThemeData + .grey800, + fontFamily: + AppThemeData.semiBold, + fontWeight: + FontWeight.w600, + ), ), ], ), @@ -630,12 +1072,17 @@ class RestaurantDetailsScreen extends StatelessWidget { ); } - Future timeShowBottomSheet(BuildContext context, RestaurantDetailsController productModel) { + Future timeShowBottomSheet( + BuildContext context, + RestaurantDetailsController productModel, + ) { return showModalBottomSheet( context: context, isScrollControlled: true, isDismissible: true, - shape: const RoundedRectangleBorder(borderRadius: BorderRadius.vertical(top: Radius.circular(30))), + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.vertical(top: Radius.circular(30)), + ), clipBehavior: Clip.antiAliasWithSaveLayer, builder: (context) => FractionallySizedBox( @@ -645,7 +1092,8 @@ class RestaurantDetailsScreen extends StatelessWidget { final themeController = Get.find(); final isDark = themeController.isDark.value; return Scaffold( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, body: Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: Column( @@ -657,7 +1105,15 @@ class RestaurantDetailsScreen extends StatelessWidget { width: 134, height: 5, margin: const EdgeInsets.only(bottom: 6), - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey50 : AppThemeData.grey800, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(3))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey800, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(3), + ), + ), ), ), ), @@ -665,11 +1121,22 @@ class RestaurantDetailsScreen extends StatelessWidget { child: ListView.builder( shrinkWrap: true, physics: const BouncingScrollPhysics(), - itemCount: productModel.vendorModel.value.workingHours!.length, + itemCount: + productModel + .vendorModel + .value + .workingHours! + .length, itemBuilder: (context, dayIndex) { - WorkingHours workingHours = productModel.vendorModel.value.workingHours![dayIndex]; + WorkingHours workingHours = + productModel + .vendorModel + .value + .workingHours![dayIndex]; return Padding( - padding: const EdgeInsets.symmetric(vertical: 10), + padding: const EdgeInsets.symmetric( + vertical: 10, + ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -682,34 +1149,72 @@ class RestaurantDetailsScreen extends StatelessWidget { overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, ), ), const SizedBox(height: 10), - workingHours.timeslot == null || workingHours.timeslot!.isEmpty + workingHours.timeslot == null || + workingHours.timeslot!.isEmpty ? const SizedBox() : ListView.builder( shrinkWrap: true, - physics: const NeverScrollableScrollPhysics(), - itemCount: workingHours.timeslot!.length, + physics: + const NeverScrollableScrollPhysics(), + itemCount: + workingHours.timeslot!.length, itemBuilder: (context, timeIndex) { - Timeslot timeSlotModel = workingHours.timeslot![timeIndex]; + Timeslot timeSlotModel = + workingHours + .timeslot![timeIndex]; return Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all( + 8.0, + ), child: Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Expanded( child: Container( - padding: const EdgeInsets.symmetric(vertical: 10), + padding: + const EdgeInsets.symmetric( + vertical: 10, + ), decoration: BoxDecoration( - borderRadius: const BorderRadius.all(Radius.circular(12)), - border: Border.all(color: isDark ? AppThemeData.grey400 : AppThemeData.grey200), + borderRadius: + const BorderRadius.all( + Radius.circular( + 12, + ), + ), + border: Border.all( + color: + isDark + ? AppThemeData + .grey400 + : AppThemeData + .grey200, + ), ), child: Center( child: Text( - timeSlotModel.from.toString(), - style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 14, color: isDark ? AppThemeData.grey400 : AppThemeData.grey500), + timeSlotModel.from + .toString(), + style: TextStyle( + fontFamily: + AppThemeData + .medium, + fontSize: 14, + color: + isDark + ? AppThemeData + .grey400 + : AppThemeData + .grey500, + ), ), ), ), @@ -717,15 +1222,42 @@ class RestaurantDetailsScreen extends StatelessWidget { const SizedBox(width: 10), Expanded( child: Container( - padding: const EdgeInsets.symmetric(vertical: 10), + padding: + const EdgeInsets.symmetric( + vertical: 10, + ), decoration: BoxDecoration( - borderRadius: const BorderRadius.all(Radius.circular(12)), - border: Border.all(color: isDark ? AppThemeData.grey400 : AppThemeData.grey200), + borderRadius: + const BorderRadius.all( + Radius.circular( + 12, + ), + ), + border: Border.all( + color: + isDark + ? AppThemeData + .grey400 + : AppThemeData + .grey200, + ), ), child: Center( child: Text( - timeSlotModel.to.toString(), - style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 14, color: isDark ? AppThemeData.grey400 : AppThemeData.grey500), + timeSlotModel.to + .toString(), + style: TextStyle( + fontFamily: + AppThemeData + .medium, + fontSize: 14, + color: + isDark + ? AppThemeData + .grey400 + : AppThemeData + .grey500, + ), ), ), ), @@ -774,10 +1306,19 @@ class CouponListView extends StatelessWidget { clipBehavior: Clip.antiAlias, decoration: ShapeDecoration( color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, - shape: RoundedRectangleBorder(side: BorderSide(width: 1, color: isDark ? AppThemeData.grey800 : AppThemeData.grey100), borderRadius: BorderRadius.circular(16)), + shape: RoundedRectangleBorder( + side: BorderSide( + width: 1, + color: isDark ? AppThemeData.grey800 : AppThemeData.grey100, + ), + borderRadius: BorderRadius.circular(16), + ), ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 5, + ), child: SizedBox( width: Responsive.width(80, context), child: Row( @@ -785,11 +1326,28 @@ class CouponListView extends StatelessWidget { children: [ Container( width: 60, - decoration: const BoxDecoration(image: DecorationImage(image: AssetImage("assets/images/offer_gif.gif"), fit: BoxFit.fill)), + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage("assets/images/offer_gif.gif"), + fit: BoxFit.fill, + ), + ), child: Center( child: Text( - offerModel.discountType == "Fix Price" ? Constant.amountShow(amount: offerModel.discount) : "${offerModel.discount}%", - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey50, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600, fontSize: 12), + offerModel.discountType == "Fix Price" + ? Constant.amountShow( + amount: offerModel.discount, + ) + : "${offerModel.discount}%", + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey50, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w600, + fontSize: 12, + ), ), ), ), @@ -800,11 +1358,21 @@ class CouponListView extends StatelessWidget { children: [ Text( offerModel.description.toString(), - style: TextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600), + style: TextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w600, + ), ), InkWell( onTap: () { - Clipboard.setData(ClipboardData(text: offerModel.code.toString())).then((value) { + Clipboard.setData( + ClipboardData(text: offerModel.code.toString()), + ).then((value) { ShowToastDialog.showToast("Copied".tr); }); }, @@ -812,15 +1380,36 @@ class CouponListView extends StatelessWidget { children: [ Text( offerModel.code.toString(), - style: TextStyle(fontSize: 12, color: isDark ? AppThemeData.grey400 : AppThemeData.grey500, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600), + style: TextStyle( + fontSize: 12, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey500, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w600, + ), ), const SizedBox(width: 5), SvgPicture.asset("assets/icons/ic_copy.svg"), - const SizedBox(height: 10, child: VerticalDivider()), + const SizedBox( + height: 10, + child: VerticalDivider(), + ), const SizedBox(width: 5), Text( - Constant.timestampToDateTime(offerModel.expiresAt!), - style: TextStyle(fontSize: 12, color: isDark ? AppThemeData.grey400 : AppThemeData.grey500, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600), + Constant.timestampToDateTime( + offerModel.expiresAt!, + ), + style: TextStyle( + fontSize: 12, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey500, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w600, + ), ), ], ), @@ -857,7 +1446,8 @@ class ProductListView extends StatelessWidget { itemCount: controller.vendorCategoryList.length, physics: const NeverScrollableScrollPhysics(), itemBuilder: (context, index) { - VendorCategoryModel vendorCategoryModel = controller.vendorCategoryList[index]; + VendorCategoryModel vendorCategoryModel = + controller.vendorCategoryList[index]; return ExpansionTile( childrenPadding: EdgeInsets.zero, tilePadding: EdgeInsets.zero, @@ -865,17 +1455,33 @@ class ProductListView extends StatelessWidget { initiallyExpanded: true, title: Text( "${vendorCategoryModel.title.toString()} (${controller.productList.where((p0) => p0.categoryID == vendorCategoryModel.id).toList().length})", - style: TextStyle(fontSize: 18, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontSize: 18, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w600, + color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + ), ), children: [ Obx( () => ListView.builder( - itemCount: controller.productList.where((p0) => p0.categoryID == vendorCategoryModel.id).toList().length, + itemCount: + controller.productList + .where( + (p0) => p0.categoryID == vendorCategoryModel.id, + ) + .toList() + .length, shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), padding: EdgeInsets.zero, itemBuilder: (context, index) { - ProductModel productModel = controller.productList.where((p0) => p0.categoryID == vendorCategoryModel.id).toList()[index]; + ProductModel productModel = + controller.productList + .where( + (p0) => p0.categoryID == vendorCategoryModel.id, + ) + .toList()[index]; String price = "0.0"; String disPrice = "0.0"; @@ -884,327 +1490,728 @@ class ProductListView extends StatelessWidget { List selectedIndexArray = []; if (productModel.itemAttribute != null) { if (productModel.itemAttribute!.attributes!.isNotEmpty) { - for (var element in productModel.itemAttribute!.attributes!) { + for (var element + in productModel.itemAttribute!.attributes!) { if (element.attributeOptions!.isNotEmpty) { - selectedVariants.add(productModel.itemAttribute!.attributes![productModel.itemAttribute!.attributes!.indexOf(element)].attributeOptions![0].toString()); - selectedIndexVariants.add('${productModel.itemAttribute!.attributes!.indexOf(element)} _${productModel.itemAttribute!.attributes![0].attributeOptions![0].toString()}'); - selectedIndexArray.add('${productModel.itemAttribute!.attributes!.indexOf(element)}_0'); + selectedVariants.add( + productModel + .itemAttribute! + .attributes![productModel + .itemAttribute! + .attributes! + .indexOf(element)] + .attributeOptions![0] + .toString(), + ); + selectedIndexVariants.add( + '${productModel.itemAttribute!.attributes!.indexOf(element)} _${productModel.itemAttribute!.attributes![0].attributeOptions![0].toString()}', + ); + selectedIndexArray.add( + '${productModel.itemAttribute!.attributes!.indexOf(element)}_0', + ); } } } - if (productModel.itemAttribute!.variants!.where((element) => element.variantSku == selectedVariants.join('-')).isNotEmpty) { + if (productModel.itemAttribute!.variants! + .where( + (element) => + element.variantSku == + selectedVariants.join('-'), + ) + .isNotEmpty) { price = Constant.productCommissionPrice( controller.vendorModel.value, - productModel.itemAttribute!.variants!.where((element) => element.variantSku == selectedVariants.join('-')).first.variantPrice ?? '0', + productModel.itemAttribute!.variants! + .where( + (element) => + element.variantSku == + selectedVariants.join('-'), + ) + .first + .variantPrice ?? + '0', ); disPrice = "0"; } } else { - price = Constant.productCommissionPrice(controller.vendorModel.value, productModel.price.toString()); - disPrice = double.parse(productModel.disPrice.toString()) <= 0 ? "0" : Constant.productCommissionPrice(controller.vendorModel.value, productModel.disPrice.toString()); + price = Constant.productCommissionPrice( + controller.vendorModel.value, + productModel.price.toString(), + ); + disPrice = + double.parse(productModel.disPrice.toString()) <= 0 + ? "0" + : Constant.productCommissionPrice( + controller.vendorModel.value, + productModel.disPrice.toString(), + ); } - return Padding( - padding: const EdgeInsets.only(bottom: 20), - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Constant.sectionConstantModel!.isProductDetails == false - ? SizedBox() - : Row( - children: [ - productModel.nonveg == true ? SvgPicture.asset("assets/icons/ic_nonveg.svg") : SvgPicture.asset("assets/icons/ic_veg.svg"), - const SizedBox(width: 5), - Text( - productModel.nonveg == true ? "Non Veg.".tr : "Pure veg.".tr, - style: TextStyle( - color: productModel.nonveg == true ? AppThemeData.danger300 : AppThemeData.success400, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + return InkWell( + onTap: () { + log("Product Clicked."); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: 20), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Constant + .sectionConstantModel! + .isProductDetails == + false + ? SizedBox() + : Row( + children: [ + productModel.nonveg == true + ? SvgPicture.asset( + "assets/icons/ic_nonveg.svg", + ) + : SvgPicture.asset( + "assets/icons/ic_veg.svg", + ), + const SizedBox(width: 5), + Text( + productModel.nonveg == true + ? ConstTexts.nonVeg.tr + : ConstTexts.veg.tr, + style: TextStyle( + color: + productModel.nonveg == true + ? AppThemeData.danger300 + : AppThemeData + .success400, + fontFamily: + AppThemeData.semiBold, + fontWeight: FontWeight.w600, + ), ), - ), - ], + ], + ), + const SizedBox(height: 5), + Text( + productModel.name.toString(), + style: TextStyle( + fontSize: 18, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w600, ), - const SizedBox(height: 5), - Text( - productModel.name.toString(), - style: TextStyle(fontSize: 18, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600), - ), - double.parse(disPrice) <= 0 - ? Text( - Constant.amountShow(amount: price), - style: TextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600), - ) - : Row( - children: [ - Text( - Constant.amountShow(amount: disPrice), - style: TextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600), - ), - const SizedBox(width: 5), - Text( - Constant.amountShow(amount: price), - style: TextStyle( - fontSize: 14, - decoration: TextDecoration.lineThrough, - decorationColor: isDark ? AppThemeData.grey500 : AppThemeData.grey400, - color: isDark ? AppThemeData.grey500 : AppThemeData.grey400, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, - ), - ), - ], - ), - Row( - children: [ - SvgPicture.asset("assets/icons/ic_star.svg", colorFilter: const ColorFilter.mode(AppThemeData.warning300, BlendMode.srcIn)), - const SizedBox(width: 5), - Text( - "${Constant.calculateReview(reviewCount: productModel.reviewsCount!.toStringAsFixed(0), reviewSum: productModel.reviewsSum.toString())} (${productModel.reviewsCount!.toStringAsFixed(0)})", - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w500), - ), - ], - ), - Text( - "${productModel.description}", - maxLines: 2, - style: TextStyle( - overflow: TextOverflow.ellipsis, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, - fontFamily: AppThemeData.regular, - fontWeight: FontWeight.w400, ), - ), - const SizedBox(height: 5), - InkWell( - onTap: () { - showDialog( - context: context, - builder: (BuildContext context) { - return infoDialog(controller, isDark, productModel); - }, - ); - }, - child: Row( - children: [ - Icon(Icons.info, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, size: 18), - const SizedBox(width: 8), - Text( - "Info".tr, - maxLines: 2, + double.parse(disPrice) <= 0 + ? Text( + Constant.amountShow(amount: price), style: TextStyle( - overflow: TextOverflow.ellipsis, fontSize: 16, - color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w600, + ), + ) + : Row( + children: [ + Text( + Constant.amountShow( + amount: disPrice, + ), + style: TextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: + AppThemeData.semiBold, + fontWeight: FontWeight.w600, + ), + ), + const SizedBox(width: 5), + Text( + Constant.amountShow( + amount: price, + ), + style: TextStyle( + fontSize: 14, + decoration: + TextDecoration.lineThrough, + decorationColor: + isDark + ? AppThemeData.grey500 + : AppThemeData.grey400, + color: + isDark + ? AppThemeData.grey500 + : AppThemeData.grey400, + fontFamily: + AppThemeData.semiBold, + fontWeight: FontWeight.w600, + ), + ), + ], + ), + Row( + children: [ + SvgPicture.asset( + "assets/icons/ic_star.svg", + colorFilter: const ColorFilter.mode( + AppThemeData.warning300, + BlendMode.srcIn, + ), + ), + const SizedBox(width: 5), + Text( + "${Constant.calculateReview(reviewCount: productModel.reviewsCount!.toStringAsFixed(0), reviewSum: productModel.reviewsSum.toString())} (${productModel.reviewsCount!.toStringAsFixed(0)})", + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, fontFamily: AppThemeData.regular, - fontWeight: FontWeight.w400, + fontWeight: FontWeight.w500, ), ), ], ), - ), - ], - ), - ), - ClipRRect( - borderRadius: const BorderRadius.all(Radius.circular(16)), - child: Stack( - children: [ - NetworkImageWidget(imageUrl: productModel.photo.toString(), fit: BoxFit.cover, height: Responsive.height(16, context), width: Responsive.width(34, context)), - Container( - height: Responsive.height(16, context), - width: Responsive.width(34, context), - decoration: BoxDecoration( - gradient: LinearGradient(begin: const Alignment(-0.00, -1.00), end: const Alignment(0, 1), colors: [Colors.black.withOpacity(0), const Color(0xFF111827)]), - ), - ), - Positioned( - right: 10, - top: 10, - child: InkWell( - onTap: () async { - if (controller.favouriteItemList.where((p0) => p0.productId == productModel.id).isNotEmpty) { - FavouriteItemModel favouriteModel = FavouriteItemModel( - productId: productModel.id, - storeId: controller.vendorModel.value.id, - userId: FireStoreUtils.getCurrentUid(), - ); - controller.favouriteItemList.removeWhere((item) => item.productId == productModel.id); - await FireStoreUtils.removeFavouriteItem(favouriteModel); - } else { - FavouriteItemModel favouriteModel = FavouriteItemModel( - productId: productModel.id, - storeId: controller.vendorModel.value.id, - userId: FireStoreUtils.getCurrentUid(), - ); - controller.favouriteItemList.add(favouriteModel); - - await FireStoreUtils.setFavouriteItem(favouriteModel); - } - }, - child: Obx( - () => - controller.favouriteItemList.where((p0) => p0.productId == productModel.id).isNotEmpty - ? SvgPicture.asset("assets/icons/ic_like_fill.svg") - : SvgPicture.asset("assets/icons/ic_like.svg"), + Text( + "${productModel.description}", + maxLines: 2, + style: TextStyle( + overflow: TextOverflow.ellipsis, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w400, ), ), - ), - controller.isOpen.value == false || Constant.userModel == null - ? const SizedBox() - : Positioned( - bottom: 10, - left: 20, - right: 20, - child: - selectedVariants.isNotEmpty || (productModel.addOnsTitle != null && productModel.addOnsTitle!.isNotEmpty) - ? RoundedButtonFill( - title: "Add".tr, - width: 10, - height: 4, - color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, - textColor: AppThemeData.primary300, - onPress: () async { - controller.selectedVariants.clear(); - controller.selectedIndexVariants.clear(); - controller.selectedIndexArray.clear(); - controller.selectedAddOns.clear(); - controller.quantity.value = 1; - if (productModel.itemAttribute != null) { - if (productModel.itemAttribute!.attributes!.isNotEmpty) { - for (var element in productModel.itemAttribute!.attributes!) { - if (element.attributeOptions!.isNotEmpty) { - controller.selectedVariants.add( - productModel.itemAttribute!.attributes![productModel.itemAttribute!.attributes!.indexOf(element)].attributeOptions![0].toString(), + const SizedBox(height: 5), + InkWell( + onTap: () { + showDialog( + context: context, + builder: (BuildContext context) { + return infoDialog( + controller, + isDark, + productModel, + ); + }, + ); + }, + child: Row( + children: [ + Icon( + Icons.info, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + size: 18, + ), + const SizedBox(width: 8), + Text( + "Info".tr, + maxLines: 2, + style: TextStyle( + overflow: TextOverflow.ellipsis, + fontSize: 16, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w400, + ), + ), + ], + ), + ), + ], + ), + ), + ClipRRect( + borderRadius: const BorderRadius.all( + Radius.circular(16), + ), + child: Stack( + children: [ + NetworkImageWidget( + imageUrl: productModel.photo.toString(), + fit: BoxFit.cover, + height: Responsive.height(16, context), + width: Responsive.width(34, context), + ), + Container( + height: Responsive.height(16, context), + width: Responsive.width(34, context), + decoration: BoxDecoration( + gradient: LinearGradient( + begin: const Alignment(-0.00, -1.00), + end: const Alignment(0, 1), + colors: [ + Colors.black.withOpacity(0), + const Color(0xFF111827), + ], + ), + ), + ), + Positioned( + right: 10, + top: 10, + child: InkWell( + onTap: () async { + if (controller.favouriteItemList + .where( + (p0) => + p0.productId == + productModel.id, + ) + .isNotEmpty) { + FavouriteItemModel + favouriteModel = FavouriteItemModel( + productId: productModel.id, + storeId: + controller + .vendorModel + .value + .id, + userId: + FireStoreUtils.getCurrentUid(), + ); + controller.favouriteItemList + .removeWhere( + (item) => + item.productId == + productModel.id, + ); + await FireStoreUtils.removeFavouriteItem( + favouriteModel, + ); + } else { + FavouriteItemModel + favouriteModel = FavouriteItemModel( + productId: productModel.id, + storeId: + controller + .vendorModel + .value + .id, + userId: + FireStoreUtils.getCurrentUid(), + ); + controller.favouriteItemList.add( + favouriteModel, + ); + + await FireStoreUtils.setFavouriteItem( + favouriteModel, + ); + } + }, + child: Obx( + () => + controller.favouriteItemList + .where( + (p0) => + p0.productId == + productModel.id, + ) + .isNotEmpty + ? SvgPicture.asset( + "assets/icons/ic_like_fill.svg", + ) + : SvgPicture.asset( + "assets/icons/ic_like.svg", + ), + ), + ), + ), + controller.isOpen.value == false || + Constant.userModel == null + ? const SizedBox() + : Positioned( + bottom: 10, + left: 20, + right: 20, + child: + selectedVariants.isNotEmpty || + (productModel + .addOnsTitle != + null && + productModel + .addOnsTitle! + .isNotEmpty) + ? RoundedButtonFill( + title: "Add".tr, + width: 10, + height: 4, + color: + isDark + ? AppThemeData + .grey900 + : AppThemeData + .grey50, + textColor: + AppThemeData.primary300, + onPress: () async { + controller + .selectedVariants + .clear(); + controller + .selectedIndexVariants + .clear(); + controller + .selectedIndexArray + .clear(); + controller.selectedAddOns + .clear(); + controller + .quantity + .value = 1; + if (productModel + .itemAttribute != + null) { + if (productModel + .itemAttribute! + .attributes! + .isNotEmpty) { + for (var element + in productModel + .itemAttribute! + .attributes!) { + if (element + .attributeOptions! + .isNotEmpty) { + controller.selectedVariants.add( + productModel + .itemAttribute! + .attributes![productModel + .itemAttribute! + .attributes! + .indexOf( + element, + )] + .attributeOptions![0] + .toString(), + ); + controller + .selectedIndexVariants + .add( + '${productModel.itemAttribute!.attributes!.indexOf(element)} _${productModel.itemAttribute!.attributes![0].attributeOptions![0].toString()}', + ); + controller + .selectedIndexArray + .add( + '${productModel.itemAttribute!.attributes!.indexOf(element)}_0', + ); + } + } + } + final bool + productIsInList = + cartItem.any( + (product) => + product.id == + "${productModel.id}~${productModel.itemAttribute!.variants!.where((element) => element.variantSku == controller.selectedVariants.join('-')).isNotEmpty ? productModel.itemAttribute!.variants!.where((element) => element.variantSku == controller.selectedVariants.join('-')).first.variantId.toString() : ""}", ); - controller.selectedIndexVariants.add( - '${productModel.itemAttribute!.attributes!.indexOf(element)} _${productModel.itemAttribute!.attributes![0].attributeOptions![0].toString()}', - ); - controller.selectedIndexArray.add('${productModel.itemAttribute!.attributes!.indexOf(element)}_0'); + + if (productIsInList) { + CartProductModel + element = cartItem + .firstWhere( + (product) => + product + .id == + "${productModel.id}~${productModel.itemAttribute!.variants!.where((element) => element.variantSku == controller.selectedVariants.join('-')).isNotEmpty ? productModel.itemAttribute!.variants!.where((element) => element.variantSku == controller.selectedVariants.join('-')).first.variantId.toString() : ""}", + ); + controller + .quantity + .value = + element.quantity!; + if (element.extras != + null) { + for (var element + in element + .extras!) { + controller + .selectedAddOns + .add(element); + } + } + } + } else { + if (cartItem + .where( + (product) => + product.id == + "${productModel.id}", + ) + .isNotEmpty) { + CartProductModel + element = cartItem + .firstWhere( + (product) => + product + .id == + "${productModel.id}", + ); + controller + .quantity + .value = + element.quantity!; + if (element.extras != + null) { + for (var element + in element + .extras!) { + controller + .selectedAddOns + .add(element); + } } } } - final bool productIsInList = cartItem.any( - (product) => - product.id == - "${productModel.id}~${productModel.itemAttribute!.variants!.where((element) => element.variantSku == controller.selectedVariants.join('-')).isNotEmpty ? productModel.itemAttribute!.variants!.where((element) => element.variantSku == controller.selectedVariants.join('-')).first.variantId.toString() : ""}", + controller.update(); + controller.calculatePrice( + productModel, ); - - if (productIsInList) { - CartProductModel element = cartItem.firstWhere( - (product) => - product.id == - "${productModel.id}~${productModel.itemAttribute!.variants!.where((element) => element.variantSku == controller.selectedVariants.join('-')).isNotEmpty ? productModel.itemAttribute!.variants!.where((element) => element.variantSku == controller.selectedVariants.join('-')).first.variantId.toString() : ""}", - ); - controller.quantity.value = element.quantity!; - if (element.extras != null) { - for (var element in element.extras!) { - controller.selectedAddOns.add(element); - } - } - } - } else { - if (cartItem.where((product) => product.id == "${productModel.id}").isNotEmpty) { - CartProductModel element = cartItem.firstWhere((product) => product.id == "${productModel.id}"); - controller.quantity.value = element.quantity!; - if (element.extras != null) { - for (var element in element.extras!) { - controller.selectedAddOns.add(element); - } - } - } - } - controller.update(); - controller.calculatePrice(productModel); - productDetailsBottomSheet(context, productModel); - }, - ) - : Obx( - () => - cartItem.where((p0) => p0.id == productModel.id).isNotEmpty - ? Container( - width: Responsive.width(100, context), - height: Responsive.height(4, context), - decoration: ShapeDecoration( - color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(200)), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - InkWell( - onTap: () { - controller.addToCart( - productModel: productModel, - price: price, - discountPrice: disPrice, - isIncrement: false, - quantity: cartItem.where((p0) => p0.id == productModel.id).first.quantity! - 1, - ); - }, - child: Icon(Icons.remove, color: isDark ? AppThemeData.grey50 : AppThemeData.greyDark50), + productDetailsBottomSheet( + context, + productModel, + ); + }, + ) + : Obx( + () => + cartItem + .where( + (p0) => + p0.id == + productModel + .id, + ) + .isNotEmpty + ? Container( + width: + Responsive.width( + 100, + context, + ), + height: + Responsive.height( + 4, + context, + ), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData + .grey900 + : AppThemeData + .grey50, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 200, + ), ), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 14), - child: Text( - cartItem.where((p0) => p0.id == productModel.id).first.quantity.toString(), - textAlign: TextAlign.start, - maxLines: 1, - style: TextStyle( - fontSize: 16, - overflow: TextOverflow.ellipsis, - fontFamily: AppThemeData.medium, - fontWeight: FontWeight.w500, - color: isDark ? AppThemeData.grey100 : AppThemeData.grey800, + ), + child: Row( + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, + children: [ + InkWell( + onTap: () { + controller.addToCart( + productModel: + productModel, + price: + price, + discountPrice: + disPrice, + isIncrement: + false, + quantity: + cartItem + .where( + ( + p0, + ) => + p0.id == + productModel.id, + ) + .first + .quantity! - + 1, + ); + }, + child: Icon( + Icons + .remove, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.greyDark50, ), ), - ), - InkWell( - onTap: () { - if ((cartItem.where((p0) => p0.id == productModel.id).first.quantity ?? 0) < (productModel.quantity ?? 0) || - (productModel.quantity ?? 0) == -1) { - controller.addToCart( - productModel: productModel, - price: price, - discountPrice: disPrice, - isIncrement: true, - quantity: cartItem.where((p0) => p0.id == productModel.id).first.quantity! + 1, - ); - } else { - ShowToastDialog.showToast("Out of stock".tr); - } - }, - child: Icon(Icons.add, color: isDark ? AppThemeData.grey50 : AppThemeData.greyDark50), - ), - ], + Padding( + padding: const EdgeInsets.symmetric( + horizontal: + 14, + ), + child: Text( + cartItem + .where( + ( + p0, + ) => + p0.id == + productModel.id, + ) + .first + .quantity + .toString(), + textAlign: + TextAlign + .start, + maxLines: + 1, + style: TextStyle( + fontSize: + 16, + overflow: + TextOverflow.ellipsis, + fontFamily: + AppThemeData.medium, + fontWeight: + FontWeight.w500, + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey800, + ), + ), + ), + InkWell( + onTap: () { + if ((cartItem + .where( + ( + p0, + ) => + p0.id == + productModel.id, + ) + .first + .quantity ?? + 0) < + (productModel.quantity ?? + 0) || + (productModel.quantity ?? + 0) == + -1) { + controller.addToCart( + productModel: + productModel, + price: + price, + discountPrice: + disPrice, + isIncrement: + true, + quantity: + cartItem + .where( + ( + p0, + ) => + p0.id == + productModel.id, + ) + .first + .quantity! + + 1, + ); + } else { + ShowToastDialog.showToast( + "Out of stock" + .tr, + ); + } + }, + child: Icon( + Icons.add, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.greyDark50, + ), + ), + ], + ), + ) + : RoundedButtonFill( + title: "Add".tr, + width: 10, + height: 4, + color: + isDark + ? AppThemeData + .grey900 + : AppThemeData + .grey50, + textColor: + AppThemeData + .primary300, + onPress: () async { + if (1 <= + (productModel.quantity ?? + 0) || + (productModel.quantity ?? + 0) == + -1) { + controller.addToCart( + productModel: + productModel, + price: + price, + discountPrice: + disPrice, + isIncrement: + true, + quantity: 1, + ); + } else { + ShowToastDialog.showToast( + "Out of stock" + .tr, + ); + } + }, ), - ) - : RoundedButtonFill( - title: "Add".tr, - width: 10, - height: 4, - color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, - textColor: AppThemeData.primary300, - onPress: () async { - if (1 <= (productModel.quantity ?? 0) || (productModel.quantity ?? 0) == -1) { - controller.addToCart(productModel: productModel, price: price, discountPrice: disPrice, isIncrement: true, quantity: 1); - } else { - ShowToastDialog.showToast("Out of stock".tr); - } - }, - ), - ), - ), - ], + ), + ), + ], + ), ), - ), - ], + ], + ), ), ); }, @@ -1217,12 +2224,17 @@ class ProductListView extends StatelessWidget { ); } - Future productDetailsBottomSheet(BuildContext context, ProductModel productModel) { + Future productDetailsBottomSheet( + BuildContext context, + ProductModel productModel, + ) { return showModalBottomSheet( context: context, isScrollControlled: true, isDismissible: true, - shape: const RoundedRectangleBorder(borderRadius: BorderRadius.vertical(top: Radius.circular(30))), + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.vertical(top: Radius.circular(30)), + ), clipBehavior: Clip.antiAliasWithSaveLayer, builder: (context) => FractionallySizedBox( @@ -1236,7 +2248,11 @@ class ProductListView extends StatelessWidget { ); } - Dialog infoDialog(RestaurantDetailsController controller, isDark, ProductModel productModel) { + Dialog infoDialog( + RestaurantDetailsController controller, + isDark, + ProductModel productModel, + ) { return Dialog( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)), insetPadding: const EdgeInsets.all(10), @@ -1259,17 +2275,33 @@ class ProductListView extends StatelessWidget { Text( "Product Information's".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.bold, fontWeight: FontWeight.w700, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.bold, + fontWeight: FontWeight.w700, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 16, + ), ), Text( productModel.description.toString(), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, fontWeight: FontWeight.w400, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w400, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), ], ), ), - productModel.grams == 0 && Constant.sectionConstantModel!.isProductDetails == false + productModel.grams == 0 && + Constant.sectionConstantModel!.isProductDetails == false ? SizedBox.shrink() : Padding( padding: const EdgeInsets.only(bottom: 10), @@ -1280,18 +2312,33 @@ class ProductListView extends StatelessWidget { child: Text( "Gram".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.regular, + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + fontSize: 16, + ), ), ), Text( productModel.grams.toString(), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.bold, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.bold, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 16, + ), ), ], ), ), - productModel.calories == 0 && Constant.sectionConstantModel!.isProductDetails == false + productModel.calories == 0 && + Constant.sectionConstantModel!.isProductDetails == false ? SizedBox.shrink() : Padding( padding: const EdgeInsets.only(bottom: 10), @@ -1302,18 +2349,33 @@ class ProductListView extends StatelessWidget { child: Text( "Calories".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.regular, + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + fontSize: 16, + ), ), ), Text( productModel.calories.toString(), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.bold, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.bold, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 16, + ), ), ], ), ), - productModel.proteins == 0 && Constant.sectionConstantModel!.isProductDetails == false + productModel.proteins == 0 && + Constant.sectionConstantModel!.isProductDetails == false ? SizedBox.shrink() : Padding( padding: const EdgeInsets.only(bottom: 10), @@ -1324,18 +2386,33 @@ class ProductListView extends StatelessWidget { child: Text( "Proteins".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.regular, + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + fontSize: 16, + ), ), ), Text( productModel.proteins.toString(), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.bold, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.bold, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 16, + ), ), ], ), ), - productModel.fats == 0 && Constant.sectionConstantModel!.isProductDetails == false + productModel.fats == 0 && + Constant.sectionConstantModel!.isProductDetails == false ? SizedBox.shrink() : Padding( padding: const EdgeInsets.only(bottom: 10), @@ -1346,19 +2423,34 @@ class ProductListView extends StatelessWidget { child: Text( "Fats".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.regular, + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + fontSize: 16, + ), ), ), Text( productModel.fats.toString(), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.bold, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.bold, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 16, + ), ), ], ), ), - productModel.productSpecification != null && productModel.productSpecification!.isNotEmpty + productModel.productSpecification != null && + productModel.productSpecification!.isNotEmpty ? Padding( padding: const EdgeInsets.only(top: 10), child: Column( @@ -1367,11 +2459,20 @@ class ProductListView extends StatelessWidget { Text( "Specification".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w700, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w700, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 16, + ), ), SizedBox(height: 8), ListView.builder( - itemCount: productModel.productSpecification!.length, + itemCount: + productModel.productSpecification!.length, shrinkWrap: true, padding: EdgeInsets.zero, physics: const NeverScrollableScrollPhysics(), @@ -1382,14 +2483,30 @@ class ProductListView extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - productModel.productSpecification!.keys.elementAt(index), + productModel.productSpecification!.keys + .elementAt(index), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.regular, + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + fontSize: 16, + ), ), Text( - productModel.productSpecification!.values.elementAt(index), + productModel.productSpecification!.values + .elementAt(index), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.bold, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.bold, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 16, + ), ), ], ), @@ -1410,13 +2527,28 @@ class ProductListView extends StatelessWidget { Text( "Brand".tr, textAlign: TextAlign.start, - style: TextStyle(fontWeight: FontWeight.w700, fontFamily: AppThemeData.bold, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + style: TextStyle( + fontWeight: FontWeight.w700, + fontFamily: AppThemeData.bold, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 16, + ), ), SizedBox(height: 5), Text( controller.getBrandName(productModel.brandId!), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 16, + ), ), ], ), @@ -1453,7 +2585,8 @@ class ProductDetailsView extends StatelessWidget { init: RestaurantDetailsController(), builder: (controller) { return Scaffold( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, body: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -1462,19 +2595,36 @@ class ProductDetailsView extends StatelessWidget { Container( color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: Row( children: [ ClipRRect( - borderRadius: const BorderRadius.all(Radius.circular(16)), + borderRadius: const BorderRadius.all( + Radius.circular(16), + ), child: Stack( children: [ - NetworkImageWidget(imageUrl: productModel.photo.toString(), height: Responsive.height(11, context), width: Responsive.width(22, context), fit: BoxFit.cover), + NetworkImageWidget( + imageUrl: productModel.photo.toString(), + height: Responsive.height(11, context), + width: Responsive.width(22, context), + fit: BoxFit.cover, + ), Container( height: Responsive.height(11, context), width: Responsive.width(22, context), decoration: BoxDecoration( - gradient: LinearGradient(begin: const Alignment(-0.00, -1.00), end: const Alignment(0, 1), colors: [Colors.black.withOpacity(0), const Color(0xFF111827)]), + gradient: LinearGradient( + begin: const Alignment(-0.00, -1.00), + end: const Alignment(0, 1), + colors: [ + Colors.black.withOpacity(0), + const Color(0xFF111827), + ], + ), ), ), ], @@ -1497,36 +2647,76 @@ class ProductDetailsView extends StatelessWidget { overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, ), ), ), InkWell( onTap: () async { - if (controller.favouriteItemList.where((p0) => p0.productId == productModel.id).isNotEmpty) { - FavouriteItemModel favouriteModel = FavouriteItemModel( + if (controller.favouriteItemList + .where( + (p0) => + p0.productId == productModel.id, + ) + .isNotEmpty) { + FavouriteItemModel + favouriteModel = FavouriteItemModel( productId: productModel.id, - storeId: controller.vendorModel.value.id, - userId: FireStoreUtils.getCurrentUid(), + storeId: + controller.vendorModel.value.id, + userId: + FireStoreUtils.getCurrentUid(), + ); + controller.favouriteItemList + .removeWhere( + (item) => + item.productId == + productModel.id, + ); + await FireStoreUtils.removeFavouriteItem( + favouriteModel, ); - controller.favouriteItemList.removeWhere((item) => item.productId == productModel.id); - await FireStoreUtils.removeFavouriteItem(favouriteModel); } else { - FavouriteItemModel favouriteModel = FavouriteItemModel( + FavouriteItemModel + favouriteModel = FavouriteItemModel( productId: productModel.id, - storeId: controller.vendorModel.value.id, - userId: FireStoreUtils.getCurrentUid(), + storeId: + controller.vendorModel.value.id, + userId: + FireStoreUtils.getCurrentUid(), + ); + controller.favouriteItemList.add( + favouriteModel, ); - controller.favouriteItemList.add(favouriteModel); - await FireStoreUtils.setFavouriteItem(favouriteModel); + await FireStoreUtils.setFavouriteItem( + favouriteModel, + ); } }, child: Obx( () => - controller.favouriteItemList.where((p0) => p0.productId == productModel.id).isNotEmpty - ? SvgPicture.asset("assets/icons/ic_like_fill.svg") - : SvgPicture.asset("assets/icons/ic_like.svg", colorFilter: const ColorFilter.mode(AppThemeData.grey500, BlendMode.srcIn)), + controller.favouriteItemList + .where( + (p0) => + p0.productId == + productModel.id, + ) + .isNotEmpty + ? SvgPicture.asset( + "assets/icons/ic_like_fill.svg", + ) + : SvgPicture.asset( + "assets/icons/ic_like.svg", + colorFilter: + const ColorFilter.mode( + AppThemeData.grey500, + BlendMode.srcIn, + ), + ), ), ), ], @@ -1534,7 +2724,15 @@ class ProductDetailsView extends StatelessWidget { Text( productModel.description.toString(), textAlign: TextAlign.start, - style: TextStyle(fontSize: 12, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w400, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontSize: 12, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w400, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), ], ), @@ -1544,7 +2742,8 @@ class ProductDetailsView extends StatelessWidget { ), ), const SizedBox(height: 10), - productModel.itemAttribute == null || productModel.itemAttribute!.attributes!.isEmpty + productModel.itemAttribute == null || + productModel.itemAttribute!.attributes!.isEmpty ? const SizedBox() : ListView.builder( itemCount: productModel.itemAttribute!.attributes!.length, @@ -1554,129 +2753,275 @@ class ProductDetailsView extends StatelessWidget { itemBuilder: (context, index) { String title = ""; for (var element in controller.attributesList) { - if (productModel.itemAttribute!.attributes![index].attributeId == element.id) { + if (productModel + .itemAttribute! + .attributes![index] + .attributeId == + element.id) { title = element.title.toString(); } } return Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 5), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 5, + ), child: Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + ), + ), child: Padding( padding: const EdgeInsets.symmetric(vertical: 10), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ - productModel.itemAttribute!.attributes![index].attributeOptions!.isNotEmpty + productModel + .itemAttribute! + .attributes![index] + .attributeOptions! + .isNotEmpty ? Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Padding( - padding: const EdgeInsets.symmetric(horizontal: 10), + padding: const EdgeInsets.symmetric( + horizontal: 10, + ), child: Text( title, style: TextStyle( fontSize: 16, overflow: TextOverflow.ellipsis, - fontFamily: AppThemeData.semiBold, + fontFamily: + AppThemeData.semiBold, fontWeight: FontWeight.w600, - color: isDark ? AppThemeData.grey100 : AppThemeData.grey800, + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey800, ), ), ), Padding( - padding: const EdgeInsets.symmetric(horizontal: 10), + padding: const EdgeInsets.symmetric( + horizontal: 10, + ), child: Text( - "Required • Select any 1 option".tr, + "Required • Select any 1 option" + .tr, style: TextStyle( fontSize: 12, overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500, - color: isDark ? AppThemeData.grey400 : AppThemeData.grey500, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey500, ), ), ), - const Padding(padding: EdgeInsets.symmetric(vertical: 10), child: Divider()), + const Padding( + padding: EdgeInsets.symmetric( + vertical: 10, + ), + child: Divider(), + ), ], ) : Offstage(), Padding( - padding: const EdgeInsets.symmetric(horizontal: 10), + padding: const EdgeInsets.symmetric( + horizontal: 10, + ), child: Wrap( spacing: 6.0, runSpacing: 6.0, children: - List.generate(productModel.itemAttribute!.attributes![index].attributeOptions!.length, (i) { - return InkWell( - onTap: () async { - if (controller.selectedIndexVariants.where((element) => element.contains('$index _')).isEmpty) { - controller.selectedVariants.insert(index, productModel.itemAttribute!.attributes![index].attributeOptions![i].toString()); - controller.selectedIndexVariants.add('$index _${productModel.itemAttribute!.attributes![index].attributeOptions![i].toString()}'); - controller.selectedIndexArray.add('${index}_$i'); - } else { - controller.selectedIndexArray.remove( - '${index}_${productModel.itemAttribute!.attributes![index].attributeOptions?.indexOf(controller.selectedIndexVariants.where((element) => element.contains('$index _')).first.replaceAll('$index _', ''))}', - ); - controller.selectedVariants.removeAt(index); - controller.selectedIndexVariants.remove(controller.selectedIndexVariants.where((element) => element.contains('$index _')).first); - controller.selectedVariants.insert(index, productModel.itemAttribute!.attributes![index].attributeOptions![i].toString()); - controller.selectedIndexVariants.add('$index _${productModel.itemAttribute!.attributes![index].attributeOptions![i].toString()}'); - controller.selectedIndexArray.add('${index}_$i'); - } + List.generate( + productModel + .itemAttribute! + .attributes![index] + .attributeOptions! + .length, + (i) { + return InkWell( + onTap: () async { + if (controller + .selectedIndexVariants + .where( + (element) => + element.contains( + '$index _', + ), + ) + .isEmpty) { + controller.selectedVariants + .insert( + index, + productModel + .itemAttribute! + .attributes![index] + .attributeOptions![i] + .toString(), + ); + controller + .selectedIndexVariants + .add( + '$index _${productModel.itemAttribute!.attributes![index].attributeOptions![i].toString()}', + ); + controller + .selectedIndexArray + .add('${index}_$i'); + } else { + controller + .selectedIndexArray + .remove( + '${index}_${productModel.itemAttribute!.attributes![index].attributeOptions?.indexOf(controller.selectedIndexVariants.where((element) => element.contains('$index _')).first.replaceAll('$index _', ''))}', + ); + controller.selectedVariants + .removeAt(index); + controller + .selectedIndexVariants + .remove( + controller + .selectedIndexVariants + .where( + ( + element, + ) => element + .contains( + '$index _', + ), + ) + .first, + ); + controller.selectedVariants + .insert( + index, + productModel + .itemAttribute! + .attributes![index] + .attributeOptions![i] + .toString(), + ); + controller + .selectedIndexVariants + .add( + '$index _${productModel.itemAttribute!.attributes![index].attributeOptions![i].toString()}', + ); + controller + .selectedIndexArray + .add('${index}_$i'); + } - final bool productIsInList = cartItem.any( - (product) => - product.id == - "${productModel.id}~${productModel.itemAttribute!.variants!.where((element) => element.variantSku == controller.selectedVariants.join('-')).isNotEmpty ? productModel.itemAttribute!.variants!.where((element) => element.variantSku == controller.selectedVariants.join('-')).first.variantId.toString() : ""}", - ); - if (productIsInList) { - CartProductModel element = cartItem.firstWhere( + final bool + productIsInList = cartItem.any( (product) => product.id == "${productModel.id}~${productModel.itemAttribute!.variants!.where((element) => element.variantSku == controller.selectedVariants.join('-')).isNotEmpty ? productModel.itemAttribute!.variants!.where((element) => element.variantSku == controller.selectedVariants.join('-')).first.variantId.toString() : ""}", ); - controller.quantity.value = element.quantity!; - } else { - controller.quantity.value = 1; - } + if (productIsInList) { + CartProductModel + element = cartItem.firstWhere( + (product) => + product.id == + "${productModel.id}~${productModel.itemAttribute!.variants!.where((element) => element.variantSku == controller.selectedVariants.join('-')).isNotEmpty ? productModel.itemAttribute!.variants!.where((element) => element.variantSku == controller.selectedVariants.join('-')).first.variantId.toString() : ""}", + ); + controller.quantity.value = + element.quantity!; + } else { + controller.quantity.value = + 1; + } - controller.update(); - controller.calculatePrice(productModel); - }, - child: Chip( - shape: const RoundedRectangleBorder(side: BorderSide(color: Colors.transparent), borderRadius: BorderRadius.all(Radius.circular(20))), - label: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - productModel.itemAttribute!.attributes![index].attributeOptions![i].toString(), - style: TextStyle( - overflow: TextOverflow.ellipsis, - fontFamily: AppThemeData.medium, - fontWeight: FontWeight.w500, - color: - controller.selectedVariants.contains(productModel.itemAttribute!.attributes![index].attributeOptions![i].toString()) - ? Colors.white - : isDark - ? AppThemeData.greyDark800 - : AppThemeData.grey800, + controller.update(); + controller.calculatePrice( + productModel, + ); + }, + child: Chip( + shape: + const RoundedRectangleBorder( + side: BorderSide( + color: + Colors + .transparent, + ), + borderRadius: + BorderRadius.all( + Radius.circular( + 20, + ), + ), ), - ), - ], + label: Row( + mainAxisSize: + MainAxisSize.min, + children: [ + Text( + productModel + .itemAttribute! + .attributes![index] + .attributeOptions![i] + .toString(), + style: TextStyle( + overflow: + TextOverflow + .ellipsis, + fontFamily: + AppThemeData + .medium, + fontWeight: + FontWeight.w500, + color: + controller.selectedVariants.contains( + productModel + .itemAttribute! + .attributes![index] + .attributeOptions![i] + .toString(), + ) + ? Colors.white + : isDark + ? AppThemeData + .greyDark800 + : AppThemeData + .grey800, + ), + ), + ], + ), + backgroundColor: + controller.selectedVariants.contains( + productModel + .itemAttribute! + .attributes![index] + .attributeOptions![i] + .toString(), + ) + ? AppThemeData + .primary300 + : isDark + ? AppThemeData.grey800 + : AppThemeData + .grey100, + elevation: 6.0, + padding: const EdgeInsets.all( + 8.0, + ), ), - backgroundColor: - controller.selectedVariants.contains(productModel.itemAttribute!.attributes![index].attributeOptions![i].toString()) - ? AppThemeData.primary300 - : isDark - ? AppThemeData.grey800 - : AppThemeData.grey100, - elevation: 6.0, - padding: const EdgeInsets.all(8.0), - ), - ); - }).toList(), + ); + }, + ).toList(), ), ), ], @@ -1686,19 +3031,33 @@ class ProductDetailsView extends StatelessWidget { ); }, ), - productModel.addOnsTitle == null || productModel.addOnsTitle!.isEmpty + productModel.addOnsTitle == null || + productModel.addOnsTitle!.isEmpty ? const SizedBox() : Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 5), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 5, + ), child: Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + ), + ), child: Padding( padding: const EdgeInsets.symmetric(vertical: 10), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( - padding: const EdgeInsets.symmetric(horizontal: 12), + padding: const EdgeInsets.symmetric( + horizontal: 12, + ), child: Text( "Addons".tr, style: TextStyle( @@ -1706,21 +3065,32 @@ class ProductDetailsView extends StatelessWidget { overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600, - color: isDark ? AppThemeData.grey100 : AppThemeData.grey800, + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey800, ), ), ), - const Padding(padding: EdgeInsets.symmetric(vertical: 10), child: Divider()), + const Padding( + padding: EdgeInsets.symmetric(vertical: 10), + child: Divider(), + ), ListView.builder( itemCount: productModel.addOnsTitle!.length, physics: const NeverScrollableScrollPhysics(), shrinkWrap: true, padding: EdgeInsets.zero, itemBuilder: (context, index) { - String title = productModel.addOnsTitle![index]; - String price = productModel.addOnsPrice![index]; + String title = + productModel.addOnsTitle![index]; + String price = + productModel.addOnsPrice![index]; return Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 5, + ), child: Row( children: [ Expanded( @@ -1733,12 +3103,21 @@ class ProductDetailsView extends StatelessWidget { overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500, - color: isDark ? AppThemeData.grey100 : AppThemeData.grey800, + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey800, ), ), ), Text( - Constant.amountShow(amount: Constant.productCommissionPrice(controller.vendorModel.value, price)), + Constant.amountShow( + amount: + Constant.productCommissionPrice( + controller.vendorModel.value, + price, + ), + ), textAlign: TextAlign.start, maxLines: 1, style: TextStyle( @@ -1746,7 +3125,10 @@ class ProductDetailsView extends StatelessWidget { overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500, - color: isDark ? AppThemeData.grey100 : AppThemeData.grey800, + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey800, ), ), const SizedBox(width: 10), @@ -1755,14 +3137,18 @@ class ProductDetailsView extends StatelessWidget { height: 24.0, width: 24.0, child: Checkbox( - value: controller.selectedAddOns.contains(title), - activeColor: AppThemeData.primary300, + value: controller.selectedAddOns + .contains(title), + activeColor: + AppThemeData.primary300, onChanged: (value) { if (value != null) { if (value == true) { - controller.selectedAddOns.add(title); + controller.selectedAddOns + .add(title); } else { - controller.selectedAddOns.remove(title); + controller.selectedAddOns + .remove(title); } controller.update(); } @@ -1794,7 +3180,15 @@ class ProductDetailsView extends StatelessWidget { child: Container( width: Responsive.width(100, context), height: Responsive.height(5.5, context), - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey700 : AppThemeData.grey200, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(200))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey700 + : AppThemeData.grey200, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(200), + ), + ), child: Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, @@ -1806,7 +3200,13 @@ class ProductDetailsView extends StatelessWidget { controller.update(); } }, - child: Icon(Icons.remove, color: isDark ? AppThemeData.grey100 : AppThemeData.grey800), + child: Icon( + Icons.remove, + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey800, + ), ), Padding( padding: const EdgeInsets.symmetric(horizontal: 16), @@ -1819,14 +3219,19 @@ class ProductDetailsView extends StatelessWidget { overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500, - color: isDark ? AppThemeData.grey100 : AppThemeData.grey800, + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey800, ), ), ), InkWell( onTap: () { if (productModel.itemAttribute == null) { - if (controller.quantity.value < (productModel.quantity ?? 0) || (productModel.quantity ?? 0) == -1) { + if (controller.quantity.value < + (productModel.quantity ?? 0) || + (productModel.quantity ?? 0) == -1) { controller.quantity.value += 1; controller.update(); } else { @@ -1834,9 +3239,20 @@ class ProductDetailsView extends StatelessWidget { } } else { int totalQuantity = int.parse( - productModel.itemAttribute!.variants!.where((element) => element.variantSku == controller.selectedVariants.join('-')).first.variantQuantity.toString(), + productModel.itemAttribute!.variants! + .where( + (element) => + element.variantSku == + controller.selectedVariants.join( + '-', + ), + ) + .first + .variantQuantity + .toString(), ); - if (controller.quantity.value < totalQuantity || totalQuantity == -1) { + if (controller.quantity.value < totalQuantity || + totalQuantity == -1) { controller.quantity.value += 1; controller.update(); } else { @@ -1844,7 +3260,13 @@ class ProductDetailsView extends StatelessWidget { } } }, - child: Icon(Icons.add, color: isDark ? AppThemeData.grey100 : AppThemeData.grey800), + child: Icon( + Icons.add, + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey800, + ), ), ], ), @@ -1854,7 +3276,9 @@ class ProductDetailsView extends StatelessWidget { Expanded( flex: 2, child: RoundedButtonFill( - title: "${'Add item'.tr} ${Constant.amountShow(amount: controller.calculatePrice(productModel))}".tr, + title: + "${'Add item'.tr} ${Constant.amountShow(amount: controller.calculatePrice(productModel))}" + .tr, height: 5.5, color: AppThemeData.primary300, textColor: AppThemeData.grey50, @@ -1863,36 +3287,94 @@ class ProductDetailsView extends StatelessWidget { if (productModel.itemAttribute == null) { await controller.addToCart( productModel: productModel, - price: Constant.productCommissionPrice(controller.vendorModel.value, productModel.price.toString()), - discountPrice: double.parse(productModel.disPrice.toString()) <= 0 ? "0" : Constant.productCommissionPrice(controller.vendorModel.value, productModel.disPrice.toString()), + price: Constant.productCommissionPrice( + controller.vendorModel.value, + productModel.price.toString(), + ), + discountPrice: + double.parse( + productModel.disPrice.toString(), + ) <= + 0 + ? "0" + : Constant.productCommissionPrice( + controller.vendorModel.value, + productModel.disPrice.toString(), + ), isIncrement: true, quantity: controller.quantity.value, ); } else { String variantPrice = "0"; - if (productModel.itemAttribute!.variants!.any((e) => e.variantSku == controller.selectedVariants.join('-'))) { + if (productModel.itemAttribute!.variants!.any( + (e) => + e.variantSku == + controller.selectedVariants.join('-'), + )) { variantPrice = Constant.productCommissionPrice( controller.vendorModel.value, - productModel.itemAttribute!.variants!.firstWhere((e) => e.variantSku == controller.selectedVariants.join('-')).variantPrice ?? '0', + productModel.itemAttribute!.variants! + .firstWhere( + (e) => + e.variantSku == + controller.selectedVariants.join( + '-', + ), + ) + .variantPrice ?? + '0', ); } Map mapData = {}; - for (var element in productModel.itemAttribute!.attributes!) { + for (var element + in productModel.itemAttribute!.attributes!) { mapData.addEntries([ MapEntry( - controller.attributesList.firstWhere((e) => e.id == element.attributeId).title.toString(), - controller.selectedVariants[productModel.itemAttribute!.attributes!.indexOf(element)], + controller.attributesList + .firstWhere( + (e) => e.id == element.attributeId, + ) + .title + .toString(), + controller.selectedVariants[productModel + .itemAttribute! + .attributes! + .indexOf(element)], ), ]); } VariantInfo variantInfo = VariantInfo( - variantPrice: productModel.itemAttribute!.variants!.firstWhere((e) => e.variantSku == controller.selectedVariants.join('-')).variantPrice ?? '0', + variantPrice: + productModel.itemAttribute!.variants! + .firstWhere( + (e) => + e.variantSku == + controller.selectedVariants.join('-'), + ) + .variantPrice ?? + '0', variantSku: controller.selectedVariants.join('-'), variantOptions: mapData, - variantImage: productModel.itemAttribute!.variants!.firstWhere((e) => e.variantSku == controller.selectedVariants.join('-')).variantImage ?? '', - variantId: productModel.itemAttribute!.variants!.firstWhere((e) => e.variantSku == controller.selectedVariants.join('-')).variantId ?? '0', + variantImage: + productModel.itemAttribute!.variants! + .firstWhere( + (e) => + e.variantSku == + controller.selectedVariants.join('-'), + ) + .variantImage ?? + '', + variantId: + productModel.itemAttribute!.variants! + .firstWhere( + (e) => + e.variantSku == + controller.selectedVariants.join('-'), + ) + .variantId ?? + '0', ); await controller.addToCart( diff --git a/lib/screen_ui/multi_vendor_service/review_list_screen/review_list_screen.dart b/lib/screen_ui/multi_vendor_service/review_list_screen/review_list_screen.dart index 84e25ae..0150348 100644 --- a/lib/screen_ui/multi_vendor_service/review_list_screen/review_list_screen.dart +++ b/lib/screen_ui/multi_vendor_service/review_list_screen/review_list_screen.dart @@ -6,12 +6,12 @@ import 'package:customer/models/rating_model.dart'; import 'package:customer/models/review_attribute_model.dart'; import 'package:customer/themes/app_them_data.dart'; import 'package:customer/themes/responsive.dart'; + import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import '../../../controllers/theme_controller.dart'; import 'package:customer/utils/network_image_widget.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; - import '../../../service/fire_store_utils.dart'; import '../chat_screens/full_screen_image_viewer.dart'; @@ -26,12 +26,22 @@ class ReviewListScreen extends StatelessWidget { init: ReviewListController(), builder: (controller) { return Scaffold( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, appBar: AppBar( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, centerTitle: false, titleSpacing: 0, - title: Text("Reviews".tr, textAlign: TextAlign.start, style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900)), + title: Text( + "Reviews".tr, + textAlign: TextAlign.start, + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 16, + color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + ), + ), ), body: controller.isLoading.value @@ -39,7 +49,10 @@ class ReviewListScreen extends StatelessWidget { : controller.ratingList.isEmpty ? Constant.showEmptyView(message: "No Review found".tr) : Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: ListView.builder( itemCount: controller.ratingList.length, itemBuilder: (context, index) { @@ -48,21 +61,54 @@ class ReviewListScreen extends StatelessWidget { padding: const EdgeInsets.symmetric(vertical: 5), child: Container( decoration: ShapeDecoration( - color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, - shape: RoundedRectangleBorder(side: BorderSide(width: 1, color: isDark ? AppThemeData.grey700 : AppThemeData.grey200), borderRadius: BorderRadius.circular(12)), + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + side: BorderSide( + width: 1, + color: + isDark + ? AppThemeData.grey700 + : AppThemeData.grey200, + ), + borderRadius: BorderRadius.circular(12), + ), ), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text(ratingModel.uname.toString(), style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 18, fontFamily: AppThemeData.semiBold)), + Text( + ratingModel.uname.toString(), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 18, + fontFamily: AppThemeData.semiBold, + ), + ), Visibility( visible: ratingModel.productId != null, child: FutureBuilder( - future: FireStoreUtils.fireStore.collection(CollectionName.vendorProducts).doc(ratingModel.productId?.split('~').first).get(), + future: + FireStoreUtils.fireStore + .collection( + CollectionName.vendorProducts, + ) + .doc( + ratingModel.productId + ?.split('~') + .first, + ) + .get(), builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { + if (snapshot.connectionState == + ConnectionState.waiting) { return const Text(''); } else { if (snapshot.hasError) { @@ -70,10 +116,21 @@ class ReviewListScreen extends StatelessWidget { } else if (snapshot.data == null) { return const Text(''); } else if (snapshot.data != null) { - ProductModel model = ProductModel.fromJson(snapshot.data!.data()!); + ProductModel model = + ProductModel.fromJson( + snapshot.data!.data()!, + ); return Text( '${'Rate for'.tr} - ${model.name ?? ''}', - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 14, fontFamily: AppThemeData.semiBold), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 14, + fontFamily: + AppThemeData.semiBold, + ), ); } else { return const Text(''); @@ -90,50 +147,101 @@ class ReviewListScreen extends StatelessWidget { direction: Axis.horizontal, itemCount: 5, itemSize: 18, - itemPadding: const EdgeInsets.symmetric(horizontal: 2.0), - itemBuilder: (context, _) => const Icon(Icons.star, color: AppThemeData.warning300), + itemPadding: const EdgeInsets.symmetric( + horizontal: 2.0, + ), + itemBuilder: + (context, _) => const Icon( + Icons.star, + color: AppThemeData.warning300, + ), unratedColor: AppThemeData.grey400, onRatingUpdate: (double rate) {}, ), const SizedBox(height: 5), Visibility( - visible: ratingModel.comment != '' && ratingModel.comment != null, + visible: + ratingModel.comment != '' && + ratingModel.comment != null, child: Text( ratingModel.comment.toString(), - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16, fontFamily: AppThemeData.medium), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontSize: 16, + fontFamily: AppThemeData.medium, + ), ), ), const SizedBox(height: 5), Visibility( - visible: ratingModel.reviewAttributes != null, + visible: + ratingModel.reviewAttributes != null, child: ListView.builder( - itemCount: ratingModel.reviewAttributes!.length, + itemCount: + ratingModel.reviewAttributes!.length, shrinkWrap: true, - physics: const NeverScrollableScrollPhysics(), + physics: + const NeverScrollableScrollPhysics(), padding: EdgeInsets.zero, itemBuilder: (context, index) { - String key = ratingModel.reviewAttributes!.keys.elementAt(index); - dynamic value = ratingModel.reviewAttributes![key]; + String key = ratingModel + .reviewAttributes! + .keys + .elementAt(index); + dynamic value = + ratingModel.reviewAttributes![key]; return Padding( - padding: const EdgeInsets.symmetric(vertical: 2), + padding: const EdgeInsets.symmetric( + vertical: 2, + ), child: Row( children: [ FutureBuilder( - future: FireStoreUtils.fireStore.collection(CollectionName.reviewAttributes).doc(key).get(), + future: + FireStoreUtils.fireStore + .collection( + CollectionName + .reviewAttributes, + ) + .doc(key) + .get(), builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { + if (snapshot + .connectionState == + ConnectionState.waiting) { return const Text(''); } else { if (snapshot.hasError) { return const Text(''); - } else if (snapshot.data == null) { + } else if (snapshot.data == + null) { return const Text(''); } else { - ReviewAttributeModel model = ReviewAttributeModel.fromJson(snapshot.data!.data()!); + ReviewAttributeModel + model = + ReviewAttributeModel.fromJson( + snapshot.data! + .data()!, + ); return Expanded( child: Text( - model.title.toString(), - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontSize: 16, fontFamily: AppThemeData.semiBold), + model.title + .toString(), + style: TextStyle( + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, + fontSize: 16, + fontFamily: + AppThemeData + .semiBold, + ), ), ); } @@ -142,15 +250,29 @@ class ReviewListScreen extends StatelessWidget { ), RatingBar.builder( ignoreGestures: true, - initialRating: value == null ? 0.0 : value ?? 0.0, + initialRating: + value == null + ? 0.0 + : value ?? 0.0, minRating: 1, direction: Axis.horizontal, itemCount: 5, itemSize: 15, - unratedColor: AppThemeData.grey400, - itemPadding: const EdgeInsets.symmetric(horizontal: 2.0), - itemBuilder: (context, _) => const Icon(Icons.star, color: AppThemeData.warning300), - onRatingUpdate: (double rate) {}, + unratedColor: + AppThemeData.grey400, + itemPadding: + const EdgeInsets.symmetric( + horizontal: 2.0, + ), + itemBuilder: + (context, _) => const Icon( + Icons.star, + color: + AppThemeData + .warning300, + ), + onRatingUpdate: + (double rate) {}, ), ], ), @@ -168,16 +290,33 @@ class ReviewListScreen extends StatelessWidget { itemBuilder: (context, index) { return InkWell( onTap: () { - Get.to(FullScreenImageViewer(imageUrl: ratingModel.photos?[index])); + Get.to( + FullScreenImageViewer( + imageUrl: + ratingModel + .photos?[index], + ), + ); }, child: Padding( - padding: const EdgeInsets.all(6.0), + padding: const EdgeInsets.all( + 6.0, + ), child: ClipRRect( - borderRadius: BorderRadius.circular(10), + borderRadius: + BorderRadius.circular(10), child: NetworkImageWidget( - imageUrl: ratingModel.photos?[index], - height: Responsive.height(9, context), - width: Responsive.height(8, context), + imageUrl: + ratingModel + .photos?[index], + height: Responsive.height( + 9, + context, + ), + width: Responsive.height( + 8, + context, + ), fit: BoxFit.fill, ), ), @@ -188,8 +327,17 @@ class ReviewListScreen extends StatelessWidget { ), const SizedBox(height: 5), Text( - Constant.timestampToDateTime(ratingModel.createdAt!), - style: TextStyle(color: isDark ? AppThemeData.grey300 : AppThemeData.grey600, fontSize: 14, fontFamily: AppThemeData.medium), + Constant.timestampToDateTime( + ratingModel.createdAt!, + ), + style: TextStyle( + color: + isDark + ? AppThemeData.grey300 + : AppThemeData.grey600, + fontSize: 14, + fontFamily: AppThemeData.medium, + ), ), ], ), diff --git a/lib/screen_ui/multi_vendor_service/scan_qrcode_screen/scan_qr_code_screen.dart b/lib/screen_ui/multi_vendor_service/scan_qrcode_screen/scan_qr_code_screen.dart index 8a8b9c4..b5f9119 100644 --- a/lib/screen_ui/multi_vendor_service/scan_qrcode_screen/scan_qr_code_screen.dart +++ b/lib/screen_ui/multi_vendor_service/scan_qrcode_screen/scan_qr_code_screen.dart @@ -1,6 +1,8 @@ +import 'package:customer/constant/const_texts.dart'; import 'package:customer/controllers/scan_qr_code_controller.dart'; import 'package:customer/models/vendor_model.dart'; import 'package:customer/themes/app_them_data.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:qr_code_dart_scan/qr_code_dart_scan.dart'; @@ -23,8 +25,17 @@ class ScanQrCodeScreen extends StatelessWidget { appBar: AppBar( centerTitle: false, titleSpacing: 0, - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, - title: Text("Scan QR Code".tr, style: TextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500)), + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + title: Text( + "Scan QR Code".tr, + style: TextStyle( + fontSize: 16, + color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + fontFamily: AppThemeData.medium, + fontWeight: FontWeight.w500, + ), + ), ), body: QRCodeDartScanView( // enable scan invert qr code ( default = false) @@ -32,17 +43,23 @@ class ScanQrCodeScreen extends StatelessWidget { // if TypeScan.takePicture will try decode when click to take a picture(default TypeScan.live) onCapture: (Result result) { Get.back(); - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); if (controller.allNearestRestaurant.isNotEmpty) { - if (controller.allNearestRestaurant.where((vendor) => vendor.id == result.text).isEmpty) { + if (controller.allNearestRestaurant + .where((vendor) => vendor.id == result.text) + .isEmpty) { ShowToastDialog.closeLoader(); ShowToastDialog.showToast("Store is not available".tr); return; } - VendorModel storeModel = controller.allNearestRestaurant.firstWhere((vendor) => vendor.id == result.text); + VendorModel storeModel = controller.allNearestRestaurant + .firstWhere((vendor) => vendor.id == result.text); ShowToastDialog.closeLoader(); Get.back(); - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": storeModel}); + Get.to( + const RestaurantDetailsScreen(), + arguments: {"vendorModel": storeModel}, + ); } else { Get.back(); ShowToastDialog.showToast("Store is not available".tr); diff --git a/lib/screen_ui/multi_vendor_service/search_screen/search_screen.dart b/lib/screen_ui/multi_vendor_service/search_screen/search_screen.dart index b5f0b51..b1992ab 100644 --- a/lib/screen_ui/multi_vendor_service/search_screen/search_screen.dart +++ b/lib/screen_ui/multi_vendor_service/search_screen/search_screen.dart @@ -5,12 +5,12 @@ import 'package:customer/models/vendor_model.dart'; import 'package:customer/themes/app_them_data.dart'; import 'package:customer/themes/responsive.dart'; import 'package:customer/themes/text_field_widget.dart'; + import '../../../controllers/theme_controller.dart'; import 'package:customer/utils/network_image_widget.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:get/get.dart'; - import '../../../service/fire_store_utils.dart'; import '../../../widget/restaurant_image_view.dart'; import '../restaurant_details_screen/restaurant_details_screen.dart'; @@ -27,21 +27,40 @@ class SearchScreen extends StatelessWidget { builder: (controller) { return Scaffold( appBar: AppBar( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, centerTitle: false, titleSpacing: 0, title: Text( - Constant.sectionConstantModel?.name?.toLowerCase().contains('restaurants') == true ? "Find your favorite products and nearby stores" : "Search Item & Store".tr, + Constant.sectionConstantModel?.name?.toLowerCase().contains( + 'restaurants', + ) == + true + ? "Find your favorite products and nearby stores" + : "Search Item & Store".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 16, + color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + ), ), bottom: PreferredSize( preferredSize: const Size.fromHeight(55), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: TextFieldWidget( - hintText: Constant.sectionConstantModel?.name?.toLowerCase().contains('restaurants') == true ? 'Find your favorite products and nearby stores'.tr : 'Search the store and item'.tr, - prefix: Padding(padding: const EdgeInsets.symmetric(horizontal: 16), child: SvgPicture.asset("assets/icons/ic_search.svg")), + hintText: + Constant.sectionConstantModel?.name + ?.toLowerCase() + .contains('restaurants') == + true + ? 'Find your favorite products and nearby stores'.tr + : 'Search the store and item'.tr, + prefix: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: SvgPicture.asset("assets/icons/ic_search.svg"), + ), controller: null, onchange: (value) { controller.onSearchTextChanged(value); @@ -54,7 +73,10 @@ class SearchScreen extends StatelessWidget { controller.isLoading.value ? Constant.loader() : Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -67,9 +89,19 @@ class SearchScreen extends StatelessWidget { Text( "Store".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), + ), + const Padding( + padding: EdgeInsets.symmetric(vertical: 10), + child: Divider(), ), - const Padding(padding: EdgeInsets.symmetric(vertical: 10), child: Divider()), ], ), ListView.builder( @@ -77,33 +109,74 @@ class SearchScreen extends StatelessWidget { physics: const NeverScrollableScrollPhysics(), itemCount: controller.vendorSearchList.length, itemBuilder: (context, index) { - VendorModel vendorModel = controller.vendorSearchList[index]; + VendorModel vendorModel = + controller.vendorSearchList[index]; return InkWell( onTap: () { - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": vendorModel}); + Get.to( + const RestaurantDetailsScreen(), + arguments: {"vendorModel": vendorModel}, + ); }, child: Padding( padding: const EdgeInsets.only(bottom: 20), child: Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + ), + ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Stack( children: [ ClipRRect( - borderRadius: const BorderRadius.only(topLeft: Radius.circular(16), topRight: Radius.circular(16)), + borderRadius: + const BorderRadius.only( + topLeft: Radius.circular( + 16, + ), + topRight: Radius.circular( + 16, + ), + ), child: Stack( children: [ - RestaurantImageView(vendorModel: vendorModel), + RestaurantImageView( + vendorModel: vendorModel, + ), Container( - height: Responsive.height(20, context), - width: Responsive.width(100, context), + height: Responsive.height( + 20, + context, + ), + width: Responsive.width( + 100, + context, + ), decoration: BoxDecoration( gradient: LinearGradient( - begin: const Alignment(-0.00, -1.00), - end: const Alignment(0, 1), - colors: [Colors.black.withOpacity(0), const Color(0xFF111827)], + begin: const Alignment( + -0.00, + -1.00, + ), + end: const Alignment( + 0, + 1, + ), + colors: [ + Colors.black + .withOpacity(0), + const Color( + 0xFF111827, + ), + ], ), ), ), @@ -111,53 +184,124 @@ class SearchScreen extends StatelessWidget { ), ), Transform.translate( - offset: Offset(Responsive.width(-3, context), Responsive.height(17.5, context)), + offset: Offset( + Responsive.width(-3, context), + Responsive.height( + 17.5, + context, + ), + ), child: Row( - mainAxisAlignment: MainAxisAlignment.end, - crossAxisAlignment: CrossAxisAlignment.end, + mainAxisAlignment: + MainAxisAlignment.end, + crossAxisAlignment: + CrossAxisAlignment.end, children: [ Visibility( - visible: (vendorModel.isSelfDelivery == true && Constant.isSelfDeliveryFeature == true), + visible: + (vendorModel.isSelfDelivery == + true && + Constant.isSelfDeliveryFeature == + true), child: Row( children: [ Container( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 7), + padding: + const EdgeInsets.symmetric( + horizontal: 10, + vertical: 7, + ), decoration: BoxDecoration( - color: AppThemeData.success300, - borderRadius: BorderRadius.circular(120), // Optional + color: + AppThemeData + .success300, + borderRadius: + BorderRadius.circular( + 120, + ), // Optional ), child: Row( children: [ - SvgPicture.asset("assets/icons/ic_free_delivery.svg"), - const SizedBox(width: 5), + SvgPicture.asset( + "assets/icons/ic_free_delivery.svg", + ), + const SizedBox( + width: 5, + ), Text( - "Free Delivery".tr, - style: TextStyle(fontSize: 14, color: AppThemeData.success300, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600), + "Free Delivery" + .tr, + style: TextStyle( + fontSize: 14, + color: + AppThemeData + .success300, + fontFamily: + AppThemeData + .semiBold, + fontWeight: + FontWeight + .w600, + ), ), ], ), ), - const SizedBox(width: 6), + const SizedBox( + width: 6, + ), ], ), ), Container( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 7), + padding: + const EdgeInsets.symmetric( + horizontal: 10, + vertical: 7, + ), decoration: ShapeDecoration( - color: isDark ? AppThemeData.primary600 : AppThemeData.primary50, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120)), + color: + isDark + ? AppThemeData + .primary600 + : AppThemeData + .primary50, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 120, + ), + ), ), child: Row( children: [ - SvgPicture.asset("assets/icons/ic_star.svg", colorFilter: ColorFilter.mode(AppThemeData.primary300, BlendMode.srcIn)), - const SizedBox(width: 5), + SvgPicture.asset( + "assets/icons/ic_star.svg", + colorFilter: + ColorFilter.mode( + AppThemeData + .primary300, + BlendMode.srcIn, + ), + ), + const SizedBox( + width: 5, + ), Text( "${Constant.calculateReview(reviewCount: vendorModel.reviewsCount!.toStringAsFixed(0), reviewSum: vendorModel.reviewsSum.toString())} (${vendorModel.reviewsCount!.toStringAsFixed(0)})", style: TextStyle( fontSize: 14, - color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + color: + isDark + ? AppThemeData + .primary300 + : AppThemeData + .primary300, + fontFamily: + AppThemeData + .semiBold, + fontWeight: + FontWeight.w600, ), ), ], @@ -165,22 +309,54 @@ class SearchScreen extends StatelessWidget { ), const SizedBox(width: 6), Container( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 7), + padding: + const EdgeInsets.symmetric( + horizontal: 10, + vertical: 7, + ), decoration: ShapeDecoration( - color: isDark ? AppThemeData.ecommerce600 : AppThemeData.ecommerce50, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(120)), + color: + isDark + ? AppThemeData + .ecommerce600 + : AppThemeData + .ecommerce50, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 120, + ), + ), ), child: Row( children: [ - SvgPicture.asset("assets/icons/ic_map_distance.svg", colorFilter: ColorFilter.mode(AppThemeData.ecommerce300, BlendMode.srcIn)), - const SizedBox(width: 5), + SvgPicture.asset( + "assets/icons/ic_map_distance.svg", + colorFilter: + ColorFilter.mode( + AppThemeData + .ecommerce300, + BlendMode.srcIn, + ), + ), + const SizedBox( + width: 5, + ), Text( "${Constant.getDistance(lat1: vendorModel.latitude.toString(), lng1: vendorModel.longitude.toString(), lat2: Constant.selectedLocation.location!.latitude.toString(), lng2: Constant.selectedLocation.location!.longitude.toString())} ${Constant.distanceType}", style: TextStyle( fontSize: 14, - color: isDark ? AppThemeData.ecommerce300 : AppThemeData.ecommerce300, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + color: + isDark + ? AppThemeData + .ecommerce300 + : AppThemeData + .ecommerce300, + fontFamily: + AppThemeData + .semiBold, + fontWeight: + FontWeight.w600, ), ), ], @@ -193,9 +369,12 @@ class SearchScreen extends StatelessWidget { ), const SizedBox(height: 15), Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), + padding: const EdgeInsets.symmetric( + horizontal: 16, + ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( vendorModel.title.toString(), @@ -203,9 +382,15 @@ class SearchScreen extends StatelessWidget { maxLines: 1, style: TextStyle( fontSize: 18, - overflow: TextOverflow.ellipsis, - fontFamily: AppThemeData.semiBold, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + overflow: + TextOverflow.ellipsis, + fontFamily: + AppThemeData.semiBold, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData + .grey900, ), ), Text( @@ -213,10 +398,16 @@ class SearchScreen extends StatelessWidget { textAlign: TextAlign.start, maxLines: 1, style: TextStyle( - overflow: TextOverflow.ellipsis, - fontFamily: AppThemeData.medium, + overflow: + TextOverflow.ellipsis, + fontFamily: + AppThemeData.medium, fontWeight: FontWeight.w500, - color: isDark ? AppThemeData.grey400 : AppThemeData.grey400, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData + .grey400, ), ), ], @@ -238,9 +429,19 @@ class SearchScreen extends StatelessWidget { Text( "Items".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), + ), + const Padding( + padding: EdgeInsets.symmetric(vertical: 10), + child: Divider(), ), - const Padding(padding: EdgeInsets.symmetric(vertical: 10), child: Divider()), ], ), ListView.builder( @@ -248,15 +449,19 @@ class SearchScreen extends StatelessWidget { physics: const NeverScrollableScrollPhysics(), itemCount: controller.productSearchList.length, itemBuilder: (context, index) { - ProductModel productModel = controller.productSearchList[index]; + ProductModel productModel = + controller.productSearchList[index]; return FutureBuilder( future: getPrice(productModel), builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { + if (snapshot.connectionState == + ConnectionState.waiting) { return Constant.loader(); } else { if (snapshot.hasError) { - return Center(child: Text('Error: ${snapshot.error}')); + return Center( + child: Text('Error: ${snapshot.error}'), + ); } else if (snapshot.data == null) { return const SizedBox(); } else { @@ -265,36 +470,79 @@ class SearchScreen extends StatelessWidget { String disPrice = map['disPrice']; return InkWell( onTap: () async { - await FireStoreUtils.getVendorById(productModel.vendorID.toString()).then((value) { + await FireStoreUtils.getVendorById( + productModel.vendorID.toString(), + ).then((value) { if (value != null) { - Get.to(const RestaurantDetailsScreen(), arguments: {"vendorModel": value}); + Get.to( + const RestaurantDetailsScreen(), + arguments: { + "vendorModel": value, + }, + ); } }); }, child: Padding( - padding: const EdgeInsets.only(bottom: 20), + padding: const EdgeInsets.only( + bottom: 20, + ), child: Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Expanded( child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ - Constant.sectionConstantModel!.isProductDetails == false + Constant + .sectionConstantModel! + .isProductDetails == + false ? SizedBox() - : productModel.nonveg == true || productModel.veg == true + : productModel.nonveg == + true || + productModel.veg == + true ? Row( children: [ - productModel.nonveg == true ? SvgPicture.asset("assets/icons/ic_nonveg.svg") : SvgPicture.asset("assets/icons/ic_veg.svg"), - const SizedBox(width: 5), + productModel.nonveg == + true + ? SvgPicture.asset( + "assets/icons/ic_nonveg.svg", + ) + : SvgPicture.asset( + "assets/icons/ic_veg.svg", + ), + const SizedBox( + width: 5, + ), Text( - productModel.nonveg == true ? "Non Veg.".tr : "Pure veg.".tr, + productModel.nonveg == + true + ? "Non Veg." + .tr + : "Pure veg." + .tr, style: TextStyle( - color: productModel.nonveg == true ? AppThemeData.danger300 : AppThemeData.success400, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + color: + productModel.nonveg == + true + ? AppThemeData + .danger300 + : AppThemeData + .success400, + fontFamily: + AppThemeData + .semiBold, + fontWeight: + FontWeight + .w600, ), ), ], @@ -302,56 +550,129 @@ class SearchScreen extends StatelessWidget { : SizedBox(), const SizedBox(height: 5), Text( - productModel.name.toString(), + productModel.name + .toString(), style: TextStyle( fontSize: 18, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, + fontFamily: + AppThemeData + .semiBold, + fontWeight: + FontWeight.w600, ), ), double.parse(disPrice) <= 0 ? Text( - Constant.amountShow(amount: price), + Constant.amountShow( + amount: price, + ), style: TextStyle( fontSize: 16, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, + fontFamily: + AppThemeData + .semiBold, + fontWeight: + FontWeight.w600, ), ) : Row( children: [ Text( - Constant.amountShow(amount: disPrice), + Constant.amountShow( + amount: + disPrice, + ), style: TextStyle( fontSize: 16, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, + fontFamily: + AppThemeData + .semiBold, + fontWeight: + FontWeight + .w600, ), ), - const SizedBox(width: 5), + const SizedBox( + width: 5, + ), Text( - Constant.amountShow(amount: price), + Constant.amountShow( + amount: price, + ), style: TextStyle( fontSize: 14, - decoration: TextDecoration.lineThrough, - decorationColor: isDark ? AppThemeData.grey500 : AppThemeData.grey400, - color: isDark ? AppThemeData.grey500 : AppThemeData.grey400, - fontFamily: AppThemeData.semiBold, - fontWeight: FontWeight.w600, + decoration: + TextDecoration + .lineThrough, + decorationColor: + isDark + ? AppThemeData + .grey500 + : AppThemeData + .grey400, + color: + isDark + ? AppThemeData + .grey500 + : AppThemeData + .grey400, + fontFamily: + AppThemeData + .semiBold, + fontWeight: + FontWeight + .w600, ), ), ], ), Row( children: [ - SvgPicture.asset("assets/icons/ic_star.svg", colorFilter: const ColorFilter.mode(AppThemeData.warning300, BlendMode.srcIn)), - const SizedBox(width: 5), + SvgPicture.asset( + "assets/icons/ic_star.svg", + colorFilter: + const ColorFilter.mode( + AppThemeData + .warning300, + BlendMode.srcIn, + ), + ), + const SizedBox( + width: 5, + ), Text( "${Constant.calculateReview(reviewCount: productModel.reviewsCount!.toStringAsFixed(0), reviewSum: productModel.reviewsSum.toString())} (${productModel.reviewsCount!.toStringAsFixed(0)})", - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w500), + style: TextStyle( + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, + fontFamily: + AppThemeData + .regular, + fontWeight: + FontWeight.w500, + ), ), ], ), @@ -359,33 +680,73 @@ class SearchScreen extends StatelessWidget { "${productModel.description}", maxLines: 2, style: TextStyle( - overflow: TextOverflow.ellipsis, - color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, - fontFamily: AppThemeData.regular, - fontWeight: FontWeight.w400, + overflow: + TextOverflow + .ellipsis, + color: + isDark + ? AppThemeData + .grey50 + : AppThemeData + .grey900, + fontFamily: + AppThemeData + .regular, + fontWeight: + FontWeight.w400, ), ), ], ), ), ClipRRect( - borderRadius: const BorderRadius.all(Radius.circular(16)), + borderRadius: + const BorderRadius.all( + Radius.circular(16), + ), child: Stack( children: [ NetworkImageWidget( - imageUrl: productModel.photo.toString(), + imageUrl: + productModel.photo + .toString(), fit: BoxFit.cover, - height: Responsive.height(16, context), - width: Responsive.width(34, context), + height: Responsive.height( + 16, + context, + ), + width: Responsive.width( + 34, + context, + ), ), Container( - height: Responsive.height(16, context), - width: Responsive.width(34, context), + height: Responsive.height( + 16, + context, + ), + width: Responsive.width( + 34, + context, + ), decoration: BoxDecoration( gradient: LinearGradient( - begin: const Alignment(-0.00, -1.00), - end: const Alignment(0, 1), - colors: [Colors.black.withOpacity(0), const Color(0xFF111827)], + begin: + const Alignment( + -0.00, + -1.00, + ), + end: const Alignment( + 0, + 1, + ), + colors: [ + Colors.black + .withOpacity(0), + const Color( + 0xFF111827, + ), + ], ), ), ), @@ -422,24 +783,56 @@ class SearchScreen extends StatelessWidget { print(productModel.price); print(productModel.disPrice); - VendorModel? vendorModel = await FireStoreUtils.getVendorById(productModel.vendorID.toString()); + VendorModel? vendorModel = await FireStoreUtils.getVendorById( + productModel.vendorID.toString(), + ); if (productModel.itemAttribute != null) { if (productModel.itemAttribute!.attributes!.isNotEmpty) { for (var element in productModel.itemAttribute!.attributes!) { if (element.attributeOptions!.isNotEmpty) { - selectedVariants.add(productModel.itemAttribute!.attributes![productModel.itemAttribute!.attributes!.indexOf(element)].attributeOptions![0].toString()); - selectedIndexVariants.add('${productModel.itemAttribute!.attributes!.indexOf(element)} _${productModel.itemAttribute!.attributes![0].attributeOptions![0].toString()}'); - selectedIndexArray.add('${productModel.itemAttribute!.attributes!.indexOf(element)}_0'); + selectedVariants.add( + productModel + .itemAttribute! + .attributes![productModel.itemAttribute!.attributes!.indexOf( + element, + )] + .attributeOptions![0] + .toString(), + ); + selectedIndexVariants.add( + '${productModel.itemAttribute!.attributes!.indexOf(element)} _${productModel.itemAttribute!.attributes![0].attributeOptions![0].toString()}', + ); + selectedIndexArray.add( + '${productModel.itemAttribute!.attributes!.indexOf(element)}_0', + ); } } } - if (productModel.itemAttribute!.variants!.where((element) => element.variantSku == selectedVariants.join('-')).isNotEmpty) { - price = Constant.productCommissionPrice(vendorModel!, productModel.itemAttribute!.variants!.where((element) => element.variantSku == selectedVariants.join('-')).first.variantPrice ?? '0'); + if (productModel.itemAttribute!.variants! + .where((element) => element.variantSku == selectedVariants.join('-')) + .isNotEmpty) { + price = Constant.productCommissionPrice( + vendorModel!, + productModel.itemAttribute!.variants! + .where( + (element) => + element.variantSku == selectedVariants.join('-'), + ) + .first + .variantPrice ?? + '0', + ); disPrice = Constant.productCommissionPrice(vendorModel, '0'); } } else { - price = Constant.productCommissionPrice(vendorModel!, productModel.price.toString()); - disPrice = Constant.productCommissionPrice(vendorModel, productModel.disPrice.toString()); + price = Constant.productCommissionPrice( + vendorModel!, + productModel.price.toString(), + ); + disPrice = Constant.productCommissionPrice( + vendorModel, + productModel.disPrice.toString(), + ); } return {'price': price, 'disPrice': disPrice}; diff --git a/lib/screen_ui/multi_vendor_service/terms_and_condition/terms_and_condition_screen.dart b/lib/screen_ui/multi_vendor_service/terms_and_condition/terms_and_condition_screen.dart index 72c8525..fab46d9 100644 --- a/lib/screen_ui/multi_vendor_service/terms_and_condition/terms_and_condition_screen.dart +++ b/lib/screen_ui/multi_vendor_service/terms_and_condition/terms_and_condition_screen.dart @@ -1,5 +1,6 @@ import 'package:customer/constant/constant.dart'; import 'package:customer/themes/app_them_data.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:flutter_html/flutter_html.dart'; @@ -25,18 +26,39 @@ class TermsAndConditionScreen extends StatelessWidget { onTap: () { Get.back(); }, - child: Icon(Icons.chevron_left_outlined, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + child: Icon( + Icons.chevron_left_outlined, + color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + ), ), title: Text( type == "privacy" ? "Privacy Policy".tr : "Terms & Conditions".tr, - style: TextStyle(color: isDark ? AppThemeData.grey100 : AppThemeData.grey800, fontFamily: AppThemeData.bold, fontSize: 18), + style: TextStyle( + color: isDark ? AppThemeData.grey100 : AppThemeData.grey800, + fontFamily: AppThemeData.bold, + fontSize: 18, + ), ), elevation: 0, - bottom: PreferredSize(preferredSize: const Size.fromHeight(4.0), child: Container(color: isDark ? AppThemeData.grey700 : AppThemeData.grey200, height: 4.0)), + bottom: PreferredSize( + preferredSize: const Size.fromHeight(4.0), + child: Container( + color: isDark ? AppThemeData.grey700 : AppThemeData.grey200, + height: 4.0, + ), + ), ), body: Padding( padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10), - child: SingleChildScrollView(child: Html(shrinkWrap: true, data: type == "privacy" ? Constant.privacyPolicy : Constant.termsAndConditions)), + child: SingleChildScrollView( + child: Html( + shrinkWrap: true, + data: + type == "privacy" + ? Constant.privacyPolicy + : Constant.termsAndConditions, + ), + ), ), ); } diff --git a/lib/screen_ui/multi_vendor_service/wallet_screen/payment_list_screen.dart b/lib/screen_ui/multi_vendor_service/wallet_screen/payment_list_screen.dart index 94b47cd..26caea8 100644 --- a/lib/screen_ui/multi_vendor_service/wallet_screen/payment_list_screen.dart +++ b/lib/screen_ui/multi_vendor_service/wallet_screen/payment_list_screen.dart @@ -6,6 +6,7 @@ import 'package:customer/screen_ui/multi_vendor_service/wallet_screen/wallet_scr import 'package:customer/themes/app_them_data.dart'; import 'package:customer/themes/round_button_fill.dart'; import 'package:customer/themes/text_field_widget.dart'; + import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:get/get.dart'; @@ -24,10 +25,19 @@ class PaymentListScreen extends StatelessWidget { builder: (controller) { return Scaffold( appBar: AppBar( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, centerTitle: false, titleSpacing: 0, - title: Text("Top up Wallet".tr, style: TextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500)), + title: Text( + "Top up Wallet".tr, + style: TextStyle( + fontSize: 16, + color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + fontFamily: AppThemeData.medium, + fontWeight: FontWeight.w500, + ), + ), ), body: SingleChildScrollView( child: Column( @@ -39,40 +49,152 @@ class PaymentListScreen extends StatelessWidget { title: 'Amount'.tr, hintText: 'Enter Amount'.tr, controller: controller.topUpAmountController.value, - textInputType: const TextInputType.numberWithOptions(decimal: true, signed: true), - prefix: Padding(padding: const EdgeInsets.all(12.0), child: Text(Constant.currencyModel!.symbol.toString(), style: const TextStyle(fontSize: 20, color: AppThemeData.grey800))), - inputFormatters: [FilteringTextInputFormatter.allow(RegExp('[0-9]'))], + textInputType: const TextInputType.numberWithOptions( + decimal: true, + signed: true, + ), + prefix: Padding( + padding: const EdgeInsets.all(12.0), + child: Text( + Constant.currencyModel!.symbol.toString(), + style: const TextStyle( + fontSize: 20, + color: AppThemeData.grey800, + ), + ), + ), + inputFormatters: [ + FilteringTextInputFormatter.allow(RegExp('[0-9]')), + ], ), ), Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: Text( "Select Top up Options".tr, - style: TextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w500), + style: TextStyle( + fontSize: 16, + color: + isDark ? AppThemeData.grey50 : AppThemeData.grey900, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w500, + ), ), ), Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: Container( - decoration: BoxDecoration(borderRadius: const BorderRadius.all(Radius.circular(20)), color: isDark ? AppThemeData.grey900 : AppThemeData.grey50), + decoration: BoxDecoration( + borderRadius: const BorderRadius.all(Radius.circular(20)), + color: + isDark ? AppThemeData.grey900 : AppThemeData.grey50, + ), child: Column( children: [ - Visibility(visible: controller.stripeModel.value.isEnabled == true, child: cardDecoration(controller, PaymentGateway.stripe, isDark, "assets/images/stripe.png")), - Visibility(visible: controller.payPalModel.value.isEnabled == true, child: cardDecoration(controller, PaymentGateway.paypal, isDark, "assets/images/paypal.png")), - Visibility(visible: controller.payStackModel.value.isEnable == true, child: cardDecoration(controller, PaymentGateway.payStack, isDark, "assets/images/paystack.png")), Visibility( - visible: controller.mercadoPagoModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.mercadoPago, isDark, "assets/images/mercado-pago.png"), + visible: + controller.stripeModel.value.isEnabled == true, + child: cardDecoration( + controller, + PaymentGateway.stripe, + isDark, + "assets/images/stripe.png", + ), ), Visibility( - visible: controller.flutterWaveModel.value.isEnable == true, - child: cardDecoration(controller, PaymentGateway.flutterWave, isDark, "assets/images/flutterwave_logo.png"), + visible: + controller.payPalModel.value.isEnabled == true, + child: cardDecoration( + controller, + PaymentGateway.paypal, + isDark, + "assets/images/paypal.png", + ), + ), + Visibility( + visible: + controller.payStackModel.value.isEnable == true, + child: cardDecoration( + controller, + PaymentGateway.payStack, + isDark, + "assets/images/paystack.png", + ), + ), + Visibility( + visible: + controller.mercadoPagoModel.value.isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.mercadoPago, + isDark, + "assets/images/mercado-pago.png", + ), + ), + Visibility( + visible: + controller.flutterWaveModel.value.isEnable == + true, + child: cardDecoration( + controller, + PaymentGateway.flutterWave, + isDark, + "assets/images/flutterwave_logo.png", + ), + ), + Visibility( + visible: + controller.payFastModel.value.isEnable == true, + child: cardDecoration( + controller, + PaymentGateway.payFast, + isDark, + "assets/images/payfast.png", + ), + ), + Visibility( + visible: + controller.razorPayModel.value.isEnabled == true, + child: cardDecoration( + controller, + PaymentGateway.razorpay, + isDark, + "assets/images/razorpay.png", + ), + ), + Visibility( + visible: + controller.midTransModel.value.enable == true, + child: cardDecoration( + controller, + PaymentGateway.midTrans, + isDark, + "assets/images/midtrans.png", + ), + ), + Visibility( + visible: + controller.orangeMoneyModel.value.enable == true, + child: cardDecoration( + controller, + PaymentGateway.orangeMoney, + isDark, + "assets/images/orange_money.png", + ), + ), + Visibility( + visible: controller.xenditModel.value.enable == true, + child: cardDecoration( + controller, + PaymentGateway.xendit, + isDark, + "assets/images/xendit.png", + ), ), - Visibility(visible: controller.payFastModel.value.isEnable == true, child: cardDecoration(controller, PaymentGateway.payFast, isDark, "assets/images/payfast.png")), - Visibility(visible: controller.razorPayModel.value.isEnabled == true, child: cardDecoration(controller, PaymentGateway.razorpay, isDark, "assets/images/razorpay.png")), - Visibility(visible: controller.midTransModel.value.enable == true, child: cardDecoration(controller, PaymentGateway.midTrans, isDark, "assets/images/midtrans.png")), - Visibility(visible: controller.orangeMoneyModel.value.enable == true, child: cardDecoration(controller, PaymentGateway.orangeMoney, isDark, "assets/images/orange_money.png")), - Visibility(visible: controller.xenditModel.value.enable == true, child: cardDecoration(controller, PaymentGateway.xendit, isDark, "assets/images/xendit.png")), ], ), ), @@ -95,40 +217,101 @@ class PaymentListScreen extends StatelessWidget { if (controller.topUpAmountController.value.text.isEmpty) { ShowToastDialog.showToast("Please Enter Amount".tr); } else { - if (double.parse(controller.topUpAmountController.value.text) >= double.parse(Constant.minimumAmountToDeposit.toString())) { - if (controller.selectedPaymentMethod.value == PaymentGateway.stripe.name) { - controller.stripeMakePayment(amount: controller.topUpAmountController.value.text); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.paypal.name) { - controller.paypalPaymentSheet(controller.topUpAmountController.value.text, context); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.payStack.name) { - controller.payStackPayment(controller.topUpAmountController.value.text); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.mercadoPago.name) { - controller.mercadoPagoMakePayment(context: context, amount: controller.topUpAmountController.value.text); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.flutterWave.name) { - controller.flutterWaveInitiatePayment(context: context, amount: controller.topUpAmountController.value.text); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.payFast.name) { - controller.payFastPayment(context: context, amount: controller.topUpAmountController.value.text); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.midTrans.name) { - controller.midtransMakePayment(context: context, amount: controller.topUpAmountController.value.text); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.orangeMoney.name) { - controller.orangeMakePayment(context: context, amount: controller.topUpAmountController.value.text); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.xendit.name) { - controller.xenditPayment(context, controller.topUpAmountController.value.text); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.razorpay.name) { - RazorPayController().createOrderRazorPay(amount: double.parse(controller.topUpAmountController.value.text), razorpayModel: controller.razorPayModel.value).then((value) { - if (value == null) { - Get.back(); - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); - } else { - CreateRazorPayOrderModel result = value; - controller.openCheckout(amount: controller.topUpAmountController.value.text, orderId: result.id); - } - }); + if (double.parse( + controller.topUpAmountController.value.text, + ) >= + double.parse( + Constant.minimumAmountToDeposit.toString(), + )) { + if (controller.selectedPaymentMethod.value == + PaymentGateway.stripe.name) { + controller.stripeMakePayment( + amount: controller.topUpAmountController.value.text, + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.paypal.name) { + controller.paypalPaymentSheet( + controller.topUpAmountController.value.text, + context, + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.payStack.name) { + controller.payStackPayment( + controller.topUpAmountController.value.text, + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.mercadoPago.name) { + controller.mercadoPagoMakePayment( + context: context, + amount: controller.topUpAmountController.value.text, + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.flutterWave.name) { + controller.flutterWaveInitiatePayment( + context: context, + amount: controller.topUpAmountController.value.text, + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.payFast.name) { + controller.payFastPayment( + context: context, + amount: controller.topUpAmountController.value.text, + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.midTrans.name) { + controller.midtransMakePayment( + context: context, + amount: controller.topUpAmountController.value.text, + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.orangeMoney.name) { + controller.orangeMakePayment( + context: context, + amount: controller.topUpAmountController.value.text, + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.xendit.name) { + controller.xenditPayment( + context, + controller.topUpAmountController.value.text, + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.razorpay.name) { + RazorPayController() + .createOrderRazorPay( + amount: double.parse( + controller.topUpAmountController.value.text, + ), + razorpayModel: controller.razorPayModel.value, + ) + .then((value) { + if (value == null) { + Get.back(); + ShowToastDialog.showToast( + "Something went wrong, please contact admin." + .tr, + ); + } else { + CreateRazorPayOrderModel result = value; + controller.openCheckout( + amount: + controller + .topUpAmountController + .value + .text, + orderId: result.id, + ); + } + }); } else { - ShowToastDialog.showToast("Please select payment method".tr); + ShowToastDialog.showToast( + "Please select payment method".tr, + ); } } else { - ShowToastDialog.showToast("${'Please Enter minimum amount of'.tr} ${Constant.amountShow(amount: Constant.minimumAmountToDeposit)}"); + ShowToastDialog.showToast( + "${'Please Enter minimum amount of'.tr} ${Constant.amountShow(amount: Constant.minimumAmountToDeposit)}", + ); } } }, @@ -140,7 +323,12 @@ class PaymentListScreen extends StatelessWidget { ); } - Obx cardDecoration(WalletController controller, PaymentGateway value, isDark, String image) { + Obx cardDecoration( + WalletController controller, + PaymentGateway value, + isDark, + String image, + ) { return Obx( () => Padding( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), @@ -153,22 +341,35 @@ class PaymentListScreen extends StatelessWidget { Container( width: 50, height: 50, - decoration: ShapeDecoration(shape: RoundedRectangleBorder(side: const BorderSide(width: 1, color: Color(0xFFE5E7EB)), borderRadius: BorderRadius.circular(8))), - child: Padding(padding: EdgeInsets.all(value.name == "payFast" ? 0 : 8.0), child: Image.asset(image)), + decoration: ShapeDecoration( + shape: RoundedRectangleBorder( + side: const BorderSide(width: 1, color: Color(0xFFE5E7EB)), + borderRadius: BorderRadius.circular(8), + ), + ), + child: Padding( + padding: EdgeInsets.all(value.name == "payFast" ? 0 : 8.0), + child: Image.asset(image), + ), ), const SizedBox(width: 10), Expanded( child: Text( value.name.capitalizeString(), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 16, + color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + ), ), ), const Expanded(child: SizedBox()), Radio( value: value.name, groupValue: controller.selectedPaymentMethod.value, - activeColor: isDark ? AppThemeData.primary300 : AppThemeData.primary300, + activeColor: + isDark ? AppThemeData.primary300 : AppThemeData.primary300, onChanged: (value) { controller.selectedPaymentMethod.value = value.toString(); }, diff --git a/lib/screen_ui/multi_vendor_service/wallet_screen/wallet_screen.dart b/lib/screen_ui/multi_vendor_service/wallet_screen/wallet_screen.dart index be02e11..832f7fa 100644 --- a/lib/screen_ui/multi_vendor_service/wallet_screen/wallet_screen.dart +++ b/lib/screen_ui/multi_vendor_service/wallet_screen/wallet_screen.dart @@ -4,6 +4,8 @@ import 'package:customer/models/wallet_transaction_model.dart'; import 'package:customer/screen_ui/multi_vendor_service/wallet_screen/payment_list_screen.dart'; import 'package:customer/themes/app_them_data.dart'; import 'package:customer/themes/round_button_fill.dart'; +import 'package:customer/utils/app_router.dart'; + import '../../../constant/collection_name.dart'; import '../../../controllers/theme_controller.dart'; import '../../../models/cab_order_model.dart'; @@ -35,7 +37,8 @@ class WalletScreen extends StatelessWidget { init: WalletController(), builder: (controller) { return Scaffold( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, body: controller.isLoading.value ? Constant.loader() @@ -48,12 +51,30 @@ class WalletScreen extends StatelessWidget { children: [ Image.asset("assets/images/login.gif", height: 120), const SizedBox(height: 12), - Text("Please Log In to Continue".tr, style: TextStyle(color: isDark ? AppThemeData.grey100 : AppThemeData.grey800, fontSize: 22, fontFamily: AppThemeData.semiBold)), + Text( + "Please Log In to Continue".tr, + style: TextStyle( + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey800, + fontSize: 22, + fontFamily: AppThemeData.semiBold, + ), + ), const SizedBox(height: 5), Text( - "You’re not logged in. Please sign in to access your account and explore all features.".tr, + "You’re not logged in. Please sign in to access your account and explore all features." + .tr, textAlign: TextAlign.center, - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey500, fontSize: 16, fontFamily: AppThemeData.bold), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey500, + fontSize: 16, + fontFamily: AppThemeData.bold, + ), ), const SizedBox(height: 20), RoundedButtonFill( @@ -70,7 +91,9 @@ class WalletScreen extends StatelessWidget { ), ) : Padding( - padding: EdgeInsets.only(top: MediaQuery.of(context).viewPadding.top), + padding: EdgeInsets.only( + top: MediaQuery.of(context).viewPadding.top, + ), child: Column( children: [ Column( @@ -78,20 +101,39 @@ class WalletScreen extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.center, children: [ Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), + padding: const EdgeInsets.symmetric( + horizontal: 16, + ), child: Row( children: [ Expanded( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( "My Wallet".tr, - style: TextStyle(fontSize: 24, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w500), + style: TextStyle( + fontSize: 24, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w500, + ), ), Text( - "Keep track of your balance, transactions, and payment methods all in one place.".tr, - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w400), + "Keep track of your balance, transactions, and payment methods all in one place." + .tr, + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w400, + ), ), ], ), @@ -101,34 +143,66 @@ class WalletScreen extends StatelessWidget { ), const SizedBox(height: 20), Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), + padding: const EdgeInsets.symmetric( + horizontal: 16, + ), child: Container( decoration: const BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(20)), - image: DecorationImage(image: AssetImage("assets/images/wallet.png"), fit: BoxFit.fill), + borderRadius: BorderRadius.all( + Radius.circular(20), + ), + image: DecorationImage( + image: AssetImage( + "assets/images/wallet.png", + ), + fit: BoxFit.fill, + ), ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 20, + ), child: Column( children: [ Text( "My Wallet".tr, maxLines: 1, style: TextStyle( - color: isDark ? AppThemeData.primary100 : AppThemeData.primary100, + color: + isDark + ? AppThemeData.primary100 + : AppThemeData.primary100, fontSize: 16, overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.regular, ), ), Text( - Constant.amountShow(amount: controller.userModel.value.walletAmount.toString()), + Constant.amountShow( + amount: + controller + .userModel + .value + .walletAmount + .toString(), + ), maxLines: 1, - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey50, fontSize: 40, overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.bold), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey50, + fontSize: 40, + overflow: TextOverflow.ellipsis, + fontFamily: AppThemeData.bold, + ), ), const SizedBox(height: 20), Padding( - padding: const EdgeInsets.symmetric(horizontal: 80), + padding: const EdgeInsets.symmetric( + horizontal: 80, + ), child: RoundedButtonFill( title: "Top up".tr, color: AppThemeData.warning300, @@ -148,15 +222,30 @@ class WalletScreen extends StatelessWidget { Expanded( child: controller.walletTransactionList.isEmpty - ? Constant.showEmptyView(message: "Transaction not found".tr) + ? Constant.showEmptyView( + message: "Transaction not found".tr, + ) : Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: ListView.builder( padding: EdgeInsets.zero, - itemCount: controller.walletTransactionList.length, + itemCount: + controller + .walletTransactionList + .length, itemBuilder: (context, index) { - WalletTransactionModel walletTractionModel = controller.walletTransactionList[index]; - return transactionCard(controller, isDark, walletTractionModel); + WalletTransactionModel + walletTractionModel = + controller + .walletTransactionList[index]; + return transactionCard( + controller, + isDark, + walletTractionModel, + ); }, ), ), @@ -169,32 +258,54 @@ class WalletScreen extends StatelessWidget { ); } - Column transactionCard(WalletController controller, isDark, WalletTransactionModel transactionModel) { + Column transactionCard( + WalletController controller, + isDark, + WalletTransactionModel transactionModel, + ) { return Column( children: [ InkWell( onTap: () async { final orderId = transactionModel.orderId.toString(); - final orderData = await FireStoreUtils.getOrderByIdFromAllCollections(orderId); + final orderData = + await FireStoreUtils.getOrderByIdFromAllCollections(orderId); if (orderData != null) { final collection = orderData['collection_name']; switch (collection) { case CollectionName.parcelOrders: - Get.to(const ParcelOrderDetails(), arguments: ParcelOrderModel.fromJson(orderData)); + Get.to( + const ParcelOrderDetails(), + arguments: ParcelOrderModel.fromJson(orderData), + ); break; case CollectionName.providerOrders: - Get.to(const OnDemandOrderDetailsScreen(), arguments: OnProviderOrderModel.fromJson(orderData)); + Get.to( + const OnDemandOrderDetailsScreen(), + arguments: OnProviderOrderModel.fromJson(orderData), + ); break; case CollectionName.rentalOrders: - Get.to(() => RentalOrderDetailsScreen(), arguments: RentalOrderModel.fromJson(orderData)); + Get.to( + () => RentalOrderDetailsScreen(), + arguments: RentalOrderModel.fromJson(orderData), + ); break; case CollectionName.rides: - Get.to(const CabOrderDetails(), arguments: {"cabOrderModel": CabOrderModel.fromJson(orderData)}); + Get.to( + const CabOrderDetails(), + arguments: { + "cabOrderModel": CabOrderModel.fromJson(orderData), + }, + ); break; case CollectionName.vendorOrders: - Get.to(const OrderDetailsScreen(), arguments: {"orderModel": OrderModel.fromJson(orderData)}); + Get.to( + const OrderDetailsScreen(), + arguments: {"orderModel": OrderModel.fromJson(orderData)}, + ); break; default: ShowToastDialog.showToast("Order details not available".tr); @@ -219,14 +330,31 @@ class WalletScreen extends StatelessWidget { children: [ Container( decoration: ShapeDecoration( - shape: RoundedRectangleBorder(side: BorderSide(width: 1, color: isDark ? AppThemeData.grey800 : AppThemeData.grey100), borderRadius: BorderRadius.circular(8)), + shape: RoundedRectangleBorder( + side: BorderSide( + width: 1, + color: + isDark + ? AppThemeData.grey800 + : AppThemeData.grey100, + ), + borderRadius: BorderRadius.circular(8), + ), ), child: Padding( padding: const EdgeInsets.all(16), child: transactionModel.isTopup == false - ? SvgPicture.asset("assets/icons/ic_debit.svg", height: 16, width: 16) - : SvgPicture.asset("assets/icons/ic_credit.svg", height: 16, width: 16), + ? SvgPicture.asset( + "assets/icons/ic_debit.svg", + height: 16, + width: 16, + ) + : SvgPicture.asset( + "assets/icons/ic_credit.svg", + height: 16, + width: 16, + ), ), ), const SizedBox(width: 10), @@ -239,19 +367,44 @@ class WalletScreen extends StatelessWidget { Expanded( child: Text( transactionModel.note.toString(), - style: TextStyle(fontSize: 16, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600, color: isDark ? AppThemeData.grey100 : AppThemeData.grey800), + style: TextStyle( + fontSize: 16, + fontFamily: AppThemeData.semiBold, + fontWeight: FontWeight.w600, + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey800, + ), ), ), Text( - Constant.amountShow(amount: transactionModel.amount.toString()), - style: TextStyle(fontSize: 16, fontFamily: AppThemeData.medium, color: transactionModel.isTopup == true ? AppThemeData.success400 : AppThemeData.danger300), + Constant.amountShow( + amount: transactionModel.amount.toString(), + ), + style: TextStyle( + fontSize: 16, + fontFamily: AppThemeData.medium, + color: + transactionModel.isTopup == true + ? AppThemeData.success400 + : AppThemeData.danger300, + ), ), ], ), const SizedBox(height: 2), Text( Constant.timestampToDateTime(transactionModel.date!), - style: TextStyle(fontSize: 12, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500, color: isDark ? AppThemeData.grey200 : AppThemeData.grey700), + style: TextStyle( + fontSize: 12, + fontFamily: AppThemeData.medium, + fontWeight: FontWeight.w500, + color: + isDark + ? AppThemeData.grey200 + : AppThemeData.grey700, + ), ), ], ), @@ -260,10 +413,30 @@ class WalletScreen extends StatelessWidget { ), ), ), - Padding(padding: const EdgeInsets.symmetric(vertical: 5), child: MySeparator(color: isDark ? AppThemeData.grey700 : AppThemeData.grey200)), + Padding( + padding: const EdgeInsets.symmetric(vertical: 5), + child: MySeparator( + color: isDark ? AppThemeData.grey700 : AppThemeData.grey200, + ), + ), ], ); } } -enum PaymentGateway { payFast, mercadoPago, paypal, stripe, flutterWave, payStack, razorpay, cod, wallet, midTrans, orangeMoney, xendit } +enum PaymentGateway { + payme, + click, + payFast, + mercadoPago, + paypal, + stripe, + flutterWave, + payStack, + razorpay, + cod, + wallet, + midTrans, + orangeMoney, + xendit, +} diff --git a/lib/screen_ui/on_boarding_screen/on_boarding_screen.dart b/lib/screen_ui/on_boarding_screen/on_boarding_screen.dart index efaeca3..b549d97 100644 --- a/lib/screen_ui/on_boarding_screen/on_boarding_screen.dart +++ b/lib/screen_ui/on_boarding_screen/on_boarding_screen.dart @@ -1,5 +1,7 @@ import 'package:customer/constant/assets.dart'; import 'package:customer/themes/round_button_fill.dart'; +import 'package:customer/utils/app_router.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../../controllers/on_boarding_controller.dart'; @@ -24,7 +26,10 @@ class OnboardingScreen extends StatelessWidget { Image.asset(AppAssets.onBoardingBG, fit: BoxFit.cover), SafeArea( child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 20), + padding: const EdgeInsets.symmetric( + horizontal: 15, + vertical: 20, + ), child: Column( children: [ const SizedBox(height: 20), @@ -34,8 +39,18 @@ class OnboardingScreen extends StatelessWidget { text: TextSpan( style: AppThemeData.regularTextStyle(fontSize: 14), children: [ - TextSpan(text: "${controller.currentPage.value + 1}", style: AppThemeData.regularTextStyle(color: AppThemeData.grey800)), - TextSpan(text: "/$pageCount", style: AppThemeData.regularTextStyle(color: AppThemeData.grey400)), + TextSpan( + text: "${controller.currentPage.value + 1}", + style: AppThemeData.regularTextStyle( + color: AppThemeData.grey800, + ), + ), + TextSpan( + text: "/$pageCount", + style: AppThemeData.regularTextStyle( + color: AppThemeData.grey400, + ), + ), ], ), ), @@ -51,11 +66,28 @@ class OnboardingScreen extends StatelessWidget { return SingleChildScrollView( child: Column( children: [ - Text(item.title ?? '', style: AppThemeData.boldTextStyle(color: AppThemeData.grey900), textAlign: TextAlign.center), + Text( + item.title ?? '', + style: AppThemeData.boldTextStyle( + color: AppThemeData.grey900, + ), + textAlign: TextAlign.center, + ), const SizedBox(height: 5), - Text(item.description ?? '', style: AppThemeData.boldTextStyle(color: AppThemeData.grey500, fontSize: 14), textAlign: TextAlign.center), + Text( + item.description ?? '', + style: AppThemeData.boldTextStyle( + color: AppThemeData.grey500, + fontSize: 14, + ), + textAlign: TextAlign.center, + ), const SizedBox(height: 40), - NetworkImageWidget(imageUrl: item.image ?? '', width: double.infinity, height: 500), + NetworkImageWidget( + imageUrl: item.image ?? '', + width: double.infinity, + height: 500, + ), ], ), ); @@ -73,7 +105,14 @@ class OnboardingScreen extends StatelessWidget { ) : Row( children: [ - Expanded(child: RoundedButtonFill(title: "Skip".tr, onPress: () => _finish(), color: AppThemeData.grey50, textColor: AppThemeData.grey900)), + Expanded( + child: RoundedButtonFill( + title: "Skip".tr, + onPress: () => _finish(), + color: AppThemeData.grey50, + textColor: AppThemeData.grey900, + ), + ), const SizedBox(width: 20), Expanded( child: RoundedButtonFill( @@ -99,6 +138,6 @@ class OnboardingScreen extends StatelessWidget { Future _finish() async { await Preferences.setBoolean(Preferences.isFinishOnBoardingKey, true); - Get.offAll(() => const LoginScreen()); + Get.offAll(LoginScreen()); } } diff --git a/lib/screen_ui/on_demand_service/favourite_ondemand_screen.dart b/lib/screen_ui/on_demand_service/favourite_ondemand_screen.dart index 5764a23..4744a1c 100644 --- a/lib/screen_ui/on_demand_service/favourite_ondemand_screen.dart +++ b/lib/screen_ui/on_demand_service/favourite_ondemand_screen.dart @@ -9,6 +9,8 @@ import 'package:customer/screen_ui/on_demand_service/on_demand_details_screen.da import 'package:customer/service/fire_store_utils.dart'; import 'package:customer/themes/app_them_data.dart'; import 'package:customer/themes/round_button_fill.dart'; +import 'package:customer/utils/app_router.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -23,7 +25,8 @@ class FavouriteOndemandScreen extends StatelessWidget { init: FavouriteOndemmandController(), builder: (controller) { return Scaffold( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, appBar: AppBar( automaticallyImplyLeading: false, backgroundColor: AppThemeData.onDemand300, @@ -32,7 +35,15 @@ class FavouriteOndemandScreen extends StatelessWidget { child: Row( children: [ const SizedBox(width: 10), - Text("Favourite Services".tr, style: TextStyle(fontFamily: AppThemeData.semiBold, color: isDark ? AppThemeData.grey900 : AppThemeData.grey900, fontSize: 20)), + Text( + "Favourite Services".tr, + style: TextStyle( + fontFamily: AppThemeData.semiBold, + color: + isDark ? AppThemeData.grey900 : AppThemeData.grey900, + fontSize: 20, + ), + ), ], ), ), @@ -49,12 +60,30 @@ class FavouriteOndemandScreen extends StatelessWidget { children: [ Image.asset("assets/images/login.gif", height: 120), const SizedBox(height: 12), - Text("Please Log In to Continue".tr, style: TextStyle(color: isDark ? AppThemeData.grey100 : AppThemeData.grey800, fontSize: 22, fontFamily: AppThemeData.semiBold)), + Text( + "Please Log In to Continue".tr, + style: TextStyle( + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey800, + fontSize: 22, + fontFamily: AppThemeData.semiBold, + ), + ), const SizedBox(height: 5), Text( - "You’re not logged in. Please sign in to access your account and explore all features.".tr, + "You’re not logged in. Please sign in to access your account and explore all features." + .tr, textAlign: TextAlign.center, - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey500, fontSize: 16, fontFamily: AppThemeData.bold), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey500, + fontSize: 16, + fontFamily: AppThemeData.bold, + ), ), const SizedBox(height: 20), RoundedButtonFill( @@ -71,10 +100,15 @@ class FavouriteOndemandScreen extends StatelessWidget { ), ) : Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: controller.lstFav.isEmpty - ? Constant.showEmptyView(message: "Favourite Service not found.".tr) + ? Constant.showEmptyView( + message: "Favourite Service not found.".tr, + ) : ListView.builder( shrinkWrap: true, padding: EdgeInsets.zero, @@ -82,86 +116,231 @@ class FavouriteOndemandScreen extends StatelessWidget { physics: const BouncingScrollPhysics(), itemCount: controller.lstFav.length, itemBuilder: (context, index) { - return FutureBuilder>( - future: FireStoreUtils.getCurrentProviderService(controller.lstFav[index]), + return FutureBuilder< + List + >( + future: + FireStoreUtils.getCurrentProviderService( + controller.lstFav[index], + ), builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { - return const Center(child: CircularProgressIndicator()); + if (snapshot.connectionState == + ConnectionState.waiting) { + return const Center( + child: CircularProgressIndicator(), + ); } - if (!snapshot.hasData || snapshot.data == null || snapshot.data!.isEmpty) { + if (!snapshot.hasData || + snapshot.data == null || + snapshot.data!.isEmpty) { return const SizedBox(); // or a placeholder widget } - final provider = snapshot.data!.first; // safer way than [0] + final provider = + snapshot + .data! + .first; // safer way than [0] return GestureDetector( onTap: () { - Get.to(() => OnDemandDetailsScreen(), arguments: {'providerModel': provider}); + Get.to( + () => OnDemandDetailsScreen(), + arguments: { + 'providerModel': provider, + }, + ); }, child: Padding( - padding: const EdgeInsets.symmetric(vertical: 5), + padding: const EdgeInsets.symmetric( + vertical: 5, + ), child: Container( - height: MediaQuery.of(context).size.height * 0.16, + height: + MediaQuery.of( + context, + ).size.height * + 0.16, decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - border: Border.all(color: isDark ? AppThemeData.grey500 : Colors.grey.shade100, width: 1), - color: isDark ? AppThemeData.grey900 : Colors.white, + borderRadius: BorderRadius.circular( + 10, + ), + border: Border.all( + color: + isDark + ? AppThemeData.grey500 + : Colors.grey.shade100, + width: 1, + ), + color: + isDark + ? AppThemeData.grey900 + : Colors.white, ), child: Row( children: [ ClipRRect( - borderRadius: const BorderRadius.only(bottomLeft: Radius.circular(10), topLeft: Radius.circular(10)), + borderRadius: + const BorderRadius.only( + bottomLeft: + Radius.circular(10), + topLeft: Radius.circular( + 10, + ), + ), child: CachedNetworkImage( - imageUrl: provider.photos.isNotEmpty ? provider.photos.first : Constant.placeHolderImage, - height: MediaQuery.of(context).size.height * 0.16, + imageUrl: + provider.photos.isNotEmpty + ? provider + .photos + .first + : Constant + .placeHolderImage, + height: + MediaQuery.of( + context, + ).size.height * + 0.16, width: 110, fit: BoxFit.cover, - placeholder: (context, url) => Center(child: CircularProgressIndicator.adaptive(valueColor: AlwaysStoppedAnimation(AppThemeData.primary300))), - errorWidget: (context, url, error) => Image.network(Constant.placeHolderImage, fit: BoxFit.cover), + placeholder: + (context, url) => Center( + child: CircularProgressIndicator.adaptive( + valueColor: + AlwaysStoppedAnimation( + AppThemeData + .primary300, + ), + ), + ), + errorWidget: + ( + context, + url, + error, + ) => Image.network( + Constant + .placeHolderImage, + fit: BoxFit.cover, + ), ), ), Expanded( child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: + const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ Expanded( child: Text( - provider.title ?? "", + provider.title ?? + "", maxLines: 1, - overflow: TextOverflow.ellipsis, - style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold, color: isDark ? Colors.white : Colors.black), + overflow: + TextOverflow + .ellipsis, + style: TextStyle( + fontSize: 18, + fontWeight: + FontWeight + .bold, + color: + isDark + ? Colors + .white + : Colors + .black, + ), ), ), Obx( () => GestureDetector( - onTap: () => controller.toggleFavourite(provider), + onTap: + () => controller + .toggleFavourite( + provider, + ), child: Icon( - controller.lstFav.where((element) => element.service_id == provider.id).isNotEmpty ? Icons.favorite : Icons.favorite_border, + controller + .lstFav + .where( + ( + element, + ) => + element.service_id == + provider.id, + ) + .isNotEmpty + ? Icons + .favorite + : Icons + .favorite_border, size: 24, color: - controller.lstFav.where((element) => element.service_id == provider.id).isNotEmpty - ? AppThemeData.primary300 - : (isDark ? Colors.white38 : Colors.black38), + controller + .lstFav + .where( + ( + element, + ) => + element.service_id == + provider.id, + ) + .isNotEmpty + ? AppThemeData + .primary300 + : (isDark + ? Colors.white38 + : Colors.black38), ), ), ), ], ), - FutureBuilder( - future: controller.getCategory(provider.categoryId ?? ""), + FutureBuilder< + CategoryModel? + >( + future: controller + .getCategory( + provider.categoryId ?? + "", + ), builder: (ctx, snap) { - if (!snap.hasData) return const SizedBox(); - return Text(snap.data?.title ?? "", style: TextStyle(fontSize: 14, color: isDark ? Colors.white : Colors.black)); + if (!snap.hasData) + return const SizedBox(); + return Text( + snap.data?.title ?? + "", + style: TextStyle( + fontSize: 14, + color: + isDark + ? Colors + .white + : Colors + .black, + ), + ); }, ), - _buildPrice(provider, isDark: isDark), + _buildPrice( + provider, + isDark: isDark, + ), _buildRating(provider), ], ), @@ -175,79 +354,231 @@ class FavouriteOndemandScreen extends StatelessWidget { }, ); FutureBuilder>( - future: FireStoreUtils.getCurrentProviderService(controller.lstFav[index]), + future: + FireStoreUtils.getCurrentProviderService( + controller.lstFav[index], + ), builder: (context, snapshot) { return snapshot.data != null ? GestureDetector( onTap: () { - Get.to(() => OnDemandDetailsScreen(), arguments: {'providerModel': snapshot.data![0]}); + Get.to( + () => OnDemandDetailsScreen(), + arguments: { + 'providerModel': + snapshot.data![0], + }, + ); }, child: Padding( - padding: const EdgeInsets.symmetric(vertical: 5), + padding: const EdgeInsets.symmetric( + vertical: 5, + ), child: Container( - height: MediaQuery.of(context).size.height * 0.16, + height: + MediaQuery.of( + context, + ).size.height * + 0.16, decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - border: Border.all(color: isDark ? AppThemeData.grey500 : Colors.grey.shade100, width: 1), - color: isDark ? AppThemeData.grey900 : Colors.white, + borderRadius: + BorderRadius.circular(10), + border: Border.all( + color: + isDark + ? AppThemeData.grey500 + : Colors + .grey + .shade100, + width: 1, + ), + color: + isDark + ? AppThemeData.grey900 + : Colors.white, ), child: Row( children: [ ClipRRect( - borderRadius: const BorderRadius.only(bottomLeft: Radius.circular(10), topLeft: Radius.circular(10)), + borderRadius: + const BorderRadius.only( + bottomLeft: + Radius.circular( + 10, + ), + topLeft: + Radius.circular( + 10, + ), + ), child: CachedNetworkImage( - imageUrl: snapshot.data![0].photos.isNotEmpty ? snapshot.data![0].photos[0] : Constant.placeHolderImage, - height: MediaQuery.of(context).size.height * 0.16, + imageUrl: + snapshot + .data![0] + .photos + .isNotEmpty + ? snapshot + .data![0] + .photos[0] + : Constant + .placeHolderImage, + height: + MediaQuery.of( + context, + ).size.height * + 0.16, width: 110, fit: BoxFit.cover, - placeholder: (context, url) => Center(child: CircularProgressIndicator.adaptive(valueColor: AlwaysStoppedAnimation(AppThemeData.primary300))), - errorWidget: (context, url, error) => Image.network(Constant.placeHolderImage, fit: BoxFit.cover), + placeholder: + ( + context, + url, + ) => Center( + child: CircularProgressIndicator.adaptive( + valueColor: + AlwaysStoppedAnimation( + AppThemeData + .primary300, + ), + ), + ), + errorWidget: + ( + context, + url, + error, + ) => Image.network( + Constant + .placeHolderImage, + fit: BoxFit.cover, + ), ), ), Expanded( child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: + const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ Expanded( child: Text( - snapshot.data![0].title ?? "", + snapshot + .data![0] + .title ?? + "", maxLines: 1, - overflow: TextOverflow.ellipsis, - style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold, color: isDark ? Colors.white : Colors.black), + overflow: + TextOverflow + .ellipsis, + style: TextStyle( + fontSize: + 18, + fontWeight: + FontWeight + .bold, + color: + isDark + ? Colors.white + : Colors.black, + ), ), ), Obx( () => GestureDetector( - onTap: () => controller.toggleFavourite(snapshot.data![0]), + onTap: + () => controller.toggleFavourite( + snapshot + .data![0], + ), child: Icon( - controller.lstFav.where((element) => element.service_id == snapshot.data![0].id).isNotEmpty - ? Icons.favorite - : Icons.favorite_border, + controller + .lstFav + .where( + ( + element, + ) => + element.service_id == + snapshot.data![0].id, + ) + .isNotEmpty + ? Icons + .favorite + : Icons + .favorite_border, size: 24, color: - controller.lstFav.where((element) => element.service_id == snapshot.data![0].id).isNotEmpty + controller.lstFav + .where( + ( + element, + ) => + element.service_id == + snapshot.data![0].id, + ) + .isNotEmpty ? AppThemeData.primary300 - : (isDark ? Colors.white38 : Colors.black38), + : (isDark + ? Colors.white38 + : Colors.black38), ), ), ), ], ), - FutureBuilder( - future: controller.getCategory(snapshot.data![0].categoryId ?? ""), - builder: (ctx, snap) { - if (!snap.hasData) return const SizedBox(); - return Text(snap.data?.title ?? "", style: TextStyle(fontSize: 14, color: isDark ? Colors.white : Colors.black)); + FutureBuilder< + CategoryModel? + >( + future: controller + .getCategory( + snapshot + .data![0] + .categoryId ?? + "", + ), + builder: ( + ctx, + snap, + ) { + if (!snap.hasData) + return const SizedBox(); + return Text( + snap + .data + ?.title ?? + "", + style: TextStyle( + fontSize: 14, + color: + isDark + ? Colors + .white + : Colors + .black, + ), + ); }, ), - _buildPrice(snapshot.data![0], isDark: isDark), - _buildRating(snapshot.data![0]), + _buildPrice( + snapshot.data![0], + isDark: isDark, + ), + _buildRating( + snapshot.data![0], + ), ], ), ), @@ -271,20 +602,38 @@ class FavouriteOndemandScreen extends StatelessWidget { Widget _buildPrice(ProviderServiceModel provider, {bool isDark = false}) { if (provider.disPrice == "" || provider.disPrice == "0") { return Text( - provider.priceUnit == 'Fixed' ? Constant.amountShow(amount: provider.price) : '${Constant.amountShow(amount: provider.price ?? "0")}/${'hr'.tr}', - style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold, color: isDark ? Colors.white : AppThemeData.primary300), + provider.priceUnit == 'Fixed' + ? Constant.amountShow(amount: provider.price) + : '${Constant.amountShow(amount: provider.price ?? "0")}/${'hr'.tr}', + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + color: isDark ? Colors.white : AppThemeData.primary300, + ), ); } else { return Row( children: [ Text( - provider.priceUnit == 'Fixed' ? Constant.amountShow(amount: provider.disPrice ?? '0') : '${Constant.amountShow(amount: provider.disPrice)}/${'hr'.tr}', - style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold, color: isDark ? Colors.white : AppThemeData.primary300), + provider.priceUnit == 'Fixed' + ? Constant.amountShow(amount: provider.disPrice ?? '0') + : '${Constant.amountShow(amount: provider.disPrice)}/${'hr'.tr}', + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + color: isDark ? Colors.white : AppThemeData.primary300, + ), ), const SizedBox(width: 5), Text( - provider.priceUnit == 'Fixed' ? Constant.amountShow(amount: provider.price) : '${Constant.amountShow(amount: provider.price ?? "0")}/${'hr'.tr}', - style: const TextStyle(fontSize: 12, color: Colors.grey, decoration: TextDecoration.lineThrough), + provider.priceUnit == 'Fixed' + ? Constant.amountShow(amount: provider.price) + : '${Constant.amountShow(amount: provider.price ?? "0")}/${'hr'.tr}', + style: const TextStyle( + fontSize: 12, + color: Colors.grey, + decoration: TextDecoration.lineThrough, + ), ), ], ); @@ -297,14 +646,24 @@ class FavouriteOndemandScreen extends StatelessWidget { rating = (provider.reviewsSum ?? 0) / (provider.reviewsCount ?? 1); } return Container( - decoration: BoxDecoration(color: AppThemeData.warning400, borderRadius: BorderRadius.circular(16)), + decoration: BoxDecoration( + color: AppThemeData.warning400, + borderRadius: BorderRadius.circular(16), + ), padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5), child: Row( mainAxisSize: MainAxisSize.min, children: [ const Icon(Icons.star, size: 16, color: Colors.white), const SizedBox(width: 3), - Text(rating.toStringAsFixed(1), style: const TextStyle(letterSpacing: 0.5, fontSize: 12, color: Colors.white)), + Text( + rating.toStringAsFixed(1), + style: const TextStyle( + letterSpacing: 0.5, + fontSize: 12, + color: Colors.white, + ), + ), ], ), ); diff --git a/lib/screen_ui/on_demand_service/my_booking_on_demand_screen.dart b/lib/screen_ui/on_demand_service/my_booking_on_demand_screen.dart index c52ab10..655f22c 100644 --- a/lib/screen_ui/on_demand_service/my_booking_on_demand_screen.dart +++ b/lib/screen_ui/on_demand_service/my_booking_on_demand_screen.dart @@ -1,4 +1,5 @@ import 'package:cached_network_image/cached_network_image.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:intl/intl.dart'; @@ -23,13 +24,24 @@ class MyBookingOnDemandScreen extends StatelessWidget { builder: (controller) { return DefaultTabController( length: controller.tabTitles.length, - initialIndex: controller.tabTitles.indexOf(controller.selectedTab.value), + initialIndex: controller.tabTitles.indexOf( + controller.selectedTab.value, + ), child: Scaffold( appBar: AppBar( automaticallyImplyLeading: false, backgroundColor: AppThemeData.primary300, centerTitle: false, - title: Padding(padding: const EdgeInsets.only(bottom: 10), child: Text("Booking History".tr, style: AppThemeData.boldTextStyle(fontSize: 18, color: AppThemeData.grey900))), + title: Padding( + padding: const EdgeInsets.only(bottom: 10), + child: Text( + "Booking History".tr, + style: AppThemeData.boldTextStyle( + fontSize: 18, + color: AppThemeData.grey900, + ), + ), + ), bottom: PreferredSize( preferredSize: const Size.fromHeight(48), child: TabBar( @@ -40,8 +52,15 @@ class MyBookingOnDemandScreen extends StatelessWidget { labelColor: AppThemeData.grey900, unselectedLabelColor: AppThemeData.grey900, labelStyle: AppThemeData.boldTextStyle(fontSize: 16), - unselectedLabelStyle: AppThemeData.mediumTextStyle(fontSize: 16), - tabs: controller.tabTitles.map((title) => Tab(child: Center(child: Text(title)))).toList(), + unselectedLabelStyle: AppThemeData.mediumTextStyle( + fontSize: 16, + ), + tabs: + controller.tabTitles + .map( + (title) => Tab(child: Center(child: Text(title))), + ) + .toList(), ), ), ), @@ -54,78 +73,217 @@ class MyBookingOnDemandScreen extends StatelessWidget { final orders = controller.getOrdersForTab(title); if (orders.isEmpty) { - return Center(child: Text("No ride found".tr, style: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900))); + return Center( + child: Text( + "No ride found".tr, + style: AppThemeData.mediumTextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + ); } return ListView.builder( padding: const EdgeInsets.all(16), itemCount: orders.length, itemBuilder: (context, index) { - OnProviderOrderModel onProviderOrder = orders[index]; - WorkerModel? worker = controller.getWorker(onProviderOrder.workerId); + OnProviderOrderModel onProviderOrder = + orders[index]; + WorkerModel? worker = controller.getWorker( + onProviderOrder.workerId, + ); return InkWell( onTap: () { - Get.to(() => OnDemandOrderDetailsScreen(), arguments: onProviderOrder); + Get.to( + () => OnDemandOrderDetailsScreen(), + arguments: onProviderOrder, + ); }, child: Container( - padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 5), + padding: const EdgeInsets.symmetric( + horizontal: 5, + vertical: 5, + ), margin: const EdgeInsets.only(bottom: 15), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), - border: Border.all(color: isDark ? AppThemeData.grey500 : Colors.grey.shade100, width: 1), - color: isDark ? AppThemeData.grey500 : Colors.white, + border: Border.all( + color: + isDark + ? AppThemeData.grey500 + : Colors.grey.shade100, + width: 1, + ), + color: + isDark + ? AppThemeData.grey500 + : Colors.white, ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Row( children: [ Padding( - padding: const EdgeInsets.symmetric(horizontal: 10), + padding: + const EdgeInsets.symmetric( + horizontal: 10, + ), child: CachedNetworkImage( - imageUrl: onProviderOrder.provider.photos.first, + imageUrl: + onProviderOrder + .provider + .photos + .first, height: 80, width: 80, imageBuilder: - (context, imageProvider) => - Container(decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), image: DecorationImage(image: imageProvider, fit: BoxFit.cover))), - placeholder: (context, url) => Center(child: CircularProgressIndicator.adaptive(valueColor: AlwaysStoppedAnimation(AppThemeData.primary300))), + ( + context, + imageProvider, + ) => Container( + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular( + 10, + ), + image: DecorationImage( + image: imageProvider, + fit: BoxFit.cover, + ), + ), + ), + placeholder: + (context, url) => Center( + child: CircularProgressIndicator.adaptive( + valueColor: + AlwaysStoppedAnimation( + AppThemeData + .primary300, + ), + ), + ), errorWidget: - (context, url, error) => ClipRRect( - borderRadius: BorderRadius.circular(10), - child: Image.network(Constant.placeHolderImage, fit: BoxFit.cover, cacheHeight: 80, cacheWidth: 80), + ( + context, + url, + error, + ) => ClipRRect( + borderRadius: + BorderRadius.circular( + 10, + ), + child: Image.network( + Constant + .placeHolderImage, + fit: BoxFit.cover, + cacheHeight: 80, + cacheWidth: 80, + ), ), fit: BoxFit.cover, ), ), Expanded( child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 20), + padding: + const EdgeInsets.symmetric( + horizontal: 20, + ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Container( - padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 12), - decoration: BoxDecoration(color: AppThemeData.info50, border: Border.all(color: AppThemeData.info300), borderRadius: BorderRadius.circular(12)), - child: Text(onProviderOrder.status, style: AppThemeData.boldTextStyle(fontSize: 14, color: AppThemeData.info500)), - ), - Padding( - padding: const EdgeInsets.only(top: 6), + padding: + const EdgeInsets.symmetric( + vertical: 6, + horizontal: 12, + ), + decoration: BoxDecoration( + color: + AppThemeData.info50, + border: Border.all( + color: + AppThemeData + .info300, + ), + borderRadius: + BorderRadius.circular( + 12, + ), + ), child: Text( - onProviderOrder.provider.title.toString(), - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + onProviderOrder.status, + style: + AppThemeData.boldTextStyle( + fontSize: 14, + color: + AppThemeData + .info500, + ), + ), + ), + Padding( + padding: + const EdgeInsets.only( + top: 6, + ), + child: Text( + onProviderOrder + .provider + .title + .toString(), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), + ), + ), + Padding( + padding: + const EdgeInsets.only( + top: 6, + ), + child: buildPriceText( + onProviderOrder, ), ), - Padding(padding: const EdgeInsets.only(top: 6), child: buildPriceText(onProviderOrder)), const SizedBox(height: 6), - if (onProviderOrder.status != Constant.orderCompleted && - onProviderOrder.status != Constant.orderCancelled && - onProviderOrder.otp != null && - onProviderOrder.otp!.isNotEmpty) + if (onProviderOrder + .status != + Constant + .orderCompleted && + onProviderOrder + .status != + Constant + .orderCancelled && + onProviderOrder.otp != + null && + onProviderOrder + .otp! + .isNotEmpty) Text( "${'OTP :'.tr} ${onProviderOrder.otp}", - style: AppThemeData.mediumTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: AppThemeData.mediumTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), ), ], ), @@ -135,7 +293,12 @@ class MyBookingOnDemandScreen extends StatelessWidget { ), /// Bottom Details (Date, Provider, Worker) - buildBottomDetails(context, onProviderOrder, isDark, worker), + buildBottomDetails( + context, + onProviderOrder, + isDark, + worker, + ), ], ), ), @@ -151,37 +314,81 @@ class MyBookingOnDemandScreen extends StatelessWidget { } Widget buildPriceText(OnProviderOrderModel order) { - final hasDiscount = order.provider.disPrice != "" && order.provider.disPrice != "0"; - final price = hasDiscount ? order.provider.disPrice.toString() : order.provider.price.toString(); + final hasDiscount = + order.provider.disPrice != "" && order.provider.disPrice != "0"; + final price = + hasDiscount + ? order.provider.disPrice.toString() + : order.provider.price.toString(); return Text( - order.provider.priceUnit == 'Fixed' ? Constant.amountShow(amount: price) : "${Constant.amountShow(amount: price)}/${'hr'.tr}", - style: AppThemeData.mediumTextStyle(fontSize: 16, color: AppThemeData.primary300), + order.provider.priceUnit == 'Fixed' + ? Constant.amountShow(amount: price) + : "${Constant.amountShow(amount: price)}/${'hr'.tr}", + style: AppThemeData.mediumTextStyle( + fontSize: 16, + color: AppThemeData.primary300, + ), ); } - Widget buildBottomDetails(BuildContext context, OnProviderOrderModel order, bool isDark, WorkerModel? worker) { + Widget buildBottomDetails( + BuildContext context, + OnProviderOrderModel order, + bool isDark, + WorkerModel? worker, + ) { return Container( margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 10), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), - border: Border.all(color: isDark ? AppThemeData.grey400 : AppThemeData.grey100, width: 1), + border: Border.all( + color: isDark ? AppThemeData.grey400 : AppThemeData.grey100, + width: 1, + ), color: isDark ? AppThemeData.greyDark100 : AppThemeData.grey100, ), child: Padding( padding: const EdgeInsets.symmetric(vertical: 10), child: Column( children: [ - detailRow("Date & Time", DateFormat('dd-MMM-yyyy hh:mm a').format(order.scheduleDateTime!.toDate()), isDark), + detailRow( + "Date & Time", + DateFormat( + 'dd-MMM-yyyy hh:mm a', + ).format(order.scheduleDateTime!.toDate()), + isDark, + ), const Divider(thickness: 1), detailRow("Provider", order.provider.authorName.toString(), isDark), if (order.provider.priceUnit == "Hourly") ...[ - if (order.startTime != null) ...[const Divider(thickness: 1), detailRow("Start Time", DateFormat('dd-MMM-yyyy hh:mm a').format(order.startTime!.toDate()), isDark)], - if (order.endTime != null) ...[const Divider(thickness: 1), detailRow("End Time", DateFormat('dd-MMM-yyyy hh:mm a').format(order.endTime!.toDate()), isDark)], + if (order.startTime != null) ...[ + const Divider(thickness: 1), + detailRow( + "Start Time", + DateFormat( + 'dd-MMM-yyyy hh:mm a', + ).format(order.startTime!.toDate()), + isDark, + ), + ], + if (order.endTime != null) ...[ + const Divider(thickness: 1), + detailRow( + "End Time", + DateFormat( + 'dd-MMM-yyyy hh:mm a', + ).format(order.endTime!.toDate()), + isDark, + ), + ], ], - if (worker != null) ...[const Divider(thickness: 1), detailRow("Worker", worker.fullName().toString(), isDark)], + if (worker != null) ...[ + const Divider(thickness: 1), + detailRow("Worker", worker.fullName().toString(), isDark), + ], ], ), ), @@ -194,8 +401,20 @@ class MyBookingOnDemandScreen extends StatelessWidget { child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text(label.tr, style: AppThemeData.mediumTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), - Text(value.tr, style: AppThemeData.regularTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + label.tr, + style: AppThemeData.mediumTextStyle( + fontSize: 14, + color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + ), + ), + Text( + value.tr, + style: AppThemeData.regularTextStyle( + fontSize: 14, + color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + ), + ), ], ), ); diff --git a/lib/screen_ui/on_demand_service/on_demand_booking_screen.dart b/lib/screen_ui/on_demand_service/on_demand_booking_screen.dart index 5ca8936..fd01d93 100644 --- a/lib/screen_ui/on_demand_service/on_demand_booking_screen.dart +++ b/lib/screen_ui/on_demand_service/on_demand_booking_screen.dart @@ -1,5 +1,7 @@ import 'package:bottom_picker/bottom_picker.dart'; +import 'package:customer/constant/const_texts.dart'; import 'package:dotted_border/dotted_border.dart'; + import 'package:flutter/material.dart'; import 'package:geocoding/geocoding.dart'; import 'package:geolocator/geolocator.dart'; @@ -41,12 +43,30 @@ class OnDemandBookingScreen extends StatelessWidget { child: Container( height: 42, width: 42, - decoration: BoxDecoration(shape: BoxShape.circle, color: AppThemeData.grey50), - child: Center(child: Padding(padding: const EdgeInsets.only(left: 5), child: Icon(Icons.arrow_back_ios, color: AppThemeData.grey900, size: 20))), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: AppThemeData.grey50, + ), + child: Center( + child: Padding( + padding: const EdgeInsets.only(left: 5), + child: Icon( + Icons.arrow_back_ios, + color: AppThemeData.grey900, + size: 20, + ), + ), + ), ), ), const SizedBox(width: 10), - Text("Book Service".tr, style: AppThemeData.boldTextStyle(fontSize: 18, color: AppThemeData.grey900)), + Text( + "Book Service".tr, + style: AppThemeData.boldTextStyle( + fontSize: 18, + color: AppThemeData.grey900, + ), + ), ], ), ), @@ -57,13 +77,28 @@ class OnDemandBookingScreen extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ // Services Section - Text("Services".tr, style: AppThemeData.semiBoldTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + "Services".tr, + style: AppThemeData.semiBoldTextStyle( + fontSize: 18, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), const SizedBox(height: 10), Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), - border: Border.all(color: isDark ? AppThemeData.greyDark400 : AppThemeData.grey100), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark400 + : AppThemeData.grey100, + ), + color: + isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, ), padding: const EdgeInsets.all(8), child: Row( @@ -72,18 +107,60 @@ class OnDemandBookingScreen extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text(controller.provider.value?.title ?? '', style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + controller.provider.value?.title ?? '', + style: AppThemeData.mediumTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), const SizedBox(height: 5), - Text(controller.categoryTitle.value, style: AppThemeData.mediumTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), - if (controller.provider.value?.priceUnit == "Fixed") ...[ + Text( + controller.categoryTitle.value, + style: AppThemeData.mediumTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + if (controller.provider.value?.priceUnit == + "Fixed") ...[ const SizedBox(height: 20), Row( children: [ - GestureDetector(onTap: controller.decrementQuantity, child: Icon(Icons.remove_circle_outline, color: AppThemeData.primary300, size: 30)), + GestureDetector( + onTap: controller.decrementQuantity, + child: Icon( + Icons.remove_circle_outline, + color: AppThemeData.primary300, + size: 30, + ), + ), const SizedBox(width: 10), - Text('${controller.quantity.value}', style: AppThemeData.mediumTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + '${controller.quantity.value}', + style: AppThemeData.mediumTextStyle( + fontSize: 18, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), const SizedBox(width: 10), - GestureDetector(onTap: controller.incrementQuantity, child: Icon(Icons.add_circle_outline, color: AppThemeData.primary300, size: 30)), + GestureDetector( + onTap: controller.incrementQuantity, + child: Icon( + Icons.add_circle_outline, + color: AppThemeData.primary300, + size: 30, + ), + ), ], ), ], @@ -97,7 +174,15 @@ class OnDemandBookingScreen extends StatelessWidget { decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: Colors.grey.shade300, - image: controller.provider.value!.photos.isNotEmpty ? DecorationImage(image: NetworkImage(controller.provider.value?.photos.first), fit: BoxFit.cover) : null, + image: + controller.provider.value!.photos.isNotEmpty + ? DecorationImage( + image: NetworkImage( + controller.provider.value?.photos.first, + ), + fit: BoxFit.cover, + ) + : null, ), ), ], @@ -108,8 +193,14 @@ class OnDemandBookingScreen extends StatelessWidget { padding: const EdgeInsets.all(8), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), - border: Border.all(color: isDark ? AppThemeData.greyDark400 : AppThemeData.grey100), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark400 + : AppThemeData.grey100, + ), + color: + isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, ), child: Row( mainAxisAlignment: MainAxisAlignment.start, @@ -118,7 +209,16 @@ class OnDemandBookingScreen extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("Address".tr, style: AppThemeData.semiBoldTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + "Address".tr, + style: AppThemeData.semiBoldTextStyle( + fontSize: 18, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), SizedBox(height: 5), InkWell( onTap: () async { @@ -126,20 +226,32 @@ class OnDemandBookingScreen extends StatelessWidget { Get.to(AddressListScreen())!.then((value) { if (value != null) { ShippingAddress shippingAddress = value; - if (Constant.checkZoneCheck(shippingAddress.location!.latitude ?? 0.0, shippingAddress.location!.longitude ?? 0.0)) { - controller.selectedAddress.value = shippingAddress; + if (Constant.checkZoneCheck( + shippingAddress.location!.latitude ?? + 0.0, + shippingAddress.location!.longitude ?? + 0.0, + )) { + controller.selectedAddress.value = + shippingAddress; controller.calculatePrice(); } else { - ShowToastDialog.showToast("Service not available in this area".tr); + ShowToastDialog.showToast( + "Service not available in this area" + .tr, + ); } } }); } else { Constant.checkPermission( onTap: () async { - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader( + ConstTexts.pleaseWait.tr, + ); - ShippingAddress shippingAddress = ShippingAddress(); + ShippingAddress shippingAddress = + ShippingAddress(); try { await Geolocator.requestPermission(); @@ -147,43 +259,81 @@ class OnDemandBookingScreen extends StatelessWidget { ShowToastDialog.closeLoader(); if (Constant.selectedMapType == 'osm') { - final result = await Get.to(() => MapPickerPage()); + final result = await Get.to( + () => MapPickerPage(), + ); if (result != null) { final firstPlace = result; - final lat = firstPlace.coordinates.latitude; - final lng = firstPlace.coordinates.longitude; + final lat = + firstPlace.coordinates.latitude; + final lng = + firstPlace + .coordinates + .longitude; final address = firstPlace.address; shippingAddress.addressAs = "Home"; - shippingAddress.locality = address.toString(); - shippingAddress.location = UserLocation(latitude: lat, longitude: lng); + shippingAddress.locality = + address.toString(); + shippingAddress + .location = UserLocation( + latitude: lat, + longitude: lng, + ); - controller.selectedAddress.value = shippingAddress; + controller.selectedAddress.value = + shippingAddress; Get.back(); } } else { - Get.to(LocationPickerScreen())!.then((value) async { + Get.to(LocationPickerScreen())!.then(( + value, + ) async { if (value != null) { - SelectedLocationModel selectedLocationModel = value; + SelectedLocationModel + selectedLocationModel = value; - shippingAddress.addressAs = "Home"; - shippingAddress.location = UserLocation(latitude: selectedLocationModel.latLng!.latitude, longitude: selectedLocationModel.latLng!.longitude); - shippingAddress.locality = "Picked from Map"; + shippingAddress.addressAs = + "Home"; + shippingAddress + .location = UserLocation( + latitude: + selectedLocationModel + .latLng! + .latitude, + longitude: + selectedLocationModel + .latLng! + .longitude, + ); + shippingAddress.locality = + "Picked from Map"; - controller.selectedAddress.value = shippingAddress; + controller.selectedAddress.value = + shippingAddress; } }); } } catch (e) { - await placemarkFromCoordinates(19.228825, 72.854118).then((valuePlaceMaker) { - Placemark placeMark = valuePlaceMaker[0]; - shippingAddress.location = UserLocation(latitude: 19.228825, longitude: 72.854118); + await placemarkFromCoordinates( + 19.228825, + 72.854118, + ).then((valuePlaceMaker) { + Placemark placeMark = + valuePlaceMaker[0]; + shippingAddress + .location = UserLocation( + latitude: 19.228825, + longitude: 72.854118, + ); String currentLocation = "${placeMark.name}, ${placeMark.subLocality}, ${placeMark.locality}, ${placeMark.administrativeArea}, ${placeMark.postalCode}, ${placeMark.country}"; - shippingAddress.locality = currentLocation; + shippingAddress.locality = + currentLocation; }); - controller.selectedAddress.value = shippingAddress; + controller.selectedAddress.value = + shippingAddress; ShowToastDialog.closeLoader(); } }, @@ -192,10 +342,17 @@ class OnDemandBookingScreen extends StatelessWidget { } }, child: Text( - controller.selectedAddress.value.getFullAddress(), + controller.selectedAddress.value + .getFullAddress(), maxLines: 1, overflow: TextOverflow.ellipsis, - style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: AppThemeData.mediumTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ), ], @@ -205,7 +362,12 @@ class OnDemandBookingScreen extends StatelessWidget { ), ), const SizedBox(height: 15), - TextFieldWidget(title: "Description".tr, hintText: "Enter Description".tr, controller: controller.descriptionController.value, maxLine: 5), + TextFieldWidget( + title: "Description".tr, + hintText: "Enter Description".tr, + controller: controller.descriptionController.value, + maxLine: 5, + ), const SizedBox(height: 10), GestureDetector( onTap: () { @@ -219,13 +381,36 @@ class OnDemandBookingScreen extends StatelessWidget { buttonSingleColor: AppThemeData.primary300, buttonPadding: 10, buttonWidth: 70, - pickerTitle: Text("", style: AppThemeData.mediumTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), - backgroundColor: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - pickerTextStyle: AppThemeData.mediumTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + pickerTitle: Text( + "", + style: AppThemeData.mediumTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + backgroundColor: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + pickerTextStyle: AppThemeData.mediumTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), closeIconColor: isDark ? Colors.white : Colors.black, ).show(context); }, - child: TextFieldWidget(title: "Booking Date & Slot".tr, hintText: "Choose Date and Time".tr, controller: controller.dateTimeController.value, enable: false), + child: TextFieldWidget( + title: "Booking Date & Slot".tr, + hintText: "Choose Date and Time".tr, + controller: controller.dateTimeController.value, + enable: false, + ), ), const SizedBox(height: 15), controller.provider.value?.priceUnit == "Fixed" @@ -240,7 +425,14 @@ class OnDemandBookingScreen extends StatelessWidget { scrollDirection: Axis.horizontal, itemBuilder: (context, index) { final coupon = controller.couponList[index]; - return GestureDetector(onTap: () => controller.applyCoupon(coupon), child: buildOfferItem(controller, index, isDark)); + return GestureDetector( + onTap: () => controller.applyCoupon(coupon), + child: buildOfferItem( + controller, + index, + isDark, + ), + ); }, ), ) @@ -248,7 +440,16 @@ class OnDemandBookingScreen extends StatelessWidget { buildPromoCode(controller, isDark), Padding( padding: EdgeInsets.symmetric(vertical: 10), - child: Text("Price Detail".tr, style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + child: Text( + "Price Detail".tr, + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), ), priceTotalRow(controller, isDark), ], @@ -259,14 +460,23 @@ class OnDemandBookingScreen extends StatelessWidget { ), bottomNavigationBar: Padding( padding: const EdgeInsets.all(20.0), - child: RoundedButtonFill(title: "Confirm".tr, color: AppThemeData.primary300, textColor: AppThemeData.grey50, onPress: () => controller.confirmBooking(context)), + child: RoundedButtonFill( + title: "Confirm".tr, + color: AppThemeData.primary300, + textColor: AppThemeData.grey50, + onPress: () => controller.confirmBooking(context), + ), ), ); }, ); } - Widget buildOfferItem(OnDemandBookingController controller, int index, bool isDark) { + Widget buildOfferItem( + OnDemandBookingController controller, + int index, + bool isDark, + ) { return Obx(() { final coupon = controller.couponList[index]; @@ -274,7 +484,11 @@ class OnDemandBookingScreen extends StatelessWidget { margin: const EdgeInsets.fromLTRB(7, 10, 7, 10), height: 85, child: DottedBorder( - options: RoundedRectDottedBorderOptions(strokeWidth: 1, radius: const Radius.circular(10), color: AppThemeData.primary300), + options: RoundedRectDottedBorderOptions( + strokeWidth: 1, + radius: const Radius.circular(10), + color: AppThemeData.primary300, + ), child: Padding( padding: const EdgeInsets.fromLTRB(12, 5, 12, 0), child: Column( @@ -283,13 +497,26 @@ class OnDemandBookingScreen extends StatelessWidget { Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - const Image(image: AssetImage('assets/images/offer_icon.png'), height: 25, width: 25), + const Image( + image: AssetImage('assets/images/offer_icon.png'), + height: 25, + width: 25, + ), const SizedBox(width: 10), Container( margin: const EdgeInsets.only(top: 3), child: Text( - coupon.discountType == "Fix Price" ? "${Constant.amountShow(amount: coupon.discount.toString())} ${'OFF'.tr}" : "${coupon.discount} ${'% Off'.tr}", - style: TextStyle(fontWeight: FontWeight.bold, letterSpacing: 0.7, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + coupon.discountType == "Fix Price" + ? "${Constant.amountShow(amount: coupon.discount.toString())} ${'OFF'.tr}" + : "${coupon.discount} ${'% Off'.tr}", + style: TextStyle( + fontWeight: FontWeight.bold, + letterSpacing: 0.7, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ), ], @@ -298,11 +525,36 @@ class OnDemandBookingScreen extends StatelessWidget { Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text(coupon.code ?? '', style: const TextStyle(fontSize: 16, fontWeight: FontWeight.normal, letterSpacing: 0.5, color: Colors.orange)), - Container(margin: const EdgeInsets.only(left: 15, right: 15, top: 3), width: 1, color: AppThemeData.grey50), Text( - "valid till ".tr + controller.getDate(coupon.expiresAt!.toDate().toString()), - style: TextStyle(letterSpacing: 0.5, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + coupon.code ?? '', + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.normal, + letterSpacing: 0.5, + color: Colors.orange, + ), + ), + Container( + margin: const EdgeInsets.only( + left: 15, + right: 15, + top: 3, + ), + width: 1, + color: AppThemeData.grey50, + ), + Text( + "valid till ".tr + + controller.getDate( + coupon.expiresAt!.toDate().toString(), + ), + style: TextStyle( + letterSpacing: 0.5, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ], ), @@ -320,7 +572,9 @@ class OnDemandBookingScreen extends StatelessWidget { margin: const EdgeInsets.only(top: 10, bottom: 13), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), - border: Border.all(color: isDark ? AppThemeData.greyDark400 : AppThemeData.grey100), + border: Border.all( + color: isDark ? AppThemeData.greyDark400 : AppThemeData.grey100, + ), color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, ), child: Padding( @@ -331,17 +585,37 @@ class OnDemandBookingScreen extends StatelessWidget { Expanded( child: Row( children: [ - Image.asset("assets/images/reedem.png", height: 50, width: 50), + Image.asset( + "assets/images/reedem.png", + height: 50, + width: 50, + ), const SizedBox(width: 10), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("Promo Code".tr, style: AppThemeData.mediumTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), overflow: TextOverflow.ellipsis), + Text( + "Promo Code".tr, + style: AppThemeData.mediumTextStyle( + fontSize: 18, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + overflow: TextOverflow.ellipsis, + ), const SizedBox(height: 5), Text( "Apply promo code".tr, - style: AppThemeData.mediumTextStyle(fontSize: 15, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: AppThemeData.mediumTextStyle( + fontSize: 15, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), overflow: TextOverflow.ellipsis, ), ], @@ -352,7 +626,13 @@ class OnDemandBookingScreen extends StatelessWidget { ), FloatingActionButton( onPressed: () { - Get.bottomSheet(promoCodeSheet(controller, isDark), isScrollControlled: true, isDismissible: true, backgroundColor: Colors.transparent, enableDrag: true); + Get.bottomSheet( + promoCodeSheet(controller, isDark), + isScrollControlled: true, + isDismissible: true, + backgroundColor: Colors.transparent, + enableDrag: true, + ); }, mini: true, backgroundColor: Colors.blueGrey.shade50, @@ -370,7 +650,10 @@ class OnDemandBookingScreen extends StatelessWidget { return Container( padding: EdgeInsets.only(bottom: Get.height / 4.3, left: 25, right: 25), height: Get.height * 0.88, - decoration: BoxDecoration(color: Colors.transparent, border: Border.all(style: BorderStyle.none)), + decoration: BoxDecoration( + color: Colors.transparent, + border: Border.all(style: BorderStyle.none), + ), child: Column( children: [ InkWell( @@ -378,14 +661,21 @@ class OnDemandBookingScreen extends StatelessWidget { child: Container( height: 45, decoration: BoxDecoration( - border: Border.all(color: isDark ? AppThemeData.greyDark400 : AppThemeData.grey100, width: 0.3), + border: Border.all( + color: + isDark ? AppThemeData.greyDark400 : AppThemeData.grey100, + width: 0.3, + ), color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, shape: BoxShape.circle, ), child: Center( child: Icon( Icons.close, - color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, // ✅ visible color + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, // ✅ visible color size: 28, ), ), @@ -394,40 +684,93 @@ class OnDemandBookingScreen extends StatelessWidget { const SizedBox(height: 25), Expanded( child: Container( - decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, + ), alignment: Alignment.center, child: SingleChildScrollView( child: Column( children: [ - Container(padding: const EdgeInsets.only(top: 30), child: const Image(image: AssetImage('assets/images/redeem_coupon.png'), width: 100)), Container( - padding: const EdgeInsets.only(top: 20), - child: Text('Redeem Your Coupons'.tr, style: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, fontSize: 16)), - ), - Center( - child: Container( - padding: const EdgeInsets.only(top: 10, left: 22, right: 22), - child: Text("Voucher or Coupon code".tr, style: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + padding: const EdgeInsets.only(top: 30), + child: const Image( + image: AssetImage('assets/images/redeem_coupon.png'), + width: 100, ), ), Container( - padding: const EdgeInsets.only(left: 20, right: 20, top: 20), + padding: const EdgeInsets.only(top: 20), + child: Text( + 'Redeem Your Coupons'.tr, + style: AppThemeData.mediumTextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + fontSize: 16, + ), + ), + ), + Center( + child: Container( + padding: const EdgeInsets.only( + top: 10, + left: 22, + right: 22, + ), + child: Text( + "Voucher or Coupon code".tr, + style: AppThemeData.mediumTextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + ), + ), + Container( + padding: const EdgeInsets.only( + left: 20, + right: 20, + top: 20, + ), child: DottedBorder( - options: RoundedRectDottedBorderOptions(strokeWidth: 1, radius: const Radius.circular(12), color: AppThemeData.primary300), + options: RoundedRectDottedBorderOptions( + strokeWidth: 1, + radius: const Radius.circular(12), + color: AppThemeData.primary300, + ), child: ClipRRect( - borderRadius: const BorderRadius.all(Radius.circular(12)), + borderRadius: const BorderRadius.all( + Radius.circular(12), + ), child: Container( padding: const EdgeInsets.all(20), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, alignment: Alignment.center, child: TextFormField( textAlign: TextAlign.center, - style: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: AppThemeData.mediumTextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), controller: controller.couponTextController.value, decoration: InputDecoration( border: InputBorder.none, hintText: "Write Coupon Code".tr, - hintStyle: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.greyDark400 : AppThemeData.grey400), + hintStyle: AppThemeData.mediumTextStyle( + color: + isDark + ? AppThemeData.greyDark400 + : AppThemeData.grey400, + ), ), ), ), @@ -435,21 +778,34 @@ class OnDemandBookingScreen extends StatelessWidget { ), ), Padding( - padding: const EdgeInsets.only(top: 30, bottom: 30, left: 15, right: 15), + padding: const EdgeInsets.only( + top: 30, + bottom: 30, + left: 15, + right: 15, + ), child: RoundedButtonFill( title: "REDEEM NOW".tr, color: AppThemeData.primary300, textColor: AppThemeData.grey50, onPress: () { - final inputCode = controller.couponTextController.value.text.trim().toLowerCase(); + final inputCode = + controller.couponTextController.value.text + .trim() + .toLowerCase(); - final matchingCoupon = controller.couponList.firstWhereOrNull((c) => c.code?.toLowerCase() == inputCode); + final matchingCoupon = controller.couponList + .firstWhereOrNull( + (c) => c.code?.toLowerCase() == inputCode, + ); if (matchingCoupon != null) { controller.applyCoupon(matchingCoupon); Get.back(); } else { - ShowToastDialog.showToast("Applied coupon not valid.".tr); + ShowToastDialog.showToast( + "Applied coupon not valid.".tr, + ); } }, ), @@ -469,14 +825,22 @@ class OnDemandBookingScreen extends StatelessWidget { return Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), - border: Border.all(color: isDark ? AppThemeData.greyDark400 : AppThemeData.grey100), + border: Border.all( + color: isDark ? AppThemeData.greyDark400 : AppThemeData.grey100, + ), color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, ), child: Column( children: [ const SizedBox(height: 5), - rowText("Price".tr, Constant.amountShow(amount: controller.price.value.toString()), isDark), - controller.discountAmount.value != 0 ? const Divider() : const SizedBox(), + rowText( + "Price".tr, + Constant.amountShow(amount: controller.price.value.toString()), + isDark, + ), + controller.discountAmount.value != 0 + ? const Divider() + : const SizedBox(), controller.discountAmount.value != 0 ? Padding( padding: const EdgeInsets.symmetric(horizontal: 10), @@ -489,19 +853,39 @@ class OnDemandBookingScreen extends StatelessWidget { children: [ Text( "${"Discount".tr} ${controller.discountType.value == 'Percentage' || controller.discountType.value == 'Percent' ? "(${controller.discountLabel.value}%)" : "(${Constant.amountShow(amount: controller.discountLabel.value)})"}", - style: TextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: TextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + Text( + controller.offerCode.value, + style: TextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), - Text(controller.offerCode.value, style: TextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), ], ), ), - Text("(-${Constant.amountShow(amount: controller.discountAmount.value.toString())})", style: const TextStyle(color: Colors.red)), + Text( + "(-${Constant.amountShow(amount: controller.discountAmount.value.toString())})", + style: const TextStyle(color: Colors.red), + ), ], ), ) : const SizedBox(), const Divider(), - rowText("SubTotal".tr, Constant.amountShow(amount: controller.subTotal.value.toString()), isDark), + rowText( + "SubTotal".tr, + Constant.amountShow(amount: controller.subTotal.value.toString()), + isDark, + ), const Divider(), ListView.builder( itemCount: Constant.taxList.length, @@ -512,19 +896,39 @@ class OnDemandBookingScreen extends StatelessWidget { return Column( children: [ Padding( - padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 10), + padding: const EdgeInsets.symmetric( + vertical: 8, + horizontal: 10, + ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded( child: Text( "${taxModel.title} (${taxModel.type == "fix" ? Constant.amountShow(amount: taxModel.tax) : "${taxModel.tax}%"})", - style: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: AppThemeData.mediumTextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ), Text( - Constant.amountShow(amount: Constant.getTaxValue(amount: controller.subTotal.value.toString(), taxModel: taxModel).toString()), - style: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + Constant.amountShow( + amount: + Constant.getTaxValue( + amount: + controller.subTotal.value.toString(), + taxModel: taxModel, + ).toString(), + ), + style: AppThemeData.mediumTextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ], ), @@ -534,7 +938,13 @@ class OnDemandBookingScreen extends StatelessWidget { ); }, ), - rowText("Total Amount".tr, Constant.amountShow(amount: controller.totalAmount.value.toString()), isDark), + rowText( + "Total Amount".tr, + Constant.amountShow( + amount: controller.totalAmount.value.toString(), + ), + isDark, + ), const SizedBox(height: 5), ], ), @@ -548,8 +958,18 @@ class OnDemandBookingScreen extends StatelessWidget { child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text(title.tr, style: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), - Text(value.tr, style: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + title.tr, + style: AppThemeData.mediumTextStyle( + color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + ), + ), + Text( + value.tr, + style: AppThemeData.mediumTextStyle( + color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + ), + ), ], ), ); diff --git a/lib/screen_ui/on_demand_service/on_demand_category_screen.dart b/lib/screen_ui/on_demand_service/on_demand_category_screen.dart index 951ab38..afb4375 100644 --- a/lib/screen_ui/on_demand_service/on_demand_category_screen.dart +++ b/lib/screen_ui/on_demand_service/on_demand_category_screen.dart @@ -1,5 +1,6 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:customer/screen_ui/on_demand_service/view_category_service_screen.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../../constant/constant.dart'; @@ -32,8 +33,20 @@ class OnDemandCategoryScreen extends StatelessWidget { child: Container( height: 42, width: 42, - decoration: BoxDecoration(shape: BoxShape.circle, color: AppThemeData.grey50), - child: Center(child: Padding(padding: const EdgeInsets.only(left: 5), child: Icon(Icons.arrow_back_ios, color: AppThemeData.grey900, size: 20))), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: AppThemeData.grey50, + ), + child: Center( + child: Padding( + padding: const EdgeInsets.only(left: 5), + child: Icon( + Icons.arrow_back_ios, + color: AppThemeData.grey900, + size: 20, + ), + ), + ), ), ), const SizedBox(width: 10), @@ -41,12 +54,22 @@ class OnDemandCategoryScreen extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("Explore services".tr, style: AppThemeData.boldTextStyle(fontSize: 18, color: AppThemeData.grey900)), Text( - "Explore services tailored for you—quick, easy, and personalized.".tr, + "Explore services".tr, + style: AppThemeData.boldTextStyle( + fontSize: 18, + color: AppThemeData.grey900, + ), + ), + Text( + "Explore services tailored for you—quick, easy, and personalized." + .tr, maxLines: 1, overflow: TextOverflow.ellipsis, - style: AppThemeData.boldTextStyle(fontSize: 14, color: AppThemeData.grey900), + style: AppThemeData.boldTextStyle( + fontSize: 14, + color: AppThemeData.grey900, + ), ), ], ), @@ -59,7 +82,10 @@ class OnDemandCategoryScreen extends StatelessWidget { controller.isLoading.value ? Constant.loader() : Padding( - padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 15), + padding: const EdgeInsets.symmetric( + vertical: 20, + horizontal: 15, + ), child: SingleChildScrollView( child: Column( children: [ @@ -70,9 +96,17 @@ class OnDemandCategoryScreen extends StatelessWidget { itemCount: controller.categories.length, shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3), + gridDelegate: + const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 3, + ), itemBuilder: (context, index) { - return categoriesCell(context, controller.categories[index], index, isDark); + return categoriesCell( + context, + controller.categories[index], + index, + isDark, + ); }, ), ], @@ -84,16 +118,42 @@ class OnDemandCategoryScreen extends StatelessWidget { ); } - Widget categoriesCell(BuildContext context, CategoryModel category, int index, bool isDark) { + Widget categoriesCell( + BuildContext context, + CategoryModel category, + int index, + bool isDark, + ) { return GestureDetector( onTap: () { - Get.to(() => ViewCategoryServiceListScreen(), arguments: {'categoryId': category.id, 'categoryTitle': category.title}); + Get.to( + () => ViewCategoryServiceListScreen(), + arguments: { + 'categoryId': category.id, + 'categoryTitle': category.title, + }, + ); }, child: Column( children: [ - ClipRRect(borderRadius: BorderRadius.circular(12), child: CachedNetworkImage(imageUrl: category.image ?? "", height: 60, width: 60, fit: BoxFit.cover)), + ClipRRect( + borderRadius: BorderRadius.circular(12), + child: CachedNetworkImage( + imageUrl: category.image ?? "", + height: 60, + width: 60, + fit: BoxFit.cover, + ), + ), const SizedBox(height: 5), - Text(category.title ?? "", style: AppThemeData.semiBoldTextStyle(fontSize: 12, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), textAlign: TextAlign.center), + Text( + category.title ?? "", + style: AppThemeData.semiBoldTextStyle( + fontSize: 12, + color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + ), + textAlign: TextAlign.center, + ), ], ), ); diff --git a/lib/screen_ui/on_demand_service/on_demand_dashboard_screen.dart b/lib/screen_ui/on_demand_service/on_demand_dashboard_screen.dart index 74e2b49..bb7b781 100644 --- a/lib/screen_ui/on_demand_service/on_demand_dashboard_screen.dart +++ b/lib/screen_ui/on_demand_service/on_demand_dashboard_screen.dart @@ -2,10 +2,10 @@ import 'package:customer/constant/constant.dart'; import 'package:customer/controllers/cab_dashboard_controller.dart'; import 'package:customer/controllers/theme_controller.dart'; import 'package:customer/themes/app_them_data.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:get/get.dart'; - import '../../controllers/on_demand_dashboard_controller.dart'; class OnDemandDashboardScreen extends StatelessWidget { @@ -26,12 +26,19 @@ class OnDemandDashboardScreen extends StatelessWidget { showUnselectedLabels: true, showSelectedLabels: true, selectedFontSize: 12, - selectedLabelStyle: const TextStyle(fontFamily: AppThemeData.bold), - unselectedLabelStyle: const TextStyle(fontFamily: AppThemeData.bold), + selectedLabelStyle: const TextStyle( + fontFamily: AppThemeData.bold, + ), + unselectedLabelStyle: const TextStyle( + fontFamily: AppThemeData.bold, + ), currentIndex: controller.selectedIndex.value, - backgroundColor: isDark ? AppThemeData.grey900 : AppThemeData.grey50, - selectedItemColor: isDark ? AppThemeData.primary300 : AppThemeData.primary300, - unselectedItemColor: isDark ? AppThemeData.grey300 : AppThemeData.grey600, + backgroundColor: + isDark ? AppThemeData.grey900 : AppThemeData.grey50, + selectedItemColor: + isDark ? AppThemeData.primary300 : AppThemeData.primary300, + unselectedItemColor: + isDark ? AppThemeData.grey300 : AppThemeData.grey600, onTap: (int index) { if (index == 0) { Get.put(CabDashboardController()); @@ -41,18 +48,72 @@ class OnDemandDashboardScreen extends StatelessWidget { items: Constant.walletSetting == false ? [ - navigationBarItem(isDark, index: 0, assetIcon: "assets/icons/ic_home_cab.svg", label: 'Home'.tr, controller: controller), - navigationBarItem(isDark, index: 1, assetIcon: "assets/icons/ic_fav.svg", label: 'Favourites'.tr, controller: controller), - navigationBarItem(isDark, index: 2, assetIcon: "assets/icons/ic_booking_cab.svg", label: 'My Bookings'.tr, controller: controller), - navigationBarItem(isDark, index: 3, assetIcon: "assets/icons/ic_profile.svg", label: 'Profile'.tr, controller: controller), + navigationBarItem( + isDark, + index: 0, + assetIcon: "assets/icons/ic_home_cab.svg", + label: 'Home'.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 1, + assetIcon: "assets/icons/ic_fav.svg", + label: 'Favourites'.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 2, + assetIcon: "assets/icons/ic_booking_cab.svg", + label: 'My Bookings'.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 3, + assetIcon: "assets/icons/ic_profile.svg", + label: 'Profile'.tr, + controller: controller, + ), ] : [ - navigationBarItem(isDark, index: 0, assetIcon: "assets/icons/ic_home_cab.svg", label: 'Home'.tr, controller: controller), - navigationBarItem(isDark, index: 1, assetIcon: "assets/icons/ic_fav.svg", label: 'Favourites'.tr, controller: controller), + navigationBarItem( + isDark, + index: 0, + assetIcon: "assets/icons/ic_home_cab.svg", + label: 'Home'.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 1, + assetIcon: "assets/icons/ic_fav.svg", + label: 'Favourites'.tr, + controller: controller, + ), - navigationBarItem(isDark, index: 2, assetIcon: "assets/icons/ic_booking_cab.svg", label: 'My Bookings'.tr, controller: controller), - navigationBarItem(isDark, index: 3, assetIcon: "assets/icons/ic_wallet_cab.svg", label: 'Wallet'.tr, controller: controller), - navigationBarItem(isDark, index: 4, assetIcon: "assets/icons/ic_profile.svg", label: 'Profile'.tr, controller: controller), + navigationBarItem( + isDark, + index: 2, + assetIcon: "assets/icons/ic_booking_cab.svg", + label: 'My Bookings'.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 3, + assetIcon: "assets/icons/ic_wallet_cab.svg", + label: 'Wallet'.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 4, + assetIcon: "assets/icons/ic_profile.svg", + label: 'Profile'.tr, + controller: controller, + ), ], ), ); @@ -61,7 +122,13 @@ class OnDemandDashboardScreen extends StatelessWidget { }); } - BottomNavigationBarItem navigationBarItem(isDark, {required int index, required String label, required String assetIcon, required OnDemandDashboardController controller}) { + BottomNavigationBarItem navigationBarItem( + isDark, { + required int index, + required String label, + required String assetIcon, + required OnDemandDashboardController controller, + }) { return BottomNavigationBarItem( icon: Padding( padding: const EdgeInsets.symmetric(vertical: 5), diff --git a/lib/screen_ui/on_demand_service/on_demand_details_screen.dart b/lib/screen_ui/on_demand_service/on_demand_details_screen.dart index 98997ee..b524540 100644 --- a/lib/screen_ui/on_demand_service/on_demand_details_screen.dart +++ b/lib/screen_ui/on_demand_service/on_demand_details_screen.dart @@ -1,6 +1,8 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:customer/constant/constant.dart'; import 'package:customer/screen_ui/on_demand_service/provider_screen.dart'; +import 'package:customer/utils/app_router.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:get/get.dart'; @@ -24,7 +26,13 @@ class OnDemandDetailsScreen extends StatelessWidget { init: OnDemandDetailsController(), builder: (controller) { return Scaffold( - body: buildSliverScrollView(context, controller, controller.provider, controller.userModel, isDark), + body: buildSliverScrollView( + context, + controller, + controller.provider, + controller.userModel, + isDark, + ), bottomNavigationBar: controller.isOpen.value == false ? SizedBox() @@ -42,9 +50,20 @@ class OnDemandDetailsScreen extends StatelessWidget { if (Constant.userModel == null) { Get.offAll(const LoginScreen()); } else { - print("providerModel ::::::::${controller.provider.title ?? 'No provider'}"); - print("categoryTitle ::::::: ${controller.categoryTitle.value}"); - Get.to(() => OnDemandBookingScreen(), arguments: {'providerModel': controller.provider, 'categoryTitle': controller.categoryTitle.value}); + print( + "providerModel ::::::::${controller.provider.title ?? 'No provider'}", + ); + print( + "categoryTitle ::::::: ${controller.categoryTitle.value}", + ); + Get.to( + () => OnDemandBookingScreen(), + arguments: { + 'providerModel': controller.provider, + 'categoryTitle': + controller.categoryTitle.value, + }, + ); } }, ), @@ -56,7 +75,13 @@ class OnDemandDetailsScreen extends StatelessWidget { ); } - SingleChildScrollView buildSliverScrollView(BuildContext context, OnDemandDetailsController controller, ProviderServiceModel provider, user, isDark) { + SingleChildScrollView buildSliverScrollView( + BuildContext context, + OnDemandDetailsController controller, + ProviderServiceModel provider, + user, + isDark, + ) { final width = MediaQuery.of(context).size.width; final height = MediaQuery.of(context).size.height; @@ -67,21 +92,54 @@ class OnDemandDetailsScreen extends StatelessWidget { Stack( children: [ CachedNetworkImage( - imageUrl: provider.photos.isNotEmpty ? provider.photos.first : "", - placeholder: (context, url) => Center(child: CircularProgressIndicator(valueColor: AlwaysStoppedAnimation(AppThemeData.primary300))), - errorWidget: (context, url, error) => Image.network(Constant.placeHolderImage, fit: BoxFit.fitWidth), + imageUrl: + provider.photos.isNotEmpty ? provider.photos.first : "", + placeholder: + (context, url) => Center( + child: CircularProgressIndicator( + valueColor: AlwaysStoppedAnimation( + AppThemeData.primary300, + ), + ), + ), + errorWidget: + (context, url, error) => Image.network( + Constant.placeHolderImage, + fit: BoxFit.fitWidth, + ), fit: BoxFit.fitWidth, width: width, height: height * 0.45, ), - Positioned(top: height * 0.05, left: width * 0.03, child: _circleButton(context, icon: Icons.arrow_back, onTap: () => Get.back())), + Positioned( + top: height * 0.05, + left: width * 0.03, + child: _circleButton( + context, + icon: Icons.arrow_back, + onTap: () => Get.back(), + ), + ), Positioned( top: height * 0.05, right: width * 0.03, child: Container( - decoration: BoxDecoration(borderRadius: BorderRadius.circular(40), color: controller.isOpen.value ? Colors.green : Colors.red), - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), - child: Text(controller.isOpen.value ? "Open".tr : "Close".tr, style: const TextStyle(fontWeight: FontWeight.bold, color: Colors.white, fontSize: 14)), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(40), + color: controller.isOpen.value ? Colors.green : Colors.red, + ), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), + child: Text( + controller.isOpen.value ? "Open".tr : "Close".tr, + style: const TextStyle( + fontWeight: FontWeight.bold, + color: Colors.white, + fontSize: 14, + ), + ), ), ), ], @@ -104,27 +162,66 @@ class OnDemandDetailsScreen extends StatelessWidget { Expanded( child: Text( provider.title.toString(), - style: TextStyle(fontSize: 20, fontFamily: AppThemeData.regular, fontWeight: FontWeight.bold, color: isDark ? Colors.white : Colors.black), + style: TextStyle( + fontSize: 20, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.bold, + color: isDark ? Colors.white : Colors.black, + ), ), ), Row( children: [ provider.disPrice == "" || provider.disPrice == "0" ? Text( - provider.priceUnit == 'Fixed' ? Constant.amountShow(amount: provider.price ?? '0') : '${Constant.amountShow(amount: provider.price ?? '0')}/${'hr'.tr}', - style: TextStyle(fontSize: 18, fontFamily: AppThemeData.regular, fontWeight: FontWeight.bold, color: isDark ? Colors.white : AppThemeData.primary300), + provider.priceUnit == 'Fixed' + ? Constant.amountShow( + amount: provider.price ?? '0', + ) + : '${Constant.amountShow(amount: provider.price ?? '0')}/${'hr'.tr}', + style: TextStyle( + fontSize: 18, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.bold, + color: + isDark + ? Colors.white + : AppThemeData.primary300, + ), ) : Row( children: [ Text( - provider.priceUnit == 'Fixed' ? Constant.amountShow(amount: provider.disPrice ?? '0') : '${Constant.amountShow(amount: provider.disPrice ?? '0')}/${'hr'.tr}', - style: TextStyle(fontSize: 18, fontFamily: AppThemeData.regular, fontWeight: FontWeight.bold, color: isDark ? Colors.white : AppThemeData.primary300), + provider.priceUnit == 'Fixed' + ? Constant.amountShow( + amount: provider.disPrice ?? '0', + ) + : '${Constant.amountShow(amount: provider.disPrice ?? '0')}/${'hr'.tr}', + style: TextStyle( + fontSize: 18, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.bold, + color: + isDark + ? Colors.white + : AppThemeData.primary300, + ), ), Padding( padding: const EdgeInsets.only(left: 8.0), child: Text( - provider.priceUnit == 'Fixed' ? Constant.amountShow(amount: provider.price ?? '0') : '${Constant.amountShow(amount: provider.price ?? '0')}/${'hr'.tr}', - style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 18, color: Colors.grey, decoration: TextDecoration.lineThrough), + provider.priceUnit == 'Fixed' + ? Constant.amountShow( + amount: provider.price ?? '0', + ) + : '${Constant.amountShow(amount: provider.price ?? '0')}/${'hr'.tr}', + style: const TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18, + color: Colors.grey, + decoration: + TextDecoration.lineThrough, + ), ), ), ], @@ -138,23 +235,51 @@ class OnDemandDetailsScreen extends StatelessWidget { Expanded( child: Padding( padding: const EdgeInsets.symmetric(vertical: 5), - child: Text(categoryTitle, style: TextStyle(fontSize: 14, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w400, color: isDark ? Colors.white : Colors.black)), + child: Text( + categoryTitle, + style: TextStyle( + fontSize: 14, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w400, + color: isDark ? Colors.white : Colors.black, + ), + ), ), ), Padding( padding: const EdgeInsets.only(left: 8.0), child: Row( children: [ - const Icon(Icons.star, size: 16, color: AppThemeData.warning400), + const Icon( + Icons.star, + size: 16, + color: AppThemeData.warning400, + ), const SizedBox(width: 3), Text( - provider.reviewsCount != 0 ? ((provider.reviewsSum ?? 0.0) / (provider.reviewsCount ?? 0.0)).toStringAsFixed(1) : '0', - style: const TextStyle(letterSpacing: 0.5, fontSize: 16, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w500, color: AppThemeData.warning400), + provider.reviewsCount != 0 + ? ((provider.reviewsSum ?? 0.0) / + (provider.reviewsCount ?? 0.0)) + .toStringAsFixed(1) + : '0', + style: const TextStyle( + letterSpacing: 0.5, + fontSize: 16, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w500, + color: AppThemeData.warning400, + ), ), const SizedBox(width: 10), Text( "(${provider.reviewsCount} ${'Reviews'.tr})", - style: TextStyle(letterSpacing: 0.5, fontSize: 16, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w500, color: isDark ? Colors.white : Colors.black), + style: TextStyle( + letterSpacing: 0.5, + fontSize: 16, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w500, + color: isDark ? Colors.white : Colors.black, + ), ), ], ), @@ -167,18 +292,40 @@ class OnDemandDetailsScreen extends StatelessWidget { children: [ subCategoryTitle.isNotEmpty ? Container( - decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), color: AppThemeData.primary300.withOpacity(0.20)), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: AppThemeData.primary300.withOpacity( + 0.20, + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), - child: Text(subCategoryTitle, style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold, fontFamily: AppThemeData.regular, color: AppThemeData.primary300)), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), + child: Text( + subCategoryTitle, + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + fontFamily: AppThemeData.regular, + color: AppThemeData.primary300, + ), + ), ), ) : Container(), const SizedBox(width: 10), Container( - decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), color: Colors.green.withOpacity(0.20)), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.green.withOpacity(0.20), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: InkWell( onTap: () { showModalBottomSheet( @@ -187,10 +334,22 @@ class OnDemandDetailsScreen extends StatelessWidget { context: context, backgroundColor: Colors.transparent, enableDrag: true, - builder: (context) => showTiming(context, controller, isDark), + builder: + (context) => showTiming( + context, + controller, + isDark, + ), ); }, - child: Text("View Timing".tr, style: const TextStyle(fontWeight: FontWeight.bold, color: Colors.green, letterSpacing: 0.5)), + child: Text( + "View Timing".tr, + style: const TextStyle( + fontWeight: FontWeight.bold, + color: Colors.green, + letterSpacing: 0.5, + ), + ), ), ), ), @@ -200,14 +359,22 @@ class OnDemandDetailsScreen extends StatelessWidget { Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Icon(Icons.location_on_outlined, color: isDark ? Colors.white : Colors.black, size: 20), + Icon( + Icons.location_on_outlined, + color: isDark ? Colors.white : Colors.black, + size: 20, + ), const SizedBox(width: 5), Expanded( child: Text( provider.address.toString(), maxLines: 2, overflow: TextOverflow.ellipsis, - style: TextStyle(fontFamily: AppThemeData.regular, fontWeight: FontWeight.w400, color: isDark ? Colors.white : Colors.black), + style: TextStyle( + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w400, + color: isDark ? Colors.white : Colors.black, + ), ), ), ], @@ -218,7 +385,11 @@ class OnDemandDetailsScreen extends StatelessWidget { _tabBar(controller), Obx(() { if (controller.tabString.value == "About") { - return aboutTabViewWidget(controller, controller.provider, isDark); + return aboutTabViewWidget( + controller, + controller.provider, + isDark, + ); } else if (controller.tabString.value == "Gallery") { return galleryTabViewWidget(controller); } else { @@ -236,14 +407,35 @@ class OnDemandDetailsScreen extends StatelessWidget { ); } - Widget _circleButton(BuildContext context, {required IconData icon, required VoidCallback onTap}) { + Widget _circleButton( + BuildContext context, { + required IconData icon, + required VoidCallback onTap, + }) { return ClipOval( - child: Container(color: Colors.black.withOpacity(0.7), child: InkWell(onTap: onTap, child: Padding(padding: const EdgeInsets.all(8.0), child: Icon(icon, size: 30, color: Colors.white)))), + child: Container( + color: Colors.black.withOpacity(0.7), + child: InkWell( + onTap: onTap, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Icon(icon, size: 30, color: Colors.white), + ), + ), + ), ); } Widget _tabBar(OnDemandDetailsController controller) { - return Obx(() => Row(children: [_tabItem("About", controller), _tabItem("Gallery", controller), _tabItem("Review", controller)])); + return Obx( + () => Row( + children: [ + _tabItem("About", controller), + _tabItem("Gallery", controller), + _tabItem("Review", controller), + ], + ), + ); } Widget _tabItem(String title, OnDemandDetailsController controller) { @@ -252,33 +444,67 @@ class OnDemandDetailsScreen extends StatelessWidget { child: Container( margin: const EdgeInsets.only(right: 10), padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), - decoration: BoxDecoration(color: controller.tabString.value == title ? AppThemeData.primary300 : Colors.grey.shade200, borderRadius: BorderRadius.circular(10)), - child: Text(title.tr, style: TextStyle(fontWeight: FontWeight.bold, color: controller.tabString.value == title ? Colors.white : Colors.black)), + decoration: BoxDecoration( + color: + controller.tabString.value == title + ? AppThemeData.primary300 + : Colors.grey.shade200, + borderRadius: BorderRadius.circular(10), + ), + child: Text( + title.tr, + style: TextStyle( + fontWeight: FontWeight.bold, + color: + controller.tabString.value == title + ? Colors.white + : Colors.black, + ), + ), ), ); } - Widget aboutTabViewWidget(OnDemandDetailsController controller, ProviderServiceModel providerModel, bool isDark) { + Widget aboutTabViewWidget( + OnDemandDetailsController controller, + ProviderServiceModel providerModel, + bool isDark, + ) { return Padding( padding: const EdgeInsets.symmetric(vertical: 10), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text((providerModel.description ?? '').tr, style: TextStyle(color: isDark ? Colors.white : Colors.black, fontSize: 14, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w500)), + Text( + (providerModel.description ?? '').tr, + style: TextStyle( + color: isDark ? Colors.white : Colors.black, + fontSize: 14, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w500, + ), + ), const SizedBox(height: 10), Obx(() { final user = controller.userModel.value; if (user == null) return const SizedBox(); return InkWell( onTap: () { - Get.to(() => ProviderScreen(), arguments: {'providerId': user.id}); + Get.to( + () => ProviderScreen(), + arguments: {'providerId': user.id}, + ); }, child: Padding( padding: const EdgeInsets.symmetric(vertical: 2), child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), - border: Border.all(color: isDark ? AppThemeData.grey500 : Colors.grey.shade100, width: 1), + border: Border.all( + color: + isDark ? AppThemeData.grey500 : Colors.grey.shade100, + width: 1, + ), color: isDark ? AppThemeData.grey500 : Colors.white, ), child: Padding( @@ -288,30 +514,86 @@ class OnDemandDetailsScreen extends StatelessWidget { Expanded( child: Row( children: [ - CircleAvatar(radius: 30, backgroundImage: NetworkImage(user.profilePictureURL?.isNotEmpty == true ? user.profilePictureURL! : Constant.placeHolderImage)), + CircleAvatar( + radius: 30, + backgroundImage: NetworkImage( + user.profilePictureURL?.isNotEmpty == true + ? user.profilePictureURL! + : Constant.placeHolderImage, + ), + ), const SizedBox(width: 10), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text(user.fullName(), style: TextStyle(color: isDark ? Colors.white : Colors.black, fontFamily: AppThemeData.regular, fontSize: 14, fontWeight: FontWeight.bold)), + Text( + user.fullName(), + style: TextStyle( + color: + isDark + ? Colors.white + : Colors.black, + fontFamily: AppThemeData.regular, + fontSize: 14, + fontWeight: FontWeight.bold, + ), + ), const SizedBox(height: 5), - Text(user.email ?? '', style: TextStyle(color: isDark ? Colors.white : Colors.black, fontFamily: AppThemeData.regular, fontSize: 14)), + Text( + user.email ?? '', + style: TextStyle( + color: + isDark + ? Colors.white + : Colors.black, + fontFamily: AppThemeData.regular, + fontSize: 14, + ), + ), const SizedBox(height: 10), // Rating Box Container( - decoration: BoxDecoration(color: AppThemeData.warning400, borderRadius: BorderRadius.circular(16)), - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5), + decoration: BoxDecoration( + color: AppThemeData.warning400, + borderRadius: BorderRadius.circular(16), + ), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 5, + ), child: Row( mainAxisSize: MainAxisSize.min, children: [ - const Icon(Icons.star, size: 16, color: Colors.white), + const Icon( + Icons.star, + size: 16, + color: Colors.white, + ), const SizedBox(width: 3), Text( - double.parse(user.reviewsCount.toString()) != 0 - ? (double.parse(user.reviewsSum.toString()) / double.parse(user.reviewsCount.toString())).toStringAsFixed(1) + double.parse( + user.reviewsCount + .toString(), + ) != + 0 + ? (double.parse( + user.reviewsSum + .toString(), + ) / + double.parse( + user.reviewsCount + .toString(), + )) + .toStringAsFixed(1) : '0', - style: const TextStyle(letterSpacing: 0.5, fontSize: 12, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w500, color: Colors.white), + style: const TextStyle( + letterSpacing: 0.5, + fontSize: 12, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w500, + color: Colors.white, + ), ), ], ), @@ -347,7 +629,12 @@ class OnDemandDetailsScreen extends StatelessWidget { shrinkWrap: true, padding: EdgeInsets.zero, physics: const NeverScrollableScrollPhysics(), - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, mainAxisSpacing: 0, crossAxisSpacing: 8, mainAxisExtent: 180), + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + mainAxisSpacing: 0, + crossAxisSpacing: 8, + mainAxisExtent: 180, + ), itemBuilder: (context, index) { final imageUrl = photos[index]; return Padding( @@ -358,9 +645,29 @@ class OnDemandDetailsScreen extends StatelessWidget { imageUrl: imageUrl, height: 60, width: 60, - imageBuilder: (context, imageProvider) => Container(decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), image: DecorationImage(image: imageProvider, fit: BoxFit.cover))), - placeholder: (context, url) => Center(child: CircularProgressIndicator.adaptive(valueColor: AlwaysStoppedAnimation(AppThemeData.primary300))), - errorWidget: (context, url, error) => Image.network(Constant.placeHolderImage, fit: BoxFit.cover), + imageBuilder: + (context, imageProvider) => Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + image: DecorationImage( + image: imageProvider, + fit: BoxFit.cover, + ), + ), + ), + placeholder: + (context, url) => Center( + child: CircularProgressIndicator.adaptive( + valueColor: AlwaysStoppedAnimation( + AppThemeData.primary300, + ), + ), + ), + errorWidget: + (context, url, error) => Image.network( + Constant.placeHolderImage, + fit: BoxFit.cover, + ), fit: BoxFit.cover, ), ), @@ -369,11 +676,24 @@ class OnDemandDetailsScreen extends StatelessWidget { ); } - Widget reviewTabViewWidget(OnDemandDetailsController controller, bool isDark) { + Widget reviewTabViewWidget( + OnDemandDetailsController controller, + bool isDark, + ) { final reviews = controller.ratingService; if (reviews.isEmpty) { - return SizedBox(height: 200, child: Center(child: Text("No review Found".tr, style: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)))); + return SizedBox( + height: 200, + child: Center( + child: Text( + "No review Found".tr, + style: AppThemeData.mediumTextStyle( + color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + ), + ), + ), + ); } return ListView.builder( @@ -389,8 +709,17 @@ class OnDemandDetailsScreen extends StatelessWidget { clipBehavior: Clip.antiAlias, decoration: ShapeDecoration( color: isDark ? AppThemeData.grey700 : AppThemeData.grey50, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), - shadows: const [BoxShadow(color: Color(0x0A000000), blurRadius: 32, offset: Offset(0, 0), spreadRadius: 0)], + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + shadows: const [ + BoxShadow( + color: Color(0x0A000000), + blurRadius: 32, + offset: Offset(0, 0), + spreadRadius: 0, + ), + ], ), child: Padding( padding: const EdgeInsets.all(8.0), @@ -400,26 +729,58 @@ class OnDemandDetailsScreen extends StatelessWidget { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text(review.uname ?? '', style: TextStyle(fontSize: 16, letterSpacing: 1, fontWeight: FontWeight.w600, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), Text( - review.createdAt != null ? DateFormat('dd MMM').format(review.createdAt!.toDate()) : '', - style: TextStyle(fontSize: 12, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + review.uname ?? '', + style: TextStyle( + fontSize: 16, + letterSpacing: 1, + fontWeight: FontWeight.w600, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + Text( + review.createdAt != null + ? DateFormat( + 'dd MMM', + ).format(review.createdAt!.toDate()) + : '', + style: TextStyle( + fontSize: 12, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ], ), const SizedBox(height: 4), RatingBar.builder( - initialRating: double.tryParse(review.rating.toString()) ?? 0, + initialRating: + double.tryParse(review.rating.toString()) ?? 0, direction: Axis.horizontal, itemSize: 20, ignoreGestures: true, itemPadding: const EdgeInsets.symmetric(horizontal: 4.0), - itemBuilder: (context, _) => Icon(Icons.star, color: AppThemeData.primary300), + itemBuilder: + (context, _) => + Icon(Icons.star, color: AppThemeData.primary300), onRatingUpdate: (rate) {}, ), const Divider(), const SizedBox(height: 5), - Text(review.comment ?? '', style: TextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + review.comment ?? '', + style: TextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), ], ), ), @@ -429,31 +790,71 @@ class OnDemandDetailsScreen extends StatelessWidget { ); } - Widget showTiming(BuildContext context, OnDemandDetailsController controller, bool isDark) { + Widget showTiming( + BuildContext context, + OnDemandDetailsController controller, + bool isDark, + ) { final provider = controller.provider; return Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.grey300 : Colors.white, borderRadius: const BorderRadius.only(topLeft: Radius.circular(20), topRight: Radius.circular(20))), + decoration: BoxDecoration( + color: isDark ? AppThemeData.grey300 : Colors.white, + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(20), + topRight: Radius.circular(20), + ), + ), child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 16), - child: Text("Service Timing".tr, style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold, fontFamily: AppThemeData.regular, color: AppThemeData.primary300)), + child: Text( + "Service Timing".tr, + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + fontFamily: AppThemeData.regular, + color: AppThemeData.primary300, + ), + ), ), Padding( padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 16), child: Row( children: [ - Expanded(child: _timeCard(context, "Start Time : ".tr, provider.startTime.toString(), isDark)), + Expanded( + child: _timeCard( + context, + "Start Time : ".tr, + provider.startTime.toString(), + isDark, + ), + ), const SizedBox(width: 10), - Expanded(child: _timeCard(context, "End Time : ".tr, provider.endTime.toString(), isDark)), + Expanded( + child: _timeCard( + context, + "End Time : ".tr, + provider.endTime.toString(), + isDark, + ), + ), ], ), ), Padding( padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 16), - child: Text("Service Days".tr, style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold, fontFamily: AppThemeData.regular, color: AppThemeData.primary300)), + child: Text( + "Service Days".tr, + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + fontFamily: AppThemeData.regular, + color: AppThemeData.primary300, + ), + ), ), Padding( padding: const EdgeInsets.symmetric(horizontal: 16), @@ -465,10 +866,30 @@ class OnDemandDetailsScreen extends StatelessWidget { .map( (day) => Card( elevation: 2, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(6), side: BorderSide(color: isDark ? const Color(0XFF3c3a2e) : const Color(0XFFC3C5D1), width: 1)), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(6), + side: BorderSide( + color: + isDark + ? const Color(0XFF3c3a2e) + : const Color(0XFFC3C5D1), + width: 1, + ), + ), child: Padding( - padding: const EdgeInsets.symmetric(vertical: 7, horizontal: 20), - child: Text(day, style: TextStyle(color: isDark ? const Color(0XFFa5a292) : const Color(0XFF5A5D6D))), + padding: const EdgeInsets.symmetric( + vertical: 7, + horizontal: 20, + ), + child: Text( + day, + style: TextStyle( + color: + isDark + ? const Color(0XFFa5a292) + : const Color(0XFF5A5D6D), + ), + ), ), ), ) @@ -481,16 +902,39 @@ class OnDemandDetailsScreen extends StatelessWidget { ); } - Widget _timeCard(BuildContext context, String title, String value, bool isDark) { + Widget _timeCard( + BuildContext context, + String title, + String value, + bool isDark, + ) { return Card( elevation: 2, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(6), side: BorderSide(color: isDark ? const Color(0XFF3c3a2e) : const Color(0XFFC3C5D1), width: 1)), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(6), + side: BorderSide( + color: isDark ? const Color(0XFF3c3a2e) : const Color(0XFFC3C5D1), + width: 1, + ), + ), child: Padding( padding: const EdgeInsets.symmetric(vertical: 7, horizontal: 20), child: Row( children: [ - Text(title, style: TextStyle(color: isDark ? const Color(0XFFa5a292) : const Color(0XFF5A5D6D))), - Text(value, style: TextStyle(color: isDark ? const Color(0XFFa5a292) : const Color(0XFF5A5D6D))), + Text( + title, + style: TextStyle( + color: + isDark ? const Color(0XFFa5a292) : const Color(0XFF5A5D6D), + ), + ), + Text( + value, + style: TextStyle( + color: + isDark ? const Color(0XFFa5a292) : const Color(0XFF5A5D6D), + ), + ), ], ), ), diff --git a/lib/screen_ui/on_demand_service/on_demand_home_screen.dart b/lib/screen_ui/on_demand_service/on_demand_home_screen.dart index 0a7f050..3d22b0c 100644 --- a/lib/screen_ui/on_demand_service/on_demand_home_screen.dart +++ b/lib/screen_ui/on_demand_service/on_demand_home_screen.dart @@ -1,4 +1,5 @@ import 'package:cached_network_image/cached_network_image.dart'; +import 'package:customer/constant/const_texts.dart'; import 'package:customer/constant/constant.dart'; import 'package:customer/controllers/theme_controller.dart'; import 'package:customer/models/banner_model.dart'; @@ -11,10 +12,12 @@ import 'package:customer/screen_ui/on_demand_service/view_category_service_scree import 'package:customer/themes/app_them_data.dart'; import 'package:customer/themes/round_button_fill.dart'; import 'package:customer/themes/show_toast_dialog.dart'; +import 'package:customer/utils/app_router.dart'; import 'package:customer/utils/network_image_widget.dart'; import 'package:customer/widget/osm_map/map_picker_page.dart'; import 'package:customer/widget/place_picker/location_picker_screen.dart'; import 'package:customer/widget/place_picker/selected_location_model.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:geocoding/geocoding.dart'; @@ -50,8 +53,20 @@ class OnDemandHomeScreen extends StatelessWidget { child: Container( height: 42, width: 42, - decoration: const BoxDecoration(shape: BoxShape.circle, color: AppThemeData.grey50), - child: const Center(child: Padding(padding: EdgeInsets.only(left: 5), child: Icon(Icons.arrow_back_ios, color: AppThemeData.grey900, size: 20))), + decoration: const BoxDecoration( + shape: BoxShape.circle, + color: AppThemeData.grey50, + ), + child: const Center( + child: Padding( + padding: EdgeInsets.only(left: 5), + child: Icon( + Icons.arrow_back_ios, + color: AppThemeData.grey900, + size: 20, + ), + ), + ), ), ), const SizedBox(width: 10), @@ -60,8 +75,23 @@ class OnDemandHomeScreen extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Constant.userModel == null - ? InkWell(onTap: () => Get.offAll(const LoginScreen()), child: Text("Login".tr, style: AppThemeData.boldTextStyle(color: AppThemeData.grey900, fontSize: 12))) - : Text(Constant.userModel!.fullName(), style: AppThemeData.boldTextStyle(color: AppThemeData.grey900, fontSize: 12)), + ? InkWell( + onTap: () => Get.offAll(const LoginScreen()), + child: Text( + "Login".tr, + style: AppThemeData.boldTextStyle( + color: AppThemeData.grey900, + fontSize: 12, + ), + ), + ) + : Text( + Constant.userModel!.fullName(), + style: AppThemeData.boldTextStyle( + color: AppThemeData.grey900, + fontSize: 12, + ), + ), InkWell( onTap: () async { if (Constant.userModel != null) { @@ -75,10 +105,13 @@ class OnDemandHomeScreen extends StatelessWidget { } else { Constant.checkPermission( onTap: () async { - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader( + ConstTexts.pleaseWait.tr, + ); // ✅ declare it once here! - ShippingAddress shippingAddress = ShippingAddress(); + ShippingAddress shippingAddress = + ShippingAddress(); try { await Geolocator.requestPermission(); @@ -86,41 +119,72 @@ class OnDemandHomeScreen extends StatelessWidget { ShowToastDialog.closeLoader(); if (Constant.selectedMapType == 'osm') { - final result = await Get.to(() => MapPickerPage()); + final result = await Get.to( + () => MapPickerPage(), + ); if (result != null) { final firstPlace = result; - final lat = firstPlace.coordinates.latitude; - final lng = firstPlace.coordinates.longitude; + final lat = + firstPlace.coordinates.latitude; + final lng = + firstPlace.coordinates.longitude; final address = firstPlace.address; shippingAddress.addressAs = "Home"; - shippingAddress.locality = address.toString(); - shippingAddress.location = UserLocation(latitude: lat, longitude: lng); - Constant.selectedLocation = shippingAddress; + shippingAddress.locality = + address.toString(); + shippingAddress.location = UserLocation( + latitude: lat, + longitude: lng, + ); + Constant.selectedLocation = + shippingAddress; controller.getData(); Get.back(); } } else { - Get.to(LocationPickerScreen())!.then((value) async { + Get.to(LocationPickerScreen())!.then(( + value, + ) async { if (value != null) { - SelectedLocationModel selectedLocationModel = value; + SelectedLocationModel + selectedLocationModel = value; shippingAddress.addressAs = "Home"; - shippingAddress.location = UserLocation(latitude: selectedLocationModel.latLng!.latitude, longitude: selectedLocationModel.latLng!.longitude); - shippingAddress.locality = "Picked from Map"; // You can reverse-geocode + shippingAddress + .location = UserLocation( + latitude: + selectedLocationModel + .latLng! + .latitude, + longitude: + selectedLocationModel + .latLng! + .longitude, + ); + shippingAddress.locality = + "Picked from Map"; // You can reverse-geocode - Constant.selectedLocation = shippingAddress; + Constant.selectedLocation = + shippingAddress; controller.getData(); } }); } } catch (e) { - await placemarkFromCoordinates(19.228825, 72.854118).then((valuePlaceMaker) { + await placemarkFromCoordinates( + 19.228825, + 72.854118, + ).then((valuePlaceMaker) { Placemark placeMark = valuePlaceMaker[0]; - shippingAddress.location = UserLocation(latitude: 19.228825, longitude: 72.854118); + shippingAddress.location = UserLocation( + latitude: 19.228825, + longitude: 72.854118, + ); String currentLocation = "${placeMark.name}, ${placeMark.subLocality}, ${placeMark.locality}, ${placeMark.administrativeArea}, ${placeMark.postalCode}, ${placeMark.country}"; - shippingAddress.locality = currentLocation; + shippingAddress.locality = + currentLocation; }); Constant.selectedLocation = shippingAddress; @@ -138,10 +202,21 @@ class OnDemandHomeScreen extends StatelessWidget { TextSpan( children: [ TextSpan( - text: Constant.selectedLocation.getFullAddress(), - style: TextStyle(fontFamily: AppThemeData.medium, overflow: TextOverflow.ellipsis, color: AppThemeData.grey900, fontSize: 14), + text: + Constant.selectedLocation + .getFullAddress(), + style: TextStyle( + fontFamily: AppThemeData.medium, + overflow: TextOverflow.ellipsis, + color: AppThemeData.grey900, + fontSize: 14, + ), + ), + WidgetSpan( + child: SvgPicture.asset( + "assets/icons/ic_down.svg", + ), ), - WidgetSpan(child: SvgPicture.asset("assets/icons/ic_down.svg")), ], ), ), @@ -156,7 +231,8 @@ class OnDemandHomeScreen extends StatelessWidget { body: controller.isLoading.value ? Constant.loader() - : Constant.isZoneAvailable == false || controller.providerList.isEmpty + : Constant.isZoneAvailable == false || + controller.providerList.isEmpty ? Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: Column( @@ -165,12 +241,30 @@ class OnDemandHomeScreen extends StatelessWidget { children: [ Image.asset("assets/images/location.gif", height: 120), const SizedBox(height: 12), - Text("No Store Found in Your Area".tr, style: TextStyle(color: isDark ? AppThemeData.grey100 : AppThemeData.grey800, fontSize: 22, fontFamily: AppThemeData.semiBold)), + Text( + "No Store Found in Your Area".tr, + style: TextStyle( + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey800, + fontSize: 22, + fontFamily: AppThemeData.semiBold, + ), + ), const SizedBox(height: 5), Text( - "Currently, there are no available store in your zone. Try changing your location to find nearby options.".tr, + "Currently, there are no available store in your zone. Try changing your location to find nearby options." + .tr, textAlign: TextAlign.center, - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey500, fontSize: 16, fontFamily: AppThemeData.bold), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey500, + fontSize: 16, + fontFamily: AppThemeData.bold, + ), ), const SizedBox(height: 20), RoundedButtonFill( @@ -187,7 +281,10 @@ class OnDemandHomeScreen extends StatelessWidget { ), ) : Padding( - padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 15), + padding: const EdgeInsets.symmetric( + vertical: 20, + horizontal: 15, + ), child: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -198,42 +295,95 @@ class OnDemandHomeScreen extends StatelessWidget { height: MediaQuery.of(context).size.height * 0.12, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), - border: Border.all(color: isDark ? AppThemeData.greyDark600 : AppThemeData.greyDark600, width: 1), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark600 + : AppThemeData.greyDark600, + width: 1, + ), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, ), child: controller.categories.isEmpty - ? Constant.showEmptyView(message: "No Categories".tr) + ? Constant.showEmptyView( + message: "No Categories".tr, + ) : Padding( - padding: const EdgeInsets.symmetric(vertical: 10), + padding: const EdgeInsets.symmetric( + vertical: 10, + ), child: Row( children: [ Expanded( child: ListView.builder( - itemCount: controller.categories.length > 3 ? 3 : controller.categories.length, + itemCount: + controller.categories.length > + 3 + ? 3 + : controller + .categories + .length, scrollDirection: Axis.horizontal, itemBuilder: (context, index) { - final category = controller.categories[index]; + final category = + controller + .categories[index]; return InkWell( onTap: () { - Get.to(() => ViewCategoryServiceListScreen(), arguments: {'categoryId': category.id, 'categoryTitle': category.title}); + Get.to( + () => + ViewCategoryServiceListScreen(), + arguments: { + 'categoryId': + category.id, + 'categoryTitle': + category.title, + }, + ); }, - child: CategoryView(category: category, index: index, isDark: isDark), + child: CategoryView( + category: category, + index: index, + isDark: isDark, + ), ); }, ), ), if (controller.categories.length > 3) Padding( - padding: const EdgeInsets.symmetric(horizontal: 10), + padding: + const EdgeInsets.symmetric( + horizontal: 10, + ), child: Column( mainAxisSize: MainAxisSize.min, children: [ InkWell( onTap: () { - Get.to(() => const OnDemandCategoryScreen()); + Get.to( + () => + const OnDemandCategoryScreen(), + ); }, - child: ClipOval(child: Container(width: 50, height: 50, color: AppThemeData.grey200, child: const Center(child: Icon(Icons.chevron_right)))), + child: ClipOval( + child: Container( + width: 50, + height: 50, + color: + AppThemeData + .grey200, + child: const Center( + child: Icon( + Icons.chevron_right, + ), + ), + ), + ), ), const SizedBox(height: 5), SizedBox( @@ -241,9 +391,17 @@ class OnDemandHomeScreen extends StatelessWidget { child: Center( child: Text( "View All".tr, - textAlign: TextAlign.center, + textAlign: + TextAlign.center, maxLines: 1, - style: AppThemeData.semiBoldTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: AppThemeData.semiBoldTextStyle( + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), ), ), ), @@ -261,14 +419,28 @@ class OnDemandHomeScreen extends StatelessWidget { Expanded( child: Text( "Most Popular services".tr, - style: TextStyle(color: isDark ? Colors.white : Colors.black, fontSize: 18, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w600), + style: TextStyle( + color: + isDark ? Colors.white : Colors.black, + fontSize: 18, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w600, + ), ), ), InkWell( onTap: () { Get.to(() => ViewAllPopularServiceScreen()); }, - child: Text("View all".tr, style: TextStyle(color: AppThemeData.primary300, fontSize: 14, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w600)), + child: Text( + "View all".tr, + style: TextStyle( + color: AppThemeData.primary300, + fontSize: 14, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w600, + ), + ), ), ], ), @@ -279,9 +451,16 @@ class OnDemandHomeScreen extends StatelessWidget { shrinkWrap: true, padding: EdgeInsets.zero, physics: const NeverScrollableScrollPhysics(), - itemCount: controller.providerList.length >= 6 ? 6 : controller.providerList.length, + itemCount: + controller.providerList.length >= 6 + ? 6 + : controller.providerList.length, itemBuilder: (_, index) { - return ServiceView(provider: controller.providerList[index], controller: controller, isDark: isDark); + return ServiceView( + provider: controller.providerList[index], + controller: controller, + isDark: isDark, + ); }, ), ], @@ -333,7 +512,13 @@ class BannerView extends StatelessWidget { final banner = bannerList[index]; return ClipRRect( borderRadius: BorderRadius.circular(15), - child: SizedBox(width: MediaQuery.of(context).size.width * 0.8, child: NetworkImageWidget(imageUrl: banner.photo ?? '', fit: BoxFit.cover)), + child: SizedBox( + width: MediaQuery.of(context).size.width * 0.8, + child: NetworkImageWidget( + imageUrl: banner.photo ?? '', + fit: BoxFit.cover, + ), + ), ); }, ), @@ -343,7 +528,18 @@ class BannerView extends StatelessWidget { return Row( children: List.generate(bannerList.length, (index) { bool isSelected = currentPage.value == index; - return Expanded(child: Container(height: 4, decoration: BoxDecoration(color: isSelected ? AppThemeData.grey300 : AppThemeData.grey100, borderRadius: BorderRadius.circular(5)))); + return Expanded( + child: Container( + height: 4, + decoration: BoxDecoration( + color: + isSelected + ? AppThemeData.grey300 + : AppThemeData.grey100, + borderRadius: BorderRadius.circular(5), + ), + ), + ); }), ); }), @@ -357,7 +553,12 @@ class CategoryView extends StatelessWidget { final int index; final bool isDark; - const CategoryView({super.key, required this.category, required this.index, required this.isDark}); + const CategoryView({ + super.key, + required this.category, + required this.index, + required this.isDark, + }); @override Widget build(BuildContext context) { @@ -369,11 +570,21 @@ class CategoryView extends StatelessWidget { Container( height: 55, width: 55, - decoration: BoxDecoration(color: Constant.colorList[index % Constant.colorList.length], borderRadius: BorderRadius.circular(50)), + decoration: BoxDecoration( + color: Constant.colorList[index % Constant.colorList.length], + borderRadius: BorderRadius.circular(50), + ), child: ClipOval( child: Padding( padding: const EdgeInsets.all(14.0), - child: CachedNetworkImage(imageUrl: category.image.toString(), errorWidget: (_, __, ___) => Image.network(Constant.placeHolderImage, fit: BoxFit.cover)), + child: CachedNetworkImage( + imageUrl: category.image.toString(), + errorWidget: + (_, __, ___) => Image.network( + Constant.placeHolderImage, + fit: BoxFit.cover, + ), + ), ), ), ), @@ -381,7 +592,15 @@ class CategoryView extends StatelessWidget { SizedBox( width: 70, child: Center( - child: Text(category.title ?? "", textAlign: TextAlign.center, maxLines: 1, style: AppThemeData.semiBoldTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + child: Text( + category.title ?? "", + textAlign: TextAlign.center, + maxLines: 1, + style: AppThemeData.semiBoldTextStyle( + color: + isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + ), + ), ), ), ], @@ -395,40 +614,70 @@ class ServiceView extends StatelessWidget { final bool isDark; final OnDemandHomeController? controller; - const ServiceView({super.key, required this.provider, this.isDark = false, this.controller}); + const ServiceView({ + super.key, + required this.provider, + this.isDark = false, + this.controller, + }); @override Widget build(BuildContext context) { return GestureDetector( onTap: () { - Get.to(() => OnDemandDetailsScreen(), arguments: {'providerModel': provider}); + Get.to( + () => OnDemandDetailsScreen(), + arguments: {'providerModel': provider}, + ); }, child: Container( margin: const EdgeInsets.symmetric(vertical: 5), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), - border: Border.all(color: isDark ? AppThemeData.grey500 : Colors.grey.shade200), + border: Border.all( + color: isDark ? AppThemeData.grey500 : Colors.grey.shade200, + ), color: isDark ? AppThemeData.grey900 : Colors.white, ), child: Row( children: [ // --- Left Image --- ClipRRect( - borderRadius: const BorderRadius.only(topLeft: Radius.circular(10), bottomLeft: Radius.circular(10)), + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(10), + bottomLeft: Radius.circular(10), + ), child: CachedNetworkImage( - imageUrl: provider.photos.isNotEmpty ? provider.photos[0] : Constant.placeHolderImage, + imageUrl: + provider.photos.isNotEmpty + ? provider.photos[0] + : Constant.placeHolderImage, width: 110, height: MediaQuery.of(context).size.height * 0.16, fit: BoxFit.cover, - placeholder: (context, url) => Center(child: CircularProgressIndicator.adaptive(valueColor: AlwaysStoppedAnimation(AppThemeData.primary300))), - errorWidget: (context, url, error) => Image.network(Constant.placeHolderImage, fit: BoxFit.cover), + placeholder: + (context, url) => Center( + child: CircularProgressIndicator.adaptive( + valueColor: AlwaysStoppedAnimation( + AppThemeData.primary300, + ), + ), + ), + errorWidget: + (context, url, error) => Image.network( + Constant.placeHolderImage, + fit: BoxFit.cover, + ), ), ), // --- Right Content --- Expanded( child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 10, + ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -441,17 +690,40 @@ class ServiceView extends StatelessWidget { provider.title ?? "", maxLines: 1, overflow: TextOverflow.ellipsis, - style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: isDark ? Colors.white : Colors.black), + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + color: isDark ? Colors.white : Colors.black, + ), ), ), if (controller != null) Obx( () => GestureDetector( - onTap: () => controller!.toggleFavourite(provider), + onTap: + () => controller!.toggleFavourite(provider), child: Icon( - controller!.lstFav.where((element) => element.service_id == provider.id).isNotEmpty ? Icons.favorite : Icons.favorite_border, + controller!.lstFav + .where( + (element) => + element.service_id == provider.id, + ) + .isNotEmpty + ? Icons.favorite + : Icons.favorite_border, size: 24, - color: controller!.lstFav.where((element) => element.service_id == provider.id).isNotEmpty ? AppThemeData.primary300 : (isDark ? Colors.white38 : Colors.black38), + color: + controller!.lstFav + .where( + (element) => + element.service_id == + provider.id, + ) + .isNotEmpty + ? AppThemeData.primary300 + : (isDark + ? Colors.white38 + : Colors.black38), ), ), ), @@ -463,10 +735,18 @@ class ServiceView extends StatelessWidget { // Category if (controller != null) FutureBuilder( - future: controller!.getCategory(provider.categoryId ?? ""), + future: controller!.getCategory( + provider.categoryId ?? "", + ), builder: (ctx, snap) { if (!snap.hasData) return const SizedBox.shrink(); - return Text(snap.data?.title ?? "", style: TextStyle(fontSize: 13, color: isDark ? Colors.white70 : Colors.black54)); + return Text( + snap.data?.title ?? "", + style: TextStyle( + fontSize: 13, + color: isDark ? Colors.white70 : Colors.black54, + ), + ); }, ), @@ -492,21 +772,39 @@ class ServiceView extends StatelessWidget { Widget _buildPrice() { if (provider.disPrice == "" || provider.disPrice == "0") { return Text( - provider.priceUnit == 'Fixed' ? Constant.amountShow(amount: provider.price) : '${Constant.amountShow(amount: provider.price ?? "0")}/${'hr'.tr}', - style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold, color: isDark ? Colors.white : AppThemeData.primary300), + provider.priceUnit == 'Fixed' + ? Constant.amountShow(amount: provider.price) + : '${Constant.amountShow(amount: provider.price ?? "0")}/${'hr'.tr}', + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + color: isDark ? Colors.white : AppThemeData.primary300, + ), ); } else { return Row( children: [ Text( - provider.priceUnit == 'Fixed' ? Constant.amountShow(amount: provider.disPrice ?? '0') : '${Constant.amountShow(amount: provider.disPrice)}/${'hr'.tr}', - style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold, color: isDark ? Colors.white : AppThemeData.primary300), + provider.priceUnit == 'Fixed' + ? Constant.amountShow(amount: provider.disPrice ?? '0') + : '${Constant.amountShow(amount: provider.disPrice)}/${'hr'.tr}', + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + color: isDark ? Colors.white : AppThemeData.primary300, + ), ), const SizedBox(width: 6), Flexible( child: Text( - provider.priceUnit == 'Fixed' ? Constant.amountShow(amount: provider.price) : '${Constant.amountShow(amount: provider.price ?? "0")}/hr', - style: const TextStyle(fontSize: 12, color: Colors.grey, decoration: TextDecoration.lineThrough), + provider.priceUnit == 'Fixed' + ? Constant.amountShow(amount: provider.price) + : '${Constant.amountShow(amount: provider.price ?? "0")}/hr', + style: const TextStyle( + fontSize: 12, + color: Colors.grey, + decoration: TextDecoration.lineThrough, + ), overflow: TextOverflow.ellipsis, ), ), @@ -521,11 +819,21 @@ class ServiceView extends StatelessWidget { rating = (provider.reviewsSum ?? 0) / (provider.reviewsCount ?? 1); } return Container( - decoration: BoxDecoration(color: AppThemeData.warning400, borderRadius: BorderRadius.circular(12)), + decoration: BoxDecoration( + color: AppThemeData.warning400, + borderRadius: BorderRadius.circular(12), + ), padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), child: Row( mainAxisSize: MainAxisSize.min, - children: [const Icon(Icons.star, size: 14, color: Colors.white), const SizedBox(width: 3), Text(rating.toStringAsFixed(1), style: const TextStyle(fontSize: 12, color: Colors.white))], + children: [ + const Icon(Icons.star, size: 14, color: Colors.white), + const SizedBox(width: 3), + Text( + rating.toStringAsFixed(1), + style: const TextStyle(fontSize: 12, color: Colors.white), + ), + ], ), ); } diff --git a/lib/screen_ui/on_demand_service/on_demand_order_details_screen.dart b/lib/screen_ui/on_demand_service/on_demand_order_details_screen.dart index f7723bc..23f7c36 100644 --- a/lib/screen_ui/on_demand_service/on_demand_order_details_screen.dart +++ b/lib/screen_ui/on_demand_service/on_demand_order_details_screen.dart @@ -1,5 +1,7 @@ import 'package:clipboard/clipboard.dart'; +import 'package:customer/constant/const_texts.dart'; import 'package:dotted_border/dotted_border.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:intl/intl.dart'; @@ -37,12 +39,30 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { child: Container( height: 42, width: 42, - decoration: BoxDecoration(shape: BoxShape.circle, color: AppThemeData.grey50), - child: Center(child: Padding(padding: const EdgeInsets.only(left: 5), child: Icon(Icons.arrow_back_ios, color: AppThemeData.grey900, size: 20))), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: AppThemeData.grey50, + ), + child: Center( + child: Padding( + padding: const EdgeInsets.only(left: 5), + child: Icon( + Icons.arrow_back_ios, + color: AppThemeData.grey900, + size: 20, + ), + ), + ), ), ), const SizedBox(width: 10), - Text("Order Details".tr, style: AppThemeData.boldTextStyle(fontSize: 18, color: AppThemeData.grey900)), + Text( + "Order Details".tr, + style: AppThemeData.boldTextStyle( + fontSize: 18, + color: AppThemeData.grey900, + ), + ), ], ), ), @@ -55,63 +75,147 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - (controller.onProviderOrder.value?.status ?? '') == Constant.orderCancelled + (controller.onProviderOrder.value?.status ?? '') == + Constant.orderCancelled ? Container( width: MediaQuery.of(context).size.width, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), - border: Border.all(color: isDark ? AppThemeData.greyDark400 : AppThemeData.grey100), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark400 + : AppThemeData.grey100, + ), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, ), child: Padding( - padding: EdgeInsets.symmetric(vertical: 8, horizontal: 8), + padding: EdgeInsets.symmetric( + vertical: 8, + horizontal: 8, + ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text('Cancel Reason'.tr, style: AppThemeData.mediumTextStyle(fontSize: 15, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), - Text(controller.onProviderOrder.value?.reason ?? '', style: AppThemeData.mediumTextStyle(fontSize: 14, color: AppThemeData.danger300)), + Text( + 'Cancel Reason'.tr, + style: AppThemeData.mediumTextStyle( + fontSize: 15, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + Text( + controller + .onProviderOrder + .value + ?.reason ?? + '', + style: AppThemeData.mediumTextStyle( + fontSize: 14, + color: AppThemeData.danger300, + ), + ), ], ), ), ) : Container(), - (controller.onProviderOrder.value?.status ?? '') == Constant.orderCancelled ? SizedBox(height: 10) : SizedBox.shrink(), + (controller.onProviderOrder.value?.status ?? '') == + Constant.orderCancelled + ? SizedBox(height: 10) + : SizedBox.shrink(), Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), - border: Border.all(color: isDark ? AppThemeData.greyDark400 : AppThemeData.grey100), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark400 + : AppThemeData.grey100, + ), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, ), child: Padding( - padding: EdgeInsets.symmetric(vertical: 15, horizontal: 10), + padding: EdgeInsets.symmetric( + vertical: 15, + horizontal: 10, + ), child: Column( children: [ Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ - Text('Booking ID'.tr, style: AppThemeData.mediumTextStyle(fontSize: 15, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + 'Booking ID'.tr, + style: AppThemeData.mediumTextStyle( + fontSize: 15, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), InkWell( onTap: () { - FlutterClipboard.copy(controller.onProviderOrder.value?.id ?? '').then((value) { + FlutterClipboard.copy( + controller + .onProviderOrder + .value + ?.id ?? + '', + ).then((value) { SnackBar snackBar = SnackBar( content: Text( "Booking ID Copied".tr, textAlign: TextAlign.center, - style: AppThemeData.mediumTextStyle(fontSize: 15, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: + AppThemeData.mediumTextStyle( + fontSize: 15, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), ), backgroundColor: Colors.black38, ); - ScaffoldMessenger.of(context).showSnackBar(snackBar); + ScaffoldMessenger.of( + context, + ).showSnackBar(snackBar); }); }, - child: Text('# ${controller.onProviderOrder.value?.id ?? ''}', style: AppThemeData.mediumTextStyle(fontSize: 15, color: AppThemeData.primary300)), + child: Text( + '# ${controller.onProviderOrder.value?.id ?? ''}', + style: AppThemeData.mediumTextStyle( + fontSize: 15, + color: AppThemeData.primary300, + ), + ), ), ], ), SizedBox(height: 10), Text( "${'Booking Address :'.tr} ${controller.onProviderOrder.value?.address?.getFullAddress()}", - style: AppThemeData.mediumTextStyle(fontSize: 15, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: AppThemeData.mediumTextStyle( + fontSize: 15, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ], ), @@ -121,8 +225,16 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), - border: Border.all(color: isDark ? AppThemeData.greyDark400 : AppThemeData.grey100), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark400 + : AppThemeData.grey100, + ), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, ), child: Row( children: [ @@ -135,8 +247,20 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { borderRadius: BorderRadius.circular(10), image: DecorationImage( image: NetworkImage( - (controller.onProviderOrder.value != null && controller.onProviderOrder.value!.provider.photos.isNotEmpty) - ? controller.onProviderOrder.value!.provider.photos.first + (controller.onProviderOrder.value != + null && + controller + .onProviderOrder + .value! + .provider + .photos + .isNotEmpty) + ? controller + .onProviderOrder + .value! + .provider + .photos + .first : Constant.placeHolderImage, ), fit: BoxFit.cover, @@ -151,23 +275,71 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { Padding( padding: const EdgeInsets.only(top: 6), child: Text( - controller.onProviderOrder.value?.provider.title ?? "", - style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + controller + .onProviderOrder + .value + ?.provider + .title ?? + "", + style: AppThemeData.mediumTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ), Row( children: [ Padding( - padding: const EdgeInsets.only(top: 6), - child: Text('${'Date:'.tr} ', style: AppThemeData.regularTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + padding: const EdgeInsets.only( + top: 6, + ), + child: Text( + '${'Date:'.tr} ', + style: + AppThemeData.regularTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), + ), ), Padding( - padding: const EdgeInsets.only(top: 6), + padding: const EdgeInsets.only( + top: 6, + ), child: Text( - controller.onProviderOrder.value?.scheduleDateTime != null - ? DateFormat('dd-MMM-yyyy').format(controller.onProviderOrder.value!.scheduleDateTime!.toDate()) + controller + .onProviderOrder + .value + ?.scheduleDateTime != + null + ? DateFormat( + 'dd-MMM-yyyy', + ).format( + controller + .onProviderOrder + .value! + .scheduleDateTime! + .toDate(), + ) : "", - style: AppThemeData.regularTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: + AppThemeData.regularTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), ), ), ], @@ -175,16 +347,51 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { Row( children: [ Padding( - padding: const EdgeInsets.only(top: 6), - child: Text('${'Time:'.tr} ', style: AppThemeData.regularTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + padding: const EdgeInsets.only( + top: 6, + ), + child: Text( + '${'Time:'.tr} ', + style: + AppThemeData.regularTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), + ), ), Padding( - padding: const EdgeInsets.only(top: 6), + padding: const EdgeInsets.only( + top: 6, + ), child: Text( - controller.onProviderOrder.value?.scheduleDateTime != null - ? DateFormat('hh:mm a').format(controller.onProviderOrder.value!.scheduleDateTime!.toDate()) + controller + .onProviderOrder + .value + ?.scheduleDateTime != + null + ? DateFormat('hh:mm a').format( + controller + .onProviderOrder + .value! + .scheduleDateTime! + .toDate(), + ) : "", - style: AppThemeData.regularTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: + AppThemeData.regularTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), ), ), ], @@ -195,23 +402,50 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { ], ), ), - (controller.onProviderOrder.value?.status == Constant.orderAccepted || - controller.onProviderOrder.value?.status == Constant.orderAssigned || - controller.onProviderOrder.value?.status == Constant.orderOngoing || - controller.onProviderOrder.value?.status == Constant.orderCompleted) && - (controller.onProviderOrder.value?.workerId != null && controller.onProviderOrder.value!.workerId!.isNotEmpty) + (controller.onProviderOrder.value?.status == + Constant.orderAccepted || + controller.onProviderOrder.value?.status == + Constant.orderAssigned || + controller.onProviderOrder.value?.status == + Constant.orderOngoing || + controller.onProviderOrder.value?.status == + Constant.orderCompleted) && + (controller.onProviderOrder.value?.workerId != + null && + controller + .onProviderOrder + .value! + .workerId! + .isNotEmpty) ? Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: EdgeInsets.symmetric(vertical: 10), - child: Text('About Worker'.tr, style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + child: Text( + 'About Worker'.tr, + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), ), Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), - border: Border.all(color: isDark ? AppThemeData.greyDark400 : AppThemeData.grey100), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark400 + : AppThemeData.grey100, + ), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, ), child: Padding( padding: const EdgeInsets.all(8.0), @@ -225,35 +459,99 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { CircleAvatar( radius: 30, backgroundImage: NetworkImage( - controller.worker.value?.profilePictureURL.isNotEmpty == true ? controller.worker.value!.profilePictureURL : Constant.placeHolderImage, + controller + .worker + .value + ?.profilePictureURL + .isNotEmpty == + true + ? controller + .worker + .value! + .profilePictureURL + : Constant + .placeHolderImage, ), ), const SizedBox(width: 10), Expanded( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ Text( - controller.worker.value?.fullName() ?? '', - style: TextStyle(color: isDark ? Colors.white : Colors.black, fontFamily: AppThemeData.regular, fontSize: 14, fontWeight: FontWeight.bold), + controller + .worker + .value + ?.fullName() ?? + '', + style: TextStyle( + color: + isDark + ? Colors + .white + : Colors + .black, + fontFamily: + AppThemeData + .regular, + fontSize: 14, + fontWeight: + FontWeight.bold, + ), + ), + const SizedBox( + height: 5, ), - const SizedBox(height: 5), Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ Padding( - padding: const EdgeInsets.only(top: 3), - child: Icon(Icons.location_on_outlined, size: 15, color: isDark ? Colors.white : Colors.black), + padding: + const EdgeInsets.only( + top: 3, + ), + child: Icon( + Icons + .location_on_outlined, + size: 15, + color: + isDark + ? Colors + .white + : Colors + .black, + ), ), Expanded( child: Text( - controller.worker.value?.address ?? '', - style: TextStyle(color: isDark ? Colors.white : Colors.black, fontFamily: AppThemeData.regular, fontSize: 14), + controller + .worker + .value + ?.address ?? + '', + style: TextStyle( + color: + isDark + ? Colors + .white + : Colors + .black, + fontFamily: + AppThemeData + .regular, + fontSize: 14, + ), ), ), ], ), - const SizedBox(height: 10), + const SizedBox( + height: 10, + ), ], ), ), @@ -263,19 +561,61 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { SizedBox(width: 10), // Rating Box Container( - decoration: BoxDecoration(color: AppThemeData.warning400, borderRadius: BorderRadius.circular(16)), - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5), + decoration: BoxDecoration( + color: AppThemeData.warning400, + borderRadius: + BorderRadius.circular(16), + ), + padding: + const EdgeInsets.symmetric( + horizontal: 10, + vertical: 5, + ), child: Row( mainAxisSize: MainAxisSize.min, children: [ - const Icon(Icons.star, size: 16, color: Colors.white), + const Icon( + Icons.star, + size: 16, + color: Colors.white, + ), const SizedBox(width: 3), Text( - (controller.worker.value != null && double.parse(controller.worker.value!.reviewsCount.toString()) != 0) - ? (double.parse(controller.worker.value!.reviewsSum.toString()) / double.parse(controller.worker.value!.reviewsCount.toString())) + (controller.worker.value != + null && + double.parse( + controller + .worker + .value! + .reviewsCount + .toString(), + ) != + 0) + ? (double.parse( + controller + .worker + .value! + .reviewsSum + .toString(), + ) / + double.parse( + controller + .worker + .value! + .reviewsCount + .toString(), + )) .toStringAsFixed(1) : '0', - style: const TextStyle(letterSpacing: 0.5, fontSize: 12, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w500, color: Colors.white), + style: const TextStyle( + letterSpacing: 0.5, + fontSize: 12, + fontFamily: + AppThemeData.regular, + fontWeight: + FontWeight.w500, + color: Colors.white, + ), ), ], ), @@ -283,17 +623,40 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { ], ), Visibility( - visible: controller.onProviderOrder.value?.status == Constant.orderCompleted ? true : false, + visible: + controller + .onProviderOrder + .value + ?.status == + Constant.orderCompleted + ? true + : false, child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 5, + ), child: SizedBox( - width: MediaQuery.of(context).size.width, + width: + MediaQuery.of( + context, + ).size.width, child: ElevatedButton( // onPressed: () async { // Get.to(() => OnDemandReviewScreen(), arguments: {'order': controller.onProviderOrder.value, 'reviewFor': "Worker"}); // }, onPressed: () async { - final result = await Get.to(() => OnDemandReviewScreen(), arguments: {'order': controller.onProviderOrder.value, 'reviewFor': "Worker"}); + final result = await Get.to( + () => + OnDemandReviewScreen(), + arguments: { + 'order': + controller + .onProviderOrder + .value, + 'reviewFor': "Worker", + }, + ); // If review was submitted successfully if (result == true) { @@ -301,33 +664,105 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { } }, - style: ElevatedButton.styleFrom(backgroundColor: Colors.orange, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16))), - child: Text('Add Review'.tr, style: AppThemeData.regularTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + style: ElevatedButton.styleFrom( + backgroundColor: + Colors.orange, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 16, + ), + ), + ), + child: Text( + 'Add Review'.tr, + style: + AppThemeData.regularTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), + ), ), ), ), ), - controller.onProviderOrder.value?.status == Constant.orderAccepted || - controller.onProviderOrder.value?.status == Constant.orderOngoing || - controller.onProviderOrder.value?.status == Constant.orderAssigned + controller + .onProviderOrder + .value + ?.status == + Constant.orderAccepted || + controller + .onProviderOrder + .value + ?.status == + Constant.orderOngoing || + controller + .onProviderOrder + .value + ?.status == + Constant.orderAssigned ? Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10), + padding: + const EdgeInsets.symmetric( + horizontal: 10, + vertical: 10, + ), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, children: [ Expanded( child: ElevatedButton( onPressed: () async { - Constant.makePhoneCall(controller.worker.value!.phoneNumber.toString()); + Constant.makePhoneCall( + controller + .worker + .value! + .phoneNumber + .toString(), + ); }, - style: ElevatedButton.styleFrom(backgroundColor: Color(0xFFFF6839), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16))), + style: ElevatedButton.styleFrom( + backgroundColor: Color( + 0xFFFF6839, + ), + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 16, + ), + ), + ), child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, children: [ - Icon(Icons.call, color: AppThemeData.grey50), + Icon( + Icons.call, + color: + AppThemeData + .grey50, + ), SizedBox(width: 10), - Text('Call'.tr, style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: AppThemeData.grey50)), + Text( + 'Call'.tr, + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + AppThemeData + .grey50, + ), + ), ], ), ), @@ -336,32 +771,90 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { Expanded( child: ElevatedButton( onPressed: () async { - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader( + ConstTexts + .pleaseWait + .tr, + ); ShowToastDialog.closeLoader(); Get.to( const ChatScreen(), arguments: { - "customerName": Constant.userModel?.fullName(), - "restaurantName": "${controller.worker.value?.firstName ?? ''} ${controller.worker.value?.lastName ?? ''}", - "orderId": controller.onProviderOrder.value?.id, - "restaurantId": controller.worker.value?.id, - "customerId": Constant.userModel?.id, - "customerProfileImage": Constant.userModel?.profilePictureURL, - "restaurantProfileImage": controller.worker.value?.profilePictureURL, - "token": controller.worker.value?.fcmToken, - "chatType": 'worker', + "customerName": + Constant + .userModel + ?.fullName(), + "restaurantName": + "${controller.worker.value?.firstName ?? ''} ${controller.worker.value?.lastName ?? ''}", + "orderId": + controller + .onProviderOrder + .value + ?.id, + "restaurantId": + controller + .worker + .value + ?.id, + "customerId": + Constant + .userModel + ?.id, + "customerProfileImage": + Constant + .userModel + ?.profilePictureURL, + "restaurantProfileImage": + controller + .worker + .value + ?.profilePictureURL, + "token": + controller + .worker + .value + ?.fcmToken, + "chatType": + 'worker', }, ); }, - style: ElevatedButton.styleFrom(backgroundColor: AppThemeData.primary300, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16))), + style: ElevatedButton.styleFrom( + backgroundColor: + AppThemeData + .primary300, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 16, + ), + ), + ), child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment + .center, + crossAxisAlignment: + CrossAxisAlignment + .center, children: [ - Icon(Icons.chat_bubble, color: AppThemeData.grey50), + Icon( + Icons.chat_bubble, + color: + AppThemeData + .grey50, + ), SizedBox(width: 10), - Text('Chat'.tr, style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: AppThemeData.grey50)), + Text( + 'Chat'.tr, + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + AppThemeData + .grey50, + ), + ), ], ), ), @@ -379,13 +872,30 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { : SizedBox(), Padding( padding: EdgeInsets.symmetric(vertical: 10), - child: Text("About provider".tr, style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + child: Text( + "About provider".tr, + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), ), Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), - border: Border.all(color: isDark ? AppThemeData.greyDark400 : AppThemeData.grey100), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark400 + : AppThemeData.grey100, + ), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, ), child: Padding( padding: const EdgeInsets.all(8.0), @@ -399,22 +909,56 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { CircleAvatar( radius: 30, backgroundImage: NetworkImage( - controller.providerUser.value?.profilePictureURL?.isNotEmpty == true ? controller.providerUser.value!.profilePictureURL! : Constant.placeHolderImage, + controller + .providerUser + .value + ?.profilePictureURL + ?.isNotEmpty == + true + ? controller + .providerUser + .value! + .profilePictureURL! + : Constant.placeHolderImage, ), ), const SizedBox(width: 10), Expanded( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( - controller.providerUser.value?.fullName() ?? '', - style: TextStyle(color: isDark ? Colors.white : Colors.black, fontFamily: AppThemeData.regular, fontSize: 14, fontWeight: FontWeight.bold), + controller.providerUser.value + ?.fullName() ?? + '', + style: TextStyle( + color: + isDark + ? Colors.white + : Colors.black, + fontFamily: + AppThemeData.regular, + fontSize: 14, + fontWeight: FontWeight.bold, + ), ), const SizedBox(height: 5), Text( - controller.providerUser.value?.email ?? '', - style: TextStyle(color: isDark ? Colors.white : Colors.black, fontFamily: AppThemeData.regular, fontSize: 14), + controller + .providerUser + .value + ?.email ?? + '', + style: TextStyle( + color: + isDark + ? Colors.white + : Colors.black, + fontFamily: + AppThemeData.regular, + fontSize: 14, + ), ), const SizedBox(height: 10), ], @@ -425,19 +969,57 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { ), // Rating Box Container( - decoration: BoxDecoration(color: AppThemeData.warning400, borderRadius: BorderRadius.circular(16)), - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5), + decoration: BoxDecoration( + color: AppThemeData.warning400, + borderRadius: BorderRadius.circular(16), + ), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 5, + ), child: Row( mainAxisSize: MainAxisSize.min, children: [ - const Icon(Icons.star, size: 16, color: Colors.white), + const Icon( + Icons.star, + size: 16, + color: Colors.white, + ), const SizedBox(width: 3), Text( - (controller.providerUser.value != null && double.parse(controller.providerUser.value!.reviewsCount.toString()) != 0) - ? (double.parse(controller.providerUser.value!.reviewsSum.toString()) / double.parse(controller.providerUser.value!.reviewsCount.toString())) + (controller.providerUser.value != + null && + double.parse( + controller + .providerUser + .value! + .reviewsCount + .toString(), + ) != + 0) + ? (double.parse( + controller + .providerUser + .value! + .reviewsSum + .toString(), + ) / + double.parse( + controller + .providerUser + .value! + .reviewsCount + .toString(), + )) .toStringAsFixed(1) : '0', - style: const TextStyle(letterSpacing: 0.5, fontSize: 12, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w500, color: Colors.white), + style: const TextStyle( + letterSpacing: 0.5, + fontSize: 12, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w500, + color: Colors.white, + ), ), ], ), @@ -445,86 +1027,251 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { ], ), Visibility( - visible: controller.onProviderOrder.value?.status == Constant.orderCompleted ? true : false, + visible: + controller + .onProviderOrder + .value + ?.status == + Constant.orderCompleted + ? true + : false, child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 5, + ), child: SizedBox( width: MediaQuery.of(context).size.width, child: ElevatedButton( onPressed: () async { - final result = await Get.to(() => OnDemandReviewScreen(), arguments: {'order': controller.onProviderOrder.value, 'reviewFor': "Provider"}); + final result = await Get.to( + () => OnDemandReviewScreen(), + arguments: { + 'order': + controller + .onProviderOrder + .value, + 'reviewFor': "Provider", + }, + ); if (result == true) { await controller.getData(); } }, - style: ElevatedButton.styleFrom(backgroundColor: Colors.orange, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16))), - child: Text('Add Review'.tr, style: AppThemeData.regularTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + style: ElevatedButton.styleFrom( + backgroundColor: Colors.orange, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular( + 16, + ), + ), + ), + child: Text( + 'Add Review'.tr, + style: AppThemeData.regularTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), ), ), ), ), - controller.onProviderOrder.value?.status == Constant.orderAccepted || - controller.onProviderOrder.value?.status == Constant.orderOngoing || - controller.onProviderOrder.value?.status == Constant.orderAssigned + controller.onProviderOrder.value?.status == + Constant.orderAccepted || + controller + .onProviderOrder + .value + ?.status == + Constant.orderOngoing || + controller + .onProviderOrder + .value + ?.status == + Constant.orderAssigned ? Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 10, + ), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ Expanded( child: ElevatedButton( onPressed: () async { - Constant.makePhoneCall(controller.providerUser.value!.phoneNumber.toString()); + Constant.makePhoneCall( + controller + .providerUser + .value! + .phoneNumber + .toString(), + ); }, - style: ElevatedButton.styleFrom(backgroundColor: Color(0xFFFF6839), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16))), + style: ElevatedButton.styleFrom( + backgroundColor: Color( + 0xFFFF6839, + ), + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(16), + ), + ), child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, children: [ - Icon(Icons.call, color: AppThemeData.grey50), + Icon( + Icons.call, + color: AppThemeData.grey50, + ), SizedBox(width: 10), - Text('Call'.tr, style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: AppThemeData.grey50)), + Text( + 'Call'.tr, + style: + AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + AppThemeData + .grey50, + ), + ), ], ), ), ), - if ((Constant.isSubscriptionModelApplied == false && Constant.sectionConstantModel?.adminCommision?.isEnabled == false) || - ((Constant.isSubscriptionModelApplied == true || Constant.sectionConstantModel?.adminCommision?.isEnabled == true) && - controller.onProviderOrder.value?.provider.subscriptionPlan?.features?.chat == true)) + if ((Constant.isSubscriptionModelApplied == + false && + Constant + .sectionConstantModel + ?.adminCommision + ?.isEnabled == + false) || + ((Constant.isSubscriptionModelApplied == + true || + Constant + .sectionConstantModel + ?.adminCommision + ?.isEnabled == + true) && + controller + .onProviderOrder + .value + ?.provider + .subscriptionPlan + ?.features + ?.chat == + true)) const SizedBox(width: 10), - if ((Constant.isSubscriptionModelApplied == false && Constant.sectionConstantModel?.adminCommision?.isEnabled == false) || - ((Constant.isSubscriptionModelApplied == true || Constant.sectionConstantModel?.adminCommision?.isEnabled == true) && - controller.onProviderOrder.value?.provider.subscriptionPlan?.features?.chat == true)) + if ((Constant.isSubscriptionModelApplied == + false && + Constant + .sectionConstantModel + ?.adminCommision + ?.isEnabled == + false) || + ((Constant.isSubscriptionModelApplied == + true || + Constant + .sectionConstantModel + ?.adminCommision + ?.isEnabled == + true) && + controller + .onProviderOrder + .value + ?.provider + .subscriptionPlan + ?.features + ?.chat == + true)) Expanded( child: ElevatedButton( onPressed: () async { - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader( + ConstTexts.pleaseWait.tr, + ); ShowToastDialog.closeLoader(); Get.to( const ChatScreen(), arguments: { - "customerName": Constant.userModel?.fullName(), - "restaurantName": "${controller.providerUser.value?.firstName ?? ''} ${controller.providerUser.value?.lastName ?? ''}", - "orderId": controller.onProviderOrder.value?.id, - "restaurantId": controller.providerUser.value?.id, - "customerId": Constant.userModel?.id, - "customerProfileImage": Constant.userModel?.profilePictureURL, - "restaurantProfileImage": controller.providerUser.value?.profilePictureURL, - "token": controller.providerUser.value?.fcmToken, + "customerName": + Constant.userModel + ?.fullName(), + "restaurantName": + "${controller.providerUser.value?.firstName ?? ''} ${controller.providerUser.value?.lastName ?? ''}", + "orderId": + controller + .onProviderOrder + .value + ?.id, + "restaurantId": + controller + .providerUser + .value + ?.id, + "customerId": + Constant + .userModel + ?.id, + "customerProfileImage": + Constant + .userModel + ?.profilePictureURL, + "restaurantProfileImage": + controller + .providerUser + .value + ?.profilePictureURL, + "token": + controller + .providerUser + .value + ?.fcmToken, "chatType": 'Provider', }, ); }, - style: ElevatedButton.styleFrom(backgroundColor: AppThemeData.primary300, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16))), + style: ElevatedButton.styleFrom( + backgroundColor: + AppThemeData.primary300, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 16, + ), + ), + ), child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, children: [ - Icon(Icons.chat_bubble, color: AppThemeData.grey50), + Icon( + Icons.chat_bubble, + color: + AppThemeData.grey50, + ), SizedBox(width: 10), - Text('Chat'.tr, style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: AppThemeData.grey50)), + Text( + 'Chat'.tr, + style: + AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + AppThemeData + .grey50, + ), + ), ], ), ), @@ -537,14 +1284,31 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { ), ), ), - (controller.onProviderOrder.value?.status != Constant.orderCompleted || controller.onProviderOrder.value?.status != Constant.orderCancelled) && - controller.onProviderOrder.value?.provider.priceUnit == "Fixed" + (controller.onProviderOrder.value?.status != + Constant.orderCompleted || + controller.onProviderOrder.value?.status != + Constant.orderCancelled) && + controller + .onProviderOrder + .value + ?.provider + .priceUnit == + "Fixed" ? Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: EdgeInsets.symmetric(vertical: 10), - child: Text("Price Detail".tr, style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + child: Text( + "Price Detail".tr, + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), ), priceTotalRow(controller, isDark), ], @@ -552,18 +1316,44 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { : Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - controller.onProviderOrder.value?.paymentStatus == false || controller.onProviderOrder.value?.extraPaymentStatus == false + controller + .onProviderOrder + .value + ?.paymentStatus == + false || + controller + .onProviderOrder + .value + ?.extraPaymentStatus == + false ? Column( children: [ controller.couponList.isNotEmpty ? SizedBox( height: 85, child: ListView.builder( - itemCount: controller.couponList.length, - scrollDirection: Axis.horizontal, + itemCount: + controller + .couponList + .length, + scrollDirection: + Axis.horizontal, itemBuilder: (context, index) { - final coupon = controller.couponList[index]; - return GestureDetector(onTap: () => controller.applyCoupon(coupon), child: buildOfferItem(controller, index, isDark)); + final coupon = + controller + .couponList[index]; + return GestureDetector( + onTap: + () => controller + .applyCoupon( + coupon, + ), + child: buildOfferItem( + controller, + index, + isDark, + ), + ); }, ), ) @@ -574,46 +1364,112 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { : Offstage(), Padding( padding: EdgeInsets.symmetric(vertical: 16), - child: Text("Price Detail".tr, style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + child: Text( + "Price Detail".tr, + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), ), priceTotalRow(controller, isDark), ], ), - controller.onProviderOrder.value?.extraCharges.toString() != "" + controller.onProviderOrder.value?.extraCharges + .toString() != + "" ? Container( margin: EdgeInsets.symmetric(vertical: 10), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), - border: Border.all(color: isDark ? AppThemeData.greyDark400 : AppThemeData.grey100), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark400 + : AppThemeData.grey100, + ), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, ), child: Container( - padding: EdgeInsets.symmetric(vertical: 8, horizontal: 10), + padding: EdgeInsets.symmetric( + vertical: 8, + horizontal: 10, + ), child: Column( children: [ Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ - Text("Total Extra Charges : ".tr, style: TextStyle(color: isDark ? Colors.white : Colors.black, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w500)), Text( - Constant.amountShow(amount: controller.onProviderOrder.value?.extraCharges.toString()), - style: TextStyle(color: isDark ? Colors.white : Colors.black, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w500), + "Total Extra Charges : ".tr, + style: TextStyle( + color: + isDark + ? Colors.white + : Colors.black, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w500, + ), + ), + Text( + Constant.amountShow( + amount: + controller + .onProviderOrder + .value + ?.extraCharges + .toString(), + ), + style: TextStyle( + color: + isDark + ? Colors.white + : Colors.black, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w500, + ), ), ], ), SizedBox(height: 5), Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ Expanded( child: Text( "Extra charge Notes : ".tr, - style: TextStyle(color: isDark ? Colors.white : Colors.black, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w500), + style: TextStyle( + color: + isDark + ? Colors.white + : Colors.black, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w500, + ), ), ), Text( - controller.onProviderOrder.value?.extraChargesDescription ?? '', - style: TextStyle(color: isDark ? Colors.white : Colors.black, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w500), + controller + .onProviderOrder + .value + ?.extraChargesDescription ?? + '', + style: TextStyle( + color: + isDark + ? Colors.white + : Colors.black, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w500, + ), ), ], ), @@ -624,39 +1480,101 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { : SizedBox(), SizedBox(height: 10), Visibility( - visible: controller.onProviderOrder.value?.status == Constant.orderPlaced || controller.onProviderOrder.value?.newScheduleDateTime != null ? true : false, + visible: + controller.onProviderOrder.value?.status == + Constant.orderPlaced || + controller + .onProviderOrder + .value + ?.newScheduleDateTime != + null + ? true + : false, child: Padding( padding: const EdgeInsets.symmetric(vertical: 10), child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), - border: Border.all(color: isDark ? AppThemeData.greyDark400 : AppThemeData.grey100), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark400 + : AppThemeData.grey100, + ), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, ), child: Padding( - padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10), + padding: EdgeInsets.symmetric( + horizontal: 10, + vertical: 10, + ), child: Column( children: [ - controller.onProviderOrder.value?.newScheduleDateTime != null + controller + .onProviderOrder + .value + ?.newScheduleDateTime != + null ? Row( children: [ - Text("New Date : ".tr, style: TextStyle(color: isDark ? Colors.white : Colors.black, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w500)), Text( - DateFormat('dd-MMM-yyyy hh:mm a').format(controller.onProviderOrder.value!.newScheduleDateTime!.toDate()), - style: TextStyle(color: isDark ? Colors.white : Colors.black, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w500), + "New Date : ".tr, + style: TextStyle( + color: + isDark + ? Colors.white + : Colors.black, + fontFamily: + AppThemeData.regular, + fontWeight: FontWeight.w500, + ), + ), + Text( + DateFormat( + 'dd-MMM-yyyy hh:mm a', + ).format( + controller + .onProviderOrder + .value! + .newScheduleDateTime! + .toDate(), + ), + style: TextStyle( + color: + isDark + ? Colors.white + : Colors.black, + fontFamily: + AppThemeData.regular, + fontWeight: FontWeight.w500, + ), ), ], ) : SizedBox(), - controller.onProviderOrder.value?.status == Constant.orderPlaced || controller.onProviderOrder.value?.status == Constant.orderAccepted + controller.onProviderOrder.value?.status == + Constant.orderPlaced || + controller + .onProviderOrder + .value + ?.status == + Constant.orderAccepted ? Padding( - padding: const EdgeInsets.symmetric(vertical: 10), + padding: const EdgeInsets.symmetric( + vertical: 10, + ), child: RoundedButtonFill( title: "Cancel Booking".tr, color: AppThemeData.primary300, textColor: AppThemeData.grey50, onPress: () { - showCancelBookingDialog(controller, isDark); + showCancelBookingDialog( + controller, + isDark, + ); }, ), ) @@ -668,7 +1586,10 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { ), ), const SizedBox(height: 20), - controller.onProviderOrder.value?.extraPaymentStatus == false && controller.onProviderOrder.value?.status == Constant.orderOngoing + controller.onProviderOrder.value?.extraPaymentStatus == + false && + controller.onProviderOrder.value?.status == + Constant.orderOngoing ? Padding( padding: const EdgeInsets.symmetric(vertical: 10), child: RoundedButtonFill( @@ -677,17 +1598,43 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { textColor: AppThemeData.grey50, onPress: () async { double finalTotalAmount = 0.0; - finalTotalAmount = double.parse(controller.onProviderOrder.value!.extraCharges.toString()); - Get.to(() => OnDemandPaymentScreen(), arguments: {'onDemandOrderModel': controller.onProviderOrder, 'totalAmount': finalTotalAmount, 'isExtra': true}); + finalTotalAmount = double.parse( + controller + .onProviderOrder + .value! + .extraCharges + .toString(), + ); + Get.to( + () => OnDemandPaymentScreen(), + arguments: { + 'onDemandOrderModel': + controller.onProviderOrder, + 'totalAmount': finalTotalAmount, + 'isExtra': true, + }, + ); }, ), ) : SizedBox(), - controller.onProviderOrder.value?.provider.priceUnit != "Fixed" && controller.onProviderOrder.value?.paymentStatus == false + controller.onProviderOrder.value?.provider.priceUnit != + "Fixed" && + controller + .onProviderOrder + .value + ?.paymentStatus == + false ? Visibility( - visible: controller.onProviderOrder.value?.status == Constant.orderOngoing ? true : false, + visible: + controller.onProviderOrder.value?.status == + Constant.orderOngoing + ? true + : false, child: Padding( - padding: const EdgeInsets.symmetric(vertical: 10), + padding: const EdgeInsets.symmetric( + vertical: 10, + ), child: RoundedButtonFill( title: 'Pay Now'.tr, color: AppThemeData.primary300, @@ -696,13 +1643,46 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { double finalTotalAmount = 0.0; finalTotalAmount = controller.totalAmount.value + - double.parse(controller.onProviderOrder.value!.extraCharges!.isNotEmpty ? controller.onProviderOrder.value!.extraCharges.toString() : "0.0"); - controller.onProviderOrder.value?.discount = controller.discountAmount.toString(); - controller.onProviderOrder.value?.discountType = controller.discountType.toString(); - controller.onProviderOrder.value?.discountLabel = controller.discountLabel.toString(); - controller.onProviderOrder.value?.couponCode = controller.offerCode.toString(); + double.parse( + controller + .onProviderOrder + .value! + .extraCharges! + .isNotEmpty + ? controller + .onProviderOrder + .value! + .extraCharges + .toString() + : "0.0", + ); + controller.onProviderOrder.value?.discount = + controller.discountAmount.toString(); + controller + .onProviderOrder + .value + ?.discountType = + controller.discountType.toString(); + controller + .onProviderOrder + .value + ?.discountLabel = + controller.discountLabel.toString(); + controller + .onProviderOrder + .value + ?.couponCode = + controller.offerCode.toString(); - Get.to(() => OnDemandPaymentScreen(), arguments: {'onDemandOrderModel': controller.onProviderOrder, 'totalAmount': finalTotalAmount, 'isExtra': false}); + Get.to( + () => OnDemandPaymentScreen(), + arguments: { + 'onDemandOrderModel': + controller.onProviderOrder, + 'totalAmount': finalTotalAmount, + 'isExtra': false, + }, + ); }, ), ), @@ -716,7 +1696,11 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { ); } - Widget buildOfferItem(OnDemandOrderDetailsController controller, int index, bool isDark) { + Widget buildOfferItem( + OnDemandOrderDetailsController controller, + int index, + bool isDark, + ) { return Obx(() { final coupon = controller.couponList[index]; @@ -724,7 +1708,11 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { margin: const EdgeInsets.fromLTRB(7, 10, 7, 10), height: 85, child: DottedBorder( - options: RoundedRectDottedBorderOptions(strokeWidth: 1, radius: const Radius.circular(10), color: AppThemeData.primary300), + options: RoundedRectDottedBorderOptions( + strokeWidth: 1, + radius: const Radius.circular(10), + color: AppThemeData.primary300, + ), child: Padding( padding: const EdgeInsets.fromLTRB(12, 5, 12, 0), child: Column( @@ -733,13 +1721,26 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - const Image(image: AssetImage('assets/images/offer_icon.png'), height: 25, width: 25), + const Image( + image: AssetImage('assets/images/offer_icon.png'), + height: 25, + width: 25, + ), const SizedBox(width: 10), Container( margin: const EdgeInsets.only(top: 3), child: Text( - coupon.discountType == "Fix Price" ? "${Constant.amountShow(amount: coupon.discount.toString())} ${'OFF'.tr}" : "${coupon.discount} ${'% Off'.tr}", - style: TextStyle(fontWeight: FontWeight.bold, letterSpacing: 0.7, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + coupon.discountType == "Fix Price" + ? "${Constant.amountShow(amount: coupon.discount.toString())} ${'OFF'.tr}" + : "${coupon.discount} ${'% Off'.tr}", + style: TextStyle( + fontWeight: FontWeight.bold, + letterSpacing: 0.7, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ), ], @@ -748,11 +1749,36 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text(coupon.code ?? '', style: const TextStyle(fontSize: 16, fontWeight: FontWeight.normal, letterSpacing: 0.5, color: Colors.orange)), - Container(margin: const EdgeInsets.only(left: 15, right: 15, top: 3), width: 1, color: AppThemeData.grey50), Text( - "valid till ".tr + controller.getDate(coupon.expiresAt!.toDate().toString()), - style: TextStyle(letterSpacing: 0.5, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + coupon.code ?? '', + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.normal, + letterSpacing: 0.5, + color: Colors.orange, + ), + ), + Container( + margin: const EdgeInsets.only( + left: 15, + right: 15, + top: 3, + ), + width: 1, + color: AppThemeData.grey50, + ), + Text( + "valid till ".tr + + controller.getDate( + coupon.expiresAt!.toDate().toString(), + ), + style: TextStyle( + letterSpacing: 0.5, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ], ), @@ -764,13 +1790,19 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { }); } - Widget buildPromoCode(OnDemandOrderDetailsController controller, bool isDark) { + Widget buildPromoCode( + OnDemandOrderDetailsController controller, + bool isDark, + ) { return GestureDetector( child: Container( margin: const EdgeInsets.only(top: 10, bottom: 13), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), - border: Border.all(color: isDark ? AppThemeData.greyDark400 : AppThemeData.grey100, width: 0.3), + border: Border.all( + color: isDark ? AppThemeData.greyDark400 : AppThemeData.grey100, + width: 0.3, + ), color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, ), child: Padding( @@ -781,17 +1813,37 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { Expanded( child: Row( children: [ - Image.asset("assets/images/reedem.png", height: 50, width: 50), + Image.asset( + "assets/images/reedem.png", + height: 50, + width: 50, + ), const SizedBox(width: 10), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("Promo Code".tr, style: AppThemeData.mediumTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), overflow: TextOverflow.ellipsis), + Text( + "Promo Code".tr, + style: AppThemeData.mediumTextStyle( + fontSize: 18, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + overflow: TextOverflow.ellipsis, + ), const SizedBox(height: 5), Text( "Apply promo code".tr, - style: AppThemeData.mediumTextStyle(fontSize: 15, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: AppThemeData.mediumTextStyle( + fontSize: 15, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), overflow: TextOverflow.ellipsis, ), ], @@ -802,7 +1854,13 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { ), FloatingActionButton( onPressed: () { - Get.bottomSheet(promoCodeSheet(controller, isDark), isScrollControlled: true, isDismissible: true, backgroundColor: Colors.transparent, enableDrag: true); + Get.bottomSheet( + promoCodeSheet(controller, isDark), + isScrollControlled: true, + isDismissible: true, + backgroundColor: Colors.transparent, + enableDrag: true, + ); }, mini: true, backgroundColor: Colors.blueGrey.shade50, @@ -816,11 +1874,17 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { ); } - Widget promoCodeSheet(OnDemandOrderDetailsController controller, bool isDark) { + Widget promoCodeSheet( + OnDemandOrderDetailsController controller, + bool isDark, + ) { return Container( padding: EdgeInsets.only(bottom: Get.height / 4.3, left: 25, right: 25), height: Get.height * 0.88, - decoration: BoxDecoration(color: Colors.transparent, border: Border.all(style: BorderStyle.none)), + decoration: BoxDecoration( + color: Colors.transparent, + border: Border.all(style: BorderStyle.none), + ), child: Column( children: [ InkWell( @@ -828,50 +1892,114 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { child: Container( height: 45, decoration: BoxDecoration( - border: Border.all(color: isDark ? AppThemeData.greyDark400 : AppThemeData.grey100, width: 0.3), + border: Border.all( + color: + isDark ? AppThemeData.greyDark400 : AppThemeData.grey100, + width: 0.3, + ), color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, shape: BoxShape.circle, ), - child: Center(child: Icon(Icons.close, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, size: 28)), + child: Center( + child: Icon( + Icons.close, + color: + isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + size: 28, + ), + ), ), ), const SizedBox(height: 25), Expanded( child: Container( - decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, + ), alignment: Alignment.center, child: SingleChildScrollView( child: Column( children: [ - Container(padding: const EdgeInsets.only(top: 30), child: const Image(image: AssetImage('assets/images/redeem_coupon.png'), width: 100)), Container( - padding: const EdgeInsets.only(top: 20), - child: Text('Redeem Your Coupons'.tr, style: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, fontSize: 16)), - ), - Center( - child: Container( - padding: const EdgeInsets.only(top: 10, left: 22, right: 22), - child: Text("Voucher or Coupon code".tr, style: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + padding: const EdgeInsets.only(top: 30), + child: const Image( + image: AssetImage('assets/images/redeem_coupon.png'), + width: 100, ), ), Container( - padding: const EdgeInsets.only(left: 20, right: 20, top: 20), + padding: const EdgeInsets.only(top: 20), + child: Text( + 'Redeem Your Coupons'.tr, + style: AppThemeData.mediumTextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + fontSize: 16, + ), + ), + ), + Center( + child: Container( + padding: const EdgeInsets.only( + top: 10, + left: 22, + right: 22, + ), + child: Text( + "Voucher or Coupon code".tr, + style: AppThemeData.mediumTextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + ), + ), + Container( + padding: const EdgeInsets.only( + left: 20, + right: 20, + top: 20, + ), child: DottedBorder( - options: RoundedRectDottedBorderOptions(strokeWidth: 1, radius: const Radius.circular(12), color: AppThemeData.primary300), + options: RoundedRectDottedBorderOptions( + strokeWidth: 1, + radius: const Radius.circular(12), + color: AppThemeData.primary300, + ), child: ClipRRect( - borderRadius: const BorderRadius.all(Radius.circular(12)), + borderRadius: const BorderRadius.all( + Radius.circular(12), + ), child: Container( padding: const EdgeInsets.all(20), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, alignment: Alignment.center, child: TextFormField( textAlign: TextAlign.center, - style: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: AppThemeData.mediumTextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), controller: controller.couponTextController.value, decoration: InputDecoration( border: InputBorder.none, hintText: "Write Coupon Code".tr, - hintStyle: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.greyDark400 : AppThemeData.grey400), + hintStyle: AppThemeData.mediumTextStyle( + color: + isDark + ? AppThemeData.greyDark400 + : AppThemeData.grey400, + ), ), ), ), @@ -879,27 +2007,47 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { ), ), Padding( - padding: const EdgeInsets.only(top: 30, bottom: 30, left: 15, right: 15), + padding: const EdgeInsets.only( + top: 30, + bottom: 30, + left: 15, + right: 15, + ), child: RoundedButtonFill( title: "REDEEM NOW".tr, color: AppThemeData.primary300, textColor: AppThemeData.grey50, onPress: () { - final inputCode = controller.couponTextController.value.text.trim().toLowerCase(); + final inputCode = + controller.couponTextController.value.text + .trim() + .toLowerCase(); print("Entered code: $inputCode"); - print("Available coupons: ${controller.couponList.map((e) => e.code).toList()}"); + print( + "Available coupons: ${controller.couponList.map((e) => e.code).toList()}", + ); - final matchingCoupon = controller.couponList.firstWhereOrNull((c) => (c.code ?? '').trim().toLowerCase() == inputCode); + final matchingCoupon = controller.couponList + .firstWhereOrNull( + (c) => + (c.code ?? '').trim().toLowerCase() == + inputCode, + ); if (matchingCoupon != null) { print("✅ Coupon matched: ${matchingCoupon.code}"); controller.applyCoupon(matchingCoupon); - Future.delayed(const Duration(milliseconds: 300), () { - Get.back(); - }); + Future.delayed( + const Duration(milliseconds: 300), + () { + Get.back(); + }, + ); } else { print("❌ No matching coupon found"); - ShowToastDialog.showToast("Applied coupon not valid.".tr); + ShowToastDialog.showToast( + "Applied coupon not valid.".tr, + ); } }, ), @@ -919,7 +2067,9 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { return Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), - border: Border.all(color: isDark ? AppThemeData.greyDark400 : AppThemeData.grey100), + border: Border.all( + color: isDark ? AppThemeData.greyDark400 : AppThemeData.grey100, + ), color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, ), child: Column( @@ -928,12 +2078,15 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { rowText( "Price".tr, //Constant.amountShow(amount: controller.price.value.toString()), - controller.onProviderOrder.value?.provider.disPrice == "" || controller.onProviderOrder.value?.provider.disPrice == "0" + controller.onProviderOrder.value?.provider.disPrice == "" || + controller.onProviderOrder.value?.provider.disPrice == "0" ? "${Constant.amountShow(amount: controller.onProviderOrder.value?.provider.price.toString())} × ${controller.onProviderOrder.value?.quantity.toStringAsFixed(2)} ${Constant.amountShow(amount: controller.price.value.toString())}" : "${Constant.amountShow(amount: controller.onProviderOrder.value?.provider.disPrice.toString())} × ${controller.onProviderOrder.value?.quantity.toStringAsFixed(2)} ${Constant.amountShow(amount: controller.price.value.toString())}", isDark, ), - controller.discountAmount.value != 0 ? const Divider() : const SizedBox(), + controller.discountAmount.value != 0 + ? const Divider() + : const SizedBox(), controller.discountAmount.value != 0 ? Padding( padding: const EdgeInsets.symmetric(horizontal: 10), @@ -946,19 +2099,39 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { children: [ Text( "${"Discount".tr} ${controller.discountType.value == 'Percentage' || controller.discountType.value == 'Percent' ? "(${controller.discountLabel.value}%)" : "(${Constant.amountShow(amount: controller.discountLabel.value)})"}", - style: TextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: TextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + Text( + controller.offerCode.value, + style: TextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), - Text(controller.offerCode.value, style: TextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), ], ), ), - Text("(-${Constant.amountShow(amount: controller.discountAmount.value.toString())})", style: const TextStyle(color: Colors.red)), + Text( + "(-${Constant.amountShow(amount: controller.discountAmount.value.toString())})", + style: const TextStyle(color: Colors.red), + ), ], ), ) : const SizedBox(), const Divider(), - rowText("SubTotal".tr, Constant.amountShow(amount: controller.subTotal.value.toString()), isDark), + rowText( + "SubTotal".tr, + Constant.amountShow(amount: controller.subTotal.value.toString()), + isDark, + ), const Divider(), ListView.builder( itemCount: Constant.taxList.length, @@ -969,19 +2142,39 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { return Column( children: [ Padding( - padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 10), + padding: const EdgeInsets.symmetric( + vertical: 8, + horizontal: 10, + ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded( child: Text( "${taxModel.title} (${taxModel.type == "fix" ? Constant.amountShow(amount: taxModel.tax) : "${taxModel.tax}%"})", - style: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: AppThemeData.mediumTextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ), Text( - Constant.amountShow(amount: Constant.getTaxValue(amount: controller.subTotal.value.toString(), taxModel: taxModel).toString()), - style: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + Constant.amountShow( + amount: + Constant.getTaxValue( + amount: + controller.subTotal.value.toString(), + taxModel: taxModel, + ).toString(), + ), + style: AppThemeData.mediumTextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ], ), @@ -992,7 +2185,13 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { }, ), // Total Amount - rowText("Total Amount".tr, Constant.amountShow(amount: controller.totalAmount.value.toString()), isDark), + rowText( + "Total Amount".tr, + Constant.amountShow( + amount: controller.totalAmount.value.toString(), + ), + isDark, + ), const SizedBox(height: 5), ], ), @@ -1006,28 +2205,55 @@ class OnDemandOrderDetailsScreen extends StatelessWidget { child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text(title, style: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), - Text(value, style: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + title, + style: AppThemeData.mediumTextStyle( + color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + ), + ), + Text( + value, + style: AppThemeData.mediumTextStyle( + color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + ), + ), ], ), ); } - Future showCancelBookingDialog(OnDemandOrderDetailsController controller, bool isDark) { + Future showCancelBookingDialog( + OnDemandOrderDetailsController controller, + bool isDark, + ) { return Get.dialog( AlertDialog( backgroundColor: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - title: Text('Please give reason for canceling this Booking'.tr, style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + title: Text( + 'Please give reason for canceling this Booking'.tr, + style: AppThemeData.mediumTextStyle( + fontSize: 16, + color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + ), + ), content: TextFormField( controller: controller.cancelBookingController.value, maxLines: 5, - decoration: InputDecoration(hintText: "Specify your reason here".tr, border: OutlineInputBorder(borderRadius: BorderRadius.circular(7))), + decoration: InputDecoration( + hintText: "Specify your reason here".tr, + border: OutlineInputBorder(borderRadius: BorderRadius.circular(7)), + ), ), actions: [ - TextButton(onPressed: () => Get.back(), child: Text('Cancel'.tr, style: TextStyle(color: Colors.red))), + TextButton( + onPressed: () => Get.back(), + child: Text('Cancel'.tr, style: TextStyle(color: Colors.red)), + ), TextButton( onPressed: () async { - if (controller.cancelBookingController.value.text.trim().isEmpty) { + if (controller.cancelBookingController.value.text + .trim() + .isEmpty) { ShowToastDialog.showToast("Please enter reason".tr); } else { await controller.cancelBooking(); diff --git a/lib/screen_ui/on_demand_service/on_demand_payment_screen.dart b/lib/screen_ui/on_demand_service/on_demand_payment_screen.dart index 1ea95bd..f455175 100644 --- a/lib/screen_ui/on_demand_service/on_demand_payment_screen.dart +++ b/lib/screen_ui/on_demand_service/on_demand_payment_screen.dart @@ -1,4 +1,5 @@ import 'package:customer/constant/constant.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../../controllers/0n_demand_payment_controller.dart'; @@ -34,12 +35,30 @@ class OnDemandPaymentScreen extends StatelessWidget { child: Container( height: 42, width: 42, - decoration: BoxDecoration(shape: BoxShape.circle, color: AppThemeData.grey50), - child: Center(child: Padding(padding: const EdgeInsets.only(left: 5), child: Icon(Icons.arrow_back_ios, color: AppThemeData.grey900, size: 20))), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: AppThemeData.grey50, + ), + child: Center( + child: Padding( + padding: const EdgeInsets.only(left: 5), + child: Icon( + Icons.arrow_back_ios, + color: AppThemeData.grey900, + size: 20, + ), + ), + ), ), ), const SizedBox(width: 10), - Text("Select Payment Method".tr, style: AppThemeData.boldTextStyle(fontSize: 18, color: AppThemeData.grey900)), + Text( + "Select Payment Method".tr, + style: AppThemeData.boldTextStyle( + fontSize: 18, + color: AppThemeData.grey900, + ), + ), ], ), ), @@ -48,45 +67,106 @@ class OnDemandPaymentScreen extends StatelessWidget { controller.isLoading.value ? Constant.loader() : Container( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20), - decoration: BoxDecoration(color: isDark ? AppThemeData.greyDark200 : Colors.white), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 20, + ), + decoration: BoxDecoration( + color: isDark ? AppThemeData.greyDark200 : Colors.white, + ), child: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("Preferred Payment".tr, textAlign: TextAlign.start, style: AppThemeData.boldTextStyle(fontSize: 15, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500)), + Text( + "Preferred Payment".tr, + textAlign: TextAlign.start, + style: AppThemeData.boldTextStyle( + fontSize: 15, + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), + ), const SizedBox(height: 10), - if (controller.walletSettingModel.value.isEnabled == true || controller.cashOnDeliverySettingModel.value.isEnabled == true) + if (controller.walletSettingModel.value.isEnabled == + true || + controller + .cashOnDeliverySettingModel + .value + .isEnabled == + true) Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ Visibility( - visible: controller.walletSettingModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.wallet, isDark, "assets/images/ic_wallet.png"), + visible: + controller + .walletSettingModel + .value + .isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.wallet, + isDark, + "assets/images/ic_wallet.png", + ), ), Visibility( - visible: controller.cashOnDeliverySettingModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.cod, isDark, "assets/images/ic_cash.png"), + visible: + controller + .cashOnDeliverySettingModel + .value + .isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.cod, + isDark, + "assets/images/ic_cash.png", + ), ), ], ), ), ), - if (controller.walletSettingModel.value.isEnabled == true || controller.cashOnDeliverySettingModel.value.isEnabled == true) + if (controller.walletSettingModel.value.isEnabled == + true || + controller + .cashOnDeliverySettingModel + .value + .isEnabled == + true) Column( children: [ const SizedBox(height: 10), Text( "Other Payment Options".tr, textAlign: TextAlign.start, - style: AppThemeData.boldTextStyle(fontSize: 15, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500), + style: AppThemeData.boldTextStyle( + fontSize: 15, + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), ), const SizedBox(height: 10), ], @@ -94,38 +174,155 @@ class OnDemandPaymentScreen extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ - Visibility(visible: controller.stripeModel.value.isEnabled == true, child: cardDecoration(controller, PaymentGateway.stripe, isDark, "assets/images/stripe.png")), - Visibility(visible: controller.payPalModel.value.isEnabled == true, child: cardDecoration(controller, PaymentGateway.paypal, isDark, "assets/images/paypal.png")), Visibility( - visible: controller.payStackModel.value.isEnable == true, - child: cardDecoration(controller, PaymentGateway.payStack, isDark, "assets/images/paystack.png"), + visible: + controller + .stripeModel + .value + .isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.stripe, + isDark, + "assets/images/stripe.png", + ), ), Visibility( - visible: controller.mercadoPagoModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.mercadoPago, isDark, "assets/images/mercado-pago.png"), + visible: + controller + .payPalModel + .value + .isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.paypal, + isDark, + "assets/images/paypal.png", + ), ), Visibility( - visible: controller.flutterWaveModel.value.isEnable == true, - child: cardDecoration(controller, PaymentGateway.flutterWave, isDark, "assets/images/flutterwave_logo.png"), + visible: + controller + .payStackModel + .value + .isEnable == + true, + child: cardDecoration( + controller, + PaymentGateway.payStack, + isDark, + "assets/images/paystack.png", + ), ), - Visibility(visible: controller.payFastModel.value.isEnable == true, child: cardDecoration(controller, PaymentGateway.payFast, isDark, "assets/images/payfast.png")), Visibility( - visible: controller.razorPayModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.razorpay, isDark, "assets/images/razorpay.png"), + visible: + controller + .mercadoPagoModel + .value + .isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.mercadoPago, + isDark, + "assets/images/mercado-pago.png", + ), ), - Visibility(visible: controller.midTransModel.value.enable == true, child: cardDecoration(controller, PaymentGateway.midTrans, isDark, "assets/images/midtrans.png")), Visibility( - visible: controller.orangeMoneyModel.value.enable == true, - child: cardDecoration(controller, PaymentGateway.orangeMoney, isDark, "assets/images/orange_money.png"), + visible: + controller + .flutterWaveModel + .value + .isEnable == + true, + child: cardDecoration( + controller, + PaymentGateway.flutterWave, + isDark, + "assets/images/flutterwave_logo.png", + ), + ), + Visibility( + visible: + controller + .payFastModel + .value + .isEnable == + true, + child: cardDecoration( + controller, + PaymentGateway.payFast, + isDark, + "assets/images/payfast.png", + ), + ), + Visibility( + visible: + controller + .razorPayModel + .value + .isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.razorpay, + isDark, + "assets/images/razorpay.png", + ), + ), + Visibility( + visible: + controller.midTransModel.value.enable == + true, + child: cardDecoration( + controller, + PaymentGateway.midTrans, + isDark, + "assets/images/midtrans.png", + ), + ), + Visibility( + visible: + controller + .orangeMoneyModel + .value + .enable == + true, + child: cardDecoration( + controller, + PaymentGateway.orangeMoney, + isDark, + "assets/images/orange_money.png", + ), + ), + Visibility( + visible: + controller.xenditModel.value.enable == + true, + child: cardDecoration( + controller, + PaymentGateway.xendit, + isDark, + "assets/images/xendit.png", + ), ), - Visibility(visible: controller.xenditModel.value.enable == true, child: cardDecoration(controller, PaymentGateway.xendit, isDark, "assets/images/xendit.png")), ], ), ), @@ -136,55 +333,151 @@ class OnDemandPaymentScreen extends StatelessWidget { color: AppThemeData.primary300, textColor: AppThemeData.grey900, onPress: () async { - print("getTotalAmount :::::::: ${"${controller.totalAmount.value}"}"); + print( + "getTotalAmount :::::::: ${"${controller.totalAmount.value}"}", + ); if (controller.isOrderPlaced.value == false) { controller.isOrderPlaced.value = true; - if (controller.selectedPaymentMethod.value == PaymentGateway.stripe.name) { - controller.stripeMakePayment(amount: "${controller.totalAmount.value}"); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.paypal.name) { - controller.paypalPaymentSheet("${controller.totalAmount.value}", context); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.payStack.name) { - controller.payStackPayment("${controller.totalAmount.value}"); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.mercadoPago.name) { - controller.mercadoPagoMakePayment(context: context, amount: "${controller.totalAmount.value}"); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.flutterWave.name) { - controller.flutterWaveInitiatePayment(context: context, amount: "${controller.totalAmount.value}"); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.payFast.name) { - controller.payFastPayment(context: context, amount: "${controller.totalAmount.value}"); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.wallet.name) { - double totalAmount = double.parse("${controller.totalAmount.value}"); - double walletAmount = double.tryParse(Constant.userModel?.walletAmount?.toString() ?? "0") ?? 0; + if (controller.selectedPaymentMethod.value == + PaymentGateway.stripe.name) { + controller.stripeMakePayment( + amount: "${controller.totalAmount.value}", + ); + } else if (controller + .selectedPaymentMethod + .value == + PaymentGateway.paypal.name) { + controller.paypalPaymentSheet( + "${controller.totalAmount.value}", + context, + ); + } else if (controller + .selectedPaymentMethod + .value == + PaymentGateway.payStack.name) { + controller.payStackPayment( + "${controller.totalAmount.value}", + ); + } else if (controller + .selectedPaymentMethod + .value == + PaymentGateway.mercadoPago.name) { + controller.mercadoPagoMakePayment( + context: context, + amount: "${controller.totalAmount.value}", + ); + } else if (controller + .selectedPaymentMethod + .value == + PaymentGateway.flutterWave.name) { + controller.flutterWaveInitiatePayment( + context: context, + amount: "${controller.totalAmount.value}", + ); + } else if (controller + .selectedPaymentMethod + .value == + PaymentGateway.payFast.name) { + controller.payFastPayment( + context: context, + amount: "${controller.totalAmount.value}", + ); + } else if (controller + .selectedPaymentMethod + .value == + PaymentGateway.wallet.name) { + double totalAmount = double.parse( + "${controller.totalAmount.value}", + ); + double walletAmount = + double.tryParse( + Constant.userModel?.walletAmount + ?.toString() ?? + "0", + ) ?? + 0; if (walletAmount == 0) { - ShowToastDialog.showToast("Wallet balance is 0. Please recharge wallet.".tr); + ShowToastDialog.showToast( + "Wallet balance is 0. Please recharge wallet." + .tr, + ); } else if (walletAmount < totalAmount) { - ShowToastDialog.showToast("Insufficient wallet balance. Please add funds.".tr); + ShowToastDialog.showToast( + "Insufficient wallet balance. Please add funds." + .tr, + ); } else { controller.placeOrder(); } - } else if (controller.selectedPaymentMethod.value == PaymentGateway.cod.name) { + } else if (controller + .selectedPaymentMethod + .value == + PaymentGateway.cod.name) { controller.placeOrder(); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.wallet.name) { + } else if (controller + .selectedPaymentMethod + .value == + PaymentGateway.wallet.name) { controller.placeOrder(); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.midTrans.name) { - controller.midtransMakePayment(context: context, amount: "${controller.totalAmount.value}"); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.orangeMoney.name) { - controller.orangeMakePayment(context: context, amount: "${controller.totalAmount.value}"); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.xendit.name) { - controller.xenditPayment(context, "${controller.totalAmount.value}"); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.razorpay.name) { - RazorPayController().createOrderRazorPay(amount: double.parse("${controller.totalAmount.value}"), razorpayModel: controller.razorPayModel.value).then((value) { - if (value == null) { - Get.back(); - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); - } else { - CreateRazorPayOrderModel result = value; - controller.openCheckout(amount: "${controller.totalAmount.value}", orderId: result.id); - } - }); + } else if (controller + .selectedPaymentMethod + .value == + PaymentGateway.midTrans.name) { + controller.midtransMakePayment( + context: context, + amount: "${controller.totalAmount.value}", + ); + } else if (controller + .selectedPaymentMethod + .value == + PaymentGateway.orangeMoney.name) { + controller.orangeMakePayment( + context: context, + amount: "${controller.totalAmount.value}", + ); + } else if (controller + .selectedPaymentMethod + .value == + PaymentGateway.xendit.name) { + controller.xenditPayment( + context, + "${controller.totalAmount.value}", + ); + } else if (controller + .selectedPaymentMethod + .value == + PaymentGateway.razorpay.name) { + RazorPayController() + .createOrderRazorPay( + amount: double.parse( + "${controller.totalAmount.value}", + ), + razorpayModel: + controller.razorPayModel.value, + ) + .then((value) { + if (value == null) { + Get.back(); + ShowToastDialog.showToast( + "Something went wrong, please contact admin." + .tr, + ); + } else { + CreateRazorPayOrderModel result = + value; + controller.openCheckout( + amount: + "${controller.totalAmount.value}", + orderId: result.id, + ); + } + }); } else { controller.isOrderPlaced.value = false; - ShowToastDialog.showToast("Please select payment method".tr); + ShowToastDialog.showToast( + "Please select payment method".tr, + ); } controller.isOrderPlaced.value = false; } @@ -214,8 +507,21 @@ class OnDemandPaymentScreen extends StatelessWidget { Container( width: 50, height: 50, - decoration: ShapeDecoration(shape: RoundedRectangleBorder(side: const BorderSide(width: 1, color: Color(0xFFE5E7EB)), borderRadius: BorderRadius.circular(8))), - child: Padding(padding: EdgeInsets.all(value.name == "payFast" ? 0 : 8.0), child: Image.asset(image)), + decoration: ShapeDecoration( + shape: RoundedRectangleBorder( + side: const BorderSide( + width: 1, + color: Color(0xFFE5E7EB), + ), + borderRadius: BorderRadius.circular(8), + ), + ), + child: Padding( + padding: EdgeInsets.all( + value.name == "payFast" ? 0 : 8.0, + ), + child: Image.asset(image), + ), ), const SizedBox(width: 10), value.name == "wallet" @@ -226,12 +532,30 @@ class OnDemandPaymentScreen extends StatelessWidget { Text( value.name.capitalizeString(), textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), Text( - Constant.amountShow(amount: Constant.userModel?.walletAmount == null ? '0.0' : Constant.userModel?.walletAmount.toString()), + Constant.amountShow( + amount: + Constant.userModel?.walletAmount == null + ? '0.0' + : Constant.userModel?.walletAmount + .toString(), + ), textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(fontSize: 14, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300), + style: AppThemeData.semiBoldTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + ), ), ], ), @@ -240,14 +564,23 @@ class OnDemandPaymentScreen extends StatelessWidget { child: Text( value.name.capitalizeString(), textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), ), const Expanded(child: SizedBox()), Radio( value: value.name, groupValue: controller.selectedPaymentMethod.value, - activeColor: isDark ? AppThemeData.primary300 : AppThemeData.primary300, + activeColor: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, onChanged: (value) { controller.selectedPaymentMethod.value = value.toString(); }, diff --git a/lib/screen_ui/on_demand_service/on_demand_review_screen.dart b/lib/screen_ui/on_demand_service/on_demand_review_screen.dart index a147698..04c83e0 100644 --- a/lib/screen_ui/on_demand_service/on_demand_review_screen.dart +++ b/lib/screen_ui/on_demand_service/on_demand_review_screen.dart @@ -33,61 +33,139 @@ class OnDemandReviewScreen extends StatelessWidget { child: Container( height: 42, width: 42, - decoration: BoxDecoration(shape: BoxShape.circle, color: AppThemeData.grey50), - child: Center(child: Padding(padding: const EdgeInsets.only(left: 5), child: Icon(Icons.arrow_back_ios, color: AppThemeData.grey900, size: 20))), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: AppThemeData.grey50, + ), + child: Center( + child: Padding( + padding: const EdgeInsets.only(left: 5), + child: Icon( + Icons.arrow_back_ios, + color: AppThemeData.grey900, + size: 20, + ), + ), + ), ), ), const SizedBox(width: 10), - Text(controller.ratingModel.value != null ? "Update Review".tr : "Add Review".tr, style: AppThemeData.boldTextStyle(fontSize: 18, color: AppThemeData.grey900)), + Text( + controller.ratingModel.value != null + ? "Update Review".tr + : "Add Review".tr, + style: AppThemeData.boldTextStyle( + fontSize: 18, + color: AppThemeData.grey900, + ), + ), ], ), ), ), body: Obx( () => - (controller.reviewFor.value == "Worker" && controller.workerModel.value == null) || (controller.reviewFor.value == "Provider" && controller.provider.value == null) + (controller.reviewFor.value == "Worker" && + controller.workerModel.value == null) || + (controller.reviewFor.value == "Provider" && + controller.provider.value == null) ? Constant.loader() : Padding( padding: const EdgeInsets.only(top: 50.0), child: Stack( children: [ Padding( - padding: const EdgeInsets.only(left: 20, right: 20, top: 42, bottom: 20), + padding: const EdgeInsets.only( + left: 20, + right: 20, + top: 42, + bottom: 20, + ), child: Card( elevation: 2, - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), child: SingleChildScrollView( child: Padding( padding: const EdgeInsets.only(top: 65), child: Column( children: [ - Text('Rate for'.tr, style: AppThemeData.mediumTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), Text( - controller.reviewFor.value == "Provider" ? controller.order.value!.provider.authorName ?? "" : controller.workerModel.value!.fullName(), - style: AppThemeData.mediumTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + 'Rate for'.tr, + style: AppThemeData.mediumTextStyle( + fontSize: 18, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + Text( + controller.reviewFor.value == "Provider" + ? controller + .order + .value! + .provider + .authorName ?? + "" + : controller.workerModel.value! + .fullName(), + style: AppThemeData.mediumTextStyle( + fontSize: 18, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), Padding( padding: const EdgeInsets.only(top: 10), child: RatingBar.builder( - initialRating: controller.ratings.value, + initialRating: + controller.ratings.value, minRating: 1, direction: Axis.horizontal, allowHalfRating: true, itemCount: 5, - itemPadding: const EdgeInsets.symmetric(horizontal: 4.0), - itemBuilder: (context, _) => const Icon(Icons.star, color: Colors.amber), - unratedColor: isDark ? AppThemeData.greyDark400 : AppThemeData.grey400, + itemPadding: + const EdgeInsets.symmetric( + horizontal: 4.0, + ), + itemBuilder: + (context, _) => const Icon( + Icons.star, + color: Colors.amber, + ), + unratedColor: + isDark + ? AppThemeData.greyDark400 + : AppThemeData.grey400, onRatingUpdate: (rating) { controller.ratings.value = rating; }, ), ), - Padding(padding: EdgeInsets.all(20.0), child: TextFieldWidget(hintText: "Type comment....".tr, controller: controller.comment, maxLine: 5)), + Padding( + padding: EdgeInsets.all(20.0), + child: TextFieldWidget( + hintText: "Type comment....".tr, + controller: controller.comment, + maxLine: 5, + ), + ), Padding( padding: const EdgeInsets.all(20.0), child: RoundedButtonFill( - title: controller.ratingModel.value != null ? "Update Review".tr : "Add Review".tr, + title: + controller.ratingModel.value != + null + ? "Update Review".tr + : "Add Review".tr, color: AppThemeData.primary300, textColor: AppThemeData.grey50, onPress: controller.submitReview, @@ -104,7 +182,19 @@ class OnDemandReviewScreen extends StatelessWidget { child: ClipRRect( borderRadius: BorderRadius.circular(50), child: NetworkImageWidget( - imageUrl: controller.reviewFor.value == "Provider" ? controller.order.value?.provider.authorProfilePic ?? '' : controller.workerModel.value?.profilePictureURL ?? '', + imageUrl: + controller.reviewFor.value == "Provider" + ? controller + .order + .value + ?.provider + .authorProfilePic ?? + '' + : controller + .workerModel + .value + ?.profilePictureURL ?? + '', fit: BoxFit.cover, height: 100, width: 100, diff --git a/lib/screen_ui/on_demand_service/provider_inbox_screen.dart b/lib/screen_ui/on_demand_service/provider_inbox_screen.dart index 617c526..344835a 100644 --- a/lib/screen_ui/on_demand_service/provider_inbox_screen.dart +++ b/lib/screen_ui/on_demand_service/provider_inbox_screen.dart @@ -1,4 +1,5 @@ import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:customer/constant/const_texts.dart'; import 'package:customer/constant/constant.dart'; import 'package:customer/models/inbox_model.dart'; import 'package:customer/models/user_model.dart'; @@ -8,9 +9,9 @@ import 'package:customer/themes/responsive.dart'; import 'package:customer/utils/network_image_widget.dart'; import 'package:customer/widget/firebase_pagination/src/fireStore_pagination.dart'; import 'package:customer/widget/firebase_pagination/src/models/view_type.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; - import '../../../controllers/theme_controller.dart'; import '../../../service/fire_store_utils.dart'; import '../../../themes/show_toast_dialog.dart'; @@ -24,10 +25,19 @@ class ProviderInboxScreen extends StatelessWidget { final isDark = themeController.isDark.value; return Scaffold( appBar: AppBar( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, centerTitle: false, titleSpacing: 0, - title: Text("Provider Inbox".tr, textAlign: TextAlign.start, style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900)), + title: Text( + "Provider Inbox".tr, + textAlign: TextAlign.start, + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 16, + color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + ), + ), ), body: FirestorePagination( //item builder type is compulsory. @@ -37,10 +47,14 @@ class ProviderInboxScreen extends StatelessWidget { InboxModel inboxModel = InboxModel.fromJson(data!); return InkWell( onTap: () async { - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); - UserModel? customer = await FireStoreUtils.getUserProfile(inboxModel.customerId.toString()); - UserModel? restaurantUser = await FireStoreUtils.getUserProfile(inboxModel.restaurantId.toString()); + UserModel? customer = await FireStoreUtils.getUserProfile( + inboxModel.customerId.toString(), + ); + UserModel? restaurantUser = await FireStoreUtils.getUserProfile( + inboxModel.restaurantId.toString(), + ); ShowToastDialog.closeLoader(); Get.to( @@ -61,15 +75,23 @@ class ProviderInboxScreen extends StatelessWidget { child: Padding( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 5), child: Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))), + decoration: ShapeDecoration( + color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), child: Padding( padding: const EdgeInsets.all(8.0), child: Row( children: [ ClipRRect( - borderRadius: const BorderRadius.all(Radius.circular(10)), + borderRadius: const BorderRadius.all( + Radius.circular(10), + ), child: NetworkImageWidget( - imageUrl: inboxModel.restaurantProfileImage.toString(), + imageUrl: + inboxModel.restaurantProfileImage.toString(), fit: BoxFit.cover, height: Responsive.height(6, context), width: Responsive.width(12, context), @@ -86,13 +108,29 @@ class ProviderInboxScreen extends StatelessWidget { child: Text( "${inboxModel.restaurantName}", textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.grey100 : AppThemeData.grey800), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + fontSize: 16, + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey800, + ), ), ), Text( - Constant.timestampToDate(inboxModel.createdAt!), + Constant.timestampToDate( + inboxModel.createdAt!, + ), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, fontSize: 16, color: isDark ? AppThemeData.grey400 : AppThemeData.grey500), + style: TextStyle( + fontFamily: AppThemeData.regular, + fontSize: 16, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey500, + ), ), ], ), @@ -100,7 +138,14 @@ class ProviderInboxScreen extends StatelessWidget { Text( "${inboxModel.lastMessage}", textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 14, color: isDark ? AppThemeData.grey200 : AppThemeData.grey700), + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 14, + color: + isDark + ? AppThemeData.grey200 + : AppThemeData.grey700, + ), ), ], ), @@ -115,7 +160,10 @@ class ProviderInboxScreen extends StatelessWidget { shrinkWrap: true, onEmpty: Constant.showEmptyView(message: "No Conversion found".tr), // orderBy is compulsory to enable pagination - query: FirebaseFirestore.instance.collection('chat_provider').where("customerId", isEqualTo: FireStoreUtils.getCurrentUid()).orderBy('createdAt', descending: true), + query: FirebaseFirestore.instance + .collection('chat_provider') + .where("customerId", isEqualTo: FireStoreUtils.getCurrentUid()) + .orderBy('createdAt', descending: true), //Change types customerId viewType: ViewType.list, initialLoader: Constant.loader(), diff --git a/lib/screen_ui/on_demand_service/provider_screen.dart b/lib/screen_ui/on_demand_service/provider_screen.dart index 9290009..d352d47 100644 --- a/lib/screen_ui/on_demand_service/provider_screen.dart +++ b/lib/screen_ui/on_demand_service/provider_screen.dart @@ -1,5 +1,6 @@ import 'package:customer/constant/constant.dart'; import 'package:customer/screen_ui/on_demand_service/on_demand_home_screen.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:get/get.dart'; @@ -25,58 +26,114 @@ class ProviderScreen extends StatelessWidget { controller.isLoading.value ? Center(child: Constant.loader()) : Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 50), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 50, + ), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ Center( child: - (controller.userModel.value?.profilePictureURL ?? "").isNotEmpty - ? CircleAvatar(backgroundImage: NetworkImage(controller.userModel.value?.profilePictureURL ?? ''), radius: 50.0) - : CircleAvatar(backgroundImage: NetworkImage(Constant.placeHolderImage), radius: 50.0), + (controller.userModel.value?.profilePictureURL ?? + "") + .isNotEmpty + ? CircleAvatar( + backgroundImage: NetworkImage( + controller + .userModel + .value + ?.profilePictureURL ?? + '', + ), + radius: 50.0, + ) + : CircleAvatar( + backgroundImage: NetworkImage( + Constant.placeHolderImage, + ), + radius: 50.0, + ), ), const SizedBox(height: 10), Text( controller.userModel.value?.fullName() ?? '', - style: TextStyle(color: isDark ? Colors.white : Colors.black, fontFamily: AppThemeData.regular, fontSize: 20, fontWeight: FontWeight.w900), + style: TextStyle( + color: isDark ? Colors.white : Colors.black, + fontFamily: AppThemeData.regular, + fontSize: 20, + fontWeight: FontWeight.w900, + ), ), const SizedBox(height: 5), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - SvgPicture.asset("assets/icons/ic_mail.svg", color: isDark ? Colors.white : Colors.black), + SvgPicture.asset( + "assets/icons/ic_mail.svg", + color: isDark ? Colors.white : Colors.black, + ), const SizedBox(width: 6), Text( controller.userModel.value?.email ?? '', - style: TextStyle(color: isDark ? Colors.white : Colors.black, fontFamily: AppThemeData.regular, fontSize: 14, fontWeight: FontWeight.w500), + style: TextStyle( + color: isDark ? Colors.white : Colors.black, + fontFamily: AppThemeData.regular, + fontSize: 14, + fontWeight: FontWeight.w500, + ), ), ], ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - SvgPicture.asset("assets/icons/ic_mobile.svg", color: isDark ? Colors.white : Colors.black), + SvgPicture.asset( + "assets/icons/ic_mobile.svg", + color: isDark ? Colors.white : Colors.black, + ), const SizedBox(width: 6), Text( controller.userModel.value?.phoneNumber ?? '', - style: TextStyle(color: isDark ? Colors.white : Colors.black, fontFamily: AppThemeData.regular, fontSize: 14, fontWeight: FontWeight.w500), + style: TextStyle( + color: isDark ? Colors.white : Colors.black, + fontFamily: AppThemeData.regular, + fontSize: 14, + fontWeight: FontWeight.w500, + ), ), ], ), const SizedBox(height: 10), Container( - decoration: const BoxDecoration(color: AppThemeData.warning400, borderRadius: BorderRadius.all(Radius.circular(16))), + decoration: const BoxDecoration( + color: AppThemeData.warning400, + borderRadius: BorderRadius.all(Radius.circular(16)), + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5), + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 5, + ), child: Row( mainAxisSize: MainAxisSize.min, children: [ - const Icon(Icons.star, size: 16, color: Colors.white), + const Icon( + Icons.star, + size: 16, + color: Colors.white, + ), const SizedBox(width: 3), Text( _getRating(controller), - style: const TextStyle(letterSpacing: 0.5, fontSize: 12, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w500, color: Colors.white), + style: const TextStyle( + letterSpacing: 0.5, + fontSize: 12, + fontFamily: AppThemeData.regular, + fontWeight: FontWeight.w500, + color: Colors.white, + ), ), ], ), @@ -92,8 +149,14 @@ class ProviderScreen extends StatelessWidget { itemCount: controller.providerList.length, padding: EdgeInsets.zero, itemBuilder: (context, index) { - ProviderServiceModel data = controller.providerList[index]; - return ServiceView(provider: data, isDark: isDark, controller: controller.onDemandHomeController.value); + ProviderServiceModel data = + controller.providerList[index]; + return ServiceView( + provider: data, + isDark: isDark, + controller: + controller.onDemandHomeController.value, + ); }, ), ), @@ -106,8 +169,16 @@ class ProviderScreen extends StatelessWidget { } String _getRating(ProviderController controller) { - final reviewsCount = double.tryParse(controller.userModel.value?.reviewsCount?.toString() ?? "0") ?? 0; - final reviewsSum = double.tryParse(controller.userModel.value?.reviewsSum?.toString() ?? "0") ?? 0; + final reviewsCount = + double.tryParse( + controller.userModel.value?.reviewsCount?.toString() ?? "0", + ) ?? + 0; + final reviewsSum = + double.tryParse( + controller.userModel.value?.reviewsSum?.toString() ?? "0", + ) ?? + 0; if (reviewsCount == 0) return "0"; final avg = reviewsSum / reviewsCount; diff --git a/lib/screen_ui/on_demand_service/view_all_popular_service_screen.dart b/lib/screen_ui/on_demand_service/view_all_popular_service_screen.dart index 67a35cc..6ccb52a 100644 --- a/lib/screen_ui/on_demand_service/view_all_popular_service_screen.dart +++ b/lib/screen_ui/on_demand_service/view_all_popular_service_screen.dart @@ -1,4 +1,5 @@ import 'package:customer/screen_ui/on_demand_service/on_demand_home_screen.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../../constant/constant.dart'; @@ -31,12 +32,30 @@ class ViewAllPopularServiceScreen extends StatelessWidget { child: Container( height: 42, width: 42, - decoration: BoxDecoration(shape: BoxShape.circle, color: AppThemeData.grey50), - child: Center(child: Padding(padding: const EdgeInsets.only(left: 5), child: Icon(Icons.arrow_back_ios, color: AppThemeData.grey900, size: 20))), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: AppThemeData.grey50, + ), + child: Center( + child: Padding( + padding: const EdgeInsets.only(left: 5), + child: Icon( + Icons.arrow_back_ios, + color: AppThemeData.grey900, + size: 20, + ), + ), + ), ), ), const SizedBox(width: 10), - Text("All Services".tr, style: AppThemeData.boldTextStyle(fontSize: 18, color: AppThemeData.grey900)), + Text( + "All Services".tr, + style: AppThemeData.boldTextStyle( + fontSize: 18, + color: AppThemeData.grey900, + ), + ), ], ), ), @@ -45,13 +64,29 @@ class ViewAllPopularServiceScreen extends StatelessWidget { controller.isLoading.value ? Constant.loader() : Padding( - padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 15), + padding: const EdgeInsets.symmetric( + vertical: 20, + horizontal: 15, + ), child: Column( children: [ - TextFieldWidget(hintText: "Search Service".tr, controller: controller.searchTextFiledController.value, onchange: (value) => controller.getFilterData(value.toString())), + TextFieldWidget( + hintText: "Search Service".tr, + controller: + controller.searchTextFiledController.value, + onchange: + (value) => + controller.getFilterData(value.toString()), + ), const SizedBox(height: 15), controller.providerList.isEmpty - ? Expanded(child: Center(child: Constant.showEmptyView(message: "No service Found".tr))) + ? Expanded( + child: Center( + child: Constant.showEmptyView( + message: "No service Found".tr, + ), + ), + ) : Expanded( child: ListView.builder( itemCount: controller.providerList.length, @@ -59,8 +94,14 @@ class ViewAllPopularServiceScreen extends StatelessWidget { padding: EdgeInsets.zero, scrollDirection: Axis.vertical, itemBuilder: (context, index) { - ProviderServiceModel data = controller.providerList[index]; - return ServiceView(provider: data, isDark: isDark, controller: controller.onDemandHomeController.value); + ProviderServiceModel data = + controller.providerList[index]; + return ServiceView( + provider: data, + isDark: isDark, + controller: + controller.onDemandHomeController.value, + ); }, ), ), diff --git a/lib/screen_ui/on_demand_service/view_category_service_screen.dart b/lib/screen_ui/on_demand_service/view_category_service_screen.dart index ae5be3d..d2165c1 100644 --- a/lib/screen_ui/on_demand_service/view_category_service_screen.dart +++ b/lib/screen_ui/on_demand_service/view_category_service_screen.dart @@ -31,12 +31,30 @@ class ViewCategoryServiceListScreen extends StatelessWidget { child: Container( height: 42, width: 42, - decoration: BoxDecoration(shape: BoxShape.circle, color: AppThemeData.grey50), - child: Center(child: Padding(padding: const EdgeInsets.only(left: 5), child: Icon(Icons.arrow_back_ios, color: AppThemeData.grey900, size: 20))), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: AppThemeData.grey50, + ), + child: Center( + child: Padding( + padding: const EdgeInsets.only(left: 5), + child: Icon( + Icons.arrow_back_ios, + color: AppThemeData.grey900, + size: 20, + ), + ), + ), ), ), const SizedBox(width: 10), - Text(controller.categoryTitle.value, style: AppThemeData.boldTextStyle(fontSize: 18, color: AppThemeData.grey900)), + Text( + controller.categoryTitle.value, + style: AppThemeData.boldTextStyle( + fontSize: 18, + color: AppThemeData.grey900, + ), + ), ], ), ), @@ -47,14 +65,22 @@ class ViewCategoryServiceListScreen extends StatelessWidget { : controller.providerList.isEmpty ? Constant.showEmptyView(message: "No Service Found".tr) : Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: ListView.builder( itemCount: controller.providerList.length, shrinkWrap: true, padding: EdgeInsets.zero, itemBuilder: (context, index) { - ProviderServiceModel providerModel = controller.providerList[index]; - return ServiceView(isDark: isDark, provider: providerModel, controller: controller.onDemandHomeController.value); + ProviderServiceModel providerModel = + controller.providerList[index]; + return ServiceView( + isDark: isDark, + provider: providerModel, + controller: controller.onDemandHomeController.value, + ); }, ), ), diff --git a/lib/screen_ui/on_demand_service/worker_inbox_screen.dart b/lib/screen_ui/on_demand_service/worker_inbox_screen.dart index acbe6ca..d500bbb 100644 --- a/lib/screen_ui/on_demand_service/worker_inbox_screen.dart +++ b/lib/screen_ui/on_demand_service/worker_inbox_screen.dart @@ -1,4 +1,5 @@ import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:customer/constant/const_texts.dart'; import 'package:customer/constant/constant.dart'; import 'package:customer/models/inbox_model.dart'; import 'package:customer/models/user_model.dart'; @@ -8,9 +9,9 @@ import 'package:customer/themes/responsive.dart'; import 'package:customer/utils/network_image_widget.dart'; import 'package:customer/widget/firebase_pagination/src/fireStore_pagination.dart'; import 'package:customer/widget/firebase_pagination/src/models/view_type.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; - import '../../../controllers/theme_controller.dart'; import '../../../service/fire_store_utils.dart'; import '../../../themes/show_toast_dialog.dart'; @@ -24,10 +25,19 @@ class WorkerInboxScreen extends StatelessWidget { final isDark = themeController.isDark.value; return Scaffold( appBar: AppBar( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, centerTitle: false, titleSpacing: 0, - title: Text("Worker Inbox".tr, textAlign: TextAlign.start, style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900)), + title: Text( + "Worker Inbox".tr, + textAlign: TextAlign.start, + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 16, + color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + ), + ), ), body: FirestorePagination( //item builder type is compulsory. @@ -37,13 +47,19 @@ class WorkerInboxScreen extends StatelessWidget { InboxModel inboxModel = InboxModel.fromJson(data!); return InkWell( onTap: () async { - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader(ConstTexts.pleaseWait.tr); - UserModel? customer = await FireStoreUtils.getUserProfile(inboxModel.customerId.toString()); - UserModel? restaurantUser = await FireStoreUtils.getUserProfile(inboxModel.restaurantId.toString()); + UserModel? customer = await FireStoreUtils.getUserProfile( + inboxModel.customerId.toString(), + ); + UserModel? restaurantUser = await FireStoreUtils.getUserProfile( + inboxModel.restaurantId.toString(), + ); ShowToastDialog.closeLoader(); - print("customerId: ${inboxModel.customerId}, restaurantId: ${inboxModel.restaurantId}"); + print( + "customerId: ${inboxModel.customerId}, restaurantId: ${inboxModel.restaurantId}", + ); Get.to( const ChatScreen(), arguments: { @@ -62,15 +78,23 @@ class WorkerInboxScreen extends StatelessWidget { child: Padding( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 5), child: Container( - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))), + decoration: ShapeDecoration( + color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), child: Padding( padding: const EdgeInsets.all(8.0), child: Row( children: [ ClipRRect( - borderRadius: const BorderRadius.all(Radius.circular(10)), + borderRadius: const BorderRadius.all( + Radius.circular(10), + ), child: NetworkImageWidget( - imageUrl: inboxModel.restaurantProfileImage.toString(), + imageUrl: + inboxModel.restaurantProfileImage.toString(), fit: BoxFit.cover, height: Responsive.height(6, context), width: Responsive.width(12, context), @@ -87,13 +111,29 @@ class WorkerInboxScreen extends StatelessWidget { child: Text( "${inboxModel.restaurantName}", textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.grey100 : AppThemeData.grey800), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + fontSize: 16, + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey800, + ), ), ), Text( - Constant.timestampToDate(inboxModel.createdAt!), + Constant.timestampToDate( + inboxModel.createdAt!, + ), textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.regular, fontSize: 16, color: isDark ? AppThemeData.grey400 : AppThemeData.grey500), + style: TextStyle( + fontFamily: AppThemeData.regular, + fontSize: 16, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData.grey500, + ), ), ], ), @@ -101,7 +141,14 @@ class WorkerInboxScreen extends StatelessWidget { Text( "${inboxModel.lastMessage}", textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 14, color: isDark ? AppThemeData.grey200 : AppThemeData.grey700), + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 14, + color: + isDark + ? AppThemeData.grey200 + : AppThemeData.grey700, + ), ), ], ), @@ -116,7 +163,10 @@ class WorkerInboxScreen extends StatelessWidget { shrinkWrap: true, onEmpty: Constant.showEmptyView(message: "No Conversion found".tr), // orderBy is compulsory to enable pagination - query: FirebaseFirestore.instance.collection('chat_worker').where("customerId", isEqualTo: FireStoreUtils.getCurrentUid()).orderBy('createdAt', descending: true), + query: FirebaseFirestore.instance + .collection('chat_worker') + .where("customerId", isEqualTo: FireStoreUtils.getCurrentUid()) + .orderBy('createdAt', descending: true), //Change types customerId viewType: ViewType.list, initialLoader: Constant.loader(), diff --git a/lib/screen_ui/parcel_service/book_parcel_screen.dart b/lib/screen_ui/parcel_service/book_parcel_screen.dart index 084b6b7..5c0e10c 100644 --- a/lib/screen_ui/parcel_service/book_parcel_screen.dart +++ b/lib/screen_ui/parcel_service/book_parcel_screen.dart @@ -4,6 +4,7 @@ import 'package:customer/themes/show_toast_dialog.dart'; import 'package:customer/utils/utils.dart'; import 'package:dotted_border/dotted_border.dart'; import 'package:dropdown_textfield/dropdown_textfield.dart'; + import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_svg/svg.dart'; @@ -42,8 +43,20 @@ class BookParcelScreen extends StatelessWidget { child: Container( height: 42, width: 42, - decoration: BoxDecoration(shape: BoxShape.circle, color: AppThemeData.grey50), - child: Center(child: Padding(padding: const EdgeInsets.only(left: 5), child: Icon(Icons.arrow_back_ios, color: AppThemeData.grey900, size: 20))), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: AppThemeData.grey50, + ), + child: Center( + child: Padding( + padding: const EdgeInsets.only(left: 5), + child: Icon( + Icons.arrow_back_ios, + color: AppThemeData.grey900, + size: 20, + ), + ), + ), ), ), const SizedBox(width: 10), @@ -51,12 +64,21 @@ class BookParcelScreen extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("Book Your Document Delivery".tr, style: AppThemeData.boldTextStyle(fontSize: 18, color: AppThemeData.grey900)), + Text( + "Book Your Document Delivery".tr, + style: AppThemeData.boldTextStyle( + fontSize: 18, + color: AppThemeData.grey900, + ), + ), Text( "Schedule a secure and timely pickup & delivery".tr, maxLines: 1, overflow: TextOverflow.ellipsis, - style: AppThemeData.mediumTextStyle(fontSize: 12, color: AppThemeData.grey900), + style: AppThemeData.mediumTextStyle( + fontSize: 12, + color: AppThemeData.grey900, + ), ), ], ), @@ -83,7 +105,8 @@ class BookParcelScreen extends StatelessWidget { nameController: controller.senderNameController.value, mobileController: controller.senderMobileController.value, noteController: controller.senderNoteController.value, - countryCodeController: controller.senderCountryCodeController.value, + countryCodeController: + controller.senderCountryCodeController.value, showWeight: true, isDark: isDark, context: context, @@ -94,14 +117,25 @@ class BookParcelScreen extends StatelessWidget { if (result != null) { final firstPlace = result; - if (Constant.checkZoneCheck(firstPlace.coordinates.latitude, firstPlace.coordinates.longitude) == true) { + if (Constant.checkZoneCheck( + firstPlace.coordinates.latitude, + firstPlace.coordinates.longitude, + ) == + true) { final address = firstPlace.address; final lat = firstPlace.coordinates.latitude; final lng = firstPlace.coordinates.longitude; - controller.senderLocationController.value.text = address; // ✅ - controller.senderLocation.value = UserLocation(latitude: lat, longitude: lng); // ✅ <-- Add this + controller.senderLocationController.value.text = + address; // ✅ + controller.senderLocation.value = UserLocation( + latitude: lat, + longitude: lng, + ); // ✅ <-- Add this } else { - ShowToastDialog.showToast("Service is unavailable at the selected address.".tr); + ShowToastDialog.showToast( + "Service is unavailable at the selected address." + .tr, + ); } } } else { @@ -109,11 +143,27 @@ class BookParcelScreen extends StatelessWidget { if (value != null) { SelectedLocationModel selectedLocationModel = value; - if (Constant.checkZoneCheck(selectedLocationModel.latLng!.latitude, selectedLocationModel.latLng!.longitude) == true) { - controller.senderLocationController.value.text = Utils.formatAddress(selectedLocation: selectedLocationModel); - controller.senderLocation.value = UserLocation(latitude: selectedLocationModel.latLng!.latitude, longitude: selectedLocationModel.latLng!.longitude); + if (Constant.checkZoneCheck( + selectedLocationModel.latLng!.latitude, + selectedLocationModel.latLng!.longitude, + ) == + true) { + controller + .senderLocationController + .value + .text = Utils.formatAddress( + selectedLocation: selectedLocationModel, + ); + controller.senderLocation.value = UserLocation( + latitude: selectedLocationModel.latLng!.latitude, + longitude: + selectedLocationModel.latLng!.longitude, + ); } else { - ShowToastDialog.showToast("Service is unavailable at the selected address.".tr); + ShowToastDialog.showToast( + "Service is unavailable at the selected address." + .tr, + ); } // ✅ <-- Add this } @@ -124,11 +174,13 @@ class BookParcelScreen extends StatelessWidget { const SizedBox(height: 16), buildInfoSectionView( title: "Receiver Information".tr, - locationController: controller.receiverLocationController.value, + locationController: + controller.receiverLocationController.value, nameController: controller.receiverNameController.value, mobileController: controller.receiverMobileController.value, noteController: controller.receiverNoteController.value, - countryCodeController: controller.receiverCountryCodeController.value, + countryCodeController: + controller.receiverCountryCodeController.value, showWeight: false, isDark: isDark, context: context, @@ -139,15 +191,26 @@ class BookParcelScreen extends StatelessWidget { if (result != null) { final firstPlace = result; - if (Constant.checkZoneCheck(firstPlace.coordinates.latitude, firstPlace.coordinates.longitude) == true) { + if (Constant.checkZoneCheck( + firstPlace.coordinates.latitude, + firstPlace.coordinates.longitude, + ) == + true) { final lat = firstPlace.coordinates.latitude; final lng = firstPlace.coordinates.longitude; final address = firstPlace.address; - controller.receiverLocationController.value.text = address; // ✅ - controller.receiverLocation.value = UserLocation(latitude: lat, longitude: lng); + controller.receiverLocationController.value.text = + address; // ✅ + controller.receiverLocation.value = UserLocation( + latitude: lat, + longitude: lng, + ); } else { - ShowToastDialog.showToast("Service is unavailable at the selected address.".tr); + ShowToastDialog.showToast( + "Service is unavailable at the selected address." + .tr, + ); } } } else { @@ -155,11 +218,27 @@ class BookParcelScreen extends StatelessWidget { if (value != null) { SelectedLocationModel selectedLocationModel = value; - if (Constant.checkZoneCheck(selectedLocationModel.latLng!.latitude, selectedLocationModel.latLng!.longitude) == true) { - controller.receiverLocationController.value.text = Utils.formatAddress(selectedLocation: selectedLocationModel); - controller.receiverLocation.value = UserLocation(latitude: selectedLocationModel.latLng!.latitude, longitude: selectedLocationModel.latLng!.longitude); // ✅ <-- Add this + if (Constant.checkZoneCheck( + selectedLocationModel.latLng!.latitude, + selectedLocationModel.latLng!.longitude, + ) == + true) { + controller + .receiverLocationController + .value + .text = Utils.formatAddress( + selectedLocation: selectedLocationModel, + ); + controller.receiverLocation.value = UserLocation( + latitude: selectedLocationModel.latLng!.latitude, + longitude: + selectedLocationModel.latLng!.longitude, + ); // ✅ <-- Add this } else { - ShowToastDialog.showToast("Service is unavailable at the selected address.".tr); + ShowToastDialog.showToast( + "Service is unavailable at the selected address." + .tr, + ); } } }); @@ -186,18 +265,30 @@ class BookParcelScreen extends StatelessWidget { ); } - Widget selectDeliveryTypeView(BookParcelController controller, bool isDark, BuildContext context) { + Widget selectDeliveryTypeView( + BookParcelController controller, + bool isDark, + BuildContext context, + ) { return Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + border: Border.all( + color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200, + ), ), padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 15), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("Select delivery type".tr, style: AppThemeData.boldTextStyle(color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500, fontSize: 13)), + Text( + "Select delivery type".tr, + style: AppThemeData.boldTextStyle( + color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500, + fontSize: 13, + ), + ), const SizedBox(height: 10), InkWell( onTap: () { @@ -206,12 +297,34 @@ class BookParcelScreen extends StatelessWidget { }, child: Row( children: [ - Image.asset("assets/images/image_parcel.png", height: 38, width: 38), + Image.asset( + "assets/images/image_parcel.png", + height: 38, + width: 38, + ), const SizedBox(width: 20), - Expanded(child: Text("As soon as possible".tr, style: AppThemeData.semiBoldTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, fontSize: 16))), + Expanded( + child: Text( + "As soon as possible".tr, + style: AppThemeData.semiBoldTextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + fontSize: 16, + ), + ), + ), Icon( - controller.selectedDeliveryType.value == 'now' ? Icons.radio_button_checked : Icons.radio_button_off, - color: controller.selectedDeliveryType.value == 'now' ? AppThemeData.primary300 : (isDark ? AppThemeData.greyDark500 : AppThemeData.grey500), + controller.selectedDeliveryType.value == 'now' + ? Icons.radio_button_checked + : Icons.radio_button_off, + color: + controller.selectedDeliveryType.value == 'now' + ? AppThemeData.primary300 + : (isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500), size: 20, ), ], @@ -227,12 +340,34 @@ class BookParcelScreen extends StatelessWidget { children: [ Row( children: [ - Image.asset("assets/images/image_parcel_scheduled.png", height: 38, width: 38), + Image.asset( + "assets/images/image_parcel_scheduled.png", + height: 38, + width: 38, + ), const SizedBox(width: 20), - Expanded(child: Text("Scheduled".tr, style: AppThemeData.semiBoldTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, fontSize: 16))), + Expanded( + child: Text( + "Scheduled".tr, + style: AppThemeData.semiBoldTextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + fontSize: 16, + ), + ), + ), Icon( - controller.selectedDeliveryType.value == 'later' ? Icons.radio_button_checked : Icons.radio_button_off, - color: controller.selectedDeliveryType.value == 'later' ? AppThemeData.primary300 : (isDark ? AppThemeData.greyDark500 : AppThemeData.grey500), + controller.selectedDeliveryType.value == 'later' + ? Icons.radio_button_checked + : Icons.radio_button_off, + color: + controller.selectedDeliveryType.value == 'later' + ? AppThemeData.primary300 + : (isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500), size: 20, ), ], @@ -245,9 +380,18 @@ class BookParcelScreen extends StatelessWidget { hintText: "When to pickup at this address".tr, controller: controller.scheduledDateController.value, enable: false, - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, - borderColor: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200, - suffix: const Padding(padding: EdgeInsets.only(right: 10), child: Icon(Icons.calendar_month_outlined)), + backgroundColor: + isDark + ? AppThemeData.surfaceDark + : AppThemeData.surface, + borderColor: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + suffix: const Padding( + padding: EdgeInsets.only(right: 10), + child: Icon(Icons.calendar_month_outlined), + ), ), ), const SizedBox(height: 10), @@ -258,9 +402,18 @@ class BookParcelScreen extends StatelessWidget { controller: controller.scheduledTimeController.value, enable: false, // onchange: (v) => controller.pickScheduledTime(context), - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, - borderColor: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200, - suffix: const Padding(padding: EdgeInsets.only(right: 10), child: Icon(Icons.access_time)), + backgroundColor: + isDark + ? AppThemeData.surfaceDark + : AppThemeData.surface, + borderColor: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + suffix: const Padding( + padding: EdgeInsets.only(right: 10), + child: Icon(Icons.access_time), + ), ), ), ], @@ -277,29 +430,75 @@ class BookParcelScreen extends StatelessWidget { decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + border: Border.all( + color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200, + ), ), padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 15), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("Upload parcel image".tr, style: AppThemeData.boldTextStyle(color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500, fontSize: 13)), + Text( + "Upload parcel image".tr, + style: AppThemeData.boldTextStyle( + color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500, + fontSize: 13, + ), + ), const SizedBox(height: 10), DottedBorder( - options: RoundedRectDottedBorderOptions(strokeWidth: 1, radius: const Radius.circular(10), color: isDark ? AppThemeData.greyDark300 : AppThemeData.grey300), + options: RoundedRectDottedBorderOptions( + strokeWidth: 1, + radius: const Radius.circular(10), + color: isDark ? AppThemeData.greyDark300 : AppThemeData.grey300, + ), child: Container( alignment: Alignment.center, - decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, + ), padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 50), child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ - SvgPicture.asset("assets/icons/ic_upload_parcel.svg", height: 40, width: 40), + SvgPicture.asset( + "assets/icons/ic_upload_parcel.svg", + height: 40, + width: 40, + ), const SizedBox(height: 10), - Text("Upload Parcel Image".tr, style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + "Upload Parcel Image".tr, + style: AppThemeData.mediumTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), const SizedBox(height: 4), - Text("Supported: .jpg, .jpeg, .png".tr, style: AppThemeData.semiBoldTextStyle(fontSize: 12, color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800)), - Text("Max size 1MB".tr, style: AppThemeData.semiBoldTextStyle(fontSize: 12, color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800)), + Text( + "Supported: .jpg, .jpeg, .png".tr, + style: AppThemeData.semiBoldTextStyle( + fontSize: 12, + color: + isDark + ? AppThemeData.greyDark800 + : AppThemeData.grey800, + ), + ), + Text( + "Max size 1MB".tr, + style: AppThemeData.semiBoldTextStyle( + fontSize: 12, + color: + isDark + ? AppThemeData.greyDark800 + : AppThemeData.grey800, + ), + ), const SizedBox(height: 8), RoundedButtonFill( title: "Browse Image".tr, @@ -325,7 +524,15 @@ class BookParcelScreen extends StatelessWidget { children: [ Container( padding: const EdgeInsets.only(top: 20, right: 20), - child: ClipRRect(borderRadius: BorderRadius.circular(8), child: Image.file(File(image.path), width: 70, height: 70, fit: BoxFit.cover)), + child: ClipRRect( + borderRadius: BorderRadius.circular(8), + child: Image.file( + File(image.path), + width: 70, + height: 70, + fit: BoxFit.cover, + ), + ), ), Positioned.fill( top: 0, @@ -333,7 +540,11 @@ class BookParcelScreen extends StatelessWidget { child: Align( alignment: Alignment.topRight, child: IconButton( - icon: const Icon(Icons.cancel, color: AppThemeData.danger300, size: 20), + icon: const Icon( + Icons.cancel, + color: AppThemeData.danger300, + size: 20, + ), onPressed: () { controller.images.remove(image); }, @@ -366,13 +577,21 @@ class BookParcelScreen extends StatelessWidget { decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + border: Border.all( + color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200, + ), ), padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 15), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text(title, style: AppThemeData.boldTextStyle(color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500, fontSize: 13)), + Text( + title, + style: AppThemeData.boldTextStyle( + color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500, + fontSize: 13, + ), + ), const SizedBox(height: 10), GestureDetector( @@ -381,9 +600,14 @@ class BookParcelScreen extends StatelessWidget { hintText: "Your Location".tr, controller: locationController, - suffix: const Padding(padding: EdgeInsets.only(right: 10), child: Icon(Icons.location_on_outlined)), - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, - borderColor: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200, + suffix: const Padding( + padding: EdgeInsets.only(right: 10), + child: Icon(Icons.location_on_outlined), + ), + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + borderColor: + isDark ? AppThemeData.greyDark200 : AppThemeData.grey200, enable: false, ), ), @@ -392,8 +616,10 @@ class BookParcelScreen extends StatelessWidget { TextFieldWidget( hintText: "Name".tr, controller: nameController, - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, - borderColor: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + borderColor: + isDark ? AppThemeData.greyDark200 : AppThemeData.grey200, ), const SizedBox(height: 10), @@ -401,24 +627,49 @@ class BookParcelScreen extends StatelessWidget { hintText: "Enter Mobile number".tr, controller: mobileController, textInputType: TextInputType.number, - inputFormatters: [FilteringTextInputFormatter.allow(RegExp('[0-9]')), LengthLimitingTextInputFormatter(10)], - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, - borderColor: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200, + inputFormatters: [ + FilteringTextInputFormatter.allow(RegExp('[0-9]')), + LengthLimitingTextInputFormatter(10), + ], + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + borderColor: + isDark ? AppThemeData.greyDark200 : AppThemeData.grey200, prefix: Row( mainAxisSize: MainAxisSize.min, children: [ CountryCodePicker( onChanged: (value) { - countryCodeController.text = value.dialCode ?? Constant.defaultCountryCode; + countryCodeController.text = + value.dialCode ?? Constant.defaultCountryCode; }, - initialSelection: countryCodeController.text.isNotEmpty ? countryCodeController.text : Constant.defaultCountryCode, + initialSelection: + countryCodeController.text.isNotEmpty + ? countryCodeController.text + : Constant.defaultCountryCode, showCountryOnly: false, showOnlyCountryWhenClosed: false, alignLeft: false, - textStyle: TextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : Colors.black), - dialogTextStyle: TextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), - searchStyle: TextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), - dialogBackgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + textStyle: TextStyle( + fontSize: 16, + color: isDark ? AppThemeData.greyDark900 : Colors.black, + ), + dialogTextStyle: TextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + searchStyle: TextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + dialogBackgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, padding: EdgeInsets.zero, ), // const Icon(Icons.keyboard_arrow_down_rounded, size: 24, color: AppThemeData.grey400), @@ -436,19 +687,37 @@ class BookParcelScreen extends StatelessWidget { enableSearch: false, textFieldDecoration: InputDecoration( hintText: "Select parcel Weight".tr, - hintStyle: AppThemeData.regularTextStyle(fontSize: 14, color: isDark ? AppThemeData.grey400 : AppThemeData.greyDark400), + hintStyle: AppThemeData.regularTextStyle( + fontSize: 14, + color: + isDark ? AppThemeData.grey400 : AppThemeData.greyDark400, + ), filled: true, - fillColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, - contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), - border: OutlineInputBorder(borderRadius: BorderRadius.circular(10), borderSide: BorderSide(color: AppThemeData.grey200)), - enabledBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(10), borderSide: BorderSide(color: AppThemeData.grey200)), - focusedBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(10), borderSide: BorderSide(color: AppThemeData.grey200)), + fillColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + contentPadding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 12, + ), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: BorderSide(color: AppThemeData.grey200), + ), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: BorderSide(color: AppThemeData.grey200), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: BorderSide(color: AppThemeData.grey200), + ), ), dropDownList: controller.parcelWeight.map((e) { return DropDownValueModel( name: e.title ?? 'Normal'.tr, - value: e.title ?? 'Normal'.tr, // safer to use title string + value: + e.title ?? 'Normal'.tr, // safer to use title string ); }).toList(), onChanged: (val) { @@ -456,7 +725,8 @@ class BookParcelScreen extends StatelessWidget { controller.senderWeightController.value.setDropDown(val); // Link it to the selectedWeight object - controller.selectedWeight = controller.parcelWeight.firstWhereOrNull((e) => e.title == val.value); + controller.selectedWeight = controller.parcelWeight + .firstWhereOrNull((e) => e.title == val.value); } }, ), @@ -466,8 +736,10 @@ class BookParcelScreen extends StatelessWidget { TextFieldWidget( hintText: "Notes (Optional)".tr, controller: noteController, - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, - borderColor: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200, + backgroundColor: + isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + borderColor: + isDark ? AppThemeData.greyDark200 : AppThemeData.grey200, ), ], ), diff --git a/lib/screen_ui/parcel_service/home_parcel_screen.dart b/lib/screen_ui/parcel_service/home_parcel_screen.dart index dd91551..23dd4df 100644 --- a/lib/screen_ui/parcel_service/home_parcel_screen.dart +++ b/lib/screen_ui/parcel_service/home_parcel_screen.dart @@ -1,3 +1,4 @@ +import 'package:customer/constant/const_texts.dart'; import 'package:customer/constant/constant.dart'; import 'package:flutter/material.dart'; import 'package:geocoding/geocoding.dart'; @@ -45,8 +46,20 @@ class HomeParcelScreen extends StatelessWidget { child: Container( height: 42, width: 42, - decoration: BoxDecoration(shape: BoxShape.circle, color: AppThemeData.grey50), - child: Center(child: Padding(padding: const EdgeInsets.only(left: 5), child: Icon(Icons.arrow_back_ios, color: AppThemeData.grey900, size: 20))), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: AppThemeData.grey50, + ), + child: Center( + child: Padding( + padding: const EdgeInsets.only(left: 5), + child: Icon( + Icons.arrow_back_ios, + color: AppThemeData.grey900, + size: 20, + ), + ), + ), ), ), const SizedBox(width: 10), @@ -59,9 +72,21 @@ class HomeParcelScreen extends StatelessWidget { onTap: () { Get.offAll(const LoginScreen()); }, - child: Text("Login".tr, style: AppThemeData.boldTextStyle(fontSize: 14, color: AppThemeData.grey900)), + child: Text( + "Login".tr, + style: AppThemeData.boldTextStyle( + fontSize: 14, + color: AppThemeData.grey900, + ), + ), ) - : Text(Constant.userModel!.fullName(), style: AppThemeData.boldTextStyle(fontSize: 14, color: AppThemeData.grey900)), + : Text( + Constant.userModel!.fullName(), + style: AppThemeData.boldTextStyle( + fontSize: 14, + color: AppThemeData.grey900, + ), + ), InkWell( onTap: () async { if (Constant.userModel != null) { @@ -74,9 +99,12 @@ class HomeParcelScreen extends StatelessWidget { } else { Constant.checkPermission( onTap: () async { - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader( + ConstTexts.pleaseWait.tr, + ); - ShippingAddress shippingAddress = ShippingAddress(); + ShippingAddress shippingAddress = + ShippingAddress(); try { await Geolocator.requestPermission(); @@ -84,40 +112,71 @@ class HomeParcelScreen extends StatelessWidget { ShowToastDialog.closeLoader(); if (Constant.selectedMapType == 'osm') { - final result = await Get.to(() => MapPickerPage()); + final result = await Get.to( + () => MapPickerPage(), + ); if (result != null) { final firstPlace = result; - final lat = firstPlace.coordinates.latitude; - final lng = firstPlace.coordinates.longitude; + final lat = + firstPlace.coordinates.latitude; + final lng = + firstPlace.coordinates.longitude; final address = firstPlace.address; shippingAddress.addressAs = "Home"; - shippingAddress.locality = address.toString(); - shippingAddress.location = UserLocation(latitude: lat, longitude: lng); + shippingAddress.locality = + address.toString(); + shippingAddress.location = UserLocation( + latitude: lat, + longitude: lng, + ); - Constant.selectedLocation = shippingAddress; + Constant.selectedLocation = + shippingAddress; Get.back(); } } else { - Get.to(LocationPickerScreen())!.then((value) async { + Get.to(LocationPickerScreen())!.then(( + value, + ) async { if (value != null) { - SelectedLocationModel selectedLocationModel = value; + SelectedLocationModel + selectedLocationModel = value; shippingAddress.addressAs = "Home"; - shippingAddress.location = UserLocation(latitude: selectedLocationModel.latLng!.latitude, longitude: selectedLocationModel.latLng!.longitude); - shippingAddress.locality = "Picked from Map"; + shippingAddress + .location = UserLocation( + latitude: + selectedLocationModel + .latLng! + .latitude, + longitude: + selectedLocationModel + .latLng! + .longitude, + ); + shippingAddress.locality = + "Picked from Map"; - Constant.selectedLocation = shippingAddress; + Constant.selectedLocation = + shippingAddress; } }); } } catch (e) { - await placemarkFromCoordinates(19.228825, 72.854118).then((valuePlaceMaker) { + await placemarkFromCoordinates( + 19.228825, + 72.854118, + ).then((valuePlaceMaker) { Placemark placeMark = valuePlaceMaker[0]; - shippingAddress.location = UserLocation(latitude: 19.228825, longitude: 72.854118); + shippingAddress.location = UserLocation( + latitude: 19.228825, + longitude: 72.854118, + ); String currentLocation = "${placeMark.name}, ${placeMark.subLocality}, ${placeMark.locality}, ${placeMark.administrativeArea}, ${placeMark.postalCode}, ${placeMark.country}"; - shippingAddress.locality = currentLocation; + shippingAddress.locality = + currentLocation; }); Constant.selectedLocation = shippingAddress; @@ -132,7 +191,10 @@ class HomeParcelScreen extends StatelessWidget { Constant.selectedLocation.getFullAddress(), maxLines: 1, overflow: TextOverflow.ellipsis, - style: AppThemeData.boldTextStyle(fontSize: 18, color: AppThemeData.grey900), + style: AppThemeData.boldTextStyle( + fontSize: 18, + color: AppThemeData.grey900, + ), ), ), ], @@ -159,22 +221,46 @@ class HomeParcelScreen extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("What are you sending?".tr, style: AppThemeData.mediumTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + "What are you sending?".tr, + style: AppThemeData.mediumTextStyle( + fontSize: 18, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), const SizedBox(height: 12), Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), + ), + padding: const EdgeInsets.symmetric( + horizontal: 20, ), - padding: const EdgeInsets.symmetric(horizontal: 20), child: ListView.builder( itemCount: controller.parcelCategory.length, shrinkWrap: true, physics: const ScrollPhysics(), - padding: const EdgeInsets.symmetric(vertical: 10), + padding: const EdgeInsets.symmetric( + vertical: 10, + ), itemBuilder: (context, index) { - return buildItems(item: controller.parcelCategory[index], isDark: isDark); + return buildItems( + item: controller.parcelCategory[index], + isDark: isDark, + ); }, ), ), @@ -198,16 +284,36 @@ class HomeParcelScreen extends StatelessWidget { if (Constant.userModel == null) { Get.to(const LoginScreen()); } else { - Get.to(const BookParcelScreen(), arguments: {'parcelCategory': item}); + Get.to( + const BookParcelScreen(), + arguments: {'parcelCategory': item}, + ); } }, child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ - NetworkImageWidget(imageUrl: item.image ?? '', height: 38, width: 38), + NetworkImageWidget( + imageUrl: item.image ?? '', + height: 38, + width: 38, + ), const SizedBox(width: 20), - Expanded(child: Text(item.title ?? '', style: AppThemeData.semiBoldTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, fontSize: 16))), - Icon(Icons.arrow_forward_ios, color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800, size: 20), + Expanded( + child: Text( + item.title ?? '', + style: AppThemeData.semiBoldTextStyle( + color: + isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + fontSize: 16, + ), + ), + ), + Icon( + Icons.arrow_forward_ios, + color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800, + size: 20, + ), ], ), ), @@ -255,7 +361,13 @@ class BannerView extends StatelessWidget { final banner = bannerList[index]; return ClipRRect( borderRadius: BorderRadius.circular(15), - child: SizedBox(width: MediaQuery.of(context).size.width * 0.8, child: NetworkImageWidget(imageUrl: banner.photo ?? '', fit: BoxFit.cover)), + child: SizedBox( + width: MediaQuery.of(context).size.width * 0.8, + child: NetworkImageWidget( + imageUrl: banner.photo ?? '', + fit: BoxFit.cover, + ), + ), ); }, ), @@ -265,7 +377,18 @@ class BannerView extends StatelessWidget { return Row( children: List.generate(bannerList.length, (index) { bool isSelected = currentPage.value == index; - return Expanded(child: Container(height: 4, decoration: BoxDecoration(color: isSelected ? AppThemeData.grey300 : AppThemeData.grey100, borderRadius: BorderRadius.circular(5)))); + return Expanded( + child: Container( + height: 4, + decoration: BoxDecoration( + color: + isSelected + ? AppThemeData.grey300 + : AppThemeData.grey100, + borderRadius: BorderRadius.circular(5), + ), + ), + ); }), ); }), diff --git a/lib/screen_ui/parcel_service/my_booking_screen.dart b/lib/screen_ui/parcel_service/my_booking_screen.dart index 2b6a99b..f5348c3 100644 --- a/lib/screen_ui/parcel_service/my_booking_screen.dart +++ b/lib/screen_ui/parcel_service/my_booking_screen.dart @@ -1,6 +1,8 @@ import 'package:customer/screen_ui/auth_screens/login_screen.dart'; import 'package:customer/screen_ui/parcel_service/parcel_order_details.dart'; import 'package:customer/themes/round_button_fill.dart'; +import 'package:customer/utils/app_router.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../../constant/constant.dart'; @@ -22,14 +24,27 @@ class MyBookingScreen extends StatelessWidget { builder: (controller) { return DefaultTabController( length: controller.tabTitles.length, - initialIndex: controller.tabTitles.indexOf(controller.selectedTab.value), + initialIndex: controller.tabTitles.indexOf( + controller.selectedTab.value, + ), child: Scaffold( appBar: AppBar( automaticallyImplyLeading: false, backgroundColor: AppThemeData.primary300, title: Padding( padding: const EdgeInsets.only(bottom: 10), - child: Row(children: [const SizedBox(width: 10), Text("Parcel History".tr, style: AppThemeData.boldTextStyle(fontSize: 18, color: AppThemeData.grey900))]), + child: Row( + children: [ + const SizedBox(width: 10), + Text( + "Parcel History".tr, + style: AppThemeData.boldTextStyle( + fontSize: 18, + color: AppThemeData.grey900, + ), + ), + ], + ), ), bottom: TabBar( // don't re-subscribe onTap — just update selectedTab (optional) @@ -40,8 +55,13 @@ class MyBookingScreen extends StatelessWidget { labelColor: AppThemeData.parcelService500, unselectedLabelColor: AppThemeData.parcelService500, labelStyle: AppThemeData.boldTextStyle(fontSize: 15), - unselectedLabelStyle: AppThemeData.mediumTextStyle(fontSize: 15), - tabs: controller.tabTitles.map((title) => Tab(child: Center(child: Text(title)))).toList(), + unselectedLabelStyle: AppThemeData.mediumTextStyle( + fontSize: 15, + ), + tabs: + controller.tabTitles + .map((title) => Tab(child: Center(child: Text(title)))) + .toList(), ), ), @@ -55,12 +75,30 @@ class MyBookingScreen extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Text("Please Log In to Continue".tr, style: TextStyle(color: isDark ? AppThemeData.grey100 : AppThemeData.grey800, fontSize: 22, fontFamily: AppThemeData.semiBold)), + Text( + "Please Log In to Continue".tr, + style: TextStyle( + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey800, + fontSize: 22, + fontFamily: AppThemeData.semiBold, + ), + ), const SizedBox(height: 5), Text( - "You’re not logged in. Please sign in to access your account and explore all features.".tr, + "You’re not logged in. Please sign in to access your account and explore all features." + .tr, textAlign: TextAlign.center, - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey500, fontSize: 16, fontFamily: AppThemeData.bold), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey500, + fontSize: 16, + fontFamily: AppThemeData.bold, + ), ), const SizedBox(height: 20), RoundedButtonFill( @@ -82,7 +120,17 @@ class MyBookingScreen extends StatelessWidget { final orders = controller.getOrdersForTab(title); if (orders.isEmpty) { - return Center(child: Text("No orders found".tr, style: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900))); + return Center( + child: Text( + "No orders found".tr, + style: AppThemeData.mediumTextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + ); } return ListView.builder( @@ -92,55 +140,98 @@ class MyBookingScreen extends StatelessWidget { final order = orders[index]; return GestureDetector( onTap: () { - Get.to(() => const ParcelOrderDetails(), arguments: order); + Get.to( + () => const ParcelOrderDetails(), + arguments: order, + ); }, child: Container( margin: const EdgeInsets.only(bottom: 16), padding: const EdgeInsets.all(16), decoration: BoxDecoration( - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, borderRadius: BorderRadius.circular(15), - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Padding( - padding: const EdgeInsets.only(bottom: 8.0), + padding: const EdgeInsets.only( + bottom: 8.0, + ), child: Text( "${'Order Date:'.tr}${order.isSchedule == true ? controller.formatDate(order.createdAt!) : controller.formatDate(order.senderPickupDateTime!)}", - style: AppThemeData.mediumTextStyle(fontSize: 14, color: AppThemeData.info400), + style: AppThemeData.mediumTextStyle( + fontSize: 14, + color: AppThemeData.info400, + ), ), ), Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Column( children: [ - Image.asset("assets/images/image_parcel.png", height: 32, width: 32), - DottedBorder( - options: CustomPathDottedBorderOptions( - color: Colors.grey.shade400, - strokeWidth: 2, - dashPattern: [4, 4], - customPath: - (size) => - Path() - ..moveTo(size.width / 2, 0) - ..lineTo(size.width / 2, size.height), - ), - child: const SizedBox(width: 20, height: 95), + Image.asset( + "assets/images/image_parcel.png", + height: 32, + width: 32, + ), + DottedBorder( + options: + CustomPathDottedBorderOptions( + color: + Colors + .grey + .shade400, + strokeWidth: 2, + dashPattern: [4, 4], + customPath: + (size) => + Path() + ..moveTo( + size.width / + 2, + 0, + ) + ..lineTo( + size.width / + 2, + size.height, + ), + ), + child: const SizedBox( + width: 20, + height: 95, + ), + ), + Image.asset( + "assets/images/image_parcel.png", + height: 32, + width: 32, ), - Image.asset("assets/images/image_parcel.png", height: 32, width: 32), ], ), const SizedBox(width: 12), Expanded( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ _infoSection( - "Pickup Address (Sender):".tr, + "Pickup Address (Sender):" + .tr, order.sender?.name ?? '', order.sender?.address ?? '', order.sender?.phone ?? '', @@ -152,9 +243,11 @@ class MyBookingScreen extends StatelessWidget { ), const SizedBox(height: 16), _infoSection( - "Delivery Address (Receiver):".tr, + "Delivery Address (Receiver):" + .tr, order.receiver?.name ?? '', - order.receiver?.address ?? '', + order.receiver?.address ?? + '', order.receiver?.phone ?? '', // order.receiverPickupDateTime != null // ? "Delivery Time: ${controller.formatDate(order.receiverPickupDateTime!)}" @@ -181,27 +274,74 @@ class MyBookingScreen extends StatelessWidget { ); } - Widget _infoSection(String title, String name, String address, String phone, String? status, bool isDark) { + Widget _infoSection( + String title, + String name, + String address, + String phone, + String? status, + bool isDark, + ) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ Expanded( - child: Text(title, style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), maxLines: 1, overflow: TextOverflow.ellipsis), + child: Text( + title, + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + ), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), ), if (status != null) ...[ Container( - padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 12), - decoration: BoxDecoration(color: AppThemeData.info50, border: Border.all(color: AppThemeData.info300), borderRadius: BorderRadius.circular(12)), - child: Text(status, style: AppThemeData.boldTextStyle(fontSize: 14, color: AppThemeData.info500)), + padding: const EdgeInsets.symmetric( + vertical: 6, + horizontal: 12, + ), + decoration: BoxDecoration( + color: AppThemeData.info50, + border: Border.all(color: AppThemeData.info300), + borderRadius: BorderRadius.circular(12), + ), + child: Text( + status, + style: AppThemeData.boldTextStyle( + fontSize: 14, + color: AppThemeData.info500, + ), + ), ), ], ], ), - Text(name, style: AppThemeData.semiBoldTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), - Text(address, style: AppThemeData.mediumTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), - Text(phone, style: AppThemeData.mediumTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + name, + style: AppThemeData.semiBoldTextStyle( + fontSize: 14, + color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + ), + ), + Text( + address, + style: AppThemeData.mediumTextStyle( + fontSize: 14, + color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + ), + ), + Text( + phone, + style: AppThemeData.mediumTextStyle( + fontSize: 14, + color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + ), + ), //Text(time, style: AppThemeData.semiBoldTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), ], ); diff --git a/lib/screen_ui/parcel_service/order_successfully_placed.dart b/lib/screen_ui/parcel_service/order_successfully_placed.dart index 9379cf1..12a0a2a 100644 --- a/lib/screen_ui/parcel_service/order_successfully_placed.dart +++ b/lib/screen_ui/parcel_service/order_successfully_placed.dart @@ -1,4 +1,6 @@ import 'package:customer/screen_ui/parcel_service/parcel_dashboard_screen.dart'; +import 'package:customer/utils/app_router.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:customer/themes/app_them_data.dart'; @@ -23,13 +25,21 @@ class OrderSuccessfullyPlaced extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Image.asset("assets/images/parcel_order_successfully_placed.png"), + Image.asset( + "assets/images/parcel_order_successfully_placed.png", + ), const SizedBox(height: 20), Padding( padding: const EdgeInsets.symmetric(horizontal: 25), child: Text( "Your Order Has Been Placed!".tr, - style: AppThemeData.boldTextStyle(fontSize: 22, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: AppThemeData.boldTextStyle( + fontSize: 22, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), textAlign: TextAlign.center, ), ), @@ -37,8 +47,15 @@ class OrderSuccessfullyPlaced extends StatelessWidget { Padding( padding: const EdgeInsets.symmetric(horizontal: 50), child: Text( - "We’ve received your parcel booking and it’s now being processed. You can track its status in real time.".tr, - style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark600 : AppThemeData.grey600), + "We’ve received your parcel booking and it’s now being processed. You can track its status in real time." + .tr, + style: AppThemeData.mediumTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark600 + : AppThemeData.grey600, + ), textAlign: TextAlign.center, ), ), @@ -49,7 +66,9 @@ class OrderSuccessfullyPlaced extends StatelessWidget { print("Tracking Order: $parcelOrder"); //Get.to(() => TrackOrderScreen(), arguments: {'order': parcelOrder}); Get.offAll(const ParcelDashboardScreen()); - ParcelDashboardController controller = Get.put(ParcelDashboardController()); + ParcelDashboardController controller = Get.put( + ParcelDashboardController(), + ); controller.selectedIndex.value = 1; }, color: AppThemeData.primary300, diff --git a/lib/screen_ui/parcel_service/parcel_coupon_screen.dart b/lib/screen_ui/parcel_service/parcel_coupon_screen.dart index 6de1f4c..f5f6fcb 100644 --- a/lib/screen_ui/parcel_service/parcel_coupon_screen.dart +++ b/lib/screen_ui/parcel_service/parcel_coupon_screen.dart @@ -6,6 +6,7 @@ import 'package:customer/themes/app_them_data.dart'; import 'package:customer/themes/responsive.dart'; import 'package:customer/widget/my_separator.dart'; import 'package:dotted_border/dotted_border.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -32,12 +33,30 @@ class ParcelCouponScreen extends StatelessWidget { child: Container( height: 42, width: 42, - decoration: BoxDecoration(shape: BoxShape.circle, color: AppThemeData.grey50), - child: Center(child: Padding(padding: const EdgeInsets.only(left: 5), child: Icon(Icons.arrow_back_ios, color: AppThemeData.grey900, size: 20))), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: AppThemeData.grey50, + ), + child: Center( + child: Padding( + padding: const EdgeInsets.only(left: 5), + child: Icon( + Icons.arrow_back_ios, + color: AppThemeData.grey900, + size: 20, + ), + ), + ), ), ), const SizedBox(width: 10), - Text("Coupon".tr, style: AppThemeData.boldTextStyle(fontSize: 18, color: AppThemeData.grey900)), + Text( + "Coupon".tr, + style: AppThemeData.boldTextStyle( + fontSize: 18, + color: AppThemeData.grey900, + ), + ), ], ), ), @@ -53,17 +72,35 @@ class ParcelCouponScreen extends StatelessWidget { itemBuilder: (context, index) { CouponModel couponModel = controller.cabCouponList[index]; return Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: Container( height: Responsive.height(16, context), - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + ), child: Row( children: [ ClipRRect( - borderRadius: const BorderRadius.only(topLeft: Radius.circular(10), bottomLeft: Radius.circular(10)), + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(10), + bottomLeft: Radius.circular(10), + ), child: Stack( children: [ - Image.asset("assets/images/ic_coupon_image.png", height: Responsive.height(16, context), fit: BoxFit.fill), + Image.asset( + "assets/images/ic_coupon_image.png", + height: Responsive.height(16, context), + fit: BoxFit.fill, + ), Padding( padding: const EdgeInsets.only(left: 10), child: Align( @@ -73,7 +110,14 @@ class ParcelCouponScreen extends StatelessWidget { child: Text( "${couponModel.discountType == "Fix Price" ? Constant.amountShow(amount: couponModel.discount) : "${couponModel.discount}%"} ${'Off'.tr}", textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey50), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey50, + ), ), ), ), @@ -83,24 +127,53 @@ class ParcelCouponScreen extends StatelessWidget { ), Expanded( child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 18), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 18, + ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Row( children: [ DottedBorder( - options: RoundedRectDottedBorderOptions(strokeWidth: 1, radius: const Radius.circular(6), color: isDark ? AppThemeData.grey400 : AppThemeData.grey500), + options: + RoundedRectDottedBorderOptions( + strokeWidth: 1, + radius: const Radius.circular( + 6, + ), + color: + isDark + ? AppThemeData.grey400 + : AppThemeData + .grey500, + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), + padding: + const EdgeInsets.symmetric( + horizontal: 16, + ), child: Text( "${couponModel.code}", textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.grey400 : AppThemeData.grey500), + style: TextStyle( + fontFamily: + AppThemeData.semiBold, + fontSize: 16, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData + .grey500, + ), ), ), ), - const Expanded(child: SizedBox(height: 10)), + const Expanded( + child: SizedBox(height: 10), + ), InkWell( onTap: () { Get.back(result: couponModel); @@ -108,18 +181,38 @@ class ParcelCouponScreen extends StatelessWidget { child: Text( "Tap To Apply".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300), + style: TextStyle( + fontFamily: AppThemeData.medium, + color: + isDark + ? AppThemeData + .primary300 + : AppThemeData + .primary300, + ), ), ), ], ), const SizedBox(height: 20), - MySeparator(color: isDark ? AppThemeData.grey700 : AppThemeData.grey200), + MySeparator( + color: + isDark + ? AppThemeData.grey700 + : AppThemeData.grey200, + ), const SizedBox(height: 20), Text( "${couponModel.description}", textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), ], ), diff --git a/lib/screen_ui/parcel_service/parcel_dashboard_screen.dart b/lib/screen_ui/parcel_service/parcel_dashboard_screen.dart index 9058bc3..2166de8 100644 --- a/lib/screen_ui/parcel_service/parcel_dashboard_screen.dart +++ b/lib/screen_ui/parcel_service/parcel_dashboard_screen.dart @@ -2,6 +2,7 @@ import 'package:customer/constant/constant.dart'; import 'package:customer/controllers/parcel_dashboard_controller.dart'; import 'package:customer/controllers/theme_controller.dart'; import 'package:customer/themes/app_them_data.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:get/get.dart'; @@ -24,12 +25,21 @@ class ParcelDashboardScreen extends StatelessWidget { showUnselectedLabels: true, showSelectedLabels: true, selectedFontSize: 12, - selectedLabelStyle: const TextStyle(fontFamily: AppThemeData.bold), - unselectedLabelStyle: const TextStyle(fontFamily: AppThemeData.bold), + selectedLabelStyle: const TextStyle( + fontFamily: AppThemeData.bold, + ), + unselectedLabelStyle: const TextStyle( + fontFamily: AppThemeData.bold, + ), currentIndex: controller.selectedIndex.value, - backgroundColor: isDark ? AppThemeData.grey900 : AppThemeData.grey50, - selectedItemColor: isDark ? AppThemeData.parcelServiceDark300 : AppThemeData.primary300, - unselectedItemColor: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500, + backgroundColor: + isDark ? AppThemeData.grey900 : AppThemeData.grey50, + selectedItemColor: + isDark + ? AppThemeData.parcelServiceDark300 + : AppThemeData.primary300, + unselectedItemColor: + isDark ? AppThemeData.greyDark500 : AppThemeData.grey500, onTap: (int index) { if (index == 0) { Get.put(ParcelDashboardController()); @@ -39,15 +49,57 @@ class ParcelDashboardScreen extends StatelessWidget { items: Constant.walletSetting == false ? [ - navigationBarItem(isDark, index: 0, assetIcon: "assets/icons/ic_home_parcel.svg", label: 'Home'.tr, controller: controller), - navigationBarItem(isDark, index: 1, assetIcon: "assets/icons/ic_mybooking_parcel.svg", label: 'My Bookings'.tr, controller: controller), - navigationBarItem(isDark, index: 2, assetIcon: "assets/icons/ic_profile_parcel.svg", label: 'Profile'.tr, controller: controller), + navigationBarItem( + isDark, + index: 0, + assetIcon: "assets/icons/ic_home_parcel.svg", + label: 'Home'.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 1, + assetIcon: "assets/icons/ic_mybooking_parcel.svg", + label: 'My Bookings'.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 2, + assetIcon: "assets/icons/ic_profile_parcel.svg", + label: 'Profile'.tr, + controller: controller, + ), ] : [ - navigationBarItem(isDark, index: 0, assetIcon: "assets/icons/ic_home_parcel.svg", label: 'Home'.tr, controller: controller), - navigationBarItem(isDark, index: 1, assetIcon: "assets/icons/ic_mybooking_parcel.svg", label: 'My Bookings'.tr, controller: controller), - navigationBarItem(isDark, index: 2, assetIcon: "assets/icons/ic_wallet_parcel.svg", label: 'Wallet'.tr, controller: controller), - navigationBarItem(isDark, index: 3, assetIcon: "assets/icons/ic_profile_parcel.svg", label: 'Profile'.tr, controller: controller), + navigationBarItem( + isDark, + index: 0, + assetIcon: "assets/icons/ic_home_parcel.svg", + label: 'Home'.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 1, + assetIcon: "assets/icons/ic_mybooking_parcel.svg", + label: 'My Bookings'.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 2, + assetIcon: "assets/icons/ic_wallet_parcel.svg", + label: 'Wallet'.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 3, + assetIcon: "assets/icons/ic_profile_parcel.svg", + label: 'Profile'.tr, + controller: controller, + ), ], ), ); @@ -56,7 +108,13 @@ class ParcelDashboardScreen extends StatelessWidget { }); } - BottomNavigationBarItem navigationBarItem(isDark, {required int index, required String label, required String assetIcon, required ParcelDashboardController controller}) { + BottomNavigationBarItem navigationBarItem( + isDark, { + required int index, + required String label, + required String assetIcon, + required ParcelDashboardController controller, + }) { return BottomNavigationBarItem( icon: Padding( padding: const EdgeInsets.symmetric(vertical: 5), diff --git a/lib/screen_ui/parcel_service/parcel_order_confirmation.dart b/lib/screen_ui/parcel_service/parcel_order_confirmation.dart index 6c54262..82da970 100644 --- a/lib/screen_ui/parcel_service/parcel_order_confirmation.dart +++ b/lib/screen_ui/parcel_service/parcel_order_confirmation.dart @@ -1,6 +1,7 @@ import 'package:customer/models/coupon_model.dart'; import 'package:customer/screen_ui/parcel_service/parcel_coupon_screen.dart'; import 'package:dotted_border/dotted_border.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:get/get.dart'; @@ -37,12 +38,30 @@ class ParcelOrderConfirmationScreen extends StatelessWidget { child: Container( height: 42, width: 42, - decoration: BoxDecoration(shape: BoxShape.circle, color: AppThemeData.grey50), - child: Center(child: Padding(padding: const EdgeInsets.only(left: 5), child: Icon(Icons.arrow_back_ios, color: AppThemeData.grey900, size: 20))), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: AppThemeData.grey50, + ), + child: Center( + child: Padding( + padding: const EdgeInsets.only(left: 5), + child: Icon( + Icons.arrow_back_ios, + color: AppThemeData.grey900, + size: 20, + ), + ), + ), ), ), const SizedBox(width: 10), - Text("Order Confirmation".tr, style: AppThemeData.boldTextStyle(fontSize: 18, color: AppThemeData.grey900)), + Text( + "Order Confirmation".tr, + style: AppThemeData.boldTextStyle( + fontSize: 18, + color: AppThemeData.grey900, + ), + ), ], ), ), @@ -59,8 +78,16 @@ class ParcelOrderConfirmationScreen extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), padding: const EdgeInsets.all(16), child: Row( @@ -69,7 +96,11 @@ class ParcelOrderConfirmationScreen extends StatelessWidget { // Timeline with icons and line Column( children: [ - Image.asset("assets/images/image_parcel.png", height: 32, width: 32), + Image.asset( + "assets/images/image_parcel.png", + height: 32, + width: 32, + ), DottedBorder( options: CustomPathDottedBorderOptions( color: Colors.grey.shade400, @@ -79,11 +110,21 @@ class ParcelOrderConfirmationScreen extends StatelessWidget { (size) => Path() ..moveTo(size.width / 2, 0) - ..lineTo(size.width / 2, size.height), + ..lineTo( + size.width / 2, + size.height, + ), + ), + child: const SizedBox( + width: 20, + height: 95, ), - child: const SizedBox(width: 20, height: 95), ), - Image.asset("assets/images/image_parcel.png", height: 32, width: 32), + Image.asset( + "assets/images/image_parcel.png", + height: 32, + width: 32, + ), ], ), const SizedBox(width: 12), @@ -94,9 +135,24 @@ class ParcelOrderConfirmationScreen extends StatelessWidget { children: [ _infoSection( "Pickup Address (Sender):".tr, - controller.parcelOrder.value.sender?.name ?? '', - controller.parcelOrder.value.sender?.address ?? '', - controller.parcelOrder.value.sender?.phone ?? '', + controller + .parcelOrder + .value + .sender + ?.name ?? + '', + controller + .parcelOrder + .value + .sender + ?.address ?? + '', + controller + .parcelOrder + .value + .sender + ?.phone ?? + '', // controller.parcelOrder.value.senderPickupDateTime != null // ? "Pickup Time: ${controller.formatDate(controller.parcelOrder.value.senderPickupDateTime!)}" // : '', @@ -105,9 +161,24 @@ class ParcelOrderConfirmationScreen extends StatelessWidget { const SizedBox(height: 16), _infoSection( "Delivery Address (Receiver):".tr, - controller.parcelOrder.value.receiver?.name ?? '', - controller.parcelOrder.value.receiver?.address ?? '', - controller.parcelOrder.value.receiver?.phone ?? '', + controller + .parcelOrder + .value + .receiver + ?.name ?? + '', + controller + .parcelOrder + .value + .receiver + ?.address ?? + '', + controller + .parcelOrder + .value + .receiver + ?.phone ?? + '', // controller.parcelOrder.value.receiverPickupDateTime != null // ? "Delivery Time: ${controller.formatDate(controller.parcelOrder.value.receiverPickupDateTime!)}" // : '', @@ -124,16 +195,42 @@ class ParcelOrderConfirmationScreen extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), padding: EdgeInsets.all(16), child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - _iconTile("${controller.parcelOrder.value.distance ?? '--'} ${'KM'.tr}", "Distance".tr, "assets/icons/ic_distance_parcel.svg", isDark), - _iconTile(controller.parcelOrder.value.parcelWeight ?? '--', "Weight".tr, "assets/icons/ic_weight_parcel.svg", isDark), - _iconTile(Constant.amountShow(amount: controller.parcelOrder.value.subTotal), "Rate".tr, "assets/icons/ic_rate_parcel.svg", isDark), + _iconTile( + "${controller.parcelOrder.value.distance ?? '--'} ${'KM'.tr}", + "Distance".tr, + "assets/icons/ic_distance_parcel.svg", + isDark, + ), + _iconTile( + controller.parcelOrder.value.parcelWeight ?? + '--', + "Weight".tr, + "assets/icons/ic_weight_parcel.svg", + isDark, + ), + _iconTile( + Constant.amountShow( + amount: controller.parcelOrder.value.subTotal, + ), + "Rate".tr, + "assets/icons/ic_rate_parcel.svg", + isDark, + ), ], ), ), @@ -142,24 +239,53 @@ class ParcelOrderConfirmationScreen extends StatelessWidget { Row( children: [ - Expanded(child: Text("Coupons".tr, style: AppThemeData.boldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900))), + Expanded( + child: Text( + "Coupons".tr, + style: AppThemeData.boldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + ), InkWell( onTap: () { Get.to(ParcelCouponScreen())!.then((value) { if (value != null) { - double couponAmount = Constant.calculateDiscount(amount: controller.subTotal.value.toString(), offerModel: value); - if (couponAmount < controller.subTotal.value) { - controller.selectedCouponModel.value = value; + double couponAmount = + Constant.calculateDiscount( + amount: + controller.subTotal.value + .toString(), + offerModel: value, + ); + if (couponAmount < + controller.subTotal.value) { + controller.selectedCouponModel.value = + value; controller.calculatePrice(); } else { - ShowToastDialog.showToast("This offer not eligible for this booking".tr); + ShowToastDialog.showToast( + "This offer not eligible for this booking" + .tr, + ); } } }); }, child: Text( "View All".tr, - style: AppThemeData.boldTextStyle(decoration: TextDecoration.underline, fontSize: 14, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300), + style: AppThemeData.boldTextStyle( + decoration: TextDecoration.underline, + fontSize: 14, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + ), ), ), ], @@ -168,21 +294,45 @@ class ParcelOrderConfirmationScreen extends StatelessWidget { // Coupon input DottedBorder( - options: RoundedRectDottedBorderOptions(strokeWidth: 1, radius: const Radius.circular(10), color: isDark ? AppThemeData.parcelServiceDark300 : AppThemeData.primary300), + options: RoundedRectDottedBorderOptions( + strokeWidth: 1, + radius: const Radius.circular(10), + color: + isDark + ? AppThemeData.parcelServiceDark300 + : AppThemeData.primary300, + ), child: Container( - decoration: BoxDecoration(color: AppThemeData.parcelService50, borderRadius: BorderRadius.circular(10)), - padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), + decoration: BoxDecoration( + color: AppThemeData.parcelService50, + borderRadius: BorderRadius.circular(10), + ), + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 8, + ), child: Row( children: [ - SvgPicture.asset("assets/icons/ic_coupon_parcel.svg", height: 28, width: 28), + SvgPicture.asset( + "assets/icons/ic_coupon_parcel.svg", + height: 28, + width: 28, + ), SizedBox(width: 15), Expanded( child: TextField( - controller: controller.couponController.value, - style: AppThemeData.semiBoldTextStyle(color: AppThemeData.parcelService500, fontSize: 16), + controller: + controller.couponController.value, + style: AppThemeData.semiBoldTextStyle( + color: AppThemeData.parcelService500, + fontSize: 16, + ), decoration: InputDecoration( hintText: "Write coupon code".tr, - hintStyle: AppThemeData.mediumTextStyle(fontSize: 16, color: AppThemeData.parcelService500), + hintStyle: AppThemeData.mediumTextStyle( + fontSize: 16, + color: AppThemeData.parcelService500, + ), border: InputBorder.none, ), ), @@ -190,22 +340,60 @@ class ParcelOrderConfirmationScreen extends StatelessWidget { RoundedButtonFill( title: "Redeem now".tr, onPress: () { - if (controller.couponList.where((element) => element.code!.toLowerCase() == controller.couponController.value.text.toLowerCase()).isNotEmpty) { - CouponModel couponModel = controller.couponList.firstWhere((p0) => p0.code!.toLowerCase() == controller.couponController.value.text.toLowerCase()); - if (couponModel.expiresAt!.toDate().isAfter(DateTime.now())) { - double couponAmount = Constant.calculateDiscount(amount: controller.subTotal.value.toString(), offerModel: couponModel); - if (couponAmount < controller.subTotal.value) { - controller.selectedCouponModel.value = couponModel; + if (controller.couponList + .where( + (element) => + element.code!.toLowerCase() == + controller + .couponController + .value + .text + .toLowerCase(), + ) + .isNotEmpty) { + CouponModel couponModel = controller + .couponList + .firstWhere( + (p0) => + p0.code!.toLowerCase() == + controller + .couponController + .value + .text + .toLowerCase(), + ); + if (couponModel.expiresAt! + .toDate() + .isAfter(DateTime.now())) { + double couponAmount = + Constant.calculateDiscount( + amount: + controller.subTotal.value + .toString(), + offerModel: couponModel, + ); + if (couponAmount < + controller.subTotal.value) { + controller.selectedCouponModel.value = + couponModel; controller.calculatePrice(); controller.update(); } else { - ShowToastDialog.showToast("This offer not eligible for this booking".tr); + ShowToastDialog.showToast( + "This offer not eligible for this booking" + .tr, + ); } } else { - ShowToastDialog.showToast("This coupon code has been expired".tr); + ShowToastDialog.showToast( + "This coupon code has been expired" + .tr, + ); } } else { - ShowToastDialog.showToast("Invalid coupon code".tr); + ShowToastDialog.showToast( + "Invalid coupon code".tr, + ); } }, borderRadius: 10, @@ -223,35 +411,84 @@ class ParcelOrderConfirmationScreen extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("Order Summary".tr, style: AppThemeData.boldTextStyle(fontSize: 14, color: AppThemeData.grey500)), + Text( + "Order Summary".tr, + style: AppThemeData.boldTextStyle( + fontSize: 14, + color: AppThemeData.grey500, + ), + ), const SizedBox(height: 8), // Subtotal - _summaryTile("Subtotal".tr, Constant.amountShow(amount: controller.subTotal.value.toString()), isDark, null), + _summaryTile( + "Subtotal".tr, + Constant.amountShow( + amount: controller.subTotal.value.toString(), + ), + isDark, + null, + ), // Discount - _summaryTile("Discount".tr, "-${Constant.amountShow(amount: controller.discount.value.toString())}", isDark, AppThemeData.dangerDark300), + _summaryTile( + "Discount".tr, + "-${Constant.amountShow(amount: controller.discount.value.toString())}", + isDark, + AppThemeData.dangerDark300, + ), // Tax List - ...List.generate(Constant.taxList.length, (index) { + ...List.generate(Constant.taxList.length, ( + index, + ) { final taxModel = Constant.taxList[index]; - final taxTitle = "${taxModel.title} ${taxModel.type == 'fix' ? '(${Constant.amountShow(amount: taxModel.tax)})' : '(${taxModel.tax}%)'}"; - final taxAmount = Constant.getTaxValue(amount: (controller.subTotal.value - controller.discount.value).toString(), taxModel: taxModel).toString(); + final taxTitle = + "${taxModel.title} ${taxModel.type == 'fix' ? '(${Constant.amountShow(amount: taxModel.tax)})' : '(${taxModel.tax}%)'}"; + final taxAmount = + Constant.getTaxValue( + amount: + (controller.subTotal.value - + controller.discount.value) + .toString(), + taxModel: taxModel, + ).toString(); - return _summaryTile(taxTitle, Constant.amountShow(amount: taxAmount), isDark, null); + return _summaryTile( + taxTitle, + Constant.amountShow(amount: taxAmount), + isDark, + null, + ); }), const Divider(), // Total - _summaryTile("Order Total".tr, Constant.amountShow(amount: controller.totalAmount.value.toString()), isDark, null), + _summaryTile( + "Order Total".tr, + Constant.amountShow( + amount: + controller.totalAmount.value.toString(), + ), + isDark, + null, + ), ], ), ), @@ -259,15 +496,32 @@ class ParcelOrderConfirmationScreen extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ // Title - Text("Payment by".tr, style: AppThemeData.boldTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500)), + Text( + "Payment by".tr, + style: AppThemeData.boldTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), + ), const SizedBox(height: 12), // Row with Sender and Receiver options @@ -275,16 +529,36 @@ class ParcelOrderConfirmationScreen extends StatelessWidget { children: [ // Sender GestureDetector( - onTap: () => controller.paymentBy.value = "Sender", + onTap: + () => + controller.paymentBy.value = + "Sender", child: Row( children: [ Icon( - controller.paymentBy.value == "Sender" ? Icons.radio_button_checked : Icons.radio_button_off, - color: controller.paymentBy.value == "Sender" ? AppThemeData.primary300 : (isDark ? AppThemeData.greyDark500 : AppThemeData.grey500), + controller.paymentBy.value == "Sender" + ? Icons.radio_button_checked + : Icons.radio_button_off, + color: + controller.paymentBy.value == + "Sender" + ? AppThemeData.primary300 + : (isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500), size: 20, ), const SizedBox(width: 6), - Text("Sender".tr, style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800)), + Text( + "Sender".tr, + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark800 + : AppThemeData.grey800, + ), + ), ], ), ), @@ -293,16 +567,37 @@ class ParcelOrderConfirmationScreen extends StatelessWidget { // Receiver GestureDetector( - onTap: () => controller.paymentBy.value = "Receiver", + onTap: + () => + controller.paymentBy.value = + "Receiver", child: Row( children: [ Icon( - controller.paymentBy.value == "Receiver" ? Icons.radio_button_checked : Icons.radio_button_off, - color: controller.paymentBy.value == "Receiver" ? AppThemeData.primary300 : (isDark ? AppThemeData.greyDark500 : AppThemeData.grey500), + controller.paymentBy.value == + "Receiver" + ? Icons.radio_button_checked + : Icons.radio_button_off, + color: + controller.paymentBy.value == + "Receiver" + ? AppThemeData.primary300 + : (isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500), size: 20, ), const SizedBox(width: 6), - Text("Receiver".tr, style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800)), + Text( + "Receiver".tr, + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark800 + : AppThemeData.grey800, + ), + ), ], ), ), @@ -316,13 +611,23 @@ class ParcelOrderConfirmationScreen extends StatelessWidget { // Continue button RoundedButtonFill( - title: controller.paymentBy.value == "Sender" ? "Select Payment Method".tr : "Continue".tr, + title: + controller.paymentBy.value == "Sender" + ? "Select Payment Method".tr + : "Continue".tr, onPress: () async { if (controller.paymentBy.value == "Sender") { Get.bottomSheet( - paymentBottomSheet(context, controller, isDark), // your widget - isScrollControlled: true, // ✅ allows full drag scrolling - backgroundColor: Colors.transparent, // so your rounded corners are visible + paymentBottomSheet( + context, + controller, + isDark, + ), // your widget + isScrollControlled: + true, // ✅ allows full drag scrolling + backgroundColor: + Colors + .transparent, // so your rounded corners are visible ); } else { controller.placeOrder(); @@ -339,14 +644,44 @@ class ParcelOrderConfirmationScreen extends StatelessWidget { ); } - Widget _infoSection(String title, String name, String address, String phone, bool isDark) { + Widget _infoSection( + String title, + String name, + String address, + String phone, + bool isDark, + ) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text(title, style: AppThemeData.semiBoldTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), - Text(name, style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), - Text(address, style: AppThemeData.mediumTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), - Text(phone, style: AppThemeData.mediumTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + title, + style: AppThemeData.semiBoldTextStyle( + fontSize: 18, + color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + ), + ), + Text( + name, + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + ), + ), + Text( + address, + style: AppThemeData.mediumTextStyle( + fontSize: 14, + color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + ), + ), + Text( + phone, + style: AppThemeData.mediumTextStyle( + fontSize: 14, + color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + ), + ), // Text(time, style: AppThemeData.semiBoldTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), ], ); @@ -356,11 +691,28 @@ class ParcelOrderConfirmationScreen extends StatelessWidget { return Column( children: [ // Icon(icon, color: AppThemeData.primary300), - SvgPicture.asset(icon, height: 28, width: 28, color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800), + SvgPicture.asset( + icon, + height: 28, + width: 28, + color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800, + ), const SizedBox(height: 6), - Text(value, style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800)), + Text( + value, + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800, + ), + ), const SizedBox(height: 6), - Text(title, style: AppThemeData.semiBoldTextStyle(fontSize: 12, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + title, + style: AppThemeData.semiBoldTextStyle( + fontSize: 12, + color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + ), + ), ], ); } @@ -371,14 +723,32 @@ class ParcelOrderConfirmationScreen extends StatelessWidget { child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text(title, style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800)), - Text(value, style: AppThemeData.semiBoldTextStyle(fontSize: title == "Order Total" ? 18 : 16, color: colors ?? (isDark ? AppThemeData.greyDark900 : AppThemeData.grey900))), + Text( + title, + style: AppThemeData.mediumTextStyle( + fontSize: 16, + color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800, + ), + ), + Text( + value, + style: AppThemeData.semiBoldTextStyle( + fontSize: title == "Order Total" ? 18 : 16, + color: + colors ?? + (isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + ), + ), ], ), ); } - Widget paymentBottomSheet(BuildContext context, ParcelOrderConfirmationController controller, bool isDark) { + Widget paymentBottomSheet( + BuildContext context, + ParcelOrderConfirmationController controller, + bool isDark, + ) { return DraggableScrollableSheet( initialChildSize: 0.70, minChildSize: 0.30, @@ -387,14 +757,26 @@ class ParcelOrderConfirmationScreen extends StatelessWidget { builder: (context, scrollController) { return Container( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20), - decoration: BoxDecoration(color: isDark ? AppThemeData.grey500 : Colors.white, borderRadius: BorderRadius.vertical(top: Radius.circular(24))), + decoration: BoxDecoration( + color: isDark ? AppThemeData.grey500 : Colors.white, + borderRadius: BorderRadius.vertical(top: Radius.circular(24)), + ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text("Select Payment Method".tr, style: AppThemeData.mediumTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + "Select Payment Method".tr, + style: AppThemeData.mediumTextStyle( + fontSize: 18, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), GestureDetector( onTap: () { Get.back(); @@ -408,63 +790,213 @@ class ParcelOrderConfirmationScreen extends StatelessWidget { child: ListView( controller: scrollController, children: [ - Text("Preferred Payment".tr, textAlign: TextAlign.start, style: AppThemeData.boldTextStyle(fontSize: 15, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500)), + Text( + "Preferred Payment".tr, + textAlign: TextAlign.start, + style: AppThemeData.boldTextStyle( + fontSize: 15, + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), + ), const SizedBox(height: 10), - if (controller.walletSettingModel.value.isEnabled == true || controller.cashOnDeliverySettingModel.value.isEnabled == true) + if (controller.walletSettingModel.value.isEnabled == true || + controller.cashOnDeliverySettingModel.value.isEnabled == + true) Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ Visibility( - visible: controller.walletSettingModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.wallet, isDark, "assets/images/ic_wallet.png"), + visible: + controller + .walletSettingModel + .value + .isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.wallet, + isDark, + "assets/images/ic_wallet.png", + ), ), Visibility( - visible: controller.cashOnDeliverySettingModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.cod, isDark, "assets/images/ic_cash.png"), + visible: + controller + .cashOnDeliverySettingModel + .value + .isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.cod, + isDark, + "assets/images/ic_cash.png", + ), ), ], ), ), ), - if (controller.walletSettingModel.value.isEnabled == true || controller.cashOnDeliverySettingModel.value.isEnabled == true) const SizedBox(height: 10), - Text("Other Payment Options".tr, textAlign: TextAlign.start, style: AppThemeData.boldTextStyle(fontSize: 15, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500)), + if (controller.walletSettingModel.value.isEnabled == true || + controller.cashOnDeliverySettingModel.value.isEnabled == + true) + const SizedBox(height: 10), + Text( + "Other Payment Options".tr, + textAlign: TextAlign.start, + style: AppThemeData.boldTextStyle( + fontSize: 15, + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), + ), const SizedBox(height: 10), Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ - Visibility(visible: controller.stripeModel.value.isEnabled == true, child: cardDecoration(controller, PaymentGateway.stripe, isDark, "assets/images/stripe.png")), - Visibility(visible: controller.payPalModel.value.isEnabled == true, child: cardDecoration(controller, PaymentGateway.paypal, isDark, "assets/images/paypal.png")), - Visibility(visible: controller.payStackModel.value.isEnable == true, child: cardDecoration(controller, PaymentGateway.payStack, isDark, "assets/images/paystack.png")), Visibility( - visible: controller.mercadoPagoModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.mercadoPago, isDark, "assets/images/mercado-pago.png"), + visible: + controller.stripeModel.value.isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.stripe, + isDark, + "assets/images/stripe.png", + ), ), Visibility( - visible: controller.flutterWaveModel.value.isEnable == true, - child: cardDecoration(controller, PaymentGateway.flutterWave, isDark, "assets/images/flutterwave_logo.png"), + visible: + controller.payPalModel.value.isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.paypal, + isDark, + "assets/images/paypal.png", + ), ), - Visibility(visible: controller.payFastModel.value.isEnable == true, child: cardDecoration(controller, PaymentGateway.payFast, isDark, "assets/images/payfast.png")), - Visibility(visible: controller.razorPayModel.value.isEnabled == true, child: cardDecoration(controller, PaymentGateway.razorpay, isDark, "assets/images/razorpay.png")), - Visibility(visible: controller.midTransModel.value.enable == true, child: cardDecoration(controller, PaymentGateway.midTrans, isDark, "assets/images/midtrans.png")), Visibility( - visible: controller.orangeMoneyModel.value.enable == true, - child: cardDecoration(controller, PaymentGateway.orangeMoney, isDark, "assets/images/orange_money.png"), + visible: + controller.payStackModel.value.isEnable == + true, + child: cardDecoration( + controller, + PaymentGateway.payStack, + isDark, + "assets/images/paystack.png", + ), + ), + Visibility( + visible: + controller.mercadoPagoModel.value.isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.mercadoPago, + isDark, + "assets/images/mercado-pago.png", + ), + ), + Visibility( + visible: + controller.flutterWaveModel.value.isEnable == + true, + child: cardDecoration( + controller, + PaymentGateway.flutterWave, + isDark, + "assets/images/flutterwave_logo.png", + ), + ), + Visibility( + visible: + controller.payFastModel.value.isEnable == + true, + child: cardDecoration( + controller, + PaymentGateway.payFast, + isDark, + "assets/images/payfast.png", + ), + ), + Visibility( + visible: + controller.razorPayModel.value.isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.razorpay, + isDark, + "assets/images/razorpay.png", + ), + ), + Visibility( + visible: + controller.midTransModel.value.enable == true, + child: cardDecoration( + controller, + PaymentGateway.midTrans, + isDark, + "assets/images/midtrans.png", + ), + ), + Visibility( + visible: + controller.orangeMoneyModel.value.enable == + true, + child: cardDecoration( + controller, + PaymentGateway.orangeMoney, + isDark, + "assets/images/orange_money.png", + ), + ), + Visibility( + visible: + controller.xenditModel.value.enable == true, + child: cardDecoration( + controller, + PaymentGateway.xendit, + isDark, + "assets/images/xendit.png", + ), ), - Visibility(visible: controller.xenditModel.value.enable == true, child: cardDecoration(controller, PaymentGateway.xendit, isDark, "assets/images/xendit.png")), ], ), ), @@ -478,25 +1010,59 @@ class ParcelOrderConfirmationScreen extends StatelessWidget { color: AppThemeData.taxiBooking300, textColor: AppThemeData.grey900, onPress: () async { - if (controller.selectedPaymentMethod.value == PaymentGateway.stripe.name) { - controller.stripeMakePayment(amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.paypal.name) { - controller.paypalPaymentSheet(controller.totalAmount.value.toString(), context); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.payStack.name) { - controller.payStackPayment(controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.mercadoPago.name) { - controller.mercadoPagoMakePayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.flutterWave.name) { - controller.flutterWaveInitiatePayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.payFast.name) { - controller.payFastPayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.cod.name) { + if (controller.selectedPaymentMethod.value == + PaymentGateway.stripe.name) { + controller.stripeMakePayment( + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.paypal.name) { + controller.paypalPaymentSheet( + controller.totalAmount.value.toString(), + context, + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.payStack.name) { + controller.payStackPayment( + controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.mercadoPago.name) { + controller.mercadoPagoMakePayment( + context: context, + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.flutterWave.name) { + controller.flutterWaveInitiatePayment( + context: context, + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.payFast.name) { + controller.payFastPayment( + context: context, + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.cod.name) { controller.placeOrder(); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.wallet.name) { - double walletBalance = double.tryParse(controller.userModel.value.walletAmount.toString()) ?? 0.0; - double amountToPay = double.tryParse(controller.totalAmount.value.toString()) ?? 0.0; + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.wallet.name) { + double walletBalance = + double.tryParse( + controller.userModel.value.walletAmount.toString(), + ) ?? + 0.0; + double amountToPay = + double.tryParse( + controller.totalAmount.value.toString(), + ) ?? + 0.0; if (walletBalance < amountToPay) { - ShowToastDialog.showToast("Insufficient wallet balance".tr); + ShowToastDialog.showToast( + "Insufficient wallet balance".tr, + ); return; } controller.placeOrder(); @@ -504,24 +1070,51 @@ class ParcelOrderConfirmationScreen extends StatelessWidget { // else if (controller.selectedPaymentMethod.value == PaymentGateway.wallet.name) { // controller.placeOrder(); // } - else if (controller.selectedPaymentMethod.value == PaymentGateway.midTrans.name) { - controller.midtransMakePayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.orangeMoney.name) { - controller.orangeMakePayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.xendit.name) { - controller.xenditPayment(context, controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.razorpay.name) { - RazorPayController().createOrderRazorPay(amount: double.parse(controller.totalAmount.value.toString()), razorpayModel: controller.razorPayModel.value).then((value) { - if (value == null) { - Get.back(); - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); - } else { - CreateRazorPayOrderModel result = value; - controller.openCheckout(amount: controller.totalAmount.value.toString(), orderId: result.id); - } - }); + else if (controller.selectedPaymentMethod.value == + PaymentGateway.midTrans.name) { + controller.midtransMakePayment( + context: context, + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.orangeMoney.name) { + controller.orangeMakePayment( + context: context, + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.xendit.name) { + controller.xenditPayment( + context, + controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.razorpay.name) { + RazorPayController() + .createOrderRazorPay( + amount: double.parse( + controller.totalAmount.value.toString(), + ), + razorpayModel: controller.razorPayModel.value, + ) + .then((value) { + if (value == null) { + Get.back(); + ShowToastDialog.showToast( + "Something went wrong, please contact admin.".tr, + ); + } else { + CreateRazorPayOrderModel result = value; + controller.openCheckout( + amount: controller.totalAmount.value.toString(), + orderId: result.id, + ); + } + }); } else { - ShowToastDialog.showToast("Please select payment method".tr); + ShowToastDialog.showToast( + "Please select payment method".tr, + ); } }, ), @@ -545,8 +1138,16 @@ class ParcelOrderConfirmationScreen extends StatelessWidget { Container( width: 50, height: 50, - decoration: ShapeDecoration(shape: RoundedRectangleBorder(side: const BorderSide(width: 1, color: Color(0xFFE5E7EB)), borderRadius: BorderRadius.circular(8))), - child: Padding(padding: EdgeInsets.all(value.name == "payFast" ? 0 : 8.0), child: Image.asset(image)), + decoration: ShapeDecoration( + shape: RoundedRectangleBorder( + side: const BorderSide(width: 1, color: Color(0xFFE5E7EB)), + borderRadius: BorderRadius.circular(8), + ), + ), + child: Padding( + padding: EdgeInsets.all(value.name == "payFast" ? 0 : 8.0), + child: Image.asset(image), + ), ), const SizedBox(width: 10), value.name == "wallet" @@ -557,12 +1158,30 @@ class ParcelOrderConfirmationScreen extends StatelessWidget { Text( value.name.capitalizeString(), textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), Text( - Constant.amountShow(amount: Constant.userModel?.walletAmount == null ? '0.0' : Constant.userModel?.walletAmount.toString()), + Constant.amountShow( + amount: + Constant.userModel?.walletAmount == null + ? '0.0' + : Constant.userModel?.walletAmount + .toString(), + ), textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(fontSize: 14, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300), + style: AppThemeData.semiBoldTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + ), ), ], ), @@ -571,13 +1190,18 @@ class ParcelOrderConfirmationScreen extends StatelessWidget { child: Text( value.name.capitalizeString(), textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark ? AppThemeData.grey50 : AppThemeData.grey900, + ), ), ), Radio( value: value.name, groupValue: controller.selectedPaymentMethod.value, - activeColor: isDark ? AppThemeData.primary300 : AppThemeData.primary300, + activeColor: + isDark ? AppThemeData.primary300 : AppThemeData.primary300, onChanged: (value) { controller.selectedPaymentMethod.value = value.toString(); }, diff --git a/lib/screen_ui/parcel_service/parcel_order_details.dart b/lib/screen_ui/parcel_service/parcel_order_details.dart index b3f6fd9..fbb482a 100644 --- a/lib/screen_ui/parcel_service/parcel_order_details.dart +++ b/lib/screen_ui/parcel_service/parcel_order_details.dart @@ -1,5 +1,7 @@ +import 'package:customer/constant/const_texts.dart'; import 'package:customer/screen_ui/parcel_service/parcel_review_screen.dart'; import 'package:dotted_border/dotted_border.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:get/get.dart'; @@ -39,8 +41,20 @@ class ParcelOrderDetails extends StatelessWidget { child: Container( height: 42, width: 42, - decoration: BoxDecoration(shape: BoxShape.circle, color: AppThemeData.grey50), - child: Center(child: Padding(padding: const EdgeInsets.only(left: 5), child: Icon(Icons.arrow_back_ios, color: AppThemeData.grey900, size: 20))), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: AppThemeData.grey50, + ), + child: Center( + child: Padding( + padding: const EdgeInsets.only(left: 5), + child: Icon( + Icons.arrow_back_ios, + color: AppThemeData.grey900, + size: 20, + ), + ), + ), ), ), const SizedBox(width: 10), @@ -48,12 +62,22 @@ class ParcelOrderDetails extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("Order Details".tr, style: AppThemeData.boldTextStyle(fontSize: 18, color: AppThemeData.grey900)), Text( - "Your parcel is on the way. Track it in real time below.".tr, + "Order Details".tr, + style: AppThemeData.boldTextStyle( + fontSize: 18, + color: AppThemeData.grey900, + ), + ), + Text( + "Your parcel is on the way. Track it in real time below." + .tr, maxLines: 1, overflow: TextOverflow.ellipsis, - style: AppThemeData.mediumTextStyle(fontSize: 14, color: AppThemeData.grey900), + style: AppThemeData.mediumTextStyle( + fontSize: 14, + color: AppThemeData.grey900, + ), ), ], ), @@ -73,23 +97,47 @@ class ParcelOrderDetails extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), width: double.infinity, padding: const EdgeInsets.all(16), child: Text( - "${'Order Id:'.tr} ${Constant.orderId(orderId: controller.parcelOrder.value.id.toString())}".tr, + "${'Order Id:'.tr} ${Constant.orderId(orderId: controller.parcelOrder.value.id.toString())}" + .tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 18, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + fontSize: 18, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), ), const SizedBox(height: 16), Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), padding: const EdgeInsets.all(16), child: Column( @@ -101,7 +149,11 @@ class ParcelOrderDetails extends StatelessWidget { // Timeline with icons and line Column( children: [ - Image.asset("assets/images/image_parcel.png", height: 32, width: 32), + Image.asset( + "assets/images/image_parcel.png", + height: 32, + width: 32, + ), DottedBorder( options: CustomPathDottedBorderOptions( color: Colors.grey.shade400, @@ -111,24 +163,50 @@ class ParcelOrderDetails extends StatelessWidget { (size) => Path() ..moveTo(size.width / 2, 0) - ..lineTo(size.width / 2, size.height), + ..lineTo( + size.width / 2, + size.height, + ), + ), + child: const SizedBox( + width: 20, + height: 95, ), - child: const SizedBox(width: 20, height: 95), ), - Image.asset("assets/images/image_parcel.png", height: 32, width: 32), + Image.asset( + "assets/images/image_parcel.png", + height: 32, + width: 32, + ), ], ), const SizedBox(width: 12), // Address Details Expanded( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ _infoSection( "Pickup Address (Sender):".tr, - controller.parcelOrder.value.sender?.name ?? '', - controller.parcelOrder.value.sender?.address ?? '', - controller.parcelOrder.value.sender?.phone ?? '', + controller + .parcelOrder + .value + .sender + ?.name ?? + '', + controller + .parcelOrder + .value + .sender + ?.address ?? + '', + controller + .parcelOrder + .value + .sender + ?.phone ?? + '', // controller.parcelOrder.value.senderPickupDateTime != null // ? "Pickup Time: ${controller.formatDate(controller.parcelOrder.value.senderPickupDateTime!)}" // : '', @@ -137,9 +215,24 @@ class ParcelOrderDetails extends StatelessWidget { const SizedBox(height: 16), _infoSection( "Delivery Address (Receiver):".tr, - controller.parcelOrder.value.receiver?.name ?? '', - controller.parcelOrder.value.receiver?.address ?? '', - controller.parcelOrder.value.receiver?.phone ?? '', + controller + .parcelOrder + .value + .receiver + ?.name ?? + '', + controller + .parcelOrder + .value + .receiver + ?.address ?? + '', + controller + .parcelOrder + .value + .receiver + ?.phone ?? + '', // controller.parcelOrder.value.receiverPickupDateTime != null // ? "Delivery Time: ${controller.formatDate(controller.parcelOrder.value.receiverPickupDateTime!)}" // : '', @@ -153,12 +246,16 @@ class ParcelOrderDetails extends StatelessWidget { const Divider(), - if (controller.parcelOrder.value.isSchedule == true) + if (controller.parcelOrder.value.isSchedule == + true) Padding( padding: const EdgeInsets.only(bottom: 8.0), child: Text( "${'Schedule Pickup time:'.tr} ${controller.formatDate(controller.parcelOrder.value.senderPickupDateTime!)}", - style: AppThemeData.mediumTextStyle(fontSize: 14, color: AppThemeData.info400), + style: AppThemeData.mediumTextStyle( + fontSize: 14, + color: AppThemeData.info400, + ), ), ), @@ -166,23 +263,61 @@ class ParcelOrderDetails extends StatelessWidget { padding: const EdgeInsets.only(bottom: 8.0), child: Text( "${'Order Date:'.tr}${controller.parcelOrder.value.isSchedule == true ? controller.formatDate(controller.parcelOrder.value.createdAt!) : controller.formatDate(controller.parcelOrder.value.senderPickupDateTime!)}", - style: AppThemeData.mediumTextStyle(fontSize: 14, color: AppThemeData.info400), + style: AppThemeData.mediumTextStyle( + fontSize: 14, + color: AppThemeData.info400, + ), ), ), Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ - Text("Parcel Type:".tr, style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800)), + Text( + "Parcel Type:".tr, + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark800 + : AppThemeData.grey800, + ), + ), Row( children: [ Text( - controller.parcelOrder.value.parcelType ?? '', - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800), + controller + .parcelOrder + .value + .parcelType ?? + '', + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark800 + : AppThemeData.grey800, + ), ), const SizedBox(width: 8), - if (controller.getSelectedCategory()?.image != null && controller.getSelectedCategory()!.image!.isNotEmpty) - NetworkImageWidget(imageUrl: controller.getSelectedCategory()?.image ?? '', height: 20, width: 20), + if (controller + .getSelectedCategory() + ?.image != + null && + controller + .getSelectedCategory()! + .image! + .isNotEmpty) + NetworkImageWidget( + imageUrl: + controller + .getSelectedCategory() + ?.image ?? + '', + height: 20, + width: 20, + ), ], ), ], @@ -192,15 +327,31 @@ class ParcelOrderDetails extends StatelessWidget { : SizedBox( height: 120, child: ListView.builder( - itemCount: controller.parcelOrder.value.parcelImages!.length, + itemCount: + controller + .parcelOrder + .value + .parcelImages! + .length, shrinkWrap: true, scrollDirection: Axis.horizontal, itemBuilder: (context, index) { return Padding( padding: const EdgeInsets.all(8.0), child: ClipRRect( - borderRadius: BorderRadius.circular(10), - child: NetworkImageWidget(imageUrl: controller.parcelOrder.value.parcelImages![index], width: 100, fit: BoxFit.cover, borderRadius: 10), + borderRadius: BorderRadius.circular( + 10, + ), + child: NetworkImageWidget( + imageUrl: + controller + .parcelOrder + .value + .parcelImages![index], + width: 100, + fit: BoxFit.cover, + borderRadius: 10, + ), ), ); }, @@ -214,16 +365,42 @@ class ParcelOrderDetails extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), padding: EdgeInsets.all(16), child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - _iconTile("${controller.parcelOrder.value.distance ?? '--'} ${Constant.distanceType}", "Distance".tr, "assets/icons/ic_distance_parcel.svg", isDark), - _iconTile(controller.parcelOrder.value.parcelWeight ?? '--', "Weight".tr, "assets/icons/ic_weight_parcel.svg", isDark), - _iconTile(Constant.amountShow(amount: controller.parcelOrder.value.subTotal), "Rate".tr, "assets/icons/ic_rate_parcel.svg", isDark), + _iconTile( + "${controller.parcelOrder.value.distance ?? '--'} ${Constant.distanceType}", + "Distance".tr, + "assets/icons/ic_distance_parcel.svg", + isDark, + ), + _iconTile( + controller.parcelOrder.value.parcelWeight ?? + '--', + "Weight".tr, + "assets/icons/ic_weight_parcel.svg", + isDark, + ), + _iconTile( + Constant.amountShow( + amount: controller.parcelOrder.value.subTotal, + ), + "Rate".tr, + "assets/icons/ic_rate_parcel.svg", + isDark, + ), ], ), ), @@ -234,18 +411,37 @@ class ParcelOrderDetails extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("About Driver".tr, style: AppThemeData.boldTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500)), + Text( + "About Driver".tr, + style: AppThemeData.boldTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), + ), const SizedBox(height: 8), Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + crossAxisAlignment: + CrossAxisAlignment.center, children: [ Row( children: [ @@ -253,19 +449,48 @@ class ParcelOrderDetails extends StatelessWidget { width: 52, height: 52, child: ClipRRect( - borderRadius: BorderRadiusGeometry.circular(10), - child: NetworkImageWidget(imageUrl: controller.driverUser.value?.profilePictureURL ?? '', height: 70, width: 70, borderRadius: 35), + borderRadius: + BorderRadiusGeometry.circular( + 10, + ), + child: NetworkImageWidget( + imageUrl: + controller + .driverUser + .value + ?.profilePictureURL ?? + '', + height: 70, + width: 70, + borderRadius: 35, + ), ), ), SizedBox(width: 20), Text( - controller.parcelOrder.value.driver?.fullName() ?? '', - style: AppThemeData.boldTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, fontSize: 18), + controller + .parcelOrder + .value + .driver + ?.fullName() ?? + '', + style: AppThemeData.boldTextStyle( + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData.grey900, + fontSize: 18, + ), ), ], ), RoundedButtonBorder( - title: controller.driverUser.value!.averageRating.toStringAsFixed(1), + title: controller + .driverUser + .value! + .averageRating + .toStringAsFixed(1), width: 20, height: 3.5, radius: 10, @@ -274,72 +499,155 @@ class ParcelOrderDetails extends StatelessWidget { textColor: AppThemeData.warning400, borderColor: AppThemeData.warning400, color: AppThemeData.warning50, - icon: SvgPicture.asset("assets/icons/ic_start.svg"), + icon: SvgPicture.asset( + "assets/icons/ic_start.svg", + ), onPress: () {}, ), ], ), Visibility( - visible: controller.parcelOrder.value.status == Constant.orderCompleted ? true : false, + visible: + controller.parcelOrder.value.status == + Constant.orderCompleted + ? true + : false, child: Padding( - padding: const EdgeInsets.symmetric(vertical: 10), + padding: const EdgeInsets.symmetric( + vertical: 10, + ), child: RoundedButtonFill( - title: controller.ratingModel.value.id != null && controller.ratingModel.value.id!.isNotEmpty ? 'Update Review'.tr : 'Add Review'.tr, + title: + controller.ratingModel.value.id != + null && + controller + .ratingModel + .value + .id! + .isNotEmpty + ? 'Update Review'.tr + : 'Add Review'.tr, onPress: () async { - final result = await Get.to(() => ParcelReviewScreen(), arguments: {'order': controller.parcelOrder.value}); + final result = await Get.to( + () => ParcelReviewScreen(), + arguments: { + 'order': + controller + .parcelOrder + .value, + }, + ); // If review was submitted successfully if (result == true) { - await controller.fetchDriverDetails(); + await controller + .fetchDriverDetails(); } }, height: 5, borderRadius: 15, color: Colors.orange, - textColor: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + textColor: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, ), ), ), - if (controller.parcelOrder.value.status != Constant.orderCompleted) + if (controller.parcelOrder.value.status != + Constant.orderCompleted) Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ InkWell( onTap: () { - Constant.makePhoneCall(controller.parcelOrder.value.driver!.phoneNumber.toString()); + Constant.makePhoneCall( + controller + .parcelOrder + .value + .driver! + .phoneNumber + .toString(), + ); }, child: Container( width: 150, height: 42, decoration: ShapeDecoration( shape: RoundedRectangleBorder( - side: BorderSide(width: 1, color: isDark ? AppThemeData.grey700 : AppThemeData.grey200), - borderRadius: BorderRadius.circular(120), + side: BorderSide( + width: 1, + color: + isDark + ? AppThemeData + .grey700 + : AppThemeData + .grey200, + ), + borderRadius: + BorderRadius.circular( + 120, + ), + ), + ), + child: Padding( + padding: const EdgeInsets.all( + 8.0, + ), + child: SvgPicture.asset( + "assets/icons/ic_phone_call.svg", ), ), - child: Padding(padding: const EdgeInsets.all(8.0), child: SvgPicture.asset("assets/icons/ic_phone_call.svg")), ), ), const SizedBox(width: 10), InkWell( onTap: () async { - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader( + ConstTexts.pleaseWait.tr, + ); - UserModel? customer = await FireStoreUtils.getUserProfile(controller.parcelOrder.value.authorID ?? ''); - UserModel? driverUser = await FireStoreUtils.getUserProfile(controller.parcelOrder.value.driverId ?? ''); + UserModel? customer = + await FireStoreUtils.getUserProfile( + controller + .parcelOrder + .value + .authorID ?? + '', + ); + UserModel? driverUser = + await FireStoreUtils.getUserProfile( + controller + .parcelOrder + .value + .driverId ?? + '', + ); ShowToastDialog.closeLoader(); Get.to( const ChatScreen(), arguments: { - "customerName": customer?.fullName(), - "restaurantName": driverUser?.fullName(), - "orderId": controller.parcelOrder.value.id, - "restaurantId": driverUser?.id, + "customerName": + customer?.fullName(), + "restaurantName": + driverUser?.fullName(), + "orderId": + controller + .parcelOrder + .value + .id, + "restaurantId": + driverUser?.id, "customerId": customer?.id, - "customerProfileImage": customer?.profilePictureURL, - "restaurantProfileImage": driverUser?.profilePictureURL, + "customerProfileImage": + customer + ?.profilePictureURL, + "restaurantProfileImage": + driverUser + ?.profilePictureURL, "token": driverUser?.fcmToken, "chatType": "Driver", }, @@ -350,11 +658,29 @@ class ParcelOrderDetails extends StatelessWidget { height: 42, decoration: ShapeDecoration( shape: RoundedRectangleBorder( - side: BorderSide(width: 1, color: isDark ? AppThemeData.grey700 : AppThemeData.grey200), - borderRadius: BorderRadius.circular(120), + side: BorderSide( + width: 1, + color: + isDark + ? AppThemeData + .grey700 + : AppThemeData + .grey200, + ), + borderRadius: + BorderRadius.circular( + 120, + ), + ), + ), + child: Padding( + padding: const EdgeInsets.all( + 8.0, + ), + child: SvgPicture.asset( + "assets/icons/ic_wechat.svg", ), ), - child: Padding(padding: const EdgeInsets.all(8.0), child: SvgPicture.asset("assets/icons/ic_wechat.svg")), ), ), ], @@ -368,43 +694,98 @@ class ParcelOrderDetails extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("Order Summary".tr, style: AppThemeData.boldTextStyle(fontSize: 14, color: AppThemeData.grey500)), + Text( + "Order Summary".tr, + style: AppThemeData.boldTextStyle( + fontSize: 14, + color: AppThemeData.grey500, + ), + ), const SizedBox(height: 8), // Subtotal - _summaryTile("Subtotal".tr, Constant.amountShow(amount: controller.subTotal.value.toString()), isDark), + _summaryTile( + "Subtotal".tr, + Constant.amountShow( + amount: controller.subTotal.value.toString(), + ), + isDark, + ), // Discount - _summaryTile("Discount".tr, Constant.amountShow(amount: controller.discount.value.toString()), isDark), + _summaryTile( + "Discount".tr, + Constant.amountShow( + amount: controller.discount.value.toString(), + ), + isDark, + ), // Tax List - ...List.generate(controller.parcelOrder.value.taxSetting!.length, (index) { - return _summaryTile( - "${controller.parcelOrder.value.taxSetting![index].title} ${controller.parcelOrder.value.taxSetting![index].type == 'fix' ? '' : '(${controller.parcelOrder.value.taxSetting![index].tax}%)'}", - Constant.amountShow( - amount: - Constant.getTaxValue( - amount: - ((double.tryParse(controller.parcelOrder.value.subTotal.toString()) ?? 0.0) - (double.tryParse(controller.parcelOrder.value.discount.toString()) ?? 0.0)) - .toString(), - taxModel: controller.parcelOrder.value.taxSetting![index], - ).toString(), - ), - isDark, - ); - }), + ...List.generate( + controller.parcelOrder.value.taxSetting!.length, + (index) { + return _summaryTile( + "${controller.parcelOrder.value.taxSetting![index].title} ${controller.parcelOrder.value.taxSetting![index].type == 'fix' ? '' : '(${controller.parcelOrder.value.taxSetting![index].tax}%)'}", + Constant.amountShow( + amount: + Constant.getTaxValue( + amount: + ((double.tryParse( + controller + .parcelOrder + .value + .subTotal + .toString(), + ) ?? + 0.0) - + (double.tryParse( + controller + .parcelOrder + .value + .discount + .toString(), + ) ?? + 0.0)) + .toString(), + taxModel: + controller + .parcelOrder + .value + .taxSetting![index], + ).toString(), + ), + isDark, + ); + }, + ), const Divider(), // Total - _summaryTile("Order Total".tr, Constant.amountShow(amount: controller.totalAmount.value.toString()), isDark), + _summaryTile( + "Order Total".tr, + Constant.amountShow( + amount: + controller.totalAmount.value.toString(), + ), + isDark, + ), ], ), ), @@ -423,7 +804,10 @@ class ParcelOrderDetails extends StatelessWidget { height: 5, borderRadius: 15, color: AppThemeData.primary300, - textColor: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + textColor: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, ), ) : SizedBox(), @@ -432,7 +816,11 @@ class ParcelOrderDetails extends StatelessWidget { ); } - Widget statusBottomSheet(BuildContext context, ParcelOrderDetailsController controller, bool isDark) { + Widget statusBottomSheet( + BuildContext context, + ParcelOrderDetailsController controller, + bool isDark, + ) { return DraggableScrollableSheet( initialChildSize: 0.30, minChildSize: 0.20, @@ -441,23 +829,46 @@ class ParcelOrderDetails extends StatelessWidget { builder: (context, scrollController) { return Container( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20), - decoration: BoxDecoration(color: isDark ? AppThemeData.grey500 : Colors.white, borderRadius: BorderRadius.vertical(top: Radius.circular(24))), + decoration: BoxDecoration( + color: isDark ? AppThemeData.grey500 : Colors.white, + borderRadius: BorderRadius.vertical(top: Radius.circular(24)), + ), child: SingleChildScrollView( controller: scrollController, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("Parcel Status Timeline".tr, style: AppThemeData.semiBoldTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, fontSize: 18)), + Text( + "Parcel Status Timeline".tr, + style: AppThemeData.semiBoldTextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + fontSize: 18, + ), + ), const SizedBox(height: 8), // Dynamic List Obx(() { - final history = controller.parcelOrder.value.statusHistory ?? []; + final history = + controller.parcelOrder.value.statusHistory ?? []; if (history.isEmpty) { return SizedBox( height: 80, - child: Center(child: Text("No status updates yet".tr, style: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900))), + child: Center( + child: Text( + "No status updates yet".tr, + style: AppThemeData.mediumTextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + ), ); } @@ -475,12 +886,26 @@ class ParcelOrderDetails extends StatelessWidget { child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ - Image.asset(isCompleted ? "assets/images/image_status_timeline.png" : "assets/images/image_timeline.png", height: 48, width: 48), + Image.asset( + isCompleted + ? "assets/images/image_status_timeline.png" + : "assets/images/image_timeline.png", + height: 48, + width: 48, + ), const SizedBox(width: 20), Expanded( child: Text( statusUpdate.status ?? '', - style: AppThemeData.semiBoldTextStyle(color: isCompleted ? (isDark ? AppThemeData.greyDark900 : AppThemeData.grey900) : AppThemeData.grey500, fontSize: 18), + style: AppThemeData.semiBoldTextStyle( + color: + isCompleted + ? (isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900) + : AppThemeData.grey500, + fontSize: 18, + ), ), ), ], @@ -498,14 +923,44 @@ class ParcelOrderDetails extends StatelessWidget { ); } - Widget _infoSection(String title, String name, String address, String phone, bool isDark) { + Widget _infoSection( + String title, + String name, + String address, + String phone, + bool isDark, + ) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text(title, style: AppThemeData.semiBoldTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), - Text(name, style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), - Text(address, style: AppThemeData.mediumTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), - Text(phone, style: AppThemeData.mediumTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + title, + style: AppThemeData.semiBoldTextStyle( + fontSize: 18, + color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + ), + ), + Text( + name, + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + ), + ), + Text( + address, + style: AppThemeData.mediumTextStyle( + fontSize: 14, + color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + ), + ), + Text( + phone, + style: AppThemeData.mediumTextStyle( + fontSize: 14, + color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + ), + ), // Text(time, style: AppThemeData.semiBoldTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), ], ); @@ -515,11 +970,28 @@ class ParcelOrderDetails extends StatelessWidget { return Column( children: [ // Icon(icon, color: AppThemeData.primary300), - SvgPicture.asset(icon, height: 28, width: 28, color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800), + SvgPicture.asset( + icon, + height: 28, + width: 28, + color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800, + ), const SizedBox(height: 6), - Text(value, style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800)), + Text( + value, + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800, + ), + ), const SizedBox(height: 6), - Text(title, style: AppThemeData.semiBoldTextStyle(fontSize: 12, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + title, + style: AppThemeData.semiBoldTextStyle( + fontSize: 12, + color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + ), + ), ], ); } @@ -530,8 +1002,20 @@ class ParcelOrderDetails extends StatelessWidget { child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text(title, style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800)), - Text(value, style: AppThemeData.semiBoldTextStyle(fontSize: title == "Order Total".tr ? 18 : 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + title, + style: AppThemeData.mediumTextStyle( + fontSize: 16, + color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800, + ), + ), + Text( + value, + style: AppThemeData.semiBoldTextStyle( + fontSize: title == "Order Total".tr ? 18 : 16, + color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + ), + ), ], ), ); diff --git a/lib/screen_ui/parcel_service/parcel_review_screen.dart b/lib/screen_ui/parcel_service/parcel_review_screen.dart index d6620d2..62a4bae 100644 --- a/lib/screen_ui/parcel_service/parcel_review_screen.dart +++ b/lib/screen_ui/parcel_service/parcel_review_screen.dart @@ -1,4 +1,5 @@ import 'package:customer/controllers/parcel_review_controller.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:get/get.dart'; @@ -25,10 +26,22 @@ class ParcelReviewScreen extends StatelessWidget { centerTitle: true, elevation: 0, backgroundColor: AppThemeData.primary300, - leading: GestureDetector(onTap: () => Get.back(), child: Icon(Icons.arrow_back_ios, color: isDark ? Colors.white : Colors.black)), + leading: GestureDetector( + onTap: () => Get.back(), + child: Icon( + Icons.arrow_back_ios, + color: isDark ? Colors.white : Colors.black, + ), + ), title: Text( - controller.ratingModel.value != null && controller.ratingModel.value!.id!.isNotEmpty ? "Update Review".tr : "Add Review".tr, - style: TextStyle(color: isDark ? Colors.white : Colors.black, fontSize: 16), + controller.ratingModel.value != null && + controller.ratingModel.value!.id!.isNotEmpty + ? "Update Review".tr + : "Add Review".tr, + style: TextStyle( + color: isDark ? Colors.white : Colors.black, + fontSize: 16, + ), ), ), body: Obx( @@ -40,11 +53,21 @@ class ParcelReviewScreen extends StatelessWidget { child: Stack( children: [ Padding( - padding: const EdgeInsets.only(left: 20, right: 20, top: 50, bottom: 20), + padding: const EdgeInsets.only( + left: 20, + right: 20, + top: 50, + bottom: 20, + ), child: Card( elevation: 2, - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), child: SingleChildScrollView( child: Padding( padding: const EdgeInsets.only(top: 65), @@ -52,65 +75,148 @@ class ParcelReviewScreen extends StatelessWidget { children: [ // Driver Name Padding( - padding: const EdgeInsets.only(top: 8.0), + padding: const EdgeInsets.only( + top: 8.0, + ), child: Text( - controller.order.value!.driver?.fullName() ?? "", - style: TextStyle(color: isDark ? Colors.white : Colors.black87, fontFamily: AppThemeData.medium, fontSize: 18), + controller.order.value!.driver + ?.fullName() ?? + "", + style: TextStyle( + color: + isDark + ? Colors.white + : Colors.black87, + fontFamily: AppThemeData.medium, + fontSize: 18, + ), ), ), // Car info - const Padding(padding: EdgeInsets.symmetric(vertical: 12), child: Divider(color: Colors.grey)), + const Padding( + padding: EdgeInsets.symmetric( + vertical: 12, + ), + child: Divider(color: Colors.grey), + ), // Title Padding( padding: const EdgeInsets.only(top: 16), - child: Text('How is your trip?'.tr, style: TextStyle(fontSize: 18, color: isDark ? Colors.white : Colors.black, fontWeight: FontWeight.bold, letterSpacing: 2)), + child: Text( + 'How is your trip?'.tr, + style: TextStyle( + fontSize: 18, + color: + isDark + ? Colors.white + : Colors.black, + fontWeight: FontWeight.bold, + letterSpacing: 2, + ), + ), ), Padding( padding: const EdgeInsets.only(top: 8), child: Text( - 'Your feedback will help us improve \n driving experience better'.tr, + 'Your feedback will help us improve \n driving experience better' + .tr, textAlign: TextAlign.center, - style: TextStyle(color: isDark ? Colors.white : Colors.black.withOpacity(0.60), letterSpacing: 0.8), + style: TextStyle( + color: + isDark + ? Colors.white + : Colors.black.withOpacity( + 0.60, + ), + letterSpacing: 0.8, + ), ), ), // Rating Padding( padding: const EdgeInsets.only(top: 20), - child: Text('Rate for'.tr, style: TextStyle(fontSize: 16, color: isDark ? Colors.white : Colors.black.withOpacity(0.60), letterSpacing: 0.8)), + child: Text( + 'Rate for'.tr, + style: TextStyle( + fontSize: 16, + color: + isDark + ? Colors.white + : Colors.black.withOpacity( + 0.60, + ), + letterSpacing: 0.8, + ), + ), ), Padding( padding: const EdgeInsets.only(top: 8), child: Text( - controller.order.value!.driver?.fullName() ?? "", - style: TextStyle(fontSize: 18, color: isDark ? Colors.white : Colors.black, fontWeight: FontWeight.bold, letterSpacing: 2), + controller.order.value!.driver + ?.fullName() ?? + "", + style: TextStyle( + fontSize: 18, + color: + isDark + ? Colors.white + : Colors.black, + fontWeight: FontWeight.bold, + letterSpacing: 2, + ), ), ), Padding( padding: const EdgeInsets.only(top: 10), child: RatingBar.builder( - initialRating: controller.ratings.value, + initialRating: + controller.ratings.value, minRating: 1, direction: Axis.horizontal, allowHalfRating: true, itemCount: 5, - itemBuilder: (context, _) => const Icon(Icons.star, color: Colors.amber), - unratedColor: isDark ? AppThemeData.greyDark400 : AppThemeData.grey400, - onRatingUpdate: (rating) => controller.ratings.value = rating, + itemBuilder: + (context, _) => const Icon( + Icons.star, + color: Colors.amber, + ), + unratedColor: + isDark + ? AppThemeData.greyDark400 + : AppThemeData.grey400, + onRatingUpdate: + (rating) => + controller.ratings.value = + rating, ), ), // Comment - Padding(padding: const EdgeInsets.all(20.0), child: TextFieldWidget(hintText: "Type comment....".tr, controller: controller.comment.value, maxLine: 5)), + Padding( + padding: const EdgeInsets.all(20.0), + child: TextFieldWidget( + hintText: "Type comment....".tr, + controller: controller.comment.value, + maxLine: 5, + ), + ), // Submit Button Padding( padding: const EdgeInsets.all(20.0), child: RoundedButtonFill( - title: controller.ratingModel.value != null ? "Update Review".tr : "Add Review".tr, + title: + controller.ratingModel.value != + null + ? "Update Review".tr + : "Add Review".tr, color: AppThemeData.primary300, - textColor: isDark ? Colors.white : Colors.black, + textColor: + isDark + ? Colors.white + : Colors.black, onPress: controller.submitReview, ), ), @@ -126,11 +232,28 @@ class ParcelReviewScreen extends StatelessWidget { decoration: BoxDecoration( borderRadius: BorderRadius.circular(60), color: Colors.white, - boxShadow: [BoxShadow(color: Colors.grey.withOpacity(0.15), blurRadius: 8, spreadRadius: 6)], + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.15), + blurRadius: 8, + spreadRadius: 6, + ), + ], ), child: ClipRRect( borderRadius: BorderRadius.circular(60), - child: NetworkImageWidget(imageUrl: controller.order.value?.driver?.profilePictureURL ?? '', fit: BoxFit.cover, height: 110, width: 110), + child: NetworkImageWidget( + imageUrl: + controller + .order + .value + ?.driver + ?.profilePictureURL ?? + '', + fit: BoxFit.cover, + height: 110, + width: 110, + ), ), ), ), diff --git a/lib/screen_ui/rental_service/my_rental_booking_screen.dart b/lib/screen_ui/rental_service/my_rental_booking_screen.dart index 268124b..321b8ad 100644 --- a/lib/screen_ui/rental_service/my_rental_booking_screen.dart +++ b/lib/screen_ui/rental_service/my_rental_booking_screen.dart @@ -4,6 +4,8 @@ import 'package:customer/screen_ui/auth_screens/login_screen.dart'; import 'package:customer/screen_ui/multi_vendor_service/wallet_screen/wallet_screen.dart'; import 'package:customer/screen_ui/rental_service/rental_order_details_screen.dart'; import 'package:customer/themes/round_button_fill.dart'; +import 'package:customer/utils/app_router.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../../constant/constant.dart'; @@ -24,14 +26,27 @@ class MyRentalBookingScreen extends StatelessWidget { builder: (controller) { return DefaultTabController( length: controller.tabTitles.length, - initialIndex: controller.tabTitles.indexOf(controller.selectedTab.value), + initialIndex: controller.tabTitles.indexOf( + controller.selectedTab.value, + ), child: Scaffold( appBar: AppBar( automaticallyImplyLeading: false, backgroundColor: AppThemeData.primary300, title: Padding( padding: const EdgeInsets.only(bottom: 10), - child: Row(children: [const SizedBox(width: 10), Text("Rental History".tr, style: AppThemeData.boldTextStyle(fontSize: 18, color: AppThemeData.grey900))]), + child: Row( + children: [ + const SizedBox(width: 10), + Text( + "Rental History".tr, + style: AppThemeData.boldTextStyle( + fontSize: 18, + color: AppThemeData.grey900, + ), + ), + ], + ), ), bottom: TabBar( onTap: (index) { @@ -41,8 +56,13 @@ class MyRentalBookingScreen extends StatelessWidget { labelColor: AppThemeData.parcelService500, unselectedLabelColor: AppThemeData.parcelService500, labelStyle: AppThemeData.boldTextStyle(fontSize: 13), - unselectedLabelStyle: AppThemeData.mediumTextStyle(fontSize: 13), - tabs: controller.tabTitles.map((title) => Tab(child: Center(child: Text(title)))).toList(), + unselectedLabelStyle: AppThemeData.mediumTextStyle( + fontSize: 13, + ), + tabs: + controller.tabTitles + .map((title) => Tab(child: Center(child: Text(title)))) + .toList(), ), ), body: @@ -55,12 +75,30 @@ class MyRentalBookingScreen extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Text("Please Log In to Continue".tr, style: TextStyle(color: isDark ? AppThemeData.grey100 : AppThemeData.grey800, fontSize: 22, fontFamily: AppThemeData.semiBold)), + Text( + "Please Log In to Continue".tr, + style: TextStyle( + color: + isDark + ? AppThemeData.grey100 + : AppThemeData.grey800, + fontSize: 22, + fontFamily: AppThemeData.semiBold, + ), + ), const SizedBox(height: 5), Text( - "You’re not logged in. Please sign in to access your account and explore all features.".tr, + "You’re not logged in. Please sign in to access your account and explore all features." + .tr, textAlign: TextAlign.center, - style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey500, fontSize: 16, fontFamily: AppThemeData.bold), + style: TextStyle( + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey500, + fontSize: 16, + fontFamily: AppThemeData.bold, + ), ), const SizedBox(height: 20), RoundedButtonFill( @@ -79,71 +117,154 @@ class MyRentalBookingScreen extends StatelessWidget { : TabBarView( children: controller.tabTitles.map((title) { - List orders = controller.getOrdersForTab(title); + List orders = controller + .getOrdersForTab(title); if (orders.isEmpty) { - return Center(child: Text("No orders found".tr, style: AppThemeData.mediumTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900))); + return Center( + child: Text( + "No orders found".tr, + style: AppThemeData.mediumTextStyle( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + ); } return ListView.builder( padding: const EdgeInsets.all(16), itemCount: orders.length, itemBuilder: (context, index) { - RentalOrderModel order = orders[index]; //use this + RentalOrderModel order = + orders[index]; //use this return InkWell( onTap: () { - Get.to(() => RentalOrderDetailsScreen(), arguments: order); + Get.to( + () => RentalOrderDetailsScreen(), + arguments: order, + ); }, child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), padding: const EdgeInsets.all(16), margin: const EdgeInsets.only(bottom: 10), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ - Padding(padding: const EdgeInsets.only(top: 5), child: Image.asset("assets/icons/pickup.png", height: 18, width: 18)), + Padding( + padding: const EdgeInsets.only( + top: 5, + ), + child: Image.asset( + "assets/icons/pickup.png", + height: 18, + width: 18, + ), + ), const SizedBox(width: 10), Expanded( //prevents overflow child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ Expanded( //text wraps if too long child: Text( - order.sourceLocationName ?? "-", - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), - overflow: TextOverflow.ellipsis, //safe cutoff + order.sourceLocationName ?? + "-", + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), + overflow: + TextOverflow + .ellipsis, //safe cutoff maxLines: 2, ), ), - if (order.status != null) ...[ - const SizedBox(width: 8), + if (order.status != + null) ...[ + const SizedBox( + width: 8, + ), Container( - padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 12), + padding: + const EdgeInsets.symmetric( + vertical: 6, + horizontal: 12, + ), decoration: BoxDecoration( - color: AppThemeData.info50, - border: Border.all(color: AppThemeData.info300), - borderRadius: BorderRadius.circular(12), + color: + AppThemeData + .info50, + border: Border.all( + color: + AppThemeData + .info300, + ), + borderRadius: + BorderRadius.circular( + 12, + ), + ), + child: Text( + order.status ?? '', + style: AppThemeData.boldTextStyle( + fontSize: 14, + color: + AppThemeData + .info500, + ), ), - child: Text(order.status ?? '', style: AppThemeData.boldTextStyle(fontSize: 14, color: AppThemeData.info500)), ), ], ], ), - if (order.bookingDateTime != null) + if (order.bookingDateTime != + null) Text( - Constant.timestampToDateTime(order.bookingDateTime!), - style: AppThemeData.mediumTextStyle(fontSize: 12, color: isDark ? AppThemeData.greyDark600 : AppThemeData.grey600), + Constant.timestampToDateTime( + order.bookingDateTime!, + ), + style: AppThemeData.mediumTextStyle( + fontSize: 12, + color: + isDark + ? AppThemeData + .greyDark600 + : AppThemeData + .grey600, + ), ), ], ), @@ -151,41 +272,112 @@ class MyRentalBookingScreen extends StatelessWidget { ], ), const SizedBox(height: 12), - Text("Vehicle Type :".tr, style: AppThemeData.boldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + "Vehicle Type :".tr, + style: AppThemeData.boldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), Padding( - padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10), + padding: const EdgeInsets.symmetric( + vertical: 10, + horizontal: 10, + ), child: Row( children: [ ClipRRect( //borderRadius: BorderRadius.circular(10), child: CachedNetworkImage( - imageUrl: order.rentalVehicleType!.rentalVehicleIcon.toString(), + imageUrl: + order + .rentalVehicleType! + .rentalVehicleIcon + .toString(), height: 60, width: 60, imageBuilder: - (context, imageProvider) => Container( - decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), image: DecorationImage(image: imageProvider, fit: BoxFit.cover)), + ( + context, + imageProvider, + ) => Container( + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular( + 10, + ), + image: DecorationImage( + image: + imageProvider, + fit: BoxFit.cover, + ), + ), + ), + placeholder: + (context, url) => Center( + child: CircularProgressIndicator.adaptive( + valueColor: + AlwaysStoppedAnimation( + AppThemeData + .primary300, + ), + ), + ), + errorWidget: + ( + context, + url, + error, + ) => Image.network( + Constant + .placeHolderImage, + fit: BoxFit.cover, ), - placeholder: (context, url) => Center(child: CircularProgressIndicator.adaptive(valueColor: AlwaysStoppedAnimation(AppThemeData.primary300))), - errorWidget: (context, url, error) => Image.network(Constant.placeHolderImage, fit: BoxFit.cover), fit: BoxFit.cover, ), ), Expanded( child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10), + padding: + const EdgeInsets.symmetric( + horizontal: 10, + ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ Text( "${order.rentalVehicleType!.name}", - style: AppThemeData.semiBoldTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: AppThemeData.semiBoldTextStyle( + fontSize: 18, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), ), Padding( - padding: const EdgeInsets.only(top: 2.0), + padding: + const EdgeInsets.only( + top: 2.0, + ), child: Text( "${order.rentalVehicleType!.shortDescription}", - style: AppThemeData.mediumTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark600 : AppThemeData.grey600), + style: AppThemeData.mediumTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData + .greyDark600 + : AppThemeData + .grey600, + ), ), ), ], @@ -195,60 +387,143 @@ class MyRentalBookingScreen extends StatelessWidget { ], ), ), - Text("Package info :".tr, style: AppThemeData.boldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + "Package info :".tr, + style: AppThemeData.boldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), Padding( - padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10), + padding: const EdgeInsets.symmetric( + vertical: 10, + horizontal: 10, + ), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ Expanded( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( - order.rentalPackageModel!.name.toString(), - style: AppThemeData.semiBoldTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + order + .rentalPackageModel! + .name + .toString(), + style: AppThemeData.semiBoldTextStyle( + fontSize: 18, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), ), const SizedBox(height: 4), Text( - order.rentalPackageModel!.description.toString(), - style: AppThemeData.mediumTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark600 : AppThemeData.grey600), + order + .rentalPackageModel! + .description + .toString(), + style: AppThemeData.mediumTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData + .greyDark600 + : AppThemeData + .grey600, + ), ), ], ), ), SizedBox(width: 10), Text( - Constant.amountShow(amount: order.rentalPackageModel!.baseFare.toString()), - style: AppThemeData.boldTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + Constant.amountShow( + amount: + order + .rentalPackageModel! + .baseFare + .toString(), + ), + style: + AppThemeData.boldTextStyle( + fontSize: 18, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), ), ], ), ), - if (Constant.isEnableOTPTripStartForRental == true) - Text("${'OTP :'.tr} ${order.otpCode}", style: AppThemeData.boldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + if (Constant + .isEnableOTPTripStartForRental == + true) + Text( + "${'OTP :'.tr} ${order.otpCode}", + style: AppThemeData.boldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), SizedBox(height: 10), Row( children: [ - order.status == Constant.orderInTransit && order.paymentStatus == false + order.status == + Constant + .orderInTransit && + order.paymentStatus == false ? Expanded( child: RoundedButtonFill( title: "Pay Now", onPress: () { - Get.to(() => RentalOrderDetailsScreen(), arguments: order); + Get.to( + () => + RentalOrderDetailsScreen(), + arguments: order, + ); }, - color: AppThemeData.primary300, - textColor: AppThemeData.grey900, + color: + AppThemeData.primary300, + textColor: + AppThemeData.grey900, ), ) : SizedBox(), - order.status == Constant.orderPlaced || order.status == Constant.driverAccepted + order.status == + Constant.orderPlaced || + order.status == + Constant.driverAccepted ? Expanded( child: RoundedButtonFill( title: "Cancel Booking", - onPress: () => controller.cancelRentalRequest(order, taxList: order.taxSetting), - color: AppThemeData.danger300, - textColor: AppThemeData.surface, + onPress: + () => controller + .cancelRentalRequest( + order, + taxList: + order + .taxSetting, + ), + color: + AppThemeData.danger300, + textColor: + AppThemeData.surface, ), ) : SizedBox(), @@ -268,7 +543,12 @@ class MyRentalBookingScreen extends StatelessWidget { ); } - Obx cardDecoration(MyRentalBookingController controller, PaymentGateway value, isDark, String image) { + Obx cardDecoration( + MyRentalBookingController controller, + PaymentGateway value, + isDark, + String image, + ) { return Obx( () => Padding( padding: const EdgeInsets.symmetric(vertical: 5), @@ -283,8 +563,21 @@ class MyRentalBookingScreen extends StatelessWidget { Container( width: 50, height: 50, - decoration: ShapeDecoration(shape: RoundedRectangleBorder(side: const BorderSide(width: 1, color: Color(0xFFE5E7EB)), borderRadius: BorderRadius.circular(8))), - child: Padding(padding: EdgeInsets.all(value.name == "payFast" ? 0 : 8.0), child: Image.asset(image)), + decoration: ShapeDecoration( + shape: RoundedRectangleBorder( + side: const BorderSide( + width: 1, + color: Color(0xFFE5E7EB), + ), + borderRadius: BorderRadius.circular(8), + ), + ), + child: Padding( + padding: EdgeInsets.all( + value.name == "payFast" ? 0 : 8.0, + ), + child: Image.asset(image), + ), ), const SizedBox(width: 10), value.name == "wallet" @@ -295,12 +588,30 @@ class MyRentalBookingScreen extends StatelessWidget { Text( value.name.capitalizeString(), textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), Text( - Constant.amountShow(amount: Constant.userModel!.walletAmount == null ? '0.0' : Constant.userModel!.walletAmount.toString()), + Constant.amountShow( + amount: + Constant.userModel!.walletAmount == null + ? '0.0' + : Constant.userModel!.walletAmount + .toString(), + ), textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(fontSize: 14, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300), + style: AppThemeData.semiBoldTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + ), ), ], ), @@ -309,14 +620,23 @@ class MyRentalBookingScreen extends StatelessWidget { child: Text( value.name.capitalizeString(), textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), ), const Expanded(child: SizedBox()), Radio( value: value.name, groupValue: controller.selectedPaymentMethod.value, - activeColor: isDark ? AppThemeData.primary300 : AppThemeData.primary300, + activeColor: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, onChanged: (value) { controller.selectedPaymentMethod.value = value.toString(); }, diff --git a/lib/screen_ui/rental_service/rental_conformation_screen.dart b/lib/screen_ui/rental_service/rental_conformation_screen.dart index 34e9b3e..03832eb 100644 --- a/lib/screen_ui/rental_service/rental_conformation_screen.dart +++ b/lib/screen_ui/rental_service/rental_conformation_screen.dart @@ -4,6 +4,7 @@ import 'package:customer/screen_ui/rental_service/rental_coupon_screen.dart'; import 'package:customer/themes/show_toast_dialog.dart'; import 'package:customer/utils/network_image_widget.dart'; import 'package:dotted_border/dotted_border.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:get/get.dart'; @@ -37,12 +38,30 @@ class RentalConformationScreen extends StatelessWidget { child: Container( height: 42, width: 42, - decoration: BoxDecoration(shape: BoxShape.circle, color: AppThemeData.grey50), - child: Center(child: Padding(padding: const EdgeInsets.only(left: 5), child: Icon(Icons.arrow_back_ios, color: AppThemeData.grey900, size: 20))), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: AppThemeData.grey50, + ), + child: Center( + child: Padding( + padding: const EdgeInsets.only(left: 5), + child: Icon( + Icons.arrow_back_ios, + color: AppThemeData.grey900, + size: 20, + ), + ), + ), ), ), const SizedBox(width: 10), - Text("Confirm Rent a Car".tr, style: AppThemeData.boldTextStyle(fontSize: 18, color: AppThemeData.grey900)), + Text( + "Confirm Rent a Car".tr, + style: AppThemeData.boldTextStyle( + fontSize: 18, + color: AppThemeData.grey900, + ), + ), ], ), ), @@ -60,26 +79,56 @@ class RentalConformationScreen extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), padding: const EdgeInsets.all(16), child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Image.asset("assets/icons/pickup.png", height: 15, width: 15), + Image.asset( + "assets/icons/pickup.png", + height: 15, + width: 15, + ), SizedBox(width: 15), Expanded( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( "${controller.rentalOrderModel.value.sourceLocationName}", - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), Text( - Constant.timestampToDate(controller.rentalOrderModel.value.bookingDateTime!), - style: AppThemeData.semiBoldTextStyle(fontSize: 12, color: isDark ? AppThemeData.greyDark600 : AppThemeData.grey600), + Constant.timestampToDate( + controller + .rentalOrderModel + .value + .bookingDateTime!, + ), + style: AppThemeData.semiBoldTextStyle( + fontSize: 12, + color: + isDark + ? AppThemeData.greyDark600 + : AppThemeData.grey600, + ), ), ], ), @@ -91,38 +140,96 @@ class RentalConformationScreen extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("Your Preference".tr, style: AppThemeData.boldTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500)), + Text( + "Your Preference".tr, + style: AppThemeData.boldTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), + ), SizedBox(height: 10), Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ Expanded( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( - controller.rentalOrderModel.value.rentalPackageModel!.name.toString(), - style: AppThemeData.semiBoldTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + controller + .rentalOrderModel + .value + .rentalPackageModel! + .name + .toString(), + style: + AppThemeData.semiBoldTextStyle( + fontSize: 18, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), ), const SizedBox(height: 4), Text( - controller.rentalOrderModel.value.rentalPackageModel!.description.toString(), - style: AppThemeData.mediumTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark600 : AppThemeData.grey600), + controller + .rentalOrderModel + .value + .rentalPackageModel! + .description + .toString(), + style: AppThemeData.mediumTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.greyDark600 + : AppThemeData.grey600, + ), ), ], ), ), SizedBox(width: 10), Text( - Constant.amountShow(amount: controller.rentalOrderModel.value.rentalPackageModel!.baseFare.toString()), - style: AppThemeData.boldTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + Constant.amountShow( + amount: + controller + .rentalOrderModel + .value + .rentalPackageModel! + .baseFare + .toString(), + ), + style: AppThemeData.boldTextStyle( + fontSize: 18, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), ], ), @@ -133,35 +240,81 @@ class RentalConformationScreen extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("Vehicle Type".tr, style: AppThemeData.boldTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500)), + Text( + "Vehicle Type".tr, + style: AppThemeData.boldTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), + ), SizedBox(height: 10), Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ ClipRRect( - borderRadius: BorderRadiusGeometry.circular(10), - child: NetworkImageWidget(imageUrl: controller.rentalOrderModel.value.rentalVehicleType!.rentalVehicleIcon.toString(), height: 50, width: 50, borderRadius: 10), + borderRadius: + BorderRadiusGeometry.circular(10), + child: NetworkImageWidget( + imageUrl: + controller + .rentalOrderModel + .value + .rentalVehicleType! + .rentalVehicleIcon + .toString(), + height: 50, + width: 50, + borderRadius: 10, + ), ), SizedBox(width: 10), Expanded( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( "${controller.rentalOrderModel.value.rentalVehicleType!.name}", - style: AppThemeData.semiBoldTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: + AppThemeData.semiBoldTextStyle( + fontSize: 18, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), ), Text( "${controller.rentalOrderModel.value.rentalVehicleType!.shortDescription}", - style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark600 : AppThemeData.grey600), + style: AppThemeData.mediumTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark600 + : AppThemeData.grey600, + ), ), ], ), @@ -175,24 +328,53 @@ class RentalConformationScreen extends StatelessWidget { Row( children: [ - Expanded(child: Text("Coupons".tr, style: AppThemeData.boldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900))), + Expanded( + child: Text( + "Coupons".tr, + style: AppThemeData.boldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + ), InkWell( onTap: () { Get.to(RentalCouponScreen())!.then((value) { if (value != null) { - double couponAmount = Constant.calculateDiscount(amount: controller.subTotal.value.toString(), offerModel: value); - if (couponAmount < controller.subTotal.value) { - controller.selectedCouponModel.value = value; + double couponAmount = + Constant.calculateDiscount( + amount: + controller.subTotal.value + .toString(), + offerModel: value, + ); + if (couponAmount < + controller.subTotal.value) { + controller.selectedCouponModel.value = + value; controller.calculateAmount(); } else { - ShowToastDialog.showToast("This offer not eligible for this booking".tr); + ShowToastDialog.showToast( + "This offer not eligible for this booking" + .tr, + ); } } }); }, child: Text( "View All".tr, - style: AppThemeData.boldTextStyle(decoration: TextDecoration.underline, fontSize: 14, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300), + style: AppThemeData.boldTextStyle( + decoration: TextDecoration.underline, + fontSize: 14, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + ), ), ), ], @@ -201,21 +383,44 @@ class RentalConformationScreen extends StatelessWidget { // Coupon input DottedBorder( - options: RoundedRectDottedBorderOptions(strokeWidth: 1, radius: const Radius.circular(10), color: isDark ? AppThemeData.parcelServiceDark300 : AppThemeData.primary300), + options: RoundedRectDottedBorderOptions( + strokeWidth: 1, + radius: const Radius.circular(10), + color: + isDark + ? AppThemeData.parcelServiceDark300 + : AppThemeData.primary300, + ), child: Container( - decoration: BoxDecoration(color: AppThemeData.parcelService50, borderRadius: BorderRadius.circular(10)), - padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), + decoration: BoxDecoration( + color: AppThemeData.parcelService50, + borderRadius: BorderRadius.circular(10), + ), + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 8, + ), child: Row( children: [ - SvgPicture.asset("assets/icons/ic_coupon_parcel.svg", height: 28, width: 28), + SvgPicture.asset( + "assets/icons/ic_coupon_parcel.svg", + height: 28, + width: 28, + ), SizedBox(width: 15), Expanded( child: TextFormField( - controller: controller.couponController.value, - style: AppThemeData.semiBoldTextStyle(color: AppThemeData.grey900), + controller: + controller.couponController.value, + style: AppThemeData.semiBoldTextStyle( + color: AppThemeData.grey900, + ), decoration: InputDecoration( hintText: "Write coupon code".tr, - hintStyle: AppThemeData.mediumTextStyle(fontSize: 16, color: AppThemeData.parcelService500), + hintStyle: AppThemeData.mediumTextStyle( + fontSize: 16, + color: AppThemeData.parcelService500, + ), border: InputBorder.none, ), ), @@ -223,22 +428,61 @@ class RentalConformationScreen extends StatelessWidget { RoundedButtonFill( title: "Redeem now".tr, onPress: () { - if (controller.couponList.where((element) => element.code!.toLowerCase() == controller.couponController.value.text.toLowerCase()).isNotEmpty) { - CouponModel couponModel = controller.couponList.firstWhere((p0) => p0.code!.toLowerCase() == controller.couponController.value.text.toLowerCase()); - if (couponModel.expiresAt!.toDate().isAfter(DateTime.now())) { - double couponAmount = Constant.calculateDiscount(amount: controller.subTotal.value.toString(), offerModel: couponModel); - if (couponAmount < controller.subTotal.value) { - controller.selectedCouponModel.value = couponModel; + if (controller.couponList + .where( + (element) => + element.code!.toLowerCase() == + controller + .couponController + .value + .text + .toLowerCase(), + ) + .isNotEmpty) { + CouponModel couponModel = controller + .couponList + .firstWhere( + (p0) => + p0.code!.toLowerCase() == + controller + .couponController + .value + .text + .toLowerCase(), + ); + if (couponModel.expiresAt! + .toDate() + .isAfter(DateTime.now())) { + double couponAmount = + Constant.calculateDiscount( + amount: + controller.subTotal.value + .toString(), + offerModel: couponModel, + ); + if (couponAmount < + controller.subTotal.value) { + controller + .selectedCouponModel + .value = couponModel; controller.calculateAmount(); controller.update(); } else { - ShowToastDialog.showToast("This offer not eligible for this booking".tr); + ShowToastDialog.showToast( + "This offer not eligible for this booking" + .tr, + ); } } else { - ShowToastDialog.showToast("This coupon code has been expired".tr); + ShowToastDialog.showToast( + "This coupon code has been expired" + .tr, + ); } } else { - ShowToastDialog.showToast("Invalid coupon code".tr); + ShowToastDialog.showToast( + "Invalid coupon code".tr, + ); } }, borderRadius: 10, @@ -256,45 +500,104 @@ class RentalConformationScreen extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("Order Summary".tr, style: AppThemeData.boldTextStyle(fontSize: 14, color: AppThemeData.grey500)), + Text( + "Order Summary".tr, + style: AppThemeData.boldTextStyle( + fontSize: 14, + color: AppThemeData.grey500, + ), + ), const SizedBox(height: 8), // Subtotal - _summaryTile("Subtotal".tr, Constant.amountShow(amount: controller.subTotal.value.toString()), isDark, null), + _summaryTile( + "Subtotal".tr, + Constant.amountShow( + amount: + controller.subTotal.value.toString(), + ), + isDark, + null, + ), // Discount - _summaryTile("Discount".tr, Constant.amountShow(amount: controller.discount.value.toString()), isDark, AppThemeData.dangerDark300), + _summaryTile( + "Discount".tr, + Constant.amountShow( + amount: + controller.discount.value.toString(), + ), + isDark, + AppThemeData.dangerDark300, + ), // Tax List - ...List.generate(controller.rentalOrderModel.value.taxSetting!.length, (index) { - final taxModel = controller.rentalOrderModel.value.taxSetting![index]; - final taxTitle = "${taxModel.title} ${taxModel.type == 'fix' ? '(${Constant.amountShow(amount: taxModel.tax)})' : '(${taxModel.tax}%)'}"; + ...List.generate( + controller + .rentalOrderModel + .value + .taxSetting! + .length, + (index) { + final taxModel = + controller + .rentalOrderModel + .value + .taxSetting![index]; + final taxTitle = + "${taxModel.title} ${taxModel.type == 'fix' ? '(${Constant.amountShow(amount: taxModel.tax)})' : '(${taxModel.tax}%)'}"; - return _summaryTile( - taxTitle, - Constant.amountShow( - amount: - Constant.getTaxValue( - amount: (controller.subTotal.value - controller.discount.value).toString(), - taxModel: controller.rentalOrderModel.value.taxSetting![index], - ).toString(), - ), - isDark, - null, - ); - }), + return _summaryTile( + taxTitle, + Constant.amountShow( + amount: + Constant.getTaxValue( + amount: + (controller.subTotal.value - + controller + .discount + .value) + .toString(), + taxModel: + controller + .rentalOrderModel + .value + .taxSetting![index], + ).toString(), + ), + isDark, + null, + ); + }, + ), const Divider(), // Total - _summaryTile("Order Total".tr, Constant.amountShow(amount: controller.totalAmount.value.toString()), isDark, null), + _summaryTile( + "Order Total".tr, + Constant.amountShow( + amount: + controller.totalAmount.value.toString(), + ), + isDark, + null, + ), ], ), ), @@ -323,8 +626,22 @@ class RentalConformationScreen extends StatelessWidget { child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text(title, style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800)), - Text(value, style: AppThemeData.semiBoldTextStyle(fontSize: title == "Order Total" ? 18 : 16, color: colors ?? (isDark ? AppThemeData.greyDark900 : AppThemeData.grey900))), + Text( + title, + style: AppThemeData.mediumTextStyle( + fontSize: 16, + color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800, + ), + ), + Text( + value, + style: AppThemeData.semiBoldTextStyle( + fontSize: title == "Order Total" ? 18 : 16, + color: + colors ?? + (isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + ), + ), ], ), ); diff --git a/lib/screen_ui/rental_service/rental_coupon_screen.dart b/lib/screen_ui/rental_service/rental_coupon_screen.dart index b721549..dbd31ce 100644 --- a/lib/screen_ui/rental_service/rental_coupon_screen.dart +++ b/lib/screen_ui/rental_service/rental_coupon_screen.dart @@ -6,6 +6,7 @@ import 'package:customer/themes/app_them_data.dart'; import 'package:customer/themes/responsive.dart'; import 'package:customer/widget/my_separator.dart'; import 'package:dotted_border/dotted_border.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -32,12 +33,30 @@ class RentalCouponScreen extends StatelessWidget { child: Container( height: 42, width: 42, - decoration: BoxDecoration(shape: BoxShape.circle, color: AppThemeData.grey50), - child: Center(child: Padding(padding: const EdgeInsets.only(left: 5), child: Icon(Icons.arrow_back_ios, color: AppThemeData.grey900, size: 20))), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: AppThemeData.grey50, + ), + child: Center( + child: Padding( + padding: const EdgeInsets.only(left: 5), + child: Icon( + Icons.arrow_back_ios, + color: AppThemeData.grey900, + size: 20, + ), + ), + ), ), ), const SizedBox(width: 10), - Text("Coupon".tr, style: AppThemeData.boldTextStyle(fontSize: 18, color: AppThemeData.grey900)), + Text( + "Coupon".tr, + style: AppThemeData.boldTextStyle( + fontSize: 18, + color: AppThemeData.grey900, + ), + ), ], ), ), @@ -53,17 +72,35 @@ class RentalCouponScreen extends StatelessWidget { itemBuilder: (context, index) { CouponModel couponModel = controller.cabCouponList[index]; return Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: Container( height: Responsive.height(16, context), - decoration: ShapeDecoration(color: isDark ? AppThemeData.grey900 : AppThemeData.grey50, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10))), + decoration: ShapeDecoration( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + ), child: Row( children: [ ClipRRect( - borderRadius: const BorderRadius.only(topLeft: Radius.circular(10), bottomLeft: Radius.circular(10)), + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(10), + bottomLeft: Radius.circular(10), + ), child: Stack( children: [ - Image.asset("assets/images/ic_coupon_image.png", height: Responsive.height(16, context), fit: BoxFit.fill), + Image.asset( + "assets/images/ic_coupon_image.png", + height: Responsive.height(16, context), + fit: BoxFit.fill, + ), Padding( padding: const EdgeInsets.only(left: 10), child: Align( @@ -73,7 +110,14 @@ class RentalCouponScreen extends StatelessWidget { child: Text( "${couponModel.discountType == "Fix Price" ? Constant.amountShow(amount: couponModel.discount) : "${couponModel.discount}%"} ${'Off'.tr}", textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey50), + style: TextStyle( + fontFamily: AppThemeData.semiBold, + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey50, + ), ), ), ), @@ -83,24 +127,53 @@ class RentalCouponScreen extends StatelessWidget { ), Expanded( child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 18), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 18, + ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Row( children: [ DottedBorder( - options: RoundedRectDottedBorderOptions(strokeWidth: 1, radius: const Radius.circular(6), color: isDark ? AppThemeData.grey400 : AppThemeData.grey500), + options: + RoundedRectDottedBorderOptions( + strokeWidth: 1, + radius: const Radius.circular( + 6, + ), + color: + isDark + ? AppThemeData.grey400 + : AppThemeData + .grey500, + ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), + padding: + const EdgeInsets.symmetric( + horizontal: 16, + ), child: Text( "${couponModel.code}", textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.semiBold, fontSize: 16, color: isDark ? AppThemeData.grey400 : AppThemeData.grey500), + style: TextStyle( + fontFamily: + AppThemeData.semiBold, + fontSize: 16, + color: + isDark + ? AppThemeData.grey400 + : AppThemeData + .grey500, + ), ), ), ), - const Expanded(child: SizedBox(height: 10)), + const Expanded( + child: SizedBox(height: 10), + ), InkWell( onTap: () { Get.back(result: couponModel); @@ -108,18 +181,38 @@ class RentalCouponScreen extends StatelessWidget { child: Text( "Tap To Apply".tr, textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300), + style: TextStyle( + fontFamily: AppThemeData.medium, + color: + isDark + ? AppThemeData + .primary300 + : AppThemeData + .primary300, + ), ), ), ], ), const SizedBox(height: 20), - MySeparator(color: isDark ? AppThemeData.grey700 : AppThemeData.grey200), + MySeparator( + color: + isDark + ? AppThemeData.grey700 + : AppThemeData.grey200, + ), const SizedBox(height: 20), Text( "${couponModel.description}", textAlign: TextAlign.start, - style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: TextStyle( + fontFamily: AppThemeData.medium, + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), ], ), diff --git a/lib/screen_ui/rental_service/rental_dashboard_screen.dart b/lib/screen_ui/rental_service/rental_dashboard_screen.dart index 99a24c9..4d7d14a 100644 --- a/lib/screen_ui/rental_service/rental_dashboard_screen.dart +++ b/lib/screen_ui/rental_service/rental_dashboard_screen.dart @@ -2,6 +2,7 @@ import 'package:customer/constant/constant.dart'; import 'package:customer/controllers/cab_dashboard_controller.dart'; import 'package:customer/controllers/theme_controller.dart'; import 'package:customer/themes/app_them_data.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:get/get.dart'; @@ -25,12 +26,19 @@ class RentalDashboardScreen extends StatelessWidget { showUnselectedLabels: true, showSelectedLabels: true, selectedFontSize: 12, - selectedLabelStyle: const TextStyle(fontFamily: AppThemeData.bold), - unselectedLabelStyle: const TextStyle(fontFamily: AppThemeData.bold), + selectedLabelStyle: const TextStyle( + fontFamily: AppThemeData.bold, + ), + unselectedLabelStyle: const TextStyle( + fontFamily: AppThemeData.bold, + ), currentIndex: controller.selectedIndex.value, - backgroundColor: isDark ? AppThemeData.grey900 : AppThemeData.grey50, - selectedItemColor: isDark ? AppThemeData.primary300 : AppThemeData.primary300, - unselectedItemColor: isDark ? AppThemeData.grey300 : AppThemeData.grey600, + backgroundColor: + isDark ? AppThemeData.grey900 : AppThemeData.grey50, + selectedItemColor: + isDark ? AppThemeData.primary300 : AppThemeData.primary300, + unselectedItemColor: + isDark ? AppThemeData.grey300 : AppThemeData.grey600, onTap: (int index) { if (index == 0) { Get.put(CabDashboardController()); @@ -40,15 +48,57 @@ class RentalDashboardScreen extends StatelessWidget { items: Constant.walletSetting == false ? [ - navigationBarItem(isDark, index: 0, assetIcon: "assets/icons/ic_home_cab.svg", label: 'Home'.tr, controller: controller), - navigationBarItem(isDark, index: 1, assetIcon: "assets/icons/ic_booking_cab.svg", label: 'My Bookings'.tr, controller: controller), - navigationBarItem(isDark, index: 2, assetIcon: "assets/icons/ic_profile.svg", label: 'Profile'.tr, controller: controller), + navigationBarItem( + isDark, + index: 0, + assetIcon: "assets/icons/ic_home_cab.svg", + label: 'Home'.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 1, + assetIcon: "assets/icons/ic_booking_cab.svg", + label: 'My Bookings'.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 2, + assetIcon: "assets/icons/ic_profile.svg", + label: 'Profile'.tr, + controller: controller, + ), ] : [ - navigationBarItem(isDark, index: 0, assetIcon: "assets/icons/ic_home_cab.svg", label: 'Home'.tr, controller: controller), - navigationBarItem(isDark, index: 1, assetIcon: "assets/icons/ic_booking_cab.svg", label: 'My Bookings'.tr, controller: controller), - navigationBarItem(isDark, index: 2, assetIcon: "assets/icons/ic_wallet_cab.svg", label: 'Wallet'.tr, controller: controller), - navigationBarItem(isDark, index: 3, assetIcon: "assets/icons/ic_profile.svg", label: 'Profile'.tr, controller: controller), + navigationBarItem( + isDark, + index: 0, + assetIcon: "assets/icons/ic_home_cab.svg", + label: 'Home'.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 1, + assetIcon: "assets/icons/ic_booking_cab.svg", + label: 'My Bookings'.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 2, + assetIcon: "assets/icons/ic_wallet_cab.svg", + label: 'Wallet'.tr, + controller: controller, + ), + navigationBarItem( + isDark, + index: 3, + assetIcon: "assets/icons/ic_profile.svg", + label: 'Profile'.tr, + controller: controller, + ), ], ), ); @@ -57,7 +107,13 @@ class RentalDashboardScreen extends StatelessWidget { }); } - BottomNavigationBarItem navigationBarItem(isDark, {required int index, required String label, required String assetIcon, required CabRentalDashboardControllers controller}) { + BottomNavigationBarItem navigationBarItem( + isDark, { + required int index, + required String label, + required String assetIcon, + required CabRentalDashboardControllers controller, + }) { return BottomNavigationBarItem( icon: Padding( padding: const EdgeInsets.symmetric(vertical: 5), diff --git a/lib/screen_ui/rental_service/rental_home_screen.dart b/lib/screen_ui/rental_service/rental_home_screen.dart index 94e8b62..9da2218 100644 --- a/lib/screen_ui/rental_service/rental_home_screen.dart +++ b/lib/screen_ui/rental_service/rental_home_screen.dart @@ -1,5 +1,7 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:customer/constant/constant.dart'; +import 'package:customer/utils/app_router.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../../controllers/rental_home_controller.dart'; @@ -43,8 +45,20 @@ class RentalHomeScreen extends StatelessWidget { child: Container( height: 42, width: 42, - decoration: BoxDecoration(shape: BoxShape.circle, color: AppThemeData.grey50), - child: Center(child: Padding(padding: const EdgeInsets.only(left: 5), child: Icon(Icons.arrow_back_ios, color: AppThemeData.grey900, size: 20))), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: AppThemeData.grey50, + ), + child: Center( + child: Padding( + padding: const EdgeInsets.only(left: 5), + child: Icon( + Icons.arrow_back_ios, + color: AppThemeData.grey900, + size: 20, + ), + ), + ), ), ), const SizedBox(width: 10), @@ -57,9 +71,21 @@ class RentalHomeScreen extends StatelessWidget { onTap: () { Get.offAll(const LoginScreen()); }, - child: Text("Login".tr, style: AppThemeData.boldTextStyle(fontSize: 14, color: AppThemeData.grey900)), + child: Text( + "Login".tr, + style: AppThemeData.boldTextStyle( + fontSize: 14, + color: AppThemeData.grey900, + ), + ), ) - : Text(Constant.userModel!.fullName(), style: AppThemeData.boldTextStyle(fontSize: 14, color: AppThemeData.grey900)), + : Text( + Constant.userModel!.fullName(), + style: AppThemeData.boldTextStyle( + fontSize: 14, + color: AppThemeData.grey900, + ), + ), ], ), ), @@ -81,30 +107,69 @@ class RentalHomeScreen extends StatelessWidget { InkWell( onTap: () async { if (Constant.selectedMapType == 'osm') { - final result = await Get.to(() => MapPickerPage()); + final result = await Get.to( + () => MapPickerPage(), + ); if (result != null) { final firstPlace = result; - if (Constant.checkZoneCheck(firstPlace.coordinates.latitude, firstPlace.coordinates.longitude) == true) { + if (Constant.checkZoneCheck( + firstPlace.coordinates.latitude, + firstPlace.coordinates.longitude, + ) == + true) { final address = firstPlace.address; final lat = firstPlace.coordinates.latitude; - final lng = firstPlace.coordinates.longitude; - controller.sourceTextEditController.value.text = address; - controller.departureLatLongOsm.value = latlong.LatLng(lat, lng); + final lng = + firstPlace.coordinates.longitude; + controller + .sourceTextEditController + .value + .text = address; + controller + .departureLatLongOsm + .value = latlong.LatLng(lat, lng); } else { - ShowToastDialog.showToast("Service is unavailable at the selected address.".tr); + ShowToastDialog.showToast( + "Service is unavailable at the selected address." + .tr, + ); } } } else { - Get.to(LocationPickerScreen())!.then((value) async { + Get.to(LocationPickerScreen())!.then(( + value, + ) async { if (value != null) { - SelectedLocationModel selectedLocationModel = value; + SelectedLocationModel + selectedLocationModel = value; - if (Constant.checkZoneCheck(selectedLocationModel.latLng!.latitude, selectedLocationModel.latLng!.longitude) == true) { - controller.sourceTextEditController.value.text = Utils.formatAddress(selectedLocation: selectedLocationModel); - controller.departureLatLong.value = latlong.LatLng(selectedLocationModel.latLng!.latitude, selectedLocationModel.latLng!.longitude); + if (Constant.checkZoneCheck( + selectedLocationModel + .latLng! + .latitude, + selectedLocationModel + .latLng! + .longitude, + ) == + true) { + controller + .sourceTextEditController + .value + .text = Utils.formatAddress( + selectedLocation: selectedLocationModel, + ); + controller + .departureLatLong + .value = latlong.LatLng( + selectedLocationModel.latLng!.latitude, + selectedLocationModel.latLng!.longitude, + ); } else { - ShowToastDialog.showToast("Service is unavailable at the selected address.".tr); + ShowToastDialog.showToast( + "Service is unavailable at the selected address." + .tr, + ); } } }); @@ -112,11 +177,18 @@ class RentalHomeScreen extends StatelessWidget { }, hoverColor: Colors.transparent, child: TextFieldWidget( - controller: controller.sourceTextEditController.value, + controller: + controller.sourceTextEditController.value, hintText: "Your current location".tr, title: "Pickup Location".tr, enable: false, - prefix: Padding(padding: EdgeInsets.only(left: 10, right: 10), child: Icon(Icons.stop_circle_outlined, color: Colors.green)), + prefix: Padding( + padding: EdgeInsets.only(left: 10, right: 10), + child: Icon( + Icons.stop_circle_outlined, + color: Colors.green, + ), + ), ), ), const SizedBox(height: 25), @@ -124,7 +196,16 @@ class RentalHomeScreen extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Text("Select Your Vehicle Type".tr, style: AppThemeData.boldTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + "Select Your Vehicle Type".tr, + style: AppThemeData.boldTextStyle( + fontSize: 18, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), const SizedBox(width: 10), GestureDetector( onTap: () => controller.pickDate(context), @@ -132,7 +213,13 @@ class RentalHomeScreen extends StatelessWidget { children: [ Text( "${controller.selectedDate.value.day}-${controller.selectedDate.value.month}-${controller.selectedDate.value.year}", - style: AppThemeData.semiBoldTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: AppThemeData.semiBoldTextStyle( + fontSize: 18, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), ), const SizedBox(width: 5), const Icon(Icons.date_range, size: 20), @@ -149,11 +236,13 @@ class RentalHomeScreen extends StatelessWidget { physics: NeverScrollableScrollPhysics(), scrollDirection: Axis.vertical, itemBuilder: (context, index) { - RentalVehicleType vehicleType = controller.vehicleTypes[index]; + RentalVehicleType vehicleType = + controller.vehicleTypes[index]; return Obx( () => InkWell( onTap: () { - controller.selectedVehicleType.value = controller.vehicleTypes[index]; + controller.selectedVehicleType.value = + controller.vehicleTypes[index]; }, child: Padding( padding: const EdgeInsets.only(bottom: 10), @@ -163,72 +252,144 @@ class RentalHomeScreen extends StatelessWidget { border: Border.all( color: isDark - ? controller.selectedVehicleType.value?.id == vehicleType.id - ? AppThemeData.carRentDark300 + ? controller + .selectedVehicleType + .value + ?.id == + vehicleType.id + ? AppThemeData + .carRentDark300 : Colors.transparent - : controller.selectedVehicleType.value?.id == vehicleType.id + : controller + .selectedVehicleType + .value + ?.id == + vehicleType.id ? AppThemeData.carRent300 : Colors.transparent, width: 1, ), color: - controller.selectedVehicleType.value?.id == vehicleType.id + controller + .selectedVehicleType + .value + ?.id == + vehicleType.id ? AppThemeData.carRent50 : isDark ? AppThemeData.carRentDark50 : Colors.white, ), child: Padding( - padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10), + padding: const EdgeInsets.symmetric( + vertical: 10, + horizontal: 10, + ), child: Row( children: [ ClipRRect( //borderRadius: BorderRadius.circular(10), child: CachedNetworkImage( - imageUrl: vehicleType.rentalVehicleIcon.toString(), + imageUrl: + vehicleType + .rentalVehicleIcon + .toString(), height: 60, width: 60, imageBuilder: - (context, imageProvider) => - Container(decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), image: DecorationImage(image: imageProvider, fit: BoxFit.cover))), - placeholder: (context, url) => Center(child: CircularProgressIndicator.adaptive(valueColor: AlwaysStoppedAnimation(AppThemeData.primary300))), - errorWidget: (context, url, error) => Image.network(Constant.placeHolderImage, fit: BoxFit.cover), + ( + context, + imageProvider, + ) => Container( + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular( + 10, + ), + image: DecorationImage( + image: imageProvider, + fit: BoxFit.cover, + ), + ), + ), + placeholder: + (context, url) => Center( + child: CircularProgressIndicator.adaptive( + valueColor: + AlwaysStoppedAnimation( + AppThemeData + .primary300, + ), + ), + ), + errorWidget: + (context, url, error) => + Image.network( + Constant + .placeHolderImage, + fit: BoxFit.cover, + ), fit: BoxFit.cover, ), ), Expanded( child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10), + padding: + const EdgeInsets.symmetric( + horizontal: 10, + ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( "${vehicleType.name}", style: TextStyle( fontSize: 16, - fontWeight: FontWeight.bold, + fontWeight: + FontWeight.bold, letterSpacing: 1, color: isDark - ? controller.selectedVehicleType.value?.id == vehicleType.id - ? AppThemeData.greyDark50 - : AppThemeData.grey50 - : AppThemeData.greyDark50, + ? controller + .selectedVehicleType + .value + ?.id == + vehicleType + .id + ? AppThemeData + .greyDark50 + : AppThemeData + .grey50 + : AppThemeData + .greyDark50, ), ), Padding( - padding: const EdgeInsets.only(top: 2.0), + padding: + const EdgeInsets.only( + top: 2.0, + ), child: Text( "${vehicleType.description}", style: TextStyle( - fontWeight: FontWeight.w400, + fontWeight: + FontWeight.w400, letterSpacing: 1, color: isDark - ? controller.selectedVehicleType.value?.id == vehicleType.id - ? AppThemeData.greyDark50 - : AppThemeData.grey50 - : AppThemeData.greyDark50, + ? controller + .selectedVehicleType + .value + ?.id == + vehicleType + .id + ? AppThemeData + .greyDark50 + : AppThemeData + .grey50 + : AppThemeData + .greyDark50, ), ), ), @@ -249,30 +410,46 @@ class RentalHomeScreen extends StatelessWidget { RoundedButtonFill( title: "Continue".tr, onPress: () async { - final sourceText = controller.sourceTextEditController.value.text.trim(); + final sourceText = + controller.sourceTextEditController.value.text + .trim(); if (Constant.userModel == null) { - ShowToastDialog.showToast("Please login to continue".tr); + ShowToastDialog.showToast( + "Please login to continue".tr, + ); return; } if (sourceText.isEmpty) { - ShowToastDialog.showToast("Please select source location".tr); + ShowToastDialog.showToast( + "Please select source location".tr, + ); return; } - if (controller.selectedVehicleType.value == null) { - ShowToastDialog.showToast("Please select a vehicle type".tr); + if (controller.selectedVehicleType.value == + null) { + ShowToastDialog.showToast( + "Please select a vehicle type".tr, + ); return; } await controller.getRentalPackage(); if (controller.rentalPackages.isEmpty) { - ShowToastDialog.showToast("No preference available for the selected vehicle type".tr); + ShowToastDialog.showToast( + "No preference available for the selected vehicle type" + .tr, + ); return; } // Open bottom sheet if packages exist - Get.bottomSheet(selectPreferences(context, controller, isDark), isScrollControlled: true, backgroundColor: Colors.transparent); + Get.bottomSheet( + selectPreferences(context, controller, isDark), + isScrollControlled: true, + backgroundColor: Colors.transparent, + ); }, color: AppThemeData.primary300, textColor: AppThemeData.grey900, @@ -288,7 +465,11 @@ class RentalHomeScreen extends StatelessWidget { ); } - Widget selectPreferences(BuildContext context, RentalHomeController controller, bool isDark) { + Widget selectPreferences( + BuildContext context, + RentalHomeController controller, + bool isDark, + ) { return DraggableScrollableSheet( initialChildSize: 0.40, minChildSize: 0.40, @@ -296,19 +477,39 @@ class RentalHomeScreen extends StatelessWidget { expand: false, builder: (context, scrollController) { return Container( - decoration: BoxDecoration(color: isDark ? Colors.black : Colors.white, borderRadius: const BorderRadius.only(topLeft: Radius.circular(24), topRight: Radius.circular(24))), + decoration: BoxDecoration( + color: isDark ? Colors.black : Colors.white, + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(24), + topRight: Radius.circular(24), + ), + ), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 15.0, vertical: 10), child: Column( children: [ // handle bar - Container(height: 4, width: 33, decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), color: Colors.grey.shade400)), + Container( + height: 4, + width: 33, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.grey.shade400, + ), + ), Align( alignment: Alignment.topLeft, child: Padding( padding: const EdgeInsets.symmetric(vertical: 10), - child: Text("Select Preferences".tr, style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18, color: isDark ? Colors.white : Colors.black)), + child: Text( + "Select Preferences".tr, + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18, + color: isDark ? Colors.white : Colors.black, + ), + ), ), ), @@ -320,30 +521,43 @@ class RentalHomeScreen extends StatelessWidget { final package = controller.rentalPackages[index]; return Obx( () => InkWell( - onTap: () => controller.selectedPackage.value = package, + onTap: + () => controller.selectedPackage.value = package, child: Container( margin: const EdgeInsets.symmetric(vertical: 6), decoration: BoxDecoration( borderRadius: BorderRadius.circular(12), border: Border.all( - color: controller.selectedPackage.value?.id == package.id ? (isDark ? AppThemeData.carRentDark300 : AppThemeData.carRent300) : Colors.transparent, + color: + controller.selectedPackage.value?.id == + package.id + ? (isDark + ? AppThemeData.carRentDark300 + : AppThemeData.carRent300) + : Colors.transparent, width: 1, ), color: - controller.selectedPackage.value?.id == package.id + controller.selectedPackage.value?.id == + package.id ? AppThemeData.carRent50 : isDark ? AppThemeData.carRentDark50 : Colors.white, ), child: Padding( - padding: const EdgeInsets.symmetric(vertical: 15, horizontal: 12), + padding: const EdgeInsets.symmetric( + vertical: 15, + horizontal: 12, + ), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ Expanded( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( package.name ?? "", @@ -351,8 +565,13 @@ class RentalHomeScreen extends StatelessWidget { fontSize: 18, color: isDark - ? controller.selectedPackage.value?.id == package.id - ? AppThemeData.greyDark50 + ? controller + .selectedPackage + .value + ?.id == + package.id + ? AppThemeData + .greyDark50 : AppThemeData.grey50 : AppThemeData.greyDark50, ), @@ -364,8 +583,13 @@ class RentalHomeScreen extends StatelessWidget { fontSize: 14, color: isDark - ? controller.selectedPackage.value?.id == package.id - ? AppThemeData.greyDark50 + ? controller + .selectedPackage + .value + ?.id == + package.id + ? AppThemeData + .greyDark50 : AppThemeData.grey50 : AppThemeData.greyDark50, ), @@ -374,12 +598,18 @@ class RentalHomeScreen extends StatelessWidget { ), ), Text( - Constant.amountShow(amount: package.baseFare.toString()), + Constant.amountShow( + amount: package.baseFare.toString(), + ), style: AppThemeData.boldTextStyle( fontSize: 18, color: isDark - ? controller.selectedPackage.value?.id == package.id + ? controller + .selectedPackage + .value + ?.id == + package.id ? AppThemeData.greyDark50 : AppThemeData.grey50 : AppThemeData.greyDark50, @@ -400,7 +630,11 @@ class RentalHomeScreen extends StatelessWidget { RoundedButtonFill( title: "Continue".tr, onPress: () { - Get.bottomSheet(paymentBottomSheet(context, controller, isDark), isScrollControlled: true, backgroundColor: Colors.transparent); + Get.bottomSheet( + paymentBottomSheet(context, controller, isDark), + isScrollControlled: true, + backgroundColor: Colors.transparent, + ); }, color: AppThemeData.primary300, textColor: AppThemeData.grey900, @@ -413,7 +647,11 @@ class RentalHomeScreen extends StatelessWidget { ); } - Widget paymentBottomSheet(BuildContext context, RentalHomeController controller, bool isDark) { + Widget paymentBottomSheet( + BuildContext context, + RentalHomeController controller, + bool isDark, + ) { return DraggableScrollableSheet( initialChildSize: 0.70, // Start height @@ -426,7 +664,10 @@ class RentalHomeScreen extends StatelessWidget { builder: (context, scrollController) { return Container( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20), - decoration: BoxDecoration(color: isDark ? AppThemeData.grey500 : Colors.white, borderRadius: const BorderRadius.vertical(top: Radius.circular(24))), + decoration: BoxDecoration( + color: isDark ? AppThemeData.grey500 : Colors.white, + borderRadius: const BorderRadius.vertical(top: Radius.circular(24)), + ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -434,8 +675,20 @@ class RentalHomeScreen extends StatelessWidget { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text("Select Payment Method".tr, style: AppThemeData.mediumTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), - GestureDetector(onTap: () => Get.back(), child: const Icon(Icons.close)), + Text( + "Select Payment Method".tr, + style: AppThemeData.mediumTextStyle( + fontSize: 18, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + GestureDetector( + onTap: () => Get.back(), + child: const Icon(Icons.close), + ), ], ), const SizedBox(height: 20), @@ -446,39 +699,89 @@ class RentalHomeScreen extends StatelessWidget { padding: EdgeInsets.zero, controller: scrollController, children: [ - Text("Preferred Payment".tr, style: AppThemeData.boldTextStyle(fontSize: 15, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500)), + Text( + "Preferred Payment".tr, + style: AppThemeData.boldTextStyle( + fontSize: 15, + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), + ), const SizedBox(height: 10), - if (controller.walletSettingModel.value.isEnabled == true || controller.cashOnDeliverySettingModel.value.isEnabled == true) + if (controller.walletSettingModel.value.isEnabled == true || + controller.cashOnDeliverySettingModel.value.isEnabled == + true) Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ Visibility( - visible: controller.walletSettingModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.wallet, isDark, "assets/images/ic_wallet.png"), + visible: + controller + .walletSettingModel + .value + .isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.wallet, + isDark, + "assets/images/ic_wallet.png", + ), ), Visibility( - visible: controller.cashOnDeliverySettingModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.cod, isDark, "assets/images/ic_cash.png"), + visible: + controller + .cashOnDeliverySettingModel + .value + .isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.cod, + isDark, + "assets/images/ic_cash.png", + ), ), ], ), ), ), - if (controller.walletSettingModel.value.isEnabled == true || controller.cashOnDeliverySettingModel.value.isEnabled == true) + if (controller.walletSettingModel.value.isEnabled == true || + controller.cashOnDeliverySettingModel.value.isEnabled == + true) Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const SizedBox(height: 10), - Text("Other Payment Options".tr, style: AppThemeData.boldTextStyle(fontSize: 15, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500)), + Text( + "Other Payment Options".tr, + style: AppThemeData.boldTextStyle( + fontSize: 15, + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), + ), const SizedBox(height: 10), ], ), @@ -487,32 +790,129 @@ class RentalHomeScreen extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ - Visibility(visible: controller.stripeModel.value.isEnabled == true, child: cardDecoration(controller, PaymentGateway.stripe, isDark, "assets/images/stripe.png")), - Visibility(visible: controller.payPalModel.value.isEnabled == true, child: cardDecoration(controller, PaymentGateway.paypal, isDark, "assets/images/paypal.png")), - Visibility(visible: controller.payStackModel.value.isEnable == true, child: cardDecoration(controller, PaymentGateway.payStack, isDark, "assets/images/paystack.png")), Visibility( - visible: controller.mercadoPagoModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.mercadoPago, isDark, "assets/images/mercado-pago.png"), + visible: + controller.stripeModel.value.isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.stripe, + isDark, + "assets/images/stripe.png", + ), ), Visibility( - visible: controller.flutterWaveModel.value.isEnable == true, - child: cardDecoration(controller, PaymentGateway.flutterWave, isDark, "assets/images/flutterwave_logo.png"), + visible: + controller.payPalModel.value.isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.paypal, + isDark, + "assets/images/paypal.png", + ), ), - Visibility(visible: controller.payFastModel.value.isEnable == true, child: cardDecoration(controller, PaymentGateway.payFast, isDark, "assets/images/payfast.png")), - Visibility(visible: controller.razorPayModel.value.isEnabled == true, child: cardDecoration(controller, PaymentGateway.razorpay, isDark, "assets/images/razorpay.png")), - Visibility(visible: controller.midTransModel.value.enable == true, child: cardDecoration(controller, PaymentGateway.midTrans, isDark, "assets/images/midtrans.png")), Visibility( - visible: controller.orangeMoneyModel.value.enable == true, - child: cardDecoration(controller, PaymentGateway.orangeMoney, isDark, "assets/images/orange_money.png"), + visible: + controller.payStackModel.value.isEnable == + true, + child: cardDecoration( + controller, + PaymentGateway.payStack, + isDark, + "assets/images/paystack.png", + ), + ), + Visibility( + visible: + controller.mercadoPagoModel.value.isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.mercadoPago, + isDark, + "assets/images/mercado-pago.png", + ), + ), + Visibility( + visible: + controller.flutterWaveModel.value.isEnable == + true, + child: cardDecoration( + controller, + PaymentGateway.flutterWave, + isDark, + "assets/images/flutterwave_logo.png", + ), + ), + Visibility( + visible: + controller.payFastModel.value.isEnable == + true, + child: cardDecoration( + controller, + PaymentGateway.payFast, + isDark, + "assets/images/payfast.png", + ), + ), + Visibility( + visible: + controller.razorPayModel.value.isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.razorpay, + isDark, + "assets/images/razorpay.png", + ), + ), + Visibility( + visible: + controller.midTransModel.value.enable == true, + child: cardDecoration( + controller, + PaymentGateway.midTrans, + isDark, + "assets/images/midtrans.png", + ), + ), + Visibility( + visible: + controller.orangeMoneyModel.value.enable == + true, + child: cardDecoration( + controller, + PaymentGateway.orangeMoney, + isDark, + "assets/images/orange_money.png", + ), + ), + Visibility( + visible: + controller.xenditModel.value.enable == true, + child: cardDecoration( + controller, + PaymentGateway.xendit, + isDark, + "assets/images/xendit.png", + ), ), - Visibility(visible: controller.xenditModel.value.enable == true, child: cardDecoration(controller, PaymentGateway.xendit, isDark, "assets/images/xendit.png")), ], ), ), @@ -529,17 +929,28 @@ class RentalHomeScreen extends StatelessWidget { textColor: AppThemeData.grey900, onPress: () async { if (controller.selectedPaymentMethod.value.isEmpty) { - ShowToastDialog.showToast("Please select a payment method".tr); + ShowToastDialog.showToast( + "Please select a payment method".tr, + ); return; } // Only check wallet if payment method is wallet if (controller.selectedPaymentMethod.value == "wallet") { - num walletAmount = controller.userModel.value.walletAmount ?? 0; - num baseFare = double.tryParse(controller.selectedPackage.value?.baseFare.toString() ?? "0") ?? 0; + num walletAmount = + controller.userModel.value.walletAmount ?? 0; + num baseFare = + double.tryParse( + controller.selectedPackage.value?.baseFare + .toString() ?? + "0", + ) ?? + 0; if (walletAmount < baseFare) { - ShowToastDialog.showToast("You do not have sufficient wallet balance".tr); + ShowToastDialog.showToast( + "You do not have sufficient wallet balance".tr, + ); return; } } @@ -554,7 +965,12 @@ class RentalHomeScreen extends StatelessWidget { ); } - Obx cardDecoration(RentalHomeController controller, PaymentGateway value, isDark, String image) { + Obx cardDecoration( + RentalHomeController controller, + PaymentGateway value, + isDark, + String image, + ) { return Obx( () => Padding( padding: const EdgeInsets.symmetric(vertical: 5), @@ -569,8 +985,21 @@ class RentalHomeScreen extends StatelessWidget { Container( width: 50, height: 50, - decoration: ShapeDecoration(shape: RoundedRectangleBorder(side: const BorderSide(width: 1, color: Color(0xFFE5E7EB)), borderRadius: BorderRadius.circular(8))), - child: Padding(padding: EdgeInsets.all(value.name == "payFast" ? 0 : 8.0), child: Image.asset(image)), + decoration: ShapeDecoration( + shape: RoundedRectangleBorder( + side: const BorderSide( + width: 1, + color: Color(0xFFE5E7EB), + ), + borderRadius: BorderRadius.circular(8), + ), + ), + child: Padding( + padding: EdgeInsets.all( + value.name == "payFast" ? 0 : 8.0, + ), + child: Image.asset(image), + ), ), const SizedBox(width: 10), value.name == "wallet" @@ -581,12 +1010,34 @@ class RentalHomeScreen extends StatelessWidget { Text( value.name.capitalizeString(), textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), Text( - Constant.amountShow(amount: controller.userModel.value.walletAmount == null ? '0.0' : controller.userModel.value.walletAmount.toString()), + Constant.amountShow( + amount: + controller.userModel.value.walletAmount == + null + ? '0.0' + : controller + .userModel + .value + .walletAmount + .toString(), + ), textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(fontSize: 14, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300), + style: AppThemeData.semiBoldTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + ), ), ], ), @@ -595,14 +1046,23 @@ class RentalHomeScreen extends StatelessWidget { child: Text( value.name.capitalizeString(), textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), ), const Expanded(child: SizedBox()), Radio( value: value.name, groupValue: controller.selectedPaymentMethod.value, - activeColor: isDark ? AppThemeData.primary300 : AppThemeData.primary300, + activeColor: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, onChanged: (value) { controller.selectedPaymentMethod.value = value.toString(); }, diff --git a/lib/screen_ui/rental_service/rental_order_details_screen.dart b/lib/screen_ui/rental_service/rental_order_details_screen.dart index 6457250..f471eff 100644 --- a/lib/screen_ui/rental_service/rental_order_details_screen.dart +++ b/lib/screen_ui/rental_service/rental_order_details_screen.dart @@ -1,3 +1,4 @@ +import 'package:customer/constant/const_texts.dart'; import 'package:customer/constant/constant.dart'; import 'package:customer/models/rental_order_model.dart'; import 'package:customer/payment/createRazorPayOrderModel.dart'; @@ -7,6 +8,7 @@ import 'package:customer/screen_ui/rental_service/rental_review_screen.dart'; import 'package:customer/themes/responsive.dart'; import 'package:customer/themes/show_toast_dialog.dart'; import 'package:customer/utils/network_image_widget.dart'; + import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_svg/svg.dart'; @@ -45,12 +47,30 @@ class RentalOrderDetailsScreen extends StatelessWidget { child: Container( height: 42, width: 42, - decoration: BoxDecoration(shape: BoxShape.circle, color: AppThemeData.grey50), - child: Center(child: Padding(padding: const EdgeInsets.only(left: 5), child: Icon(Icons.arrow_back_ios, color: AppThemeData.grey900, size: 20))), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: AppThemeData.grey50, + ), + child: Center( + child: Padding( + padding: const EdgeInsets.only(left: 5), + child: Icon( + Icons.arrow_back_ios, + color: AppThemeData.grey900, + size: 20, + ), + ), + ), ), ), const SizedBox(width: 10), - Text("Order Details".tr, style: AppThemeData.boldTextStyle(fontSize: 18, color: AppThemeData.grey900)), + Text( + "Order Details".tr, + style: AppThemeData.boldTextStyle( + fontSize: 18, + color: AppThemeData.grey900, + ), + ), ], ), ), @@ -63,7 +83,10 @@ class RentalOrderDetailsScreen extends StatelessWidget { Expanded( child: SingleChildScrollView( child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 20, + ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -71,8 +94,16 @@ class RentalOrderDetailsScreen extends StatelessWidget { padding: const EdgeInsets.all(16), decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), child: Column( children: [ @@ -81,13 +112,31 @@ class RentalOrderDetailsScreen extends StatelessWidget { Expanded( child: Text( "${'Booking Id :'.tr} ${controller.order.value.id}", - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark700 : AppThemeData.grey700), + style: + AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData + .greyDark700 + : AppThemeData + .grey700, + ), ), ), InkWell( onTap: () { - Clipboard.setData(ClipboardData(text: controller.order.value.id.toString())); - ShowToastDialog.showToast("Booking ID copied to clipboard".tr); + Clipboard.setData( + ClipboardData( + text: + controller.order.value.id + .toString(), + ), + ); + ShowToastDialog.showToast( + "Booking ID copied to clipboard" + .tr, + ); }, child: Icon(Icons.copy), ), @@ -95,22 +144,64 @@ class RentalOrderDetailsScreen extends StatelessWidget { ), SizedBox(height: 10), Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ - Padding(padding: const EdgeInsets.only(top: 5), child: Image.asset("assets/icons/pickup.png", height: 15, width: 15)), + Padding( + padding: const EdgeInsets.only( + top: 5, + ), + child: Image.asset( + "assets/icons/pickup.png", + height: 15, + width: 15, + ), + ), const SizedBox(width: 15), Expanded( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( - controller.order.value.sourceLocationName ?? "-", - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + controller + .order + .value + .sourceLocationName ?? + "-", + style: + AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), ), - if (controller.order.value.bookingDateTime != null) + if (controller + .order + .value + .bookingDateTime != + null) Text( - Constant.timestampToDate(controller.order.value.bookingDateTime!), - style: AppThemeData.semiBoldTextStyle(fontSize: 12, color: isDark ? AppThemeData.greyDark600 : AppThemeData.grey600), + Constant.timestampToDate( + controller + .order + .value + .bookingDateTime!, + ), + style: + AppThemeData.semiBoldTextStyle( + fontSize: 12, + color: + isDark + ? AppThemeData + .greyDark600 + : AppThemeData + .grey600, + ), ), ], ), @@ -121,43 +212,107 @@ class RentalOrderDetailsScreen extends StatelessWidget { ), ), const SizedBox(height: 15), - if (controller.order.value.rentalPackageModel != null) + if (controller.order.value.rentalPackageModel != + null) Container( padding: const EdgeInsets.all(16), decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ - Text("Your Preference".tr, style: AppThemeData.boldTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500)), + Text( + "Your Preference".tr, + style: AppThemeData.boldTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), + ), SizedBox(height: 10), Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ Expanded( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( - controller.order.value.rentalPackageModel!.name ?? "-", - style: AppThemeData.semiBoldTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + controller + .order + .value + .rentalPackageModel! + .name ?? + "-", + style: + AppThemeData.semiBoldTextStyle( + fontSize: 18, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), ), const SizedBox(height: 4), Text( - controller.order.value.rentalPackageModel!.description ?? "", - style: AppThemeData.mediumTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark600 : AppThemeData.grey600), + controller + .order + .value + .rentalPackageModel! + .description ?? + "", + style: + AppThemeData.mediumTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData + .greyDark600 + : AppThemeData + .grey600, + ), ), ], ), ), const SizedBox(width: 10), Text( - Constant.amountShow(amount: controller.order.value.rentalPackageModel!.baseFare.toString()), - style: AppThemeData.boldTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + Constant.amountShow( + amount: + controller + .order + .value + .rentalPackageModel! + .baseFare + .toString(), + ), + style: AppThemeData.boldTextStyle( + fontSize: 18, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData.grey900, + ), ), ], ), @@ -170,19 +325,43 @@ class RentalOrderDetailsScreen extends StatelessWidget { children: [ Container( decoration: BoxDecoration( - borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + borderRadius: BorderRadius.circular( + 15, + ), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), padding: const EdgeInsets.all(16), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ - Text("About Driver".tr, style: AppThemeData.boldTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500)), + Text( + "About Driver".tr, + style: AppThemeData.boldTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData + .greyDark500 + : AppThemeData.grey500, + ), + ), const SizedBox(height: 8), Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Row( children: [ @@ -190,109 +369,279 @@ class RentalOrderDetailsScreen extends StatelessWidget { width: 52, height: 52, child: ClipRRect( - borderRadius: BorderRadiusGeometry.circular(10), - child: NetworkImageWidget(imageUrl: controller.driverUser.value?.profilePictureURL ?? '', height: 70, width: 70, borderRadius: 35), + borderRadius: + BorderRadiusGeometry.circular( + 10, + ), + child: NetworkImageWidget( + imageUrl: + controller + .driverUser + .value + ?.profilePictureURL ?? + '', + height: 70, + width: 70, + borderRadius: 35, + ), ), ), SizedBox(width: 20), Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ Text( - controller.order.value.driver?.fullName() ?? '', - style: AppThemeData.boldTextStyle(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, fontSize: 18), + controller + .order + .value + .driver + ?.fullName() ?? + '', + style: AppThemeData.boldTextStyle( + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + fontSize: 18, + ), ), Text( "${controller.order.value.driver?.vehicleType ?? ''} | ${controller.order.value.driver?.carMakes.toString()}", - style: TextStyle(fontFamily: AppThemeData.medium, color: isDark ? AppThemeData.greyDark700 : AppThemeData.grey700, fontSize: 14), + style: TextStyle( + fontFamily: + AppThemeData + .medium, + color: + isDark + ? AppThemeData + .greyDark700 + : AppThemeData + .grey700, + fontSize: 14, + ), ), Text( - controller.order.value.driver?.carNumber ?? '', - style: AppThemeData.boldTextStyle(color: isDark ? AppThemeData.greyDark700 : AppThemeData.grey700, fontSize: 16), + controller + .order + .value + .driver + ?.carNumber ?? + '', + style: AppThemeData.boldTextStyle( + color: + isDark + ? AppThemeData + .greyDark700 + : AppThemeData + .grey700, + fontSize: 16, + ), ), ], ), ], ), RoundedButtonBorder( - title: controller.driverUser.value?.averageRating.toString() ?? '', + title: + controller + .driverUser + .value + ?.averageRating + .toString() ?? + '', width: 20, height: 3.5, radius: 10, isRight: false, isCenter: true, - textColor: AppThemeData.warning400, - borderColor: AppThemeData.warning400, + textColor: + AppThemeData.warning400, + borderColor: + AppThemeData.warning400, color: AppThemeData.warning50, - icon: SvgPicture.asset("assets/icons/ic_start.svg"), + icon: SvgPicture.asset( + "assets/icons/ic_start.svg", + ), onPress: () {}, ), ], ), Visibility( - visible: controller.order.value.status == Constant.orderCompleted ? true : false, + visible: + controller + .order + .value + .status == + Constant + .orderCompleted + ? true + : false, child: Padding( - padding: const EdgeInsets.symmetric(vertical: 10), + padding: + const EdgeInsets.symmetric( + vertical: 10, + ), child: RoundedButtonFill( - title: controller.ratingModel.value.id != null && controller.ratingModel.value.id!.isNotEmpty ? 'Update Review'.tr : 'Add Review'.tr, + title: + controller + .ratingModel + .value + .id != + null && + controller + .ratingModel + .value + .id! + .isNotEmpty + ? 'Update Review'.tr + : 'Add Review'.tr, onPress: () async { - final result = await Get.to(() => RentalReviewScreen(), arguments: {'order': controller.order.value}); + final result = await Get.to( + () => + RentalReviewScreen(), + arguments: { + 'order': + controller + .order + .value, + }, + ); // If review was submitted successfully if (result == true) { - await controller.fetchDriverDetails(); + await controller + .fetchDriverDetails(); } }, height: 5, borderRadius: 15, color: Colors.orange, - textColor: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + textColor: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, ), ), ), - controller.order.value.status == Constant.orderCompleted || controller.order.value.status == Constant.orderCancelled + controller.order.value.status == + Constant + .orderCompleted || + controller + .order + .value + .status == + Constant.orderCancelled ? SizedBox() : Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, children: [ InkWell( onTap: () { - Constant.makePhoneCall(controller.order.value.driver!.phoneNumber ?? ''); + Constant.makePhoneCall( + controller + .order + .value + .driver! + .phoneNumber ?? + '', + ); }, child: Container( width: 150, height: 42, decoration: ShapeDecoration( shape: RoundedRectangleBorder( - side: BorderSide(width: 1, color: isDark ? AppThemeData.grey700 : AppThemeData.grey200), - borderRadius: BorderRadius.circular(120), + side: BorderSide( + width: 1, + color: + isDark + ? AppThemeData + .grey700 + : AppThemeData + .grey200, + ), + borderRadius: + BorderRadius.circular( + 120, + ), + ), + ), + child: Padding( + padding: + const EdgeInsets.all( + 8.0, + ), + child: SvgPicture.asset( + "assets/icons/ic_phone_call.svg", ), ), - child: Padding(padding: const EdgeInsets.all(8.0), child: SvgPicture.asset("assets/icons/ic_phone_call.svg")), ), ), const SizedBox(width: 10), InkWell( onTap: () async { - ShowToastDialog.showLoader("Please wait...".tr); + ShowToastDialog.showLoader( + ConstTexts + .pleaseWait + .tr, + ); - UserModel? customer = await FireStoreUtils.getUserProfile(controller.order.value.authorID ?? ''); - UserModel? driverUser = await FireStoreUtils.getUserProfile(controller.order.value.driverId ?? ''); + UserModel? customer = + await FireStoreUtils.getUserProfile( + controller + .order + .value + .authorID ?? + '', + ); + UserModel? driverUser = + await FireStoreUtils.getUserProfile( + controller + .order + .value + .driverId ?? + '', + ); ShowToastDialog.closeLoader(); Get.to( const ChatScreen(), arguments: { - "customerName": customer?.fullName(), - "restaurantName": driverUser?.fullName(), - "orderId": controller.order.value.id, - "restaurantId": driverUser?.id, - "customerId": customer?.id, - "customerProfileImage": customer?.profilePictureURL, - "restaurantProfileImage": driverUser?.profilePictureURL, - "token": driverUser?.fcmToken, - "chatType": "Driver", + "customerName": + customer + ?.fullName(), + "restaurantName": + driverUser + ?.fullName(), + "orderId": + controller + .order + .value + .id, + "restaurantId": + driverUser?.id, + "customerId": + customer?.id, + "customerProfileImage": + customer + ?.profilePictureURL, + "restaurantProfileImage": + driverUser + ?.profilePictureURL, + "token": + driverUser + ?.fcmToken, + "chatType": + "Driver", }, ); }, @@ -301,11 +650,30 @@ class RentalOrderDetailsScreen extends StatelessWidget { height: 42, decoration: ShapeDecoration( shape: RoundedRectangleBorder( - side: BorderSide(width: 1, color: isDark ? AppThemeData.grey700 : AppThemeData.grey200), - borderRadius: BorderRadius.circular(120), + side: BorderSide( + width: 1, + color: + isDark + ? AppThemeData + .grey700 + : AppThemeData + .grey200, + ), + borderRadius: + BorderRadius.circular( + 120, + ), + ), + ), + child: Padding( + padding: + const EdgeInsets.all( + 8.0, + ), + child: SvgPicture.asset( + "assets/icons/ic_wechat.svg", ), ), - child: Padding(padding: const EdgeInsets.all(8.0), child: SvgPicture.asset("assets/icons/ic_wechat.svg")), ), ), ], @@ -316,37 +684,96 @@ class RentalOrderDetailsScreen extends StatelessWidget { const SizedBox(height: 15), ], ), - if (controller.order.value.rentalVehicleType != null) + if (controller.order.value.rentalVehicleType != + null) Container( padding: const EdgeInsets.all(16), decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ - Text("Vehicle Type".tr, style: AppThemeData.boldTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500)), + Text( + "Vehicle Type".tr, + style: AppThemeData.boldTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), + ), SizedBox(height: 10), Row( children: [ ClipRRect( - borderRadius: BorderRadius.circular(10), - child: NetworkImageWidget(imageUrl: controller.order.value.rentalVehicleType!.rentalVehicleIcon ?? "", height: 50, width: 50), + borderRadius: + BorderRadius.circular(10), + child: NetworkImageWidget( + imageUrl: + controller + .order + .value + .rentalVehicleType! + .rentalVehicleIcon ?? + "", + height: 50, + width: 50, + ), ), const SizedBox(width: 10), Expanded( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( - controller.order.value.rentalVehicleType!.name ?? "", - style: AppThemeData.semiBoldTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + controller + .order + .value + .rentalVehicleType! + .name ?? + "", + style: + AppThemeData.semiBoldTextStyle( + fontSize: 18, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), ), Text( - controller.order.value.rentalVehicleType!.shortDescription ?? "", - style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark600 : AppThemeData.grey600), + controller + .order + .value + .rentalVehicleType! + .shortDescription ?? + "", + style: + AppThemeData.mediumTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData + .greyDark600 + : AppThemeData + .grey600, + ), ), ], ), @@ -363,107 +790,249 @@ class RentalOrderDetailsScreen extends StatelessWidget { width: Responsive.width(100, context), decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ - Text("Rental Details".tr, style: AppThemeData.boldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), - Divider(color: isDark ? AppThemeData.greyDark300 : AppThemeData.grey300), + Text( + "Rental Details".tr, + style: AppThemeData.boldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), + Divider( + color: + isDark + ? AppThemeData.greyDark300 + : AppThemeData.grey300, + ), Padding( - padding: const EdgeInsets.symmetric(vertical: 10), + padding: const EdgeInsets.symmetric( + vertical: 10, + ), child: Row( children: [ Expanded( child: Text( 'Rental Package'.tr, textAlign: TextAlign.start, - style: AppThemeData.mediumTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: + AppThemeData.mediumTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), ), ), Text( - controller.order.value.rentalPackageModel!.name.toString().tr, + controller + .order + .value + .rentalPackageModel! + .name + .toString() + .tr, textAlign: TextAlign.start, - style: AppThemeData.boldTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: + AppThemeData.boldTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), ), ], ), ), Padding( - padding: const EdgeInsets.symmetric(vertical: 10), + padding: const EdgeInsets.symmetric( + vertical: 10, + ), child: Row( children: [ Expanded( child: Text( 'Rental Package Price'.tr, textAlign: TextAlign.start, - style: AppThemeData.mediumTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: + AppThemeData.mediumTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), ), ), Text( - Constant.amountShow(amount: controller.order.value.rentalPackageModel!.baseFare.toString()).tr, + Constant.amountShow( + amount: + controller + .order + .value + .rentalPackageModel! + .baseFare + .toString(), + ).tr, textAlign: TextAlign.start, - style: AppThemeData.boldTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: + AppThemeData.boldTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), ), ], ), ), Padding( - padding: const EdgeInsets.symmetric(vertical: 10), + padding: const EdgeInsets.symmetric( + vertical: 10, + ), child: Row( children: [ Expanded( child: Text( '${'Including'.tr} ${Constant.distanceType.tr}', textAlign: TextAlign.start, - style: AppThemeData.mediumTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: + AppThemeData.mediumTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), ), ), Text( - "${controller.order.value.rentalPackageModel!.includedDistance.toString()} ${Constant.distanceType}".tr, + "${controller.order.value.rentalPackageModel!.includedDistance.toString()} ${Constant.distanceType}" + .tr, textAlign: TextAlign.start, - style: AppThemeData.boldTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: + AppThemeData.boldTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), ), ], ), ), Padding( - padding: const EdgeInsets.symmetric(vertical: 10), + padding: const EdgeInsets.symmetric( + vertical: 10, + ), child: Row( children: [ Expanded( child: Text( 'Including Hours'.tr, textAlign: TextAlign.start, - style: AppThemeData.mediumTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: + AppThemeData.mediumTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), ), ), Text( - "${controller.order.value.rentalPackageModel!.includedHours.toString()} ${'Hr'.tr}".tr, + "${controller.order.value.rentalPackageModel!.includedHours.toString()} ${'Hr'.tr}" + .tr, textAlign: TextAlign.start, - style: AppThemeData.boldTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: + AppThemeData.boldTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), ), ], ), ), Padding( - padding: const EdgeInsets.symmetric(vertical: 10), + padding: const EdgeInsets.symmetric( + vertical: 10, + ), child: Row( children: [ Expanded( child: Text( '${'Extra'.tr} ${Constant.distanceType}', textAlign: TextAlign.start, - style: AppThemeData.mediumTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: + AppThemeData.mediumTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), ), ), Text( controller.getExtraKm(), textAlign: TextAlign.start, - style: AppThemeData.boldTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: + AppThemeData.boldTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), ), ], ), @@ -491,20 +1060,41 @@ class RentalOrderDetailsScreen extends StatelessWidget { controller.order.value.endTime == null ? SizedBox() : Padding( - padding: const EdgeInsets.symmetric(vertical: 10), + padding: + const EdgeInsets.symmetric( + vertical: 10, + ), child: Row( children: [ Expanded( child: Text( 'Extra Minutes'.tr, - textAlign: TextAlign.start, - style: AppThemeData.mediumTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + textAlign: + TextAlign.start, + style: AppThemeData.mediumTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), ), ), Text( "${controller.order.value.endTime == null ? "0" : (((controller.order.value.endTime!.toDate().difference(controller.order.value.startTime!.toDate()).inMinutes) - (int.parse(controller.order.value.rentalPackageModel!.includedHours.toString()) * 60)).clamp(0, double.infinity).toInt().toString())} ${'Min'.tr}", textAlign: TextAlign.start, - style: AppThemeData.boldTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + style: + AppThemeData.boldTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData + .greyDark900 + : AppThemeData + .grey900, + ), ), ], ), @@ -518,31 +1108,99 @@ class RentalOrderDetailsScreen extends StatelessWidget { padding: const EdgeInsets.all(16), decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ - Text("Order Summary".tr, style: AppThemeData.boldTextStyle(fontSize: 14, color: AppThemeData.grey500)), + Text( + "Order Summary".tr, + style: AppThemeData.boldTextStyle( + fontSize: 14, + color: AppThemeData.grey500, + ), + ), const SizedBox(height: 8), - _summaryTile("Subtotal".tr, Constant.amountShow(amount: controller.subTotal.value.toString()), isDark, null), - _summaryTile("Discount".tr, Constant.amountShow(amount: controller.discount.value.toString()), isDark, AppThemeData.dangerDark300), + _summaryTile( + "Subtotal".tr, + Constant.amountShow( + amount: + controller.subTotal.value + .toString(), + ), + isDark, + null, + ), + _summaryTile( + "Discount".tr, + Constant.amountShow( + amount: + controller.discount.value + .toString(), + ), + isDark, + AppThemeData.dangerDark300, + ), - ...List.generate(controller.order.value.taxSetting?.length ?? 0, (index) { - final taxModel = controller.order.value.taxSetting![index]; - final taxTitle = "${taxModel.title} ${taxModel.type == 'fix' ? '(${Constant.amountShow(amount: taxModel.tax)})' : '(${taxModel.tax}%)'}"; - return _summaryTile( - taxTitle, - Constant.amountShow(amount: Constant.getTaxValue(amount: (controller.subTotal.value - controller.discount.value).toString(), taxModel: taxModel).toString()), - isDark, - null, - ); - }), + ...List.generate( + controller + .order + .value + .taxSetting + ?.length ?? + 0, + (index) { + final taxModel = + controller + .order + .value + .taxSetting![index]; + final taxTitle = + "${taxModel.title} ${taxModel.type == 'fix' ? '(${Constant.amountShow(amount: taxModel.tax)})' : '(${taxModel.tax}%)'}"; + return _summaryTile( + taxTitle, + Constant.amountShow( + amount: + Constant.getTaxValue( + amount: + (controller + .subTotal + .value - + controller + .discount + .value) + .toString(), + taxModel: taxModel, + ).toString(), + ), + isDark, + null, + ); + }, + ), const Divider(), - _summaryTile("Order Total".tr, Constant.amountShow(amount: controller.totalAmount.value.toString()), isDark, null), + _summaryTile( + "Order Total".tr, + Constant.amountShow( + amount: + controller.totalAmount.value + .toString(), + ), + isDark, + null, + ), ], ), ), @@ -552,32 +1210,66 @@ class RentalOrderDetailsScreen extends StatelessWidget { ), ), Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 10, + ), child: Row( children: [ - if (controller.order.value.status == Constant.orderInTransit && controller.order.value.paymentStatus == false) + if (controller.order.value.status == + Constant.orderInTransit && + controller.order.value.paymentStatus == false) Expanded( child: RoundedButtonFill( title: "Pay Now", onPress: () { - if (controller.order.value.endKitoMetersReading == null || - controller.order.value.endKitoMetersReading == "0.0" || - controller.order.value.endKitoMetersReading!.isEmpty) { - ShowToastDialog.showToast("You are not able to pay now until driver adds kilometer".tr); + if (controller + .order + .value + .endKitoMetersReading == + null || + controller + .order + .value + .endKitoMetersReading == + "0.0" || + controller + .order + .value + .endKitoMetersReading! + .isEmpty) { + ShowToastDialog.showToast( + "You are not able to pay now until driver adds kilometer" + .tr, + ); } else { - Get.bottomSheet(paymentBottomSheet(context, controller, isDark, controller.order.value), isScrollControlled: true, backgroundColor: Colors.transparent); + Get.bottomSheet( + paymentBottomSheet( + context, + controller, + isDark, + controller.order.value, + ), + isScrollControlled: true, + backgroundColor: Colors.transparent, + ); } }, color: AppThemeData.primary300, textColor: AppThemeData.grey900, ), ), - if (controller.order.value.status == Constant.orderPlaced || controller.order.value.status == Constant.driverAccepted) + if (controller.order.value.status == + Constant.orderPlaced || + controller.order.value.status == + Constant.driverAccepted) Expanded( child: RoundedButtonFill( title: "Cancel Booking", onPress: () { - controller.cancelRentalRequest(controller.order.value); + controller.cancelRentalRequest( + controller.order.value, + ); }, color: AppThemeData.danger300, textColor: AppThemeData.surface, @@ -599,14 +1291,33 @@ class RentalOrderDetailsScreen extends StatelessWidget { child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text(title, style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800)), - Text(value, style: AppThemeData.semiBoldTextStyle(fontSize: title == "Order Total" ? 18 : 16, color: colors ?? (isDark ? AppThemeData.greyDark900 : AppThemeData.grey900))), + Text( + title, + style: AppThemeData.mediumTextStyle( + fontSize: 16, + color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800, + ), + ), + Text( + value, + style: AppThemeData.semiBoldTextStyle( + fontSize: title == "Order Total" ? 18 : 16, + color: + colors ?? + (isDark ? AppThemeData.greyDark900 : AppThemeData.grey900), + ), + ), ], ), ); } - Widget paymentBottomSheet(BuildContext context, RentalOrderDetailsController controller, bool isDark, RentalOrderModel orderModel) { + Widget paymentBottomSheet( + BuildContext context, + RentalOrderDetailsController controller, + bool isDark, + RentalOrderModel orderModel, + ) { return DraggableScrollableSheet( initialChildSize: 0.70, // Start height @@ -619,14 +1330,26 @@ class RentalOrderDetailsScreen extends StatelessWidget { builder: (context, scrollController) { return Container( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20), - decoration: BoxDecoration(color: isDark ? AppThemeData.grey500 : Colors.white, borderRadius: BorderRadius.vertical(top: Radius.circular(24))), + decoration: BoxDecoration( + color: isDark ? AppThemeData.grey500 : Colors.white, + borderRadius: BorderRadius.vertical(top: Radius.circular(24)), + ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text("Select Payment Method".tr, style: AppThemeData.mediumTextStyle(fontSize: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + "Select Payment Method".tr, + style: AppThemeData.mediumTextStyle( + fontSize: 18, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), GestureDetector( onTap: () { Get.back(); @@ -641,32 +1364,74 @@ class RentalOrderDetailsScreen extends StatelessWidget { padding: EdgeInsets.zero, controller: scrollController, children: [ - Text("Preferred Payment".tr, textAlign: TextAlign.start, style: AppThemeData.boldTextStyle(fontSize: 15, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500)), + Text( + "Preferred Payment".tr, + textAlign: TextAlign.start, + style: AppThemeData.boldTextStyle( + fontSize: 15, + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), + ), const SizedBox(height: 10), - if (controller.walletSettingModel.value.isEnabled == true || controller.cashOnDeliverySettingModel.value.isEnabled == true) + if (controller.walletSettingModel.value.isEnabled == true || + controller.cashOnDeliverySettingModel.value.isEnabled == + true) Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ Visibility( - visible: controller.walletSettingModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.wallet, isDark, "assets/images/ic_wallet.png"), + visible: + controller + .walletSettingModel + .value + .isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.wallet, + isDark, + "assets/images/ic_wallet.png", + ), ), Visibility( - visible: controller.cashOnDeliverySettingModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.cod, isDark, "assets/images/ic_cash.png"), + visible: + controller + .cashOnDeliverySettingModel + .value + .isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.cod, + isDark, + "assets/images/ic_cash.png", + ), ), ], ), ), ), - if (controller.walletSettingModel.value.isEnabled == true || controller.cashOnDeliverySettingModel.value.isEnabled == true) + if (controller.walletSettingModel.value.isEnabled == true || + controller.cashOnDeliverySettingModel.value.isEnabled == + true) Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -674,7 +1439,13 @@ class RentalOrderDetailsScreen extends StatelessWidget { Text( "Other Payment Options".tr, textAlign: TextAlign.start, - style: AppThemeData.boldTextStyle(fontSize: 15, color: isDark ? AppThemeData.greyDark500 : AppThemeData.grey500), + style: AppThemeData.boldTextStyle( + fontSize: 15, + color: + isDark + ? AppThemeData.greyDark500 + : AppThemeData.grey500, + ), ), const SizedBox(height: 10), ], @@ -682,32 +1453,129 @@ class RentalOrderDetailsScreen extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - border: Border.all(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + border: Border.all( + color: + isDark + ? AppThemeData.greyDark200 + : AppThemeData.grey200, + ), ), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ - Visibility(visible: controller.stripeModel.value.isEnabled == true, child: cardDecoration(controller, PaymentGateway.stripe, isDark, "assets/images/stripe.png")), - Visibility(visible: controller.payPalModel.value.isEnabled == true, child: cardDecoration(controller, PaymentGateway.paypal, isDark, "assets/images/paypal.png")), - Visibility(visible: controller.payStackModel.value.isEnable == true, child: cardDecoration(controller, PaymentGateway.payStack, isDark, "assets/images/paystack.png")), Visibility( - visible: controller.mercadoPagoModel.value.isEnabled == true, - child: cardDecoration(controller, PaymentGateway.mercadoPago, isDark, "assets/images/mercado-pago.png"), + visible: + controller.stripeModel.value.isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.stripe, + isDark, + "assets/images/stripe.png", + ), ), Visibility( - visible: controller.flutterWaveModel.value.isEnable == true, - child: cardDecoration(controller, PaymentGateway.flutterWave, isDark, "assets/images/flutterwave_logo.png"), + visible: + controller.payPalModel.value.isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.paypal, + isDark, + "assets/images/paypal.png", + ), ), - Visibility(visible: controller.payFastModel.value.isEnable == true, child: cardDecoration(controller, PaymentGateway.payFast, isDark, "assets/images/payfast.png")), - Visibility(visible: controller.razorPayModel.value.isEnabled == true, child: cardDecoration(controller, PaymentGateway.razorpay, isDark, "assets/images/razorpay.png")), - Visibility(visible: controller.midTransModel.value.enable == true, child: cardDecoration(controller, PaymentGateway.midTrans, isDark, "assets/images/midtrans.png")), Visibility( - visible: controller.orangeMoneyModel.value.enable == true, - child: cardDecoration(controller, PaymentGateway.orangeMoney, isDark, "assets/images/orange_money.png"), + visible: + controller.payStackModel.value.isEnable == + true, + child: cardDecoration( + controller, + PaymentGateway.payStack, + isDark, + "assets/images/paystack.png", + ), + ), + Visibility( + visible: + controller.mercadoPagoModel.value.isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.mercadoPago, + isDark, + "assets/images/mercado-pago.png", + ), + ), + Visibility( + visible: + controller.flutterWaveModel.value.isEnable == + true, + child: cardDecoration( + controller, + PaymentGateway.flutterWave, + isDark, + "assets/images/flutterwave_logo.png", + ), + ), + Visibility( + visible: + controller.payFastModel.value.isEnable == + true, + child: cardDecoration( + controller, + PaymentGateway.payFast, + isDark, + "assets/images/payfast.png", + ), + ), + Visibility( + visible: + controller.razorPayModel.value.isEnabled == + true, + child: cardDecoration( + controller, + PaymentGateway.razorpay, + isDark, + "assets/images/razorpay.png", + ), + ), + Visibility( + visible: + controller.midTransModel.value.enable == true, + child: cardDecoration( + controller, + PaymentGateway.midTrans, + isDark, + "assets/images/midtrans.png", + ), + ), + Visibility( + visible: + controller.orangeMoneyModel.value.enable == + true, + child: cardDecoration( + controller, + PaymentGateway.orangeMoney, + isDark, + "assets/images/orange_money.png", + ), + ), + Visibility( + visible: + controller.xenditModel.value.enable == true, + child: cardDecoration( + controller, + PaymentGateway.xendit, + isDark, + "assets/images/xendit.png", + ), ), - Visibility(visible: controller.xenditModel.value.enable == true, child: cardDecoration(controller, PaymentGateway.xendit, isDark, "assets/images/xendit.png")), ], ), ), @@ -722,48 +1590,107 @@ class RentalOrderDetailsScreen extends StatelessWidget { textColor: AppThemeData.grey900, onPress: () async { if (controller.selectedPaymentMethod.value.isEmpty) { - ShowToastDialog.showToast("Please select a payment method".tr); + ShowToastDialog.showToast( + "Please select a payment method".tr, + ); } else { - if (controller.selectedPaymentMethod.value == PaymentGateway.stripe.name) { - controller.stripeMakePayment(amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.paypal.name) { - controller.paypalPaymentSheet(controller.totalAmount.value.toString(), context); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.payStack.name) { - controller.payStackPayment(controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.mercadoPago.name) { - controller.mercadoPagoMakePayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.flutterWave.name) { - controller.flutterWaveInitiatePayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.payFast.name) { - controller.payFastPayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.cod.name) { + if (controller.selectedPaymentMethod.value == + PaymentGateway.stripe.name) { + controller.stripeMakePayment( + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.paypal.name) { + controller.paypalPaymentSheet( + controller.totalAmount.value.toString(), + context, + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.payStack.name) { + controller.payStackPayment( + controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.mercadoPago.name) { + controller.mercadoPagoMakePayment( + context: context, + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.flutterWave.name) { + controller.flutterWaveInitiatePayment( + context: context, + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.payFast.name) { + controller.payFastPayment( + context: context, + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.cod.name) { controller.completeOrder(); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.wallet.name) { - if (Constant.userModel!.walletAmount == null || Constant.userModel!.walletAmount! < controller.totalAmount.value) { - ShowToastDialog.showToast("You do not have sufficient wallet balance".tr); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.wallet.name) { + if (Constant.userModel!.walletAmount == null || + Constant.userModel!.walletAmount! < + controller.totalAmount.value) { + ShowToastDialog.showToast( + "You do not have sufficient wallet balance".tr, + ); } else { controller.completeOrder(); } - } else if (controller.selectedPaymentMethod.value == PaymentGateway.cod.name) { + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.cod.name) { controller.completeOrder(); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.midTrans.name) { - controller.midtransMakePayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.orangeMoney.name) { - controller.orangeMakePayment(context: context, amount: controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.xendit.name) { - controller.xenditPayment(context, controller.totalAmount.value.toString()); - } else if (controller.selectedPaymentMethod.value == PaymentGateway.razorpay.name) { - RazorPayController().createOrderRazorPay(amount: double.parse(controller.totalAmount.value.toString()), razorpayModel: controller.razorPayModel.value).then((value) { - if (value == null) { - Get.back(); - ShowToastDialog.showToast("Something went wrong, please contact admin.".tr); - } else { - CreateRazorPayOrderModel result = value; - controller.openCheckout(amount: controller.totalAmount.value.toString(), orderId: result.id); - } - }); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.midTrans.name) { + controller.midtransMakePayment( + context: context, + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.orangeMoney.name) { + controller.orangeMakePayment( + context: context, + amount: controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.xendit.name) { + controller.xenditPayment( + context, + controller.totalAmount.value.toString(), + ); + } else if (controller.selectedPaymentMethod.value == + PaymentGateway.razorpay.name) { + RazorPayController() + .createOrderRazorPay( + amount: double.parse( + controller.totalAmount.value.toString(), + ), + razorpayModel: controller.razorPayModel.value, + ) + .then((value) { + if (value == null) { + Get.back(); + ShowToastDialog.showToast( + "Something went wrong, please contact admin." + .tr, + ); + } else { + CreateRazorPayOrderModel result = value; + controller.openCheckout( + amount: controller.totalAmount.value.toString(), + orderId: result.id, + ); + } + }); } else { - ShowToastDialog.showToast("Please select payment method".tr); + ShowToastDialog.showToast( + "Please select payment method".tr, + ); } } }, @@ -775,7 +1702,12 @@ class RentalOrderDetailsScreen extends StatelessWidget { ); } - Obx cardDecoration(RentalOrderDetailsController controller, PaymentGateway value, isDark, String image) { + Obx cardDecoration( + RentalOrderDetailsController controller, + PaymentGateway value, + isDark, + String image, + ) { return Obx( () => Padding( padding: const EdgeInsets.symmetric(vertical: 5), @@ -790,8 +1722,21 @@ class RentalOrderDetailsScreen extends StatelessWidget { Container( width: 50, height: 50, - decoration: ShapeDecoration(shape: RoundedRectangleBorder(side: const BorderSide(width: 1, color: Color(0xFFE5E7EB)), borderRadius: BorderRadius.circular(8))), - child: Padding(padding: EdgeInsets.all(value.name == "payFast" ? 0 : 8.0), child: Image.asset(image)), + decoration: ShapeDecoration( + shape: RoundedRectangleBorder( + side: const BorderSide( + width: 1, + color: Color(0xFFE5E7EB), + ), + borderRadius: BorderRadius.circular(8), + ), + ), + child: Padding( + padding: EdgeInsets.all( + value.name == "payFast" ? 0 : 8.0, + ), + child: Image.asset(image), + ), ), const SizedBox(width: 10), value.name == "wallet" @@ -802,12 +1747,30 @@ class RentalOrderDetailsScreen extends StatelessWidget { Text( value.name.capitalizeString(), textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), Text( - Constant.amountShow(amount: Constant.userModel!.walletAmount == null ? '0.0' : Constant.userModel!.walletAmount.toString()), + Constant.amountShow( + amount: + Constant.userModel!.walletAmount == null + ? '0.0' + : Constant.userModel!.walletAmount + .toString(), + ), textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(fontSize: 14, color: isDark ? AppThemeData.primary300 : AppThemeData.primary300), + style: AppThemeData.semiBoldTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, + ), ), ], ), @@ -816,14 +1779,23 @@ class RentalOrderDetailsScreen extends StatelessWidget { child: Text( value.name.capitalizeString(), textAlign: TextAlign.start, - style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900), + style: AppThemeData.semiBoldTextStyle( + fontSize: 16, + color: + isDark + ? AppThemeData.grey50 + : AppThemeData.grey900, + ), ), ), const Expanded(child: SizedBox()), Radio( value: value.name, groupValue: controller.selectedPaymentMethod.value, - activeColor: isDark ? AppThemeData.primary300 : AppThemeData.primary300, + activeColor: + isDark + ? AppThemeData.primary300 + : AppThemeData.primary300, onChanged: (value) { controller.selectedPaymentMethod.value = value.toString(); }, diff --git a/lib/screen_ui/rental_service/rental_review_screen.dart b/lib/screen_ui/rental_service/rental_review_screen.dart index 98c00b1..140776d 100644 --- a/lib/screen_ui/rental_service/rental_review_screen.dart +++ b/lib/screen_ui/rental_service/rental_review_screen.dart @@ -27,11 +27,19 @@ class RentalReviewScreen extends StatelessWidget { backgroundColor: AppThemeData.primary300, leading: GestureDetector( onTap: () => Get.back(), - child: Icon(Icons.arrow_back_ios, color: isDark ? Colors.white : Colors.black), + child: Icon( + Icons.arrow_back_ios, + color: isDark ? Colors.white : Colors.black, + ), ), title: Text( - controller.ratingModel.value != null ? "Update Review".tr : "Add Review".tr, - style: TextStyle(color: isDark ? Colors.white : Colors.black, fontSize: 16), + controller.ratingModel.value != null + ? "Update Review".tr + : "Add Review".tr, + style: TextStyle( + color: isDark ? Colors.white : Colors.black, + fontSize: 16, + ), ), ), body: Obx( @@ -43,11 +51,21 @@ class RentalReviewScreen extends StatelessWidget { child: Stack( children: [ Padding( - padding: const EdgeInsets.only(left: 20, right: 20, top: 50, bottom: 20), + padding: const EdgeInsets.only( + left: 20, + right: 20, + top: 50, + bottom: 20, + ), child: Card( elevation: 2, - color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), child: SingleChildScrollView( child: Padding( padding: const EdgeInsets.only(top: 65), @@ -55,11 +73,18 @@ class RentalReviewScreen extends StatelessWidget { children: [ // Driver Name Padding( - padding: const EdgeInsets.only(top: 8.0), + padding: const EdgeInsets.only( + top: 8.0, + ), child: Text( - controller.order.value!.driver?.fullName() ?? "", + controller.order.value!.driver + ?.fullName() ?? + "", style: TextStyle( - color: isDark ? Colors.white : Colors.black87, + color: + isDark + ? Colors.white + : Colors.black87, fontFamily: AppThemeData.medium, fontSize: 18, ), @@ -67,12 +92,21 @@ class RentalReviewScreen extends StatelessWidget { ), // Car info Row( - mainAxisAlignment: MainAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment.center, children: [ Text( - controller.driverUser.value?.carNumber?.toUpperCase() ?? '', + controller + .driverUser + .value + ?.carNumber + ?.toUpperCase() ?? + '', style: TextStyle( - color: isDark ? Colors.white : Colors.black87, + color: + isDark + ? Colors.white + : Colors.black87, fontFamily: AppThemeData.medium, ), ), @@ -80,14 +114,22 @@ class RentalReviewScreen extends StatelessWidget { Text( "${controller.driverUser.value?.carName} ${controller.driverUser.value?.carMakes}", style: TextStyle( - color: isDark ? Colors.white : Colors.black38, + color: + isDark + ? Colors.white + : Colors.black38, fontFamily: AppThemeData.medium, ), ), ], ), - const Padding(padding: EdgeInsets.symmetric(vertical: 12), child: Divider(color: Colors.grey)), + const Padding( + padding: EdgeInsets.symmetric( + vertical: 12, + ), + child: Divider(color: Colors.grey), + ), // Title Padding( @@ -96,7 +138,10 @@ class RentalReviewScreen extends StatelessWidget { 'How is your trip?'.tr, style: TextStyle( fontSize: 18, - color: isDark ? Colors.white : Colors.black, + color: + isDark + ? Colors.white + : Colors.black, fontWeight: FontWeight.bold, letterSpacing: 2, ), @@ -105,10 +150,16 @@ class RentalReviewScreen extends StatelessWidget { Padding( padding: const EdgeInsets.only(top: 8), child: Text( - 'Your feedback will help us improve \n driving experience better'.tr, + 'Your feedback will help us improve \n driving experience better' + .tr, textAlign: TextAlign.center, style: TextStyle( - color: isDark ? Colors.white : Colors.black.withOpacity(0.60), + color: + isDark + ? Colors.white + : Colors.black.withOpacity( + 0.60, + ), letterSpacing: 0.8, ), ), @@ -121,7 +172,12 @@ class RentalReviewScreen extends StatelessWidget { 'Rate for'.tr, style: TextStyle( fontSize: 16, - color: isDark ? Colors.white : Colors.black.withOpacity(0.60), + color: + isDark + ? Colors.white + : Colors.black.withOpacity( + 0.60, + ), letterSpacing: 0.8, ), ), @@ -129,10 +185,15 @@ class RentalReviewScreen extends StatelessWidget { Padding( padding: const EdgeInsets.only(top: 8), child: Text( - controller.order.value!.driver?.fullName() ?? "", + controller.order.value!.driver + ?.fullName() ?? + "", style: TextStyle( fontSize: 18, - color: isDark ? Colors.white : Colors.black, + color: + isDark + ? Colors.white + : Colors.black, fontWeight: FontWeight.bold, letterSpacing: 2, ), @@ -141,14 +202,25 @@ class RentalReviewScreen extends StatelessWidget { Padding( padding: const EdgeInsets.only(top: 10), child: RatingBar.builder( - initialRating: controller.ratings.value, + initialRating: + controller.ratings.value, minRating: 1, direction: Axis.horizontal, allowHalfRating: true, itemCount: 5, - itemBuilder: (context, _) => const Icon(Icons.star, color: Colors.amber), - unratedColor: isDark ? AppThemeData.greyDark400 : AppThemeData.grey400, - onRatingUpdate: (rating) => controller.ratings.value = rating, + itemBuilder: + (context, _) => const Icon( + Icons.star, + color: Colors.amber, + ), + unratedColor: + isDark + ? AppThemeData.greyDark400 + : AppThemeData.grey400, + onRatingUpdate: + (rating) => + controller.ratings.value = + rating, ), ), @@ -166,9 +238,16 @@ class RentalReviewScreen extends StatelessWidget { Padding( padding: const EdgeInsets.all(20.0), child: RoundedButtonFill( - title: controller.ratingModel.value != null ? "Update Review" : "Add Review", + title: + controller.ratingModel.value != + null + ? "Update Review" + : "Add Review", color: AppThemeData.primary300, - textColor: isDark ? Colors.white : Colors.black, + textColor: + isDark + ? Colors.white + : Colors.black, onPress: controller.submitReview, ), ), @@ -184,12 +263,24 @@ class RentalReviewScreen extends StatelessWidget { decoration: BoxDecoration( borderRadius: BorderRadius.circular(60), color: Colors.white, - boxShadow: [BoxShadow(color: Colors.grey.withOpacity(0.15), blurRadius: 8, spreadRadius: 6)], + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.15), + blurRadius: 8, + spreadRadius: 6, + ), + ], ), child: ClipRRect( borderRadius: BorderRadius.circular(60), child: NetworkImageWidget( - imageUrl: controller.order.value?.driver?.profilePictureURL ?? '', + imageUrl: + controller + .order + .value + ?.driver + ?.profilePictureURL ?? + '', fit: BoxFit.cover, height: 110, width: 110, diff --git a/lib/screen_ui/service_home_screen/service_list_screen.dart b/lib/screen_ui/service_home_screen/service_list_screen.dart index b6a5aaf..81faa14 100644 --- a/lib/screen_ui/service_home_screen/service_list_screen.dart +++ b/lib/screen_ui/service_home_screen/service_list_screen.dart @@ -1,8 +1,11 @@ -import 'package:customer/constant/constant.dart'; +import 'dart:developer'; +import 'package:customer/constant/const_texts.dart'; +import 'package:customer/models/section_model.dart'; + import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import '../../controllers/service_list_controller.dart'; -import '../../controllers/theme_controller.dart'; import '../../themes/app_them_data.dart'; import '../../utils/network_image_widget.dart'; @@ -11,22 +14,28 @@ class ServiceListScreen extends StatelessWidget { @override Widget build(BuildContext context) { - final themeController = Get.find(); + // final themeController = Get.find(); return GetX( init: ServiceListController(), builder: (controller) { return Scaffold( + backgroundColor: AppThemeData.cardColor, appBar: AppBar( elevation: 0, automaticallyImplyLeading: false, titleSpacing: 20, centerTitle: false, + backgroundColor: AppThemeData.cardColor, title: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("eMart".tr, style: AppThemeData.semiBoldTextStyle(fontSize: 22, color: themeController.isDark.value ? AppThemeData.grey50 : AppThemeData.grey900)), - Text("All Your Needs in One App!".tr, style: AppThemeData.regularTextStyle(fontSize: 14, color: themeController.isDark.value ? AppThemeData.grey100 : AppThemeData.grey700)), + Image.asset( + "assets/images/fondex_logo.png", + height: 32.r, + width: 124.r, + fit: BoxFit.contain, + ), ], ), ), @@ -37,54 +46,153 @@ class ServiceListScreen extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - const SizedBox(height: 12), - controller.serviceListBanner.isEmpty ? SizedBox() : BannerView(bannerList: controller.serviceListBanner), - const SizedBox(height: 12), + // controller.serviceListBanner.isEmpty + // ? SizedBox() + // : Padding( + // padding: EdgeInsets.symmetric(horizontal: 16.r), + // child: BannerView( + // bannerList: controller.serviceListBanner, + // ), + // ), + SizedBox(height: 10.h), + // Main Cards Section + _mainCardsSection( + context: context, + controller: controller, + sectionModel: controller.sectionList, + ), + + SizedBox(height: 15.h), + + // Other Services Section Title Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text("Explore Our Services".tr, style: AppThemeData.semiBoldTextStyle(fontSize: 20, color: themeController.isDark.value ? AppThemeData.grey50 : AppThemeData.grey900)), - const SizedBox(height: 12), - GridView.builder( - itemCount: controller.sectionList.length, - physics: const NeverScrollableScrollPhysics(), - shrinkWrap: true, - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, mainAxisSpacing: 12, crossAxisSpacing: 12, mainAxisExtent: 130), - itemBuilder: (context, index) { - final section = controller.sectionList[index]; - return GestureDetector( - onTap: () => controller.onServiceTap(context, section), - child: Container( - decoration: BoxDecoration( - gradient: LinearGradient(colors: Constant.sectionColor[index % Constant.sectionColor.length], begin: Alignment.topCenter, end: Alignment.bottomCenter), - borderRadius: BorderRadius.circular(12), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(top: 10, left: 5, right: 5), - child: Text( - section.name ?? '', - textAlign: TextAlign.center, - maxLines: 2, - overflow: TextOverflow.ellipsis, - style: AppThemeData.semiBoldTextStyle(fontSize: 14, color: AppThemeData.grey900), - ), - ), - const Spacer(), - NetworkImageWidget(imageUrl: section.sectionImage ?? '', width: 80, height: 60, fit: BoxFit.contain), - ], - ), - ), - ); - }, - ), - ], + padding: EdgeInsets.symmetric(horizontal: 16.r), + child: Text( + ConstTexts.otherServices.tr, + style: TextStyle( + fontFamily: AppThemeData.bold, + fontWeight: FontWeight.w700, + fontSize: 20.sp, + color: AppThemeData.darkGrey, + ), ), ), + SizedBox(height: 10.h), + + // Other Services Section + controller.sectionList.firstWhereOrNull( + (element) => + element.serviceTypeFlag == + "ondemand-service", + ) == + null + ? SizedBox.shrink() + : _otherServicesCardMaker( + image: "assets/images/garderob_img.png", + title: ConstTexts.updateYourWardrobe.tr, + subtitle: ConstTexts.weDeliverSafely.tr, + onTap: () { + SectionModel? innerSectionModel = controller + .sectionList + .firstWhereOrNull( + (element) => + element.serviceTypeFlag == + "ondemand-service", + ); + + if (innerSectionModel != null) { + controller.onServiceTap( + context, + innerSectionModel, + ); + } + }, + ), + controller.sectionList.firstWhereOrNull( + (element) => + element.serviceTypeFlag == + "rental-service", + ) == + null + ? SizedBox.shrink() + : _otherServicesCardMaker( + image: "assets/images/keys_img.png", + title: ConstTexts.rent.tr, + subtitle: ConstTexts.hugeSelectionOfAds.tr, + onTap: () { + SectionModel? innerSectionModel = controller + .sectionList + .firstWhereOrNull( + (element) => + element.serviceTypeFlag == + "rental-service", + ); + + if (innerSectionModel != null) { + controller.onServiceTap( + context, + innerSectionModel, + ); + } + }, + ), + controller.sectionList.firstWhereOrNull( + (element) => + element.serviceTypeFlag == + "ecommerce-service", + ) == + null + ? SizedBox.shrink() + : _otherServicesCardMaker( + image: "assets/images/cosmetics_img.png", + title: ConstTexts.cosmetics.tr, + subtitle: ConstTexts.moreThan1000Products.tr, + onTap: () { + SectionModel? innerSectionModel = controller + .sectionList + .firstWhereOrNull( + (element) => + element.serviceTypeFlag == + "ecommerce-service", + ); + + if (innerSectionModel != null) { + controller.onServiceTap( + context, + innerSectionModel, + ); + } + }, + ), + controller.sectionList.firstWhereOrNull( + (element) => + element.serviceTypeFlag == + "ondemand-service", + ) == + null + ? SizedBox.shrink() + : _otherServicesCardMaker( + image: "assets/images/products_img.png", + title: ConstTexts.foodProducts.tr, + subtitle: ConstTexts.moreThan1000Products.tr, + onTap: () { + SectionModel? innerSectionModel = controller + .sectionList + .firstWhereOrNull( + (element) => + element.serviceTypeFlag == + "ondemand-service", + ); + + if (innerSectionModel != null) { + controller.onServiceTap( + context, + innerSectionModel, + ); + } + }, + ), + SizedBox(height: 45.h), ], ), ), @@ -92,6 +200,267 @@ class ServiceListScreen extends StatelessWidget { }, ); } + + Widget _otherServicesCardMaker({ + required String image, + required String title, + required String subtitle, + required VoidCallback onTap, + }) { + return InkWell( + onTap: onTap, + child: Container( + width: double.infinity, + margin: EdgeInsets.symmetric(horizontal: 16.r).copyWith(bottom: 10.r), + padding: EdgeInsets.only(left: 6.r, right: 12.r, top: 6.r, bottom: 6.r), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(16.r), + color: AppThemeData.grey50, + ), + child: Row( + spacing: 15.r, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Row( + spacing: 10.r, + children: [ + Container( + height: 52.r, + width: 52.r, + decoration: BoxDecoration( + color: AppThemeData.cardColor, + borderRadius: BorderRadius.circular(14.r), + ), + child: Image.asset( + image, + height: 62.r, + width: 62.r, + fit: BoxFit.contain, + ), + ), + Expanded( + child: Column( + spacing: 2.r, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + title, + style: TextStyle( + overflow: TextOverflow.ellipsis, + fontFamily: AppThemeData.semiBold, + fontSize: 16.sp, + fontWeight: FontWeight.w700, + color: AppThemeData.darkGrey, + ), + ), + Text( + subtitle, + style: TextStyle( + overflow: TextOverflow.ellipsis, + fontFamily: AppThemeData.semiBold, + fontSize: 13.sp, + fontWeight: FontWeight.w400, + color: AppThemeData.darkGrey, + ), + ), + ], + ), + ), + ], + ), + ), + Icon( + Icons.arrow_forward_ios, + size: 18.r, + color: AppThemeData.darkGrey, + ), + ], + ), + ), + ); + } + + Widget _mainCardsSection({ + required BuildContext context, + required ServiceListController controller, + required RxList sectionModel, + }) { + return Container( + padding: EdgeInsets.symmetric(vertical: 16.r, horizontal: 16.r), + decoration: BoxDecoration( + color: AppThemeData.grey50, + borderRadius: BorderRadius.circular(16.r), + ), + child: Row( + spacing: 12.r, + children: [ + // Food & Garderobe Cards + Column( + spacing: 12.r, + children: [ + _mainCardsMaker( + title: ConstTexts.foodDelivery.tr, + image: "assets/images/food_img.png", + // onTap: () { + // log("Main Card Tapped"); + onTap: () async { + SectionModel? innerSectionModel = sectionModel + .firstWhereOrNull( + (element) => + element.serviceTypeFlag == "delivery-service", + ); + + if (innerSectionModel != null) { + controller.onServiceTap(context, innerSectionModel); + } + }, + // }, + ), + _mainCardsMaker( + title: ConstTexts.delivery.tr, + image: "assets/images/delivery_img.png", + onTap: () { + log("Main Card Tapped"); + SectionModel? innerSectionModel = sectionModel + .firstWhereOrNull( + (element) => + element.serviceTypeFlag == "parcel_delivery", + ); + + if (innerSectionModel != null) { + controller.onServiceTap(context, innerSectionModel); + } + }, + ), + ], + ), + // Taxi Card + InkWell( + onTap: () { + log("Taxi Card Tapped"); + // push(context, DashBoardCabService(user: null)); + SectionModel? innerSectionModel = sectionModel.firstWhereOrNull( + (element) => element.serviceTypeFlag == "cab-service", + ); + + if (innerSectionModel != null) { + controller.onServiceTap(context, innerSectionModel); + } + }, + child: Container( + height: 192.h, + width: 166.w, + padding: EdgeInsets.only(top: 12.r, right: 12.r), + decoration: BoxDecoration( + color: AppThemeData.yellow, + borderRadius: BorderRadius.circular(16.r), + ), + child: Column( + children: [ + Expanded( + child: Padding( + padding: EdgeInsets.only(left: 12.r), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Text( + maxLines: 2, + ConstTexts.bookingTaxi.tr, + style: TextStyle( + overflow: TextOverflow.ellipsis, + fontFamily: AppThemeData.bold, + fontSize: 18.sp, + fontWeight: FontWeight.w700, + color: AppThemeData.grey50, + ), + ), + ), + Container( + height: 36.r, + width: 36.r, + decoration: BoxDecoration( + color: AppThemeData.grey50.withValues(alpha: 0.3), + borderRadius: BorderRadius.circular(8.r), + ), + child: Icon( + Icons.arrow_outward_rounded, + size: 20.r, + color: AppThemeData.grey50, + ), + ), + ], + ), + ), + ), + Image.asset( + "assets/images/taxi_img.png", + height: 119.r, + width: 156.r, + fit: BoxFit.contain, + ), + ], + ), + ), + ), + ], + ), + ); + } + + Widget _mainCardsMaker({ + required String title, + required String image, + required VoidCallback onTap, + }) { + return InkWell( + onTap: onTap, + child: Container( + height: 93.h, + width: 165.w, + padding: EdgeInsets.only(left: 12.r), + decoration: BoxDecoration( + color: AppThemeData.cardColor, + borderRadius: BorderRadius.circular(16.r), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Expanded( + child: Padding( + padding: EdgeInsets.only(bottom: 12.r, top: 12.r), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + maxLines: 2, + title, + style: TextStyle( + overflow: TextOverflow.ellipsis, + fontFamily: AppThemeData.bold, + fontSize: 15.sp, + fontWeight: FontWeight.w700, + color: AppThemeData.darkGrey, + ), + ), + Icon( + Icons.arrow_outward_rounded, + size: 24.r, + color: AppThemeData.darkGrey, + ), + ], + ), + ), + ), + Image.asset(image, height: 71.r, width: 71.r, fit: BoxFit.contain), + ], + ), + ), + ); + } } class BannerView extends StatelessWidget { @@ -132,7 +501,13 @@ class BannerView extends StatelessWidget { itemBuilder: (context, index) { return ClipRRect( borderRadius: BorderRadius.circular(12), - child: SizedBox(width: MediaQuery.of(context).size.width * 0.8, child: NetworkImageWidget(imageUrl: bannerList[index].toString(), fit: BoxFit.fill)), + child: SizedBox( + width: MediaQuery.of(context).size.width * 0.8, + child: NetworkImageWidget( + imageUrl: bannerList[index].toString(), + fit: BoxFit.fill, + ), + ), ); }, ), @@ -142,7 +517,18 @@ class BannerView extends StatelessWidget { return Row( children: List.generate(bannerList.length, (index) { final isSelected = currentPage.value == index; - return Expanded(child: Container(height: 4, decoration: BoxDecoration(color: isSelected ? AppThemeData.grey300 : AppThemeData.grey100, borderRadius: BorderRadius.circular(5)))); + return Expanded( + child: Container( + height: 4, + decoration: BoxDecoration( + color: + isSelected + ? AppThemeData.grey300 + : AppThemeData.grey100, + borderRadius: BorderRadius.circular(5), + ), + ), + ); }), ); }), diff --git a/lib/screen_ui/splash_screen/splash_screen.dart b/lib/screen_ui/splash_screen/splash_screen.dart index 652d0e0..4777563 100644 --- a/lib/screen_ui/splash_screen/splash_screen.dart +++ b/lib/screen_ui/splash_screen/splash_screen.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; -import '../../constant/assets.dart'; import '../../controllers/splash_controller.dart'; import '../../themes/app_them_data.dart'; @@ -10,9 +9,18 @@ class SplashScreen extends StatelessWidget { @override Widget build(BuildContext context) { return GetBuilder( - init: SplashController(), + init: SplashController(context: context), builder: (controller) { - return Scaffold(backgroundColor: AppThemeData.surface, body: Center(child: Image.asset(AppAssets.icAppLogo, width: 120, height: 120))); + return Scaffold( + backgroundColor: AppThemeData.mainColor, + body: Center( + child: Image.asset( + "assets/images/fondex_logo_main.png", + width: 120, + height: 120, + ), + ), + ); }, ); } diff --git a/lib/service/cart_provider.dart b/lib/service/cart_provider.dart index 4853938..08f4e54 100644 --- a/lib/service/cart_provider.dart +++ b/lib/service/cart_provider.dart @@ -3,13 +3,14 @@ import 'dart:developer'; import 'package:customer/constant/constant.dart'; import 'package:customer/models/cart_product_model.dart'; import 'package:customer/themes/custom_dialog_box.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; - import 'database_helper.dart'; class CartProvider with ChangeNotifier { - final _cartStreamController = StreamController>.broadcast(); + final _cartStreamController = + StreamController>.broadcast(); List _cartItems = []; Stream> get cartStream => _cartStreamController.stream; @@ -23,7 +24,11 @@ class CartProvider with ChangeNotifier { _cartStreamController.sink.add(_cartItems); } - Future addToCart(BuildContext context, CartProductModel product, int quantity) async { + Future addToCart( + BuildContext context, + CartProductModel product, + int quantity, + ) async { _cartItems = await DatabaseHelper.instance.fetchCartProducts(); if ((_cartItems.where((item) => item.id == product.id)).isNotEmpty) { var index = _cartItems.indexWhere((item) => item.id == product.id); @@ -37,7 +42,10 @@ class CartProvider with ChangeNotifier { } await DatabaseHelper.instance.updateCartProduct(_cartItems[index]); } else { - if (_cartItems.isEmpty || _cartItems.where((item) => item.vendorID == product.vendorID).isNotEmpty) { + if (_cartItems.isEmpty || + _cartItems + .where((item) => item.vendorID == product.vendorID) + .isNotEmpty) { product.quantity = quantity; _cartItems.add(product); cartItem.add(product); @@ -49,7 +57,9 @@ class CartProvider with ChangeNotifier { builder: (BuildContext context) { return CustomDialogBox( title: "Alert".tr, - descriptions: "Your cart already contains items from another restaurant. Would you like to replace them with items from this restaurant instead?".tr, + descriptions: + "Your cart already contains items from another restaurant. Would you like to replace them with items from this restaurant instead?" + .tr, positiveString: "Add".tr, negativeString: "Cancel".tr, positiveClick: () async { diff --git a/lib/service/fire_store_utils.dart b/lib/service/fire_store_utils.dart index 8c56d2f..558cb8d 100644 --- a/lib/service/fire_store_utils.dart +++ b/lib/service/fire_store_utils.dart @@ -9,6 +9,7 @@ import 'package:customer/models/rental_order_model.dart'; import 'package:customer/models/rental_package_model.dart'; import 'package:customer/models/user_model.dart'; import 'package:customer/models/zone_model.dart'; + import 'package:firebase_auth/firebase_auth.dart' as auth; import 'package:firebase_storage/firebase_storage.dart'; import 'package:flutter/cupertino.dart'; @@ -83,7 +84,11 @@ class FireStoreUtils { static FirebaseFirestore fireStore = FirebaseFirestore.instance; static String getCurrentUid() { - return auth.FirebaseAuth.instance.currentUser!.uid; + final user = auth.FirebaseAuth.instance.currentUser; + if (user != null) { + return user.uid; + } + return "hello"; } static Future isLogin() async { diff --git a/lib/service/localization_service.dart b/lib/service/localization_service.dart index b3040e7..cfd87c1 100644 --- a/lib/service/localization_service.dart +++ b/lib/service/localization_service.dart @@ -1,20 +1,37 @@ +import 'dart:convert'; +import 'package:flutter/services.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; -import '../lang/app_en.dart'; class LocalizationService extends Translations { - // Default locale - static const locale = Locale('en', 'US'); + static Map> _keys = {}; - static final locales = [const Locale('en')]; + static const fallbackLocale = Locale('en', 'US'); + + static const supportedLocales = [ + Locale('en', 'US'), + Locale('uz', 'UZ'), + Locale('ru', 'RU'), + ]; - // Keys and their translations - // Translations are separated maps in `lang` file @override - Map> get keys => {'en_US': enUS}; + Map> get keys => _keys; - // Gets locale from language, and updates the locale - void changeLocale(String lang) { - Get.updateLocale(Locale(lang)); + // Load JSONs before starting the app + static Future init() async { + _keys = { + "en_US": await _loadJson("assets/translations/en.json"), + "uz_UZ": await _loadJson("assets/translations/uz.json"), + "ru_RU": await _loadJson("assets/translations/ru.json"), + }; + } + + static Future> _loadJson(String path) async { + final data = await rootBundle.loadString(path); + return Map.from(json.decode(data)); + } + + static void changeLocale(Locale locale) { + Get.updateLocale(locale); } } diff --git a/lib/themes/app_them_data.dart b/lib/themes/app_them_data.dart index 47dcaa8..d9485f1 100644 --- a/lib/themes/app_them_data.dart +++ b/lib/themes/app_them_data.dart @@ -199,6 +199,12 @@ class AppThemeData { static const Color warningDark500 = Color(0xFFFFE9AB); static const Color warningDark600 = Color(0xFFFFF8E5); + static const Color yellow = Color(0xFFE5AE3E); + static const Color cardColor = Color(0xFFEEEFF2); + static const Color darkGrey = Color(0xFF1F2937); + static const Color mainColor = Color(0xFFFF6839); + static const lightGrey = Color(0xFF8E8E93); + static const Color primary50 = Color(0xFFFFEBE5); static const Color primary100 = Color(0xFFFFC0AB); static const Color primary200 = Color(0xFFFF9472); diff --git a/lib/themes/custom_dialog_box.dart b/lib/themes/custom_dialog_box.dart index 6c87843..ccfffcd 100644 --- a/lib/themes/custom_dialog_box.dart +++ b/lib/themes/custom_dialog_box.dart @@ -1,4 +1,5 @@ import 'package:customer/themes/responsive.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../controllers/theme_controller.dart'; @@ -28,23 +29,46 @@ class CustomDialogBox extends StatelessWidget { return Obx(() { final isDark = themeController.isDark.value; - return Dialog(shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)), elevation: 0, backgroundColor: Colors.transparent, child: contentBox(context, isDark)); + return Dialog( + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)), + elevation: 0, + backgroundColor: Colors.transparent, + child: contentBox(context, isDark), + ); }); } Widget contentBox(BuildContext context, bool isDark) { return Container( padding: const EdgeInsets.all(20), - decoration: BoxDecoration(shape: BoxShape.rectangle, color: isDark ? AppThemeData.greyDark100 : AppThemeData.grey100, borderRadius: BorderRadius.circular(20)), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: isDark ? AppThemeData.greyDark100 : AppThemeData.grey100, + borderRadius: BorderRadius.circular(20), + ), child: Column( mainAxisSize: MainAxisSize.min, children: [ img ?? const SizedBox(), const SizedBox(height: 20), - if (title.isNotEmpty) Text(title.tr, style: AppThemeData.boldTextStyle(fontSize: 20, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + if (title.isNotEmpty) + Text( + title.tr, + style: AppThemeData.boldTextStyle( + fontSize: 20, + color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + ), + ), const SizedBox(height: 5), if (descriptions.isNotEmpty) - Text(descriptions.tr, textAlign: TextAlign.center, style: AppThemeData.regularTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + Text( + descriptions.tr, + textAlign: TextAlign.center, + style: AppThemeData.regularTextStyle( + fontSize: 14, + color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, + ), + ), const SizedBox(height: 20), Row( children: [ @@ -54,9 +78,25 @@ class CustomDialogBox extends StatelessWidget { child: Container( width: Responsive.width(100, context), height: Responsive.height(5, context), - decoration: BoxDecoration(color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900, borderRadius: BorderRadius.circular(200)), + decoration: BoxDecoration( + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + borderRadius: BorderRadius.circular(200), + ), child: Center( - child: Text(negativeString.tr, textAlign: TextAlign.center, style: AppThemeData.mediumTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark100 : AppThemeData.grey100)), + child: Text( + negativeString.tr, + textAlign: TextAlign.center, + style: AppThemeData.mediumTextStyle( + fontSize: 14, + color: + isDark + ? AppThemeData.greyDark100 + : AppThemeData.grey100, + ), + ), ), ), ), @@ -68,8 +108,20 @@ class CustomDialogBox extends StatelessWidget { child: Container( width: Responsive.width(100, context), height: Responsive.height(5, context), - decoration: BoxDecoration(color: AppThemeData.success300, borderRadius: BorderRadius.circular(200)), - child: Center(child: Text('Confirm'.tr, textAlign: TextAlign.center, style: AppThemeData.mediumTextStyle(fontSize: 14, color: AppThemeData.grey100))), + decoration: BoxDecoration( + color: AppThemeData.success300, + borderRadius: BorderRadius.circular(200), + ), + child: Center( + child: Text( + 'Confirm'.tr, + textAlign: TextAlign.center, + style: AppThemeData.mediumTextStyle( + fontSize: 14, + color: AppThemeData.grey100, + ), + ), + ), ), ), ), diff --git a/lib/themes/round_button_border.dart b/lib/themes/round_button_border.dart index f93be6e..12d0c61 100644 --- a/lib/themes/round_button_border.dart +++ b/lib/themes/round_button_border.dart @@ -1,5 +1,6 @@ import 'package:customer/controllers/theme_controller.dart'; import 'package:customer/themes/responsive.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'app_them_data.dart'; @@ -48,26 +49,51 @@ class RoundedButtonBorder extends StatelessWidget { height: Responsive.height(height ?? 6, context), decoration: ShapeDecoration( color: color ?? Colors.transparent, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(radius ?? 50), side: BorderSide(color: borderColor ?? AppThemeData.danger300)), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(radius ?? 50), + side: BorderSide(color: borderColor ?? AppThemeData.danger300), + ), ), child: Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ - if (isRight == false) Padding(padding: const EdgeInsets.only(right: 10, left: 0), child: icon), + if (isRight == false) + Padding( + padding: const EdgeInsets.only(right: 10, left: 0), + child: icon, + ), isCenter == true - ? Text(title.tr, textAlign: TextAlign.center, style: AppThemeData.semiBoldTextStyle(fontSize: fontSizes ?? 14, color: textColor ?? AppThemeData.grey800)) + ? Text( + title.tr, + textAlign: TextAlign.center, + style: AppThemeData.semiBoldTextStyle( + fontSize: fontSizes ?? 14, + color: textColor ?? AppThemeData.grey800, + ), + ) : Expanded( child: Padding( padding: EdgeInsets.only(right: isRight == null ? 0 : 30), child: Text( title.tr, textAlign: TextAlign.center, - style: AppThemeData.semiBoldTextStyle(fontSize: fontSizes ?? 14, color: textColor ?? (isDark ? AppThemeData.grey100 : AppThemeData.grey700)), + style: AppThemeData.semiBoldTextStyle( + fontSize: fontSizes ?? 14, + color: + textColor ?? + (isDark + ? AppThemeData.grey100 + : AppThemeData.grey700), + ), ), ), ), - if (isRight == true) Padding(padding: const EdgeInsets.only(left: 10, right: 20), child: icon), + if (isRight == true) + Padding( + padding: const EdgeInsets.only(left: 10, right: 20), + child: icon, + ), ], ), ), diff --git a/lib/themes/round_button_fill.dart b/lib/themes/round_button_fill.dart index eada310..7ae0005 100644 --- a/lib/themes/round_button_fill.dart +++ b/lib/themes/round_button_fill.dart @@ -1,4 +1,5 @@ import 'package:customer/themes/responsive.dart'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'app_them_data.dart'; @@ -44,21 +45,48 @@ class RoundedButtonFill extends StatelessWidget { child: Container( width: Responsive.width(width ?? 100, context), height: Responsive.height(height ?? 6, context), - decoration: ShapeDecoration(color: color, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(borderRadius ?? 50))), + decoration: ShapeDecoration( + color: color, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(borderRadius ?? 50), + ), + ), child: Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ - if (isRight == false) Padding(padding: const EdgeInsets.only(right: 10, left: 10), child: icon), + if (isRight == false) + Padding( + padding: const EdgeInsets.only(right: 10, left: 10), + child: icon, + ), isCenter == true - ? Text(title.tr, textAlign: TextAlign.center, style: AppThemeData.semiBoldTextStyle(fontSize: fontSizes ?? 16, color: textColor ?? AppThemeData.grey50)) + ? Text( + title.tr, + textAlign: TextAlign.center, + style: AppThemeData.semiBoldTextStyle( + fontSize: fontSizes ?? 16, + color: textColor ?? AppThemeData.grey50, + ), + ) : Expanded( child: Padding( padding: EdgeInsets.only(right: isRight == null ? 0 : 30), - child: Text(title.tr, textAlign: TextAlign.center, style: AppThemeData.semiBoldTextStyle(fontSize: fontSizes ?? 16, color: textColor ?? AppThemeData.grey50)), + child: Text( + title.tr, + textAlign: TextAlign.center, + style: AppThemeData.semiBoldTextStyle( + fontSize: fontSizes ?? 16, + color: textColor ?? AppThemeData.grey50, + ), + ), ), ), - if (isRight == true) Padding(padding: const EdgeInsets.only(left: 10, right: 10), child: icon), + if (isRight == true) + Padding( + padding: const EdgeInsets.only(left: 10, right: 10), + child: icon, + ), ], ), ), diff --git a/lib/themes/text_field_widget.dart b/lib/themes/text_field_widget.dart index 8e0b58c..8b53c35 100644 --- a/lib/themes/text_field_widget.dart +++ b/lib/themes/text_field_widget.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import '../controllers/theme_controller.dart'; import 'app_them_data.dart'; @@ -75,20 +76,39 @@ class _TextFieldWidgetState extends State { final themeController = Get.find(); final isDark = themeController.isDark.value; - final borderColor = widget.borderColor ?? (_focusNode.hasFocus ? (isDark ? AppThemeData.greyDark400 : AppThemeData.grey400) : (isDark ? AppThemeData.greyDark200 : AppThemeData.grey200)); + final borderColor = + widget.borderColor ?? + (_focusNode.hasFocus + ? (isDark ? AppThemeData.greyDark400 : AppThemeData.grey400) + : (isDark ? AppThemeData.greyDark200 : AppThemeData.grey200)); final fillColor = - widget.backgroundColor ?? (isDark ? (_focusNode.hasFocus ? AppThemeData.greyDark50 : AppThemeData.greyDark100) : (_focusNode.hasFocus ? AppThemeData.grey100 : Colors.transparent)); + widget.backgroundColor ?? + (isDark + ? (_focusNode.hasFocus + ? AppThemeData.greyDark50 + : AppThemeData.greyDark100) + : (_focusNode.hasFocus + ? AppThemeData.grey100 + : Colors.transparent)); final textColor = isDark ? AppThemeData.greyDark900 : AppThemeData.grey900; - final hintColor = widget.hintColor ?? (isDark ? AppThemeData.grey400 : AppThemeData.greyDark400); + final hintColor = + widget.hintColor ?? + (isDark ? AppThemeData.grey400 : AppThemeData.greyDark400); return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ if (widget.title != null) ...[ - Text(widget.title!.tr, style: AppThemeData.boldTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800)), + Text( + widget.title!.tr, + style: AppThemeData.boldTextStyle( + fontSize: 14, + color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800, + ), + ), const SizedBox(height: 5), ], TextFormField( @@ -110,18 +130,46 @@ class _TextFieldWidgetState extends State { filled: true, enabled: widget.enable ?? true, fillColor: fillColor, - contentPadding: EdgeInsets.symmetric(vertical: widget.title == null ? 15 : (widget.enable == false ? 13 : 8), horizontal: 10), + contentPadding: EdgeInsets.symmetric( + vertical: + widget.title == null ? 15 : (widget.enable == false ? 13 : 8), + horizontal: 10, + ), prefixIcon: widget.prefix, suffixIcon: widget.suffix, - prefixIconConstraints: const BoxConstraints(minHeight: 20, minWidth: 20), - suffixIconConstraints: const BoxConstraints(minHeight: 20, minWidth: 20), - border: OutlineInputBorder(borderRadius: BorderRadius.circular(8), borderSide: BorderSide(color: borderColor)), - enabledBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(8), borderSide: BorderSide(color: borderColor)), - focusedBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(8), borderSide: BorderSide(color: borderColor, width: 1.2)), - errorBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(8), borderSide: const BorderSide(color: Colors.red)), - disabledBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(8), borderSide: BorderSide(color: borderColor)), + prefixIconConstraints: const BoxConstraints( + minHeight: 20, + minWidth: 20, + ), + suffixIconConstraints: const BoxConstraints( + minHeight: 20, + minWidth: 20, + ), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: BorderSide(color: borderColor), + ), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: BorderSide(color: borderColor), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: BorderSide(color: borderColor, width: 1.2), + ), + errorBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: const BorderSide(color: Colors.red), + ), + disabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: BorderSide(color: borderColor), + ), hintText: widget.hintText.tr, - hintStyle: AppThemeData.regularTextStyle(fontSize: 14, color: hintColor), + hintStyle: AppThemeData.regularTextStyle( + fontSize: 14.sp, + color: hintColor, + ), ), ), ], diff --git a/lib/utils/app_router.dart b/lib/utils/app_router.dart new file mode 100644 index 0000000..95b05e1 --- /dev/null +++ b/lib/utils/app_router.dart @@ -0,0 +1,42 @@ +import 'package:flutter/material.dart'; + +class AppRouter { + static final GlobalKey navigatorKey = + GlobalKey(); + + static void close() { + if (navigatorKey.currentState?.canPop() ?? false) { + navigatorKey.currentState!.pop(); + } + } + + static void go(Widget page) { + navigatorKey.currentState?.push(_createRoute(page)); + } + + static void open(Widget page) { + navigatorKey.currentState?.pushAndRemoveUntil( + _createRoute(page), + (Route route) => false, + ); + } + + static PageRouteBuilder _createRoute(Widget page) { + return PageRouteBuilder( + transitionDuration: const Duration(milliseconds: 200), + reverseTransitionDuration: const Duration(milliseconds: 100), + pageBuilder: (context, animation, secondaryAnimation) => page, + transitionsBuilder: (context, animation, secondaryAnimation, child) { + final curvedAnimation = CurvedAnimation( + parent: animation, + curve: Curves.ease, + ); + return ScaleTransition( + alignment: Alignment.center, + scale: Tween(begin: 0.950, end: 1).animate(curvedAnimation), + child: child, + ); + }, + ); + } +} \ No newline at end of file diff --git a/lib/utils/notification_service.dart b/lib/utils/notification_service.dart index 1832fcb..8b13c65 100644 --- a/lib/utils/notification_service.dart +++ b/lib/utils/notification_service.dart @@ -9,25 +9,51 @@ Future firebaseMessageBackgroundHandle(RemoteMessage message) async { } class NotificationService { - FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin(); + FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = + FlutterLocalNotificationsPlugin(); Future initInfo() async { - await FirebaseMessaging.instance.setForegroundNotificationPresentationOptions(alert: true, badge: true, sound: true); - var request = await FirebaseMessaging.instance.requestPermission(alert: true, announcement: false, badge: true, carPlay: false, criticalAlert: false, provisional: false, sound: true); + await FirebaseMessaging.instance + .setForegroundNotificationPresentationOptions( + alert: true, + badge: true, + sound: true, + ); + var request = await FirebaseMessaging.instance.requestPermission( + alert: true, + announcement: false, + badge: true, + carPlay: false, + criticalAlert: false, + provisional: false, + sound: true, + ); - if (request.authorizationStatus == AuthorizationStatus.authorized || request.authorizationStatus == AuthorizationStatus.provisional) { - const AndroidInitializationSettings initializationSettingsAndroid = AndroidInitializationSettings('@mipmap/ic_launcher'); + if (request.authorizationStatus == AuthorizationStatus.authorized || + request.authorizationStatus == AuthorizationStatus.provisional) { + const AndroidInitializationSettings initializationSettingsAndroid = + AndroidInitializationSettings('@mipmap/ic_launcher'); var iosInitializationSettings = const DarwinInitializationSettings(); - final InitializationSettings initializationSettings = InitializationSettings(android: initializationSettingsAndroid, iOS: iosInitializationSettings); - await flutterLocalNotificationsPlugin.initialize(initializationSettings, onDidReceiveNotificationResponse: (payload) {}); + final InitializationSettings initializationSettings = + InitializationSettings( + android: initializationSettingsAndroid, + iOS: iosInitializationSettings, + ); + await flutterLocalNotificationsPlugin.initialize( + initializationSettings, + onDidReceiveNotificationResponse: (payload) {}, + ); setupInteractedMessage(); } } Future setupInteractedMessage() async { - RemoteMessage? initialMessage = await FirebaseMessaging.instance.getInitialMessage(); + RemoteMessage? initialMessage = + await FirebaseMessaging.instance.getInitialMessage(); if (initialMessage != null) { - FirebaseMessaging.onBackgroundMessage((message) => firebaseMessageBackgroundHandle(message)); + FirebaseMessaging.onBackgroundMessage( + (message) => firebaseMessageBackgroundHandle(message), + ); } FirebaseMessaging.onMessage.listen((RemoteMessage message) { @@ -103,18 +129,38 @@ class NotificationService { log('Got a message whilst in the foreground!'); log('Message data: ${message.notification!.body.toString()}'); try { - AndroidNotificationChannel channel = const AndroidNotificationChannel('0', 'eMart customer', description: 'Show eMart Notification', importance: Importance.max); - AndroidNotificationDetails notificationDetails = AndroidNotificationDetails( - channel.id, - channel.name, - channelDescription: 'your channel Description', - importance: Importance.high, - priority: Priority.high, - ticker: 'ticker', + AndroidNotificationChannel channel = const AndroidNotificationChannel( + '0', + 'eMart customer', + description: 'Show eMart Notification', + importance: Importance.max, + ); + AndroidNotificationDetails notificationDetails = + AndroidNotificationDetails( + channel.id, + channel.name, + channelDescription: 'your channel Description', + importance: Importance.high, + priority: Priority.high, + ticker: 'ticker', + ); + const DarwinNotificationDetails darwinNotificationDetails = + DarwinNotificationDetails( + presentAlert: true, + presentBadge: true, + presentSound: true, + ); + NotificationDetails notificationDetailsBoth = NotificationDetails( + android: notificationDetails, + iOS: darwinNotificationDetails, + ); + await FlutterLocalNotificationsPlugin().show( + 0, + message.notification!.title, + message.notification!.body, + notificationDetailsBoth, + payload: jsonEncode(message.data), ); - const DarwinNotificationDetails darwinNotificationDetails = DarwinNotificationDetails(presentAlert: true, presentBadge: true, presentSound: true); - NotificationDetails notificationDetailsBoth = NotificationDetails(android: notificationDetails, iOS: darwinNotificationDetails); - await FlutterLocalNotificationsPlugin().show(0, message.notification!.title, message.notification!.body, notificationDetailsBoth, payload: jsonEncode(message.data)); } on Exception catch (e) { log(e.toString()); } diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index 3e2b574..97b5582 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -1,7 +1,9 @@ import 'package:customer/constant/constant.dart'; import 'package:customer/widget/place_picker/selected_location_model.dart'; + import 'package:geolocator/geolocator.dart'; -import 'package:get/get_utils/src/extensions/internacionalization.dart'; +import 'package:get/get.dart'; + import 'package:map_launcher/map_launcher.dart'; import '../themes/show_toast_dialog.dart'; import 'package:geocoding/geocoding.dart'; @@ -36,7 +38,9 @@ class Utils { if (permission == LocationPermission.deniedForever) { // Permissions are denied forever, handle appropriately. - return Future.error('Location permissions are permanently denied, we cannot request permissions.'); + return Future.error( + 'Location permissions are permanently denied, we cannot request permissions.', + ); } // When we reach here, permissions are granted and we can @@ -44,12 +48,16 @@ class Utils { return await Geolocator.getCurrentPosition(); } - static Future getAddressFromCoordinates(double lat, double lng) async { + static Future getAddressFromCoordinates( + double lat, + double lng, + ) async { try { List placemarks = await placemarkFromCoordinates(lat, lng); if (placemarks.isNotEmpty) { Placemark place = placemarks.first; - String address = "${place.name ?? ''}, ${place.subLocality ?? ''}, ${place.locality ?? ''}, ${place.administrativeArea ?? ''}, ${place.country ?? ''}"; + String address = + "${place.name ?? ''}, ${place.subLocality ?? ''}, ${place.locality ?? ''}, ${place.administrativeArea ?? ''}, ${place.country ?? ''}"; return address; } return "Unknown location"; @@ -58,67 +66,122 @@ class Utils { } } - static Future redirectMap({required String name, required double latitude, required double longLatitude}) async { + static Future redirectMap({ + required String name, + required double latitude, + required double longLatitude, + }) async { if (Constant.mapType == "google") { bool? isAvailable = await MapLauncher.isMapAvailable(MapType.google); if (isAvailable == true) { - await MapLauncher.showDirections(mapType: MapType.google, directionsMode: DirectionsMode.driving, destinationTitle: name, destination: Coords(latitude, longLatitude)); + await MapLauncher.showDirections( + mapType: MapType.google, + directionsMode: DirectionsMode.driving, + destinationTitle: name, + destination: Coords(latitude, longLatitude), + ); } else { ShowToastDialog.showToast("Google map is not installed".tr); } } else if (Constant.mapType == "googleGo") { bool? isAvailable = await MapLauncher.isMapAvailable(MapType.googleGo); if (isAvailable == true) { - await MapLauncher.showDirections(mapType: MapType.googleGo, directionsMode: DirectionsMode.driving, destinationTitle: name, destination: Coords(latitude, longLatitude)); + await MapLauncher.showDirections( + mapType: MapType.googleGo, + directionsMode: DirectionsMode.driving, + destinationTitle: name, + destination: Coords(latitude, longLatitude), + ); } else { ShowToastDialog.showToast("Google Go map is not installed".tr); } } else if (Constant.mapType == "waze") { bool? isAvailable = await MapLauncher.isMapAvailable(MapType.waze); if (isAvailable == true) { - await MapLauncher.showDirections(mapType: MapType.waze, directionsMode: DirectionsMode.driving, destinationTitle: name, destination: Coords(latitude, longLatitude)); + await MapLauncher.showDirections( + mapType: MapType.waze, + directionsMode: DirectionsMode.driving, + destinationTitle: name, + destination: Coords(latitude, longLatitude), + ); } else { ShowToastDialog.showToast("Waze is not installed".tr); } } else if (Constant.mapType == "mapswithme") { bool? isAvailable = await MapLauncher.isMapAvailable(MapType.mapswithme); if (isAvailable == true) { - await MapLauncher.showDirections(mapType: MapType.mapswithme, directionsMode: DirectionsMode.driving, destinationTitle: name, destination: Coords(latitude, longLatitude)); + await MapLauncher.showDirections( + mapType: MapType.mapswithme, + directionsMode: DirectionsMode.driving, + destinationTitle: name, + destination: Coords(latitude, longLatitude), + ); } else { ShowToastDialog.showToast("Mapswithme is not installed".tr); } } else if (Constant.mapType == "yandexNavi") { bool? isAvailable = await MapLauncher.isMapAvailable(MapType.yandexNavi); if (isAvailable == true) { - await MapLauncher.showDirections(mapType: MapType.yandexNavi, directionsMode: DirectionsMode.driving, destinationTitle: name, destination: Coords(latitude, longLatitude)); + await MapLauncher.showDirections( + mapType: MapType.yandexNavi, + directionsMode: DirectionsMode.driving, + destinationTitle: name, + destination: Coords(latitude, longLatitude), + ); } else { ShowToastDialog.showToast("YandexNavi is not installed".tr); } } else if (Constant.mapType == "yandexMaps") { bool? isAvailable = await MapLauncher.isMapAvailable(MapType.yandexMaps); if (isAvailable == true) { - await MapLauncher.showDirections(mapType: MapType.yandexMaps, directionsMode: DirectionsMode.driving, destinationTitle: name, destination: Coords(latitude, longLatitude)); + await MapLauncher.showDirections( + mapType: MapType.yandexMaps, + directionsMode: DirectionsMode.driving, + destinationTitle: name, + destination: Coords(latitude, longLatitude), + ); } else { ShowToastDialog.showToast("yandexMaps map is not installed".tr); } } } - static String formatAddress({required SelectedLocationModel selectedLocation}) { + static String formatAddress({ + required SelectedLocationModel selectedLocation, + }) { List parts = []; - if (selectedLocation.address!.name != null && selectedLocation.address!.name!.isNotEmpty) parts.add(selectedLocation.address!.name!); - if (selectedLocation.address!.subThoroughfare != null && selectedLocation.address!.subThoroughfare!.isNotEmpty) parts.add(selectedLocation.address!.subThoroughfare!); - if (selectedLocation.address!.thoroughfare != null && selectedLocation.address!.thoroughfare!.isNotEmpty) parts.add(selectedLocation.address!.thoroughfare!); - if (selectedLocation.address!.subLocality != null && selectedLocation.address!.subLocality!.isNotEmpty) parts.add(selectedLocation.address!.subLocality!); - if (selectedLocation.address!.locality != null && selectedLocation.address!.locality!.isNotEmpty) parts.add(selectedLocation.address!.locality!); - if (selectedLocation.address!.subAdministrativeArea != null && selectedLocation.address!.subAdministrativeArea!.isNotEmpty) { + if (selectedLocation.address!.name != null && + selectedLocation.address!.name!.isNotEmpty) + parts.add(selectedLocation.address!.name!); + if (selectedLocation.address!.subThoroughfare != null && + selectedLocation.address!.subThoroughfare!.isNotEmpty) + parts.add(selectedLocation.address!.subThoroughfare!); + if (selectedLocation.address!.thoroughfare != null && + selectedLocation.address!.thoroughfare!.isNotEmpty) + parts.add(selectedLocation.address!.thoroughfare!); + if (selectedLocation.address!.subLocality != null && + selectedLocation.address!.subLocality!.isNotEmpty) + parts.add(selectedLocation.address!.subLocality!); + if (selectedLocation.address!.locality != null && + selectedLocation.address!.locality!.isNotEmpty) + parts.add(selectedLocation.address!.locality!); + if (selectedLocation.address!.subAdministrativeArea != null && + selectedLocation.address!.subAdministrativeArea!.isNotEmpty) { parts.add(selectedLocation.address!.subAdministrativeArea!); } - if (selectedLocation.address!.administrativeArea != null && selectedLocation.address!.administrativeArea!.isNotEmpty) parts.add(selectedLocation.address!.administrativeArea!); - if (selectedLocation.address!.postalCode != null && selectedLocation.address!.postalCode!.isNotEmpty) parts.add(selectedLocation.address!.postalCode!); - if (selectedLocation.address!.country != null && selectedLocation.address!.country!.isNotEmpty) parts.add(selectedLocation.address!.country!); - if (selectedLocation.address!.isoCountryCode != null && selectedLocation.address!.isoCountryCode!.isNotEmpty) parts.add(selectedLocation.address!.isoCountryCode!); + if (selectedLocation.address!.administrativeArea != null && + selectedLocation.address!.administrativeArea!.isNotEmpty) + parts.add(selectedLocation.address!.administrativeArea!); + if (selectedLocation.address!.postalCode != null && + selectedLocation.address!.postalCode!.isNotEmpty) + parts.add(selectedLocation.address!.postalCode!); + if (selectedLocation.address!.country != null && + selectedLocation.address!.country!.isNotEmpty) + parts.add(selectedLocation.address!.country!); + if (selectedLocation.address!.isoCountryCode != null && + selectedLocation.address!.isoCountryCode!.isNotEmpty) + parts.add(selectedLocation.address!.isoCountryCode!); return parts.join(', '); } diff --git a/lib/widget/firebase_pagination/src/widgets/defaults/empty_screen.dart b/lib/widget/firebase_pagination/src/widgets/defaults/empty_screen.dart index 7c9c853..4598366 100644 --- a/lib/widget/firebase_pagination/src/widgets/defaults/empty_screen.dart +++ b/lib/widget/firebase_pagination/src/widgets/defaults/empty_screen.dart @@ -1,4 +1,5 @@ // Flutter Packages + import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -9,8 +10,6 @@ class EmptyScreen extends StatelessWidget { @override Widget build(BuildContext context) { - return Center( - child: Text('Nothing found here...'.tr), - ); + return Center(child: Text('Nothing found here...'.tr)); } } diff --git a/lib/widget/osm_map/map_controller.dart b/lib/widget/osm_map/map_controller.dart index 182b786..7f528fb 100644 --- a/lib/widget/osm_map/map_controller.dart +++ b/lib/widget/osm_map/map_controller.dart @@ -20,11 +20,15 @@ class OSMMapController extends GetxController { } final url = Uri.parse( - 'https://nominatim.openstreetmap.org/search?q=$query&format=json&addressdetails=1&limit=10'); + 'https://nominatim.openstreetmap.org/search?q=$query&format=json&addressdetails=1&limit=10', + ); - final response = await http.get(url, headers: { - 'User-Agent': 'FlutterMapApp/1.0 (menil.siddhiinfosoft@gmail.com)', - }); + final response = await http.get( + url, + headers: { + 'User-Agent': 'FlutterMapApp/1.0 (menil.siddhiinfosoft@gmail.com)', + }, + ); if (response.statusCode == 200) { final data = json.decode(response.body); @@ -52,11 +56,15 @@ class OSMMapController extends GetxController { Future _getAddressFromLatLng(LatLng coords) async { final url = Uri.parse( - 'https://nominatim.openstreetmap.org/reverse?lat=${coords.latitude}&lon=${coords.longitude}&format=json'); + 'https://nominatim.openstreetmap.org/reverse?lat=${coords.latitude}&lon=${coords.longitude}&format=json', + ); - final response = await http.get(url, headers: { - 'User-Agent': 'FlutterMapApp/1.0 (menil.siddhiinfosoft@gmail.com)', - }); + final response = await http.get( + url, + headers: { + 'User-Agent': 'FlutterMapApp/1.0 (menil.siddhiinfosoft@gmail.com)', + }, + ); if (response.statusCode == 200) { final data = json.decode(response.body); @@ -79,10 +87,13 @@ class OSMMapController extends GetxController { Future getCurrentLocation() async { Position? location = await Utils.getCurrentLocation(); - LatLng latlng = - LatLng(location?.latitude ?? 0.0, location?.longitude ?? 0.0); + LatLng latlng = LatLng( + location?.latitude ?? 0.0, + location?.longitude ?? 0.0, + ); addLatLngOnly( - LatLng(location?.latitude ?? 0.0, location?.longitude ?? 0.0)); + LatLng(location?.latitude ?? 0.0, location?.longitude ?? 0.0), + ); mapController.move(latlng, mapController.camera.zoom); } } diff --git a/lib/widget/osm_map/map_picker_page.dart b/lib/widget/osm_map/map_picker_page.dart index 4e55913..d5014a1 100644 --- a/lib/widget/osm_map/map_picker_page.dart +++ b/lib/widget/osm_map/map_picker_page.dart @@ -1,8 +1,12 @@ +import 'dart:developer'; + import 'package:customer/themes/app_them_data.dart'; import 'package:customer/themes/round_button_fill.dart'; import 'package:customer/widget/osm_map/map_controller.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:latlong2/latlong.dart'; import '../../controllers/theme_controller.dart'; @@ -18,38 +22,68 @@ class MapPickerPage extends StatelessWidget { final themeController = Get.find(); final isDark = themeController.isDark.value; return Scaffold( - appBar: AppBar( - backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface, - centerTitle: false, - titleSpacing: 0, - title: Text("PickUp Location".tr, textAlign: TextAlign.start, style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900)), - ), + // appBar: AppBar( + // backgroundColor: + // isDark ? AppThemeData.surfaceDark : AppThemeData.surface, + // centerTitle: false, + // titleSpacing: 0, + // title: Text( + // "PickUp Location".tr, + // textAlign: TextAlign.start, + // style: TextStyle( + // fontFamily: AppThemeData.medium, + // fontSize: 16, + // color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, + // ), + // ), + // ), body: Stack( children: [ Obx( () => FlutterMap( mapController: controller.mapController, options: MapOptions( - initialCenter: controller.pickedPlace.value?.coordinates ?? LatLng(20.5937, 78.9629), // Default India center + initialCenter: + controller.pickedPlace.value?.coordinates ?? + LatLng(41.3775, 64.5853), // Default UZB center initialZoom: 13, onTap: (tapPos, latlng) { controller.addLatLngOnly(latlng); - controller.mapController.move(latlng, controller.mapController.camera.zoom); + controller.mapController.move( + latlng, + controller.mapController.camera.zoom, + ); }, ), children: [ - TileLayer(urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', subdomains: const ['a', 'b', 'c'], userAgentPackageName: 'com.emart.app'), + TileLayer( + urlTemplate: + 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', + subdomains: const ['a', 'b', 'c'], + userAgentPackageName: 'com.emart.app', + ), MarkerLayer( markers: controller.pickedPlace.value != null - ? [Marker(point: controller.pickedPlace.value!.coordinates, width: 40, height: 40, child: const Icon(Icons.location_pin, size: 36, color: Colors.red))] + ? [ + Marker( + point: controller.pickedPlace.value!.coordinates, + width: 40, + height: 40, + child: const Icon( + Icons.location_pin, + size: 36, + color: Colors.red, + ), + ), + ] : [], ), ], ), ), Positioned( - top: 16, + top: MediaQuery.of(context).size.height / 9, left: 16, right: 16, child: Column( @@ -59,10 +93,18 @@ class MapPickerPage extends StatelessWidget { borderRadius: BorderRadius.circular(8), child: TextField( controller: searchController, - style: TextStyle(color: isDark ? AppThemeData.grey900 : AppThemeData.grey900), + style: TextStyle( + color: + isDark ? AppThemeData.grey900 : AppThemeData.grey900, + ), decoration: InputDecoration( hintText: 'Search location...'.tr, - hintStyle: TextStyle(color: isDark ? AppThemeData.grey900 : AppThemeData.grey900), + hintStyle: TextStyle( + color: + isDark + ? AppThemeData.grey900 + : AppThemeData.grey900, + ), contentPadding: EdgeInsets.all(12), border: InputBorder.none, prefixIcon: Icon(Icons.search), @@ -76,7 +118,10 @@ class MapPickerPage extends StatelessWidget { } return Container( margin: const EdgeInsets.only(top: 4), - decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8)), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(8), + ), child: ListView.builder( shrinkWrap: true, itemCount: controller.searchResults.length, @@ -111,8 +156,13 @@ class MapPickerPage extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ Text( - controller.pickedPlace.value != null ? "Picked Location:".tr : "No Location Picked".tr, - style: TextStyle(color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600), + controller.pickedPlace.value != null + ? "Picked Location:".tr + : "No Location Picked".tr, + style: AppThemeData.boldTextStyle( + color: AppThemeData.grey900, + fontSize: 17.sp, + ), ), const SizedBox(height: 4), if (controller.pickedPlace.value != null) @@ -129,20 +179,26 @@ class MapPickerPage extends StatelessWidget { Expanded( child: RoundedButtonFill( title: "Confirm Location".tr, - color: AppThemeData.primary300, + color: AppThemeData.mainColor, textColor: AppThemeData.grey50, - height: 5, + borderRadius: 12, + height: 6, onPress: () async { final selected = controller.pickedPlace.value; if (selected != null) { - Get.back(result: selected); // ✅ Return the selected place - print("Selected location: $selected"); + Get.back( + result: selected, + ); // ✅ Return the selected place + log("Selected location: $selected"); } }, ), ), - const SizedBox(width: 10), - IconButton(icon: const Icon(Icons.delete_forever, color: Colors.red), onPressed: controller.clearAll), + SizedBox(width: 10.w), + IconButton( + icon: const Icon(Icons.delete_forever, color: Colors.red), + onPressed: controller.clearAll, + ), ], ), ], diff --git a/lib/widget/permission_dialog.dart b/lib/widget/permission_dialog.dart index da17132..f26e0e2 100644 --- a/lib/widget/permission_dialog.dart +++ b/lib/widget/permission_dialog.dart @@ -20,10 +20,15 @@ class PermissionDialog extends StatelessWidget { child: Column( mainAxisSize: MainAxisSize.min, children: [ - Icon(Icons.add_location_alt_rounded, color: Theme.of(context).primaryColor, size: 100), + Icon( + Icons.add_location_alt_rounded, + color: Theme.of(context).primaryColor, + size: 100, + ), const SizedBox(height: 20), Text( - 'You denied location permission forever. Please allow location permission from your app settings and receive more accurate delivery.'.tr, + 'You denied location permission forever. Please allow location permission from your app settings and receive more accurate delivery.' + .tr, textAlign: TextAlign.center, style: TextStyle(fontSize: 18), ), @@ -33,7 +38,13 @@ class PermissionDialog extends StatelessWidget { Expanded( child: TextButton( style: TextButton.styleFrom( - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30), side: BorderSide(width: 2, color: Theme.of(context).primaryColor)), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(30), + side: BorderSide( + width: 2, + color: Theme.of(context).primaryColor, + ), + ), minimumSize: const Size(1, 50), ), child: Text('close'.tr), diff --git a/lib/widget/place_picker/location_controller.dart b/lib/widget/place_picker/location_controller.dart index c9eb0d6..7721776 100644 --- a/lib/widget/place_picker/location_controller.dart +++ b/lib/widget/place_picker/location_controller.dart @@ -34,11 +34,15 @@ class LocationController extends GetxController { Future getCurrentLocation() async { try { - Position position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high); + Position position = await Geolocator.getCurrentPosition( + desiredAccuracy: LocationAccuracy.high, + ); selectedLocation.value = LatLng(position.latitude, position.longitude); if (mapController != null) { - mapController!.animateCamera(CameraUpdate.newLatLngZoom(selectedLocation.value!, 15)); + mapController!.animateCamera( + CameraUpdate.newLatLngZoom(selectedLocation.value!, 15), + ); } await getAddressFromLatLng(selectedLocation.value!); @@ -49,11 +53,15 @@ class LocationController extends GetxController { Future getAddressFromLatLng(LatLng latLng) async { try { - List placemarks = await placemarkFromCoordinates(latLng.latitude, latLng.longitude); + List placemarks = await placemarkFromCoordinates( + latLng.latitude, + latLng.longitude, + ); if (placemarks.isNotEmpty) { Placemark place = placemarks.first; selectedPlaceAddress.value = place; - address.value = "${place.street}, ${place.locality}, ${place.administrativeArea}, ${place.country}"; + address.value = + "${place.street}, ${place.locality}, ${place.administrativeArea}, ${place.country}"; } else { address.value = "Address not found"; } @@ -71,7 +79,10 @@ class LocationController extends GetxController { try { List locations = await locationFromAddress(zipCode); if (locations.isNotEmpty) { - selectedLocation.value = LatLng(locations.first.latitude, locations.first.longitude); + selectedLocation.value = LatLng( + locations.first.latitude, + locations.first.longitude, + ); } } catch (e) { print("Error getting coordinates for ZIP code: $e"); @@ -80,7 +91,10 @@ class LocationController extends GetxController { void confirmLocation() { if (selectedLocation.value != null) { - SelectedLocationModel selectedLocationModel = SelectedLocationModel(address: selectedPlaceAddress.value, latLng: selectedLocation.value); + SelectedLocationModel selectedLocationModel = SelectedLocationModel( + address: selectedPlaceAddress.value, + latLng: selectedLocation.value, + ); Get.back(result: selectedLocationModel); } } diff --git a/lib/widget/place_picker/location_picker_screen.dart b/lib/widget/place_picker/location_picker_screen.dart index efb1fdc..e1190e4 100644 --- a/lib/widget/place_picker/location_picker_screen.dart +++ b/lib/widget/place_picker/location_picker_screen.dart @@ -4,6 +4,7 @@ import 'package:customer/themes/round_button_fill.dart'; import 'package:customer/widget/place_picker/location_controller.dart'; import 'package:customer/constant/constant.dart'; import 'package:customer/controllers/theme_controller.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_google_places_hoc081098/flutter_google_places_hoc081098.dart'; import 'package:flutter_google_places_hoc081098/google_maps_webservice_places.dart'; @@ -31,7 +32,10 @@ class LocationPickerScreen extends StatelessWidget { onMapCreated: (controllers) { controller.mapController = controllers; }, - initialCameraPosition: CameraPosition(target: controller.selectedLocation.value!, zoom: 15), + initialCameraPosition: CameraPosition( + target: controller.selectedLocation.value!, + zoom: 15, + ), onTap: (LatLng tappedPosition) { controller.selectedLocation.value = tappedPosition; controller.getAddressFromLatLng(tappedPosition); @@ -44,14 +48,18 @@ class LocationPickerScreen extends StatelessWidget { markerId: const MarkerId("selected-location"), position: controller.selectedLocation.value!, onTap: () { - controller.getAddressFromLatLng(controller.selectedLocation.value!); + controller.getAddressFromLatLng( + controller.selectedLocation.value!, + ); }, ), }, onCameraMove: controller.onMapMoved, onCameraIdle: () { if (controller.selectedLocation.value != null) { - controller.getAddressFromLatLng(controller.selectedLocation.value!); + controller.getAddressFromLatLng( + controller.selectedLocation.value!, + ); } }, ), @@ -67,29 +75,65 @@ class LocationPickerScreen extends StatelessWidget { Get.back(); }, child: Container( - decoration: BoxDecoration(color: isDark ? AppThemeData.greyDark50 : AppThemeData.grey50, borderRadius: BorderRadius.circular(30)), - child: Padding(padding: const EdgeInsets.all(10), child: Icon(Icons.arrow_back_ios_new_outlined, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)), + decoration: BoxDecoration( + color: + isDark + ? AppThemeData.greyDark50 + : AppThemeData.grey50, + borderRadius: BorderRadius.circular(30), + ), + child: Padding( + padding: const EdgeInsets.all(10), + child: Icon( + Icons.arrow_back_ios_new_outlined, + color: + isDark + ? AppThemeData.greyDark900 + : AppThemeData.grey900, + ), + ), ), ), SizedBox(height: 20), GestureDetector( onTap: () async { - Prediction? p = await PlacesAutocomplete.show(context: context, apiKey: Constant.mapAPIKey, mode: Mode.overlay, language: "en"); + Prediction? p = await PlacesAutocomplete.show( + context: context, + apiKey: Constant.mapAPIKey, + mode: Mode.overlay, + language: "en", + ); if (p != null) { - final detail = await _places.getDetailsByPlaceId(p.placeId!); + final detail = await _places.getDetailsByPlaceId( + p.placeId!, + ); final lat = detail.result.geometry!.location.lat; final lng = detail.result.geometry!.location.lng; final LatLng pos = LatLng(lat, lng); controller.selectedLocation.value = pos; - controller.mapController?.animateCamera(CameraUpdate.newLatLngZoom(pos, 15)); + controller.mapController?.animateCamera( + CameraUpdate.newLatLngZoom(pos, 15), + ); controller.getAddressFromLatLng(pos); } }, child: Container( width: Responsive.width(100, context), - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), - decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(60)), - child: Row(children: [Icon(Icons.search), SizedBox(width: 8), Text("Search place...".tr)]), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 12, + ), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(60), + ), + child: Row( + children: [ + Icon(Icons.search), + SizedBox(width: 8), + Text("Search place...".tr), + ], + ), ), ), ], @@ -101,13 +145,34 @@ class LocationPickerScreen extends StatelessWidget { right: 20, child: Container( padding: const EdgeInsets.all(10), - decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(10), boxShadow: const [BoxShadow(color: Colors.black26, blurRadius: 5)]), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(10), + boxShadow: const [ + BoxShadow(color: Colors.black26, blurRadius: 5), + ], + ), child: Column( mainAxisSize: MainAxisSize.min, children: [ - Obx(() => Text(controller.address.value, textAlign: TextAlign.center, style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w500))), + Obx( + () => Text( + controller.address.value, + textAlign: TextAlign.center, + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, + ), + ), + ), const SizedBox(height: 10), - RoundedButtonFill(title: "Confirm Location".tr, height: 5.5, color: AppThemeData.primary300, textColor: AppThemeData.grey50, onPress: () => controller.confirmLocation()), + RoundedButtonFill( + title: "Confirm Location", + height: 5.5, + color: AppThemeData.mainColor, + textColor: AppThemeData.grey50, + onPress: () => controller.confirmLocation(), + ), ], ), ), diff --git a/lib/widget/story_view/widgets/story_image.dart b/lib/widget/story_view/widgets/story_image.dart index c7cd2a4..5d8ef01 100644 --- a/lib/widget/story_view/widgets/story_image.dart +++ b/lib/widget/story_view/widgets/story_image.dart @@ -3,8 +3,7 @@ import 'dart:ui' as ui; import 'package:flutter/material.dart'; import 'package:flutter_cache_manager/flutter_cache_manager.dart'; -import 'package:get/get_utils/src/extensions/internacionalization.dart'; - +import 'package:get/get.dart'; import '../controller/story_controller.dart'; import '../utils.dart'; @@ -29,7 +28,10 @@ class ImageLoader { onComplete(); } - final fileStream = DefaultCacheManager().getFileStream(url, headers: requestHeaders as Map?); + final fileStream = DefaultCacheManager().getFileStream( + url, + headers: requestHeaders as Map?, + ); fileStream.listen( (fileResponse) { @@ -45,13 +47,18 @@ class ImageLoader { state = LoadState.success; - ui.instantiateImageCodec(imageBytes).then((codec) { - frames = codec; - onComplete(); - }, onError: (error) { - state = LoadState.failure; - onComplete(); - }); + ui + .instantiateImageCodec(imageBytes) + .then( + (codec) { + frames = codec; + onComplete(); + }, + onError: (error) { + state = LoadState.failure; + onComplete(); + }, + ); }, onError: (error) { state = LoadState.failure; @@ -93,10 +100,7 @@ class StoryImage extends StatefulWidget { Key? key, }) { return StoryImage( - ImageLoader( - url, - requestHeaders: requestHeaders, - ), + ImageLoader(url, requestHeaders: requestHeaders), controller: controller, fit: fit, loadingWidget: loadingWidget, @@ -121,7 +125,9 @@ class StoryImageState extends State { super.initState(); if (widget.controller != null) { - _streamSubscription = widget.controller!.playbackNotifier.listen((playbackState) { + _streamSubscription = widget.controller!.playbackNotifier.listen(( + playbackState, + ) { // for the case of gifs we need to pause/play if (widget.imageLoader.frames == null) { return; @@ -168,7 +174,9 @@ class StoryImageState extends State { void forward() async { _timer?.cancel(); - if (widget.controller != null && widget.controller!.playbackNotifier.stream.value == PlaybackState.pause) { + if (widget.controller != null && + widget.controller!.playbackNotifier.stream.value == + PlaybackState.pause) { return; } @@ -186,22 +194,20 @@ class StoryImageState extends State { Widget getContentView() { switch (widget.imageLoader.state) { case LoadState.success: - return RawImage( - image: currentFrame, - fit: widget.fit, - ); + return RawImage(image: currentFrame, fit: widget.fit); case LoadState.failure: return Center( - child: widget.errorWidget ?? - Text( - "Image failed to load.".tr, - style: TextStyle( - color: Colors.white, - ), - )); + child: + widget.errorWidget ?? + Text( + "Image failed to load.".tr, + style: TextStyle(color: Colors.white), + ), + ); default: return Center( - child: widget.loadingWidget ?? + child: + widget.loadingWidget ?? const SizedBox( width: 70, height: 70, diff --git a/pubspec.lock b/pubspec.lock index 8d3bc1b..d0c04cc 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -93,42 +93,42 @@ packages: dependency: transitive description: name: camera - sha256: d6ec2cbdbe2fa8f5e0d07d8c06368fe4effa985a4a5ddade9cc58a8cd849557d + sha256: eefad89f262a873f38d21e5eec853461737ea074d7c9ede39f3ceb135d201cab url: "https://pub.dev" source: hosted - version: "0.11.2" + version: "0.11.3" camera_android_camerax: dependency: transitive description: name: camera_android_camerax - sha256: "0db8e7b161ec6cdb2219540eaa4cf599dc963929e5f8ded3b20b3acb52712fa4" + sha256: "360a9436980590e7268e0ff9eff482ff73ac3e0f66fffdd203cd93d1bfed0fc4" url: "https://pub.dev" source: hosted - version: "0.6.21+1" + version: "0.6.25+1" camera_avfoundation: dependency: transitive description: name: camera_avfoundation - sha256: a5a90297520e3b9841331161a7511626681153849c690c138e04a2b6d0af3026 + sha256: "035b90c1e33c2efad7548f402572078f6e514d4f82be0a315cd6c6af7e855aa8" url: "https://pub.dev" source: hosted - version: "0.9.21+3" + version: "0.9.22+6" camera_platform_interface: dependency: transitive description: name: camera_platform_interface - sha256: ea1ef6ba79cdbed93df2d3eeef11542a90dec24dbcd9cde574926b86d7a09a10 + sha256: "98cfc9357e04bad617671b4c1f78a597f25f08003089dd94050709ae54effc63" url: "https://pub.dev" source: hosted - version: "2.11.0" + version: "2.12.0" camera_web: dependency: transitive description: name: camera_web - sha256: "595f28c89d1fb62d77c73c633193755b781c6d2e0ebcd8dc25b763b514e6ba8f" + sha256: "3bc7bb1657a0f29c34116453c5d5e528c23efcf5e75aac0a3387cf108040bf65" url: "https://pub.dev" source: hosted - version: "0.3.5" + version: "0.3.5+2" characters: dependency: transitive description: @@ -209,22 +209,30 @@ packages: url: "https://pub.dev" source: hosted version: "3.4.1" + country_flags: + dependency: "direct main" + description: + name: country_flags + sha256: "714f2d415e74828eb08787d552a05e94cdf2cbe0607a5656f3e70087cd7bb7e0" + url: "https://pub.dev" + source: hosted + version: "4.1.0" cross_file: dependency: transitive description: name: cross_file - sha256: "7caf6a750a0c04effbb52a676dce9a4a592e10ad35c34d6d2d0e4811160d5670" + sha256: "701dcfc06da0882883a2657c445103380e53e647060ad8d9dfb710c100996608" url: "https://pub.dev" source: hosted - version: "0.3.4+2" + version: "0.3.5+1" crypto: dependency: transitive description: name: crypto - sha256: "1e445881f28f22d6140f181e07737b22f1e099a5e1ff94b0af2f9e4a463f4855" + sha256: c8ea0233063ba03258fbcf2ca4d6dadfefe14f02fab57702265467a19f27fadf url: "https://pub.dev" source: hosted - version: "3.0.6" + version: "3.0.7" csslib: dependency: transitive description: @@ -321,6 +329,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.0" + enum_to_string: + dependency: transitive + description: + name: enum_to_string + sha256: "93b75963d3b0c9f6a90c095b3af153e1feccb79f6f08282d3274ff8d9eea52bc" + url: "https://pub.dev" + source: hosted + version: "2.2.1" equatable: dependency: transitive description: @@ -365,34 +381,34 @@ packages: dependency: transitive description: name: file_selector_linux - sha256: "54cbbd957e1156d29548c7d9b9ec0c0ebb6de0a90452198683a7d23aed617a33" + sha256: "2567f398e06ac72dcf2e98a0c95df2a9edd03c2c2e0cacd4780f20cdf56263a0" url: "https://pub.dev" source: hosted - version: "0.9.3+2" + version: "0.9.4" file_selector_macos: dependency: transitive description: name: file_selector_macos - sha256: "19124ff4a3d8864fdc62072b6a2ef6c222d55a3404fe14893a3c02744907b60c" + sha256: "5e0bbe9c312416f1787a68259ea1505b52f258c587f12920422671807c4d618a" url: "https://pub.dev" source: hosted - version: "0.9.4+4" + version: "0.9.5" file_selector_platform_interface: dependency: transitive description: name: file_selector_platform_interface - sha256: a3994c26f10378a039faa11de174d7b78eb8f79e4dd0af2a451410c1a5c3f66b + sha256: "35e0bd61ebcdb91a3505813b055b09b79dfdc7d0aee9c09a7ba59ae4bb13dc85" url: "https://pub.dev" source: hosted - version: "2.6.2" + version: "2.7.0" file_selector_windows: dependency: transitive description: name: file_selector_windows - sha256: "320fcfb6f33caa90f0b58380489fc5ac05d99ee94b61aa96ec2bff0ba81d3c2b" + sha256: "62197474ae75893a62df75939c777763d39c2bc5f73ce5b88497208bc269abfd" url: "https://pub.dev" source: hosted - version: "0.9.3+4" + version: "0.9.3+5" firebase_auth: dependency: "direct main" description: @@ -521,6 +537,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.1" + flag: + dependency: "direct main" + description: + name: flag + sha256: "69e3e1d47453349ef72e2ebf4234b88024c0d57f9bcfaa7cc7facec49cd8561f" + url: "https://pub.dev" + source: hosted + version: "7.0.2" flutter: dependency: "direct main" description: flutter @@ -558,6 +582,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.0" + flutter_hooks: + dependency: "direct main" + description: + name: flutter_hooks + sha256: "8ae1f090e5f4ef5cfa6670ce1ab5dddadd33f3533a7f9ba19d9f958aa2a89f42" + url: "https://pub.dev" + source: hosted + version: "0.21.3+1" flutter_html: dependency: "direct main" description: @@ -606,6 +638,19 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.3" + flutter_localization: + dependency: "direct main" + description: + name: flutter_localization + sha256: "578a73455a0deffc4169ef9372ba0562a3e2cff563e5c524ea87bc96daa519c0" + url: "https://pub.dev" + source: hosted + version: "0.3.3" + flutter_localizations: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" flutter_map: dependency: "direct main" description: @@ -650,10 +695,10 @@ packages: dependency: transitive description: name: flutter_plugin_android_lifecycle - sha256: b0694b7fb1689b0e6cc193b3f1fcac6423c4f93c74fb20b806c6b6f196db0c31 + sha256: ee8068e0e1cd16c4a82714119918efdeed33b3ba7772c54b5d094ab53f9b7fd1 url: "https://pub.dev" source: hosted - version: "2.0.30" + version: "2.0.33" flutter_polyline_points: dependency: "direct main" description: @@ -678,6 +723,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.1" + flutter_screenutil: + dependency: "direct main" + description: + name: flutter_screenutil + sha256: "8239210dd68bee6b0577aa4a090890342d04a136ce1c81f98ee513fc0ce891de" + url: "https://pub.dev" + source: hosted + version: "5.9.3" flutter_spinkit: dependency: transitive description: @@ -868,34 +921,34 @@ packages: dependency: transitive description: name: google_maps_flutter_android - sha256: a6c9d43f6a944ff4bae5c3deb34817970ac3d591dcd7f5bd2ea450ab9e9c514a + sha256: "3835f6ae5e8b8d4d454d913575069513c9f216e088b87aa5c18cb3610951c6b4" url: "https://pub.dev" source: hosted - version: "2.18.2" + version: "2.18.6" google_maps_flutter_ios: dependency: transitive description: name: google_maps_flutter_ios - sha256: ca02463b19a9abc7d31fcaf22631d021d647107467f741b917a69fa26659fd75 + sha256: "115b03c2e637e74d084a78c0e1faf42884fcd8e65d1a9ce58d909ca5493afa32" url: "https://pub.dev" source: hosted - version: "2.15.5" + version: "2.15.7" google_maps_flutter_platform_interface: dependency: transitive description: name: google_maps_flutter_platform_interface - sha256: f4b9b44f7b12a1f6707ffc79d082738e0b7e194bf728ee61d2b3cdf5fdf16081 + sha256: e8b1232419fcdd35c1fdafff96843f5a40238480365599d8ca661dde96d283dd url: "https://pub.dev" source: hosted - version: "2.14.0" + version: "2.14.1" google_maps_flutter_web: dependency: transitive description: name: google_maps_flutter_web - sha256: "53e5dbf73ff04153acc55a038248706967c21d5b6ef6657a57fce2be73c2895a" + sha256: d416602944e1859f3cbbaa53e34785c223fa0a11eddb34a913c964c5cbb5d8cf url: "https://pub.dev" source: hosted - version: "0.5.14+2" + version: "0.5.14+3" google_polyline_algorithm: dependency: transitive description: @@ -916,18 +969,18 @@ packages: dependency: transitive description: name: google_sign_in_android - sha256: "7abdfa0088dc8f7d08eb3dbb1665a72bcb5b37afa256c9ec5d21e1e2d7503e5c" + sha256: "5ec98ab35387c68c0050495bb211bd88375873723a80fae7c2e9266ea0bdd8bb" url: "https://pub.dev" source: hosted - version: "7.2.0" + version: "7.2.7" google_sign_in_ios: dependency: transitive description: name: google_sign_in_ios - sha256: d9d80f953a244a099a40df1ff6aadc10ee375e6a098bbd5d55be332ce26db18c + sha256: aee8bb29484611a37607849175a2009d423de6bd7c129326c69fd7068f0b6ed7 url: "https://pub.dev" source: hosted - version: "6.2.1" + version: "6.2.4" google_sign_in_platform_interface: dependency: transitive description: @@ -1012,26 +1065,26 @@ packages: dependency: transitive description: name: image_picker_android - sha256: "8dfe08ea7fcf7467dbaf6889e72eebd5e0d6711caae201fdac780eb45232cd02" + sha256: "5e9bf126c37c117cf8094215373c6d561117a3cfb50ebc5add1a61dc6e224677" url: "https://pub.dev" source: hosted - version: "0.8.13+3" + version: "0.8.13+10" image_picker_for_web: dependency: transitive description: name: image_picker_for_web - sha256: "40c2a6a0da15556dc0f8e38a3246064a971a9f512386c3339b89f76db87269b6" + sha256: "66257a3191ab360d23a55c8241c91a6e329d31e94efa7be9cf7a212e65850214" url: "https://pub.dev" source: hosted - version: "3.1.0" + version: "3.1.1" image_picker_ios: dependency: transitive description: name: image_picker_ios - sha256: eb06fe30bab4c4497bad449b66448f50edcc695f1c59408e78aa3a8059eb8f0e + sha256: "956c16a42c0c708f914021666ffcd8265dde36e673c9fa68c81f7d085d9774ad" url: "https://pub.dev" source: hosted - version: "0.8.13" + version: "0.8.13+3" image_picker_linux: dependency: transitive description: @@ -1044,18 +1097,18 @@ packages: dependency: transitive description: name: image_picker_macos - sha256: d58cd9d67793d52beefd6585b12050af0a7663c0c2a6ece0fb110a35d6955e04 + sha256: "86f0f15a309de7e1a552c12df9ce5b59fe927e71385329355aec4776c6a8ec91" url: "https://pub.dev" source: hosted - version: "0.2.2" + version: "0.2.2+1" image_picker_platform_interface: dependency: transitive description: name: image_picker_platform_interface - sha256: "9f143b0dba3e459553209e20cc425c9801af48e6dfa4f01a0fcf927be3f41665" + sha256: "567e056716333a1647c64bb6bd873cff7622233a5c3f694be28a583d4715690c" url: "https://pub.dev" source: hosted - version: "2.11.0" + version: "2.11.1" image_picker_windows: dependency: transitive description: @@ -1088,6 +1141,22 @@ packages: url: "https://pub.dev" source: hosted version: "0.20.2" + jovial_misc: + dependency: transitive + description: + name: jovial_misc + sha256: "4301011027d87b8b919cb862db84071a34448eadbb32cc8d40fe505424dfe69a" + url: "https://pub.dev" + source: hosted + version: "0.9.2" + jovial_svg: + dependency: transitive + description: + name: jovial_svg + sha256: "08dd24b800d48796c9c0227acb96eb00c6cacccb1d7de58d79fc924090049868" + url: "https://pub.dev" + source: hosted + version: "1.1.28" json_annotation: dependency: transitive description: @@ -1188,10 +1257,10 @@ packages: dependency: transitive description: name: logger - sha256: "55d6c23a6c15db14920e037fe7e0dc32e7cdaf3b64b4b25df2d541b5b6b81c0c" + sha256: a7967e31b703831a893bbc3c3dd11db08126fe5f369b5c648a36f821979f5be3 url: "https://pub.dev" source: hosted - version: "2.6.1" + version: "2.6.2" logging: dependency: transitive description: @@ -1324,18 +1393,18 @@ packages: dependency: transitive description: name: path_provider_android - sha256: "993381400e94d18469750e5b9dcb8206f15bc09f9da86b9e44a9b0092a0066db" + sha256: f2c65e21139ce2c3dad46922be8272bb5963516045659e71bb16e151c93b580e url: "https://pub.dev" source: hosted - version: "2.2.18" + version: "2.2.22" path_provider_foundation: dependency: transitive description: name: path_provider_foundation - sha256: "16eef174aacb07e09c351502740fa6254c165757638eba1e9116b0a781201bbd" + sha256: "6d13aece7b3f5c5a9731eaf553ff9dcbc2eff41087fd2df587fd0fed9a3eb0c4" url: "https://pub.dev" source: hosted - version: "2.4.2" + version: "2.5.1" path_provider_linux: dependency: transitive description: @@ -1572,18 +1641,18 @@ packages: dependency: transitive description: name: shared_preferences_android - sha256: a2608114b1ffdcbc9c120eb71a0e207c71da56202852d4aab8a5e30a82269e74 + sha256: "83af5c682796c0f7719c2bbf74792d113e40ae97981b8f266fa84574573556bc" url: "https://pub.dev" source: hosted - version: "2.4.12" + version: "2.4.18" shared_preferences_foundation: dependency: transitive description: name: shared_preferences_foundation - sha256: "6a52cfcdaeac77cad8c97b539ff688ccfc458c007b4db12be584fbe5c0e49e03" + sha256: "4e7eaffc2b17ba398759f1151415869a34771ba11ebbccd1b0145472a619a64f" url: "https://pub.dev" source: hosted - version: "2.5.4" + version: "2.5.6" shared_preferences_linux: dependency: transitive description: @@ -1813,6 +1882,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.3.1" + universal_io: + dependency: transitive + description: + name: universal_io + sha256: f63cbc48103236abf48e345e07a03ce5757ea86285ed313a6a032596ed9301e2 + url: "https://pub.dev" + source: hosted + version: "2.3.1" url_launcher: dependency: transitive description: @@ -1825,34 +1902,34 @@ packages: dependency: transitive description: name: url_launcher_android - sha256: "199bc33e746088546a39cc5f36bac5a278c5e53b40cb3196f99e7345fdcfae6b" + sha256: "767344bf3063897b5cf0db830e94f904528e6dd50a6dfaf839f0abf509009611" url: "https://pub.dev" source: hosted - version: "6.3.22" + version: "6.3.28" url_launcher_ios: dependency: transitive description: name: url_launcher_ios - sha256: d80b3f567a617cb923546034cc94bfe44eb15f989fe670b37f26abdb9d939cb7 + sha256: cfde38aa257dae62ffe79c87fab20165dfdf6988c1d31b58ebf59b9106062aad url: "https://pub.dev" source: hosted - version: "6.3.4" + version: "6.3.6" url_launcher_linux: dependency: transitive description: name: url_launcher_linux - sha256: "4e9ba368772369e3e08f231d2301b4ef72b9ff87c31192ef471b380ef29a4935" + sha256: d5e14138b3bc193a0f63c10a53c94b91d399df0512b1f29b94a043db7482384a url: "https://pub.dev" source: hosted - version: "3.2.1" + version: "3.2.2" url_launcher_macos: dependency: transitive description: name: url_launcher_macos - sha256: c043a77d6600ac9c38300567f33ef12b0ef4f4783a2c1f00231d2b1941fea13f + sha256: "368adf46f71ad3c21b8f06614adb38346f193f3a59ba8fe9a2fd74133070ba18" url: "https://pub.dev" source: hosted - version: "3.2.3" + version: "3.2.5" url_launcher_platform_interface: dependency: transitive description: @@ -1873,10 +1950,10 @@ packages: dependency: transitive description: name: url_launcher_windows - sha256: "3284b6d2ac454cf34f114e1d3319866fdd1e19cdc329999057e44ffe936cfa77" + sha256: "712c70ab1b99744ff066053cbe3e80c73332b38d46e5e945c98689b2e66fc15f" url: "https://pub.dev" source: hosted - version: "3.1.4" + version: "3.1.5" uuid: dependency: "direct main" description: @@ -1937,26 +2014,26 @@ packages: dependency: transitive description: name: video_player_android - sha256: "59e5a457ddcc1688f39e9aef0efb62aa845cf0cbbac47e44ac9730dc079a2385" + sha256: d74b66f283afff135d5be0ceccca2ca74dff7df1e9b1eaca6bd4699875d3ae60 url: "https://pub.dev" source: hosted - version: "2.8.13" + version: "2.8.22" video_player_avfoundation: dependency: transitive description: name: video_player_avfoundation - sha256: f9a780aac57802b2892f93787e5ea53b5f43cc57dc107bee9436458365be71cd + sha256: e4d33b79a064498c6eb3a6a492b6a5012573d4943c28d566caf1a6c0840fe78d url: "https://pub.dev" source: hosted - version: "2.8.4" + version: "2.8.8" video_player_platform_interface: dependency: transitive description: name: video_player_platform_interface - sha256: cf2a1d29a284db648fd66cbd18aacc157f9862d77d2cc790f6f9678a46c1db5a + sha256: "57c5d73173f76d801129d0531c2774052c5a7c11ccb962f1830630decd9f24ec" url: "https://pub.dev" source: hosted - version: "6.4.0" + version: "6.6.0" video_player_web: dependency: transitive description: @@ -2009,18 +2086,18 @@ packages: dependency: transitive description: name: webview_flutter_wkwebview - sha256: fea63576b3b7e02b2df8b78ba92b48ed66caec2bb041e9a0b1cbd586d5d80bfd + sha256: e49f378ed066efb13fc36186bbe0bd2425630d4ea0dbc71a18fdd0e4d8ed8ebc url: "https://pub.dev" source: hosted - version: "3.23.1" + version: "3.23.5" win32: dependency: transitive description: name: win32 - sha256: "66814138c3562338d05613a6e368ed8cfb237ad6d64a9e9334be3f309acfca03" + sha256: d7cb55e04cd34096cd3a79b3330245f54cb96a370a1c27adb3c84b917de8b08e url: "https://pub.dev" source: hosted - version: "5.14.0" + version: "5.15.0" wkt_parser: dependency: transitive description: @@ -2045,6 +2122,14 @@ packages: url: "https://pub.dev" source: hosted version: "6.6.1" + yaml: + dependency: transitive + description: + name: yaml + sha256: b9da305ac7c39faa3f030eccd175340f968459dae4af175130b3fc47e40d76ce + url: "https://pub.dev" + source: hosted + version: "3.1.3" zxing_lib: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index a196789..fddee45 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: customer description: "A new Flutter project." -version: 1.0.0+1 +version: 1.0.0+5 environment: sdk: ^3.7.2 @@ -86,6 +86,12 @@ dependencies: intl: ^0.20.2 uuid: ^4.5.2 flutter_google_places_hoc081098: ^2.0.0 + flutter_screenutil: ^5.9.3 + flutter_hooks: ^0.21.3+1 + flutter_localization: ^0.3.3 + country_flags: ^4.1.0 + flag: ^7.0.2 + dependency_overrides: webview_flutter: ^4.9.0 @@ -96,6 +102,8 @@ dependency_overrides: dev_dependencies: flutter_test: sdk: flutter + flutter_localizations: + sdk: flutter flutter_lints: ^6.0.0 @@ -105,6 +113,7 @@ flutter: - assets/images/ - assets/icons/ - assets/fonts/ + - assets/translations/ - assets/ fonts: