25-8-4-1
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import 'package:sefer_driver/constant/colors.dart';
|
||||
import 'package:sefer_driver/controller/profile/setting_controller.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:sefer_driver/constant/style.dart';
|
||||
import 'package:sefer_driver/constant/colors.dart';
|
||||
import 'package:sefer_driver/controller/profile/setting_controller.dart';
|
||||
import 'package:sefer_driver/views/lang/languages.dart';
|
||||
import 'package:sefer_driver/views/widgets/my_scafold.dart';
|
||||
import 'package:sefer_driver/views/widgets/mydialoug.dart';
|
||||
|
||||
import '../../../../controller/functions/vibrate.dart';
|
||||
// تأكد من صحة مسارات الاستيراد هذه
|
||||
import '../../../../controller/functions/vibrate.dart'; // Controller with isVibrate
|
||||
import '../../../auth/country_widget.dart';
|
||||
import 'about_us.dart';
|
||||
import 'frequantly_question.dart';
|
||||
@@ -18,140 +18,188 @@ class SettingsCaptain extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Get.put(SettingController());
|
||||
Get.put(HomePageController());
|
||||
// تحميل الـ Controllers المطلوبة
|
||||
final settingsController = Get.put(SettingController());
|
||||
final homeController = Get.put(HomePageController());
|
||||
|
||||
return MyScafolld(
|
||||
title: 'Settings'.tr,
|
||||
isleading: true,
|
||||
body: [
|
||||
ListView(
|
||||
physics: const BouncingScrollPhysics(),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 20.0),
|
||||
children: <Widget>[
|
||||
// General Section
|
||||
_buildSectionHeader('General'.tr),
|
||||
CupertinoListSection(
|
||||
margin: EdgeInsets.zero,
|
||||
// --- القسم الأول: عام ---
|
||||
_buildSectionHeader('General'.tr, context),
|
||||
_buildSettingsCard(
|
||||
children: [
|
||||
CupertinoListTile(
|
||||
leading: const Icon(CupertinoIcons.globe),
|
||||
title: Text('Language'.tr, style: AppStyle.headTitle2),
|
||||
subtitle: Text('You can change the language of the app'.tr,
|
||||
style: AppStyle.subtitle),
|
||||
trailing: const CupertinoListTileChevron(),
|
||||
onTap: () => Get.to(const Language()),
|
||||
_buildListTile(
|
||||
icon: Icons.language_outlined,
|
||||
title: 'Language'.tr,
|
||||
subtitle: 'Change the app language'.tr,
|
||||
onTap: () => Get.to(() => const Language()),
|
||||
),
|
||||
CupertinoListTile(
|
||||
leading: const Icon(CupertinoIcons.flag_fill),
|
||||
title: Text('Change Country'.tr, style: AppStyle.headTitle2),
|
||||
subtitle: Text(
|
||||
'You can change the Country to get all features'.tr,
|
||||
style: AppStyle.subtitle),
|
||||
trailing: const CupertinoListTileChevron(),
|
||||
_buildListTile(
|
||||
icon: Icons.flag_outlined,
|
||||
title: 'Change Country'.tr,
|
||||
subtitle: 'Get features for your country'.tr,
|
||||
onTap: () => Get.to(
|
||||
MyScafolld(
|
||||
() => MyScafolld(
|
||||
title: 'Change Country'.tr,
|
||||
body: [CountryPickerFromSetting()],
|
||||
isleading: true,
|
||||
// isCupertino: true, // Indicate it's a Cupertino style page
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// App Preferences Section
|
||||
_buildSectionHeader('App Preferences'.tr),
|
||||
CupertinoListSection(
|
||||
margin: EdgeInsets.zero,
|
||||
// --- القسم الثاني: تفضيلات التطبيق ---
|
||||
_buildSectionHeader('App Preferences'.tr, context),
|
||||
_buildSettingsCard(
|
||||
children: [
|
||||
CupertinoListTile(
|
||||
leading: Icon(
|
||||
CupertinoIcons.map_pin_ellipse,
|
||||
color: AppColor.redColor,
|
||||
),
|
||||
title: Text('Google Map App'.tr, style: AppStyle.headTitle2),
|
||||
subtitle: Text(
|
||||
'If you want to make Google Map App run directly when you apply order'
|
||||
.tr,
|
||||
style: AppStyle.subtitle,
|
||||
),
|
||||
trailing: GetBuilder<SettingController>(
|
||||
builder: (settingController) {
|
||||
return CupertinoSwitch(
|
||||
value: settingController.isGoogleMapsEnabled,
|
||||
activeTrackColor: AppColor.primaryColor,
|
||||
onChanged: (bool value) {
|
||||
settingController.onChangMapApp();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
_buildSwitchTile(
|
||||
icon: Icons.map_outlined,
|
||||
color: AppColor.redColor,
|
||||
title: 'Google Map App'.tr,
|
||||
subtitle: 'Run Google Maps directly'.tr,
|
||||
controller: settingsController,
|
||||
valueGetter: (ctrl) => (ctrl).isGoogleMapsEnabled,
|
||||
onChanged: (ctrl) => (ctrl).onChangMapApp(),
|
||||
),
|
||||
CupertinoListTile(
|
||||
leading: Icon(Icons.vibration),
|
||||
title: Text('Vibration'.tr, style: AppStyle.headTitle2),
|
||||
subtitle: Text(
|
||||
"You can change the vibration feedback for all buttons".tr,
|
||||
style: AppStyle.subtitle,
|
||||
),
|
||||
trailing: GetBuilder<HomePageController>(
|
||||
builder: (controller) => CupertinoSwitch(
|
||||
value: controller.isVibrate,
|
||||
onChanged: controller.changeVibrateOption,
|
||||
activeTrackColor: AppColor.primaryColor,
|
||||
),
|
||||
),
|
||||
onTap: () => print('3'),
|
||||
_buildSwitchTile(
|
||||
icon: Icons.vibration,
|
||||
title: 'Vibration'.tr,
|
||||
subtitle: 'Vibration feedback for buttons'.tr,
|
||||
controller: homeController,
|
||||
valueGetter: (ctrl) => (ctrl).isVibrate,
|
||||
onChanged: (ctrl) => (ctrl)
|
||||
.changeVibrateOption(true), // قد تحتاج لتعديل الدالة
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Help & Support Section
|
||||
_buildSectionHeader('Help & Support'.tr),
|
||||
CupertinoListSection(
|
||||
margin: EdgeInsets.zero,
|
||||
// --- القسم الثالث: المساعدة والدعم ---
|
||||
_buildSectionHeader('Help & Support'.tr, context),
|
||||
_buildSettingsCard(
|
||||
children: [
|
||||
CupertinoListTile(
|
||||
leading: const Icon(CupertinoIcons.question_circle_fill),
|
||||
title: Text('Frequently Questions'.tr,
|
||||
style: AppStyle.headTitle2),
|
||||
trailing: const CupertinoListTileChevron(),
|
||||
_buildListTile(
|
||||
icon: Icons.quiz_outlined,
|
||||
title: 'Frequently Questions'.tr,
|
||||
onTap: () => Get.to(() => const FrequentlyQuestionsPage()),
|
||||
),
|
||||
CupertinoListTile(
|
||||
leading: const Icon(CupertinoIcons.hand_raised_fill),
|
||||
title:
|
||||
Text("How to use Intaleq".tr, style: AppStyle.headTitle2),
|
||||
trailing: const CupertinoListTileChevron(),
|
||||
_buildListTile(
|
||||
icon: Icons.support_agent,
|
||||
title: "How to use App".tr,
|
||||
onTap: () => Get.to(() => const UsingAppPage()),
|
||||
),
|
||||
CupertinoListTile(
|
||||
leading: const Icon(CupertinoIcons.info_circle_fill),
|
||||
title: Text('About Us'.tr, style: AppStyle.headTitle2),
|
||||
trailing: const CupertinoListTileChevron(),
|
||||
_buildListTile(
|
||||
icon: Icons.info_outline,
|
||||
title: 'About Us'.tr,
|
||||
onTap: () => Get.to(() => const AboutPage()),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// --- القسم الرابع: تسجيل الخروج ---
|
||||
_buildSectionHeader('Account'.tr, context),
|
||||
_buildSettingsCard(
|
||||
children: [
|
||||
ListTile(
|
||||
leading: const Icon(Icons.logout, color: Colors.red),
|
||||
title: Text(
|
||||
'Logout'.tr,
|
||||
style: const TextStyle(
|
||||
color: Colors.red, fontWeight: FontWeight.w500),
|
||||
),
|
||||
onTap: () {
|
||||
MyDialog().getDialog(
|
||||
'Logout'.tr,
|
||||
'Are you sure you want to logout?'.tr,
|
||||
() {
|
||||
// أضف دالة تسجيل الخروج هنا
|
||||
Get.back(); // لإغلاق مربع الحوار
|
||||
},
|
||||
// isConfirmation: true,
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
isleading: true,
|
||||
// isCupertino: true, // Indicate this screen is generally Cupertino style
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSectionHeader(String title) {
|
||||
// ويدجت لبناء عنوان كل قسم
|
||||
Widget _buildSectionHeader(String title, BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(left: 16.0, top: 20.0, bottom: 10.0),
|
||||
padding: const EdgeInsets.only(left: 8.0, bottom: 12.0),
|
||||
child: Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 17.0,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: CupertinoColors.secondaryLabel,
|
||||
),
|
||||
style: Theme.of(context).textTheme.titleSmall?.copyWith(
|
||||
color: Colors.grey.shade600,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ويدجت لبناء بطاقة الإعدادات
|
||||
Widget _buildSettingsCard({required List<Widget> children}) {
|
||||
return Card(
|
||||
elevation: 2,
|
||||
shadowColor: Colors.black.withOpacity(0.1),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
||||
clipBehavior: Clip.antiAlias, // مهم لجعل splash effect داخل حدود البطاقة
|
||||
child: Column(children: children),
|
||||
);
|
||||
}
|
||||
|
||||
// ويدجت لبناء عنصر قابل للضغط (مثل اللغة، عن التطبيق)
|
||||
Widget _buildListTile({
|
||||
required IconData icon,
|
||||
required String title,
|
||||
String? subtitle,
|
||||
required VoidCallback onTap,
|
||||
}) {
|
||||
return ListTile(
|
||||
leading: Icon(icon, color: Colors.grey.shade700),
|
||||
title: Text(title, style: const TextStyle(fontWeight: FontWeight.w500)),
|
||||
subtitle: subtitle != null ? Text(subtitle) : null,
|
||||
trailing:
|
||||
const Icon(Icons.arrow_forward_ios, size: 16, color: Colors.grey),
|
||||
onTap: onTap,
|
||||
);
|
||||
}
|
||||
|
||||
// ويدجت لبناء عنصر يحتوي على مفتاح تفعيل/إلغاء (Switch)
|
||||
Widget _buildSwitchTile<T extends GetxController>({
|
||||
required IconData icon,
|
||||
Color? color,
|
||||
required String title,
|
||||
required String subtitle,
|
||||
required T controller,
|
||||
required bool Function(T) valueGetter,
|
||||
required Function(T) onChanged,
|
||||
}) {
|
||||
return GetBuilder<T>(
|
||||
init: controller,
|
||||
builder: (ctrl) {
|
||||
return SwitchListTile(
|
||||
secondary: Icon(icon, color: color ?? Colors.grey.shade700),
|
||||
title:
|
||||
Text(title, style: const TextStyle(fontWeight: FontWeight.w500)),
|
||||
subtitle: Text(subtitle),
|
||||
value: valueGetter(ctrl),
|
||||
onChanged: (value) => onChanged(ctrl),
|
||||
activeColor: AppColor.primaryColor,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user