Files
intaleq/intaleq_driver/lib/controller/rate/rate_app_controller.dart
T
Hamza-AyedandClaude Opus 5 0aab85c732 refactor: إعادة تسمية التطبيقات الأربعة siro_* → intaleq_*
المجلدات وأسماء حزم dart واستيراداتها:
  siro_rider → intaleq_rider    siro_driver  → intaleq_driver
  siro_admin → intaleq_admin    siro_service → intaleq_service

شمل ذلك `name:` في كل pubspec وكل `package:siro_*` في الاستيرادات
(115 ملفاً في rider وحده)، وإشارات أسماء المجلدات في docs/ وتعليق في
backend/Admin/notifications/broadcast.php. لم تبقَ إشارة واحدة (تحقّقت).

+ ضُمّت حزم get و get_storage داخل intaleq_driver/packages/ وحُوّلت
مساراتها الثلاثة من `../../Intaleq/packages/*` إلى `./packages/*`. كانت
تُحل عرضاً إلى مجلد App/Intaleq القديم المجاور — تبعية خارج المستودع
تنكسر بأول نقل. لم يبقَ في أي تطبيق تبعية مسار خارج الشجرة.

⚠️ لم تُمسّ بعد: هويات المتاجر (applicationId · PRODUCT_BUNDLE_IDENTIFIER ·
shorebird app_id) ولا الألوان ولا النصوص المرئية ولا النطاقات — كل منها
كوميت منفصل، والهويات تحتاج قرار المالك.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 16:10:58 +03:00

95 lines
3.2 KiB
Dart
Executable File

import 'dart:convert';
import 'package:intaleq_driver/constant/box_name.dart';
import 'package:intaleq_driver/constant/links.dart';
import 'package:intaleq_driver/controller/functions/crud.dart';
import 'package:intaleq_driver/main.dart';
import 'package:intaleq_driver/views/widgets/error_snakbar.dart';
import 'package:intaleq_driver/views/widgets/mydialoug.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
// Import url_launcher to open the app store
import 'package:url_launcher/url_launcher.dart';
class RatingController extends GetxController {
var userRating = 0.obs;
final comment = TextEditingController();
void submitRating(int rating) {
userRating.value = rating;
_saveRating(rating);
}
void _redirectToAppStore() async {
// URLs for App Store and Google Play Store
const appStoreUrl =
'https://apps.apple.com/st/app/siro-driver/id6482995159';
const playStoreUrl =
'https://play.google.com/store/apps/details?id=com.intaleq_driver';
final url = GetPlatform.isIOS ? appStoreUrl : playStoreUrl;
if (await launchUrl(Uri.parse(url))) {
await launchUrl(Uri.parse(url));
} else {
mySnackbarError("Could not open the app store.");
}
}
Future<void> _saveRating(int rating) async {
// Build the payload with user data
final payload = {
"name": box.read(BoxName.driverID) != null
? box.read(BoxName.nameDriver)
: box.read(BoxName.name),
"email": (box.read(BoxName.emailDriver)).toString(),
"phone": (box.read(BoxName.phoneDriver)).toString(),
"userId": box.read(BoxName.driverID),
"userType": "driver",
"rating": rating.toString(),
"comment": comment.text.isEmpty
? 'nothing'
: comment.text, // Get actual text from comment controller
};
// Send the rating data to the backend
var res = await CRUD().post(link: AppLink.addRateApp, payload: payload);
// Handle the response and check if it's JSON-formatted
if (res != 'failure') {
try {
// Attempt to parse the response as JSON
final parsedResponse = (res);
if (parsedResponse['status'] == 'success') {
// Display a success message
CRUD().post(link: AppLink.sendEmailRateingApp, payload: {
"name": payload["name"],
"email": payload["email"],
"phone": payload["phone"],
"rating": rating.toString(),
"comment": payload["comment"],
});
MyDialog().getDialog('Rating submitted successfully'.tr, '', () {
if (rating == 5) {
Get.back();
_redirectToAppStore();
} else {
Get.back();
}
});
// Send confirmation email if the rating was successfully submitted
} else {
mySnackbarError('Failed to submit rating');
}
} catch (e) {
// If JSON decoding fails, log the response directly
// Get.snackbar('Success', 'Rating submitted successfully',
// backgroundColor: AppColor.greenColor);
}
} else {
mySnackbarError('Failed to connect to the server');
}
}
}