diff --git a/.github/workflows/build_release.yml b/.github/workflows/build_release.yml
new file mode 100644
index 0000000..cccc1c1
--- /dev/null
+++ b/.github/workflows/build_release.yml
@@ -0,0 +1,33 @@
+name: Build and Release APK
+
+on:
+ push:
+ branches:
+ - master
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v2
+
+ - name: Set up Flutter
+ uses: subosito/flutter-action@v2
+ with:
+ flutter-version: '3.13.0' # Adjust this to your Flutter version
+
+ - name: Build APK
+ run: flutter build apk --release
+
+ - name: Create Release
+ id: create_release
+ uses: softprops/action-gh-release@v1
+ with:
+ files: build/app/outputs/flutter-apk/app-release.apk
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Get Release URL
+ run: echo "Release URL: ${{ steps.create_release.outputs.upload_url }}"
diff --git a/.gradle/buildOutputCleanup/cache.properties b/.gradle/buildOutputCleanup/cache.properties
deleted file mode 100644
index 00990ad..0000000
--- a/.gradle/buildOutputCleanup/cache.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-#Sat Mar 06 22:19:25 EET 2021
-gradle.version=6.1.1
diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 0000000..27c8652
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,26 @@
+{
+ "configurations": [
+ {
+ "name": "Flutter Debug",
+ "type": "dart",
+ "request": "launch",
+ "program": "lib/main.dart",
+ "flutterMode": "debug"
+ },
+ {
+ "name": "Flutter Profile",
+ "type": "dart",
+ "request": "launch",
+ "program": "lib/main.dart",
+ "flutterMode": "profile"
+ },
+
+ {
+ "name": "Flutter Release",
+ "type": "dart",
+ "request": "launch",
+ "program": "lib/main.dart",
+ "flutterMode": "release"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..7a55dae
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,14 @@
+{
+ "[dart]": {
+ "editor.tabSize": 2,
+ "editor.insertSpaces": true,
+ "editor.detectIndentation": false,
+ "editor.suggest.insertMode": "replace",
+ "editor.defaultFormatter": "Dart-Code.dart-code",
+ "editor.inlayHints.enabled": "offUnlessPressed",
+ "editor.formatOnSave": true,
+ "editor.codeActionsOnSave": {
+ "source.fixAll": true
+ }
+ }
+}
\ No newline at end of file
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..f5fba8f
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,11 @@
+
+generate_localization:
+ flutter pub run easy_localization:generate -S "assets/translations" -O "lib/src/translations"
+
+generate_localization_keys:
+ flutter pub run easy_localization:generate -S "assets/translations" -O "lib/src/translations" -o "locale_keys.g.dart" -f keys
+
+gen_translate: generate_localization generate_localization_keys
+
+flutter_generate:
+ flutter packages pub run build_runner build --delete-conflicting-outputs
diff --git a/android/app/build.gradle b/android/app/build.gradle
index f1521a2..cb4b12e 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -71,7 +71,6 @@ android {
release {
signingConfig signingConfigs.release
minifyEnabled true
- useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index 842de41..2dde25f 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -2,6 +2,7 @@
package="com.mazen.livine">
-
-
+
-
-
+
diff --git a/android/app/src/main/res/xml/filepaths.xml b/android/app/src/main/res/xml/filepaths.xml
new file mode 100644
index 0000000..b3abc6b
--- /dev/null
+++ b/android/app/src/main/res/xml/filepaths.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/android/app/src/main/res/xml/network_security_config.xml b/android/app/src/main/res/xml/network_security_config.xml
new file mode 100644
index 0000000..dca93c0
--- /dev/null
+++ b/android/app/src/main/res/xml/network_security_config.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/android/build.gradle b/android/build.gradle
index d499190..beada5c 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -1,12 +1,12 @@
buildscript {
- ext.kotlin_version = '1.6.10'
+ ext.kotlin_version = '1.7.10'
repositories {
google()
mavenCentral()
}
dependencies {
- classpath 'com.android.tools.build:gradle:4.1.0'
+ classpath 'com.android.tools.build:gradle:7.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
@@ -25,6 +25,6 @@ subprojects {
project.evaluationDependsOn(':app')
}
-task clean(type: Delete) {
+tasks.register("clean", Delete) {
delete rootProject.buildDir
}
diff --git a/android/gradle.properties b/android/gradle.properties
index 94adc3a..ffbfe84 100644
--- a/android/gradle.properties
+++ b/android/gradle.properties
@@ -1,3 +1,3 @@
-org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
+org.gradle.jvmargs=-Xmx4608m
diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties
index cc5527d..6b66533 100644
--- a/android/gradle/wrapper/gradle-wrapper.properties
+++ b/android/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
diff --git a/assets/images/difficulty/sad.png b/assets/images/difficulty/sad.png
deleted file mode 100644
index 1767962..0000000
Binary files a/assets/images/difficulty/sad.png and /dev/null differ
diff --git a/assets/images/difficulty/smile.png b/assets/images/difficulty/smile.png
deleted file mode 100644
index d1ba963..0000000
Binary files a/assets/images/difficulty/smile.png and /dev/null differ
diff --git a/assets/images/difficulty/wow.png b/assets/images/difficulty/wow.png
deleted file mode 100644
index be1897c..0000000
Binary files a/assets/images/difficulty/wow.png and /dev/null differ
diff --git a/assets/images/icon/pristine.png b/assets/images/icon/pristine.png
deleted file mode 100644
index 8fba438..0000000
Binary files a/assets/images/icon/pristine.png and /dev/null differ
diff --git a/assets/images/icons/chief_hat.svg b/assets/images/icons/chief_hat.svg
new file mode 100644
index 0000000..80971e4
--- /dev/null
+++ b/assets/images/icons/chief_hat.svg
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/assets/images/windows/login.webp b/assets/images/windows/login.webp
deleted file mode 100644
index 0069099..0000000
Binary files a/assets/images/windows/login.webp and /dev/null differ
diff --git a/assets/images/windows/register.webp b/assets/images/windows/register.webp
deleted file mode 100644
index ee7bd22..0000000
Binary files a/assets/images/windows/register.webp and /dev/null differ
diff --git a/assets/model/labels.txt b/assets/model/labels.txt
deleted file mode 100644
index b1df57a..0000000
--- a/assets/model/labels.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-0 Healthy
-1 UnHealthy
\ No newline at end of file
diff --git a/assets/model/model.tflite b/assets/model/model.tflite
deleted file mode 100644
index 1173942..0000000
Binary files a/assets/model/model.tflite and /dev/null differ
diff --git a/assets/translations/ar.json b/assets/translations/ar.json
deleted file mode 100644
index 8204941..0000000
--- a/assets/translations/ar.json
+++ /dev/null
@@ -1,85 +0,0 @@
-{
- "Welcome": "اهلا بك،",
- "Settings": "الاعدادات",
- "Logout": "تسجيل الخروج",
- "Profile": "الحساب الشخصي",
- "Languages": "اللغات",
- "Theme": "الوضع",
- "Feedback": "إبلاغ",
- "Report_a_bug": "إبلاغ عن مشكلة ",
- "Misc": "متفرقات",
- "Terms_and_conditions": "الأحكام والشروط",
- "Privacy_Policy": "سياسة الخصوصية",
- "Info": "عن البرنامج",
- "Version": "النسخة",
- "Language": "اللغة",
- "General": "عام",
- "Breakfast": "الفطار",
- "Dinner": "العشاء",
- "Lunch": "الغذاء",
- "Snacks": "وجبات خفيفة",
- "Ingridents": "المكونات",
- "Video": "فيديو",
- "Shakshuka": "شكشوكة",
- "Crustless_Quiche": "كيشي بدون قشرة",
- "Burrito": "بوريتو",
- "Baked_Oatmeal": "شوفان مشوي",
- "Apple_Cinnamon_Oat": "التفاح بالقرفة والشوفان",
- "Banana_Bread": "خبر بالموز",
- "Waffles": "بسكويتات الوفل",
- "Wild_Mushroom_Risotto": "ريزوتو بالفطر ",
- "Grilled_Steak_Tortilla_Salad": "سلطة تورتيلا ستيك مشوي",
- "Feta_Shrimp_and_Polenta": "روبيان فيتا وبولينتا",
- "Black_Bean_Soup": "شربة فول",
- "Bass_With_Radish_Salsa": "باس مع صلصة الفجل",
- "Eggplant_Parmesan": "بارما الباذنجان",
- "Roasted_Cauliflower_Tacos": "قرنبيط محمص تاكو",
- "Carrot_with_Radish_Salad": "سلطة جزر بالفجل",
- "Salmon_Salad": "سلطة سلمون",
- "Panzanella": "بانزانيلا",
- "Caesar_Salad": "سلطة سيزر",
- "Mixed_Nuts": "مكسرات مشكله",
- "Red_pepper_guacamole": "الفلفل الأحمر جواكامولي",
- "Yogurt_with_mixed_berries": "زبادي مع توت مشكل",
- "Apple_slices_with_peanut": "شرائح التفاح مع الفول السوداني",
- "Cottage_cheese": "جبن",
- "Celery_sticks_with_Cheese": "أعواد الكرفس بالجبن",
- "System_Prefrence": "الوضع النظام ",
- "Light_Mode": "الوضع الضوء",
- "Dark_Mode": "الوضع المظلم",
- "life_pristine": "اجعل حياتك نقية",
- "Pristine_access": "يمنحك النظام الوصول إلى ميزاتنا باهظة الثمن بالكامل",
- "gateway": "اختار طريقة الدفع",
- "three_months": "3شهور",
- "total_price": "السعر الكلي",
- "monthly": "شهريا",
- "cancel_sub": "يمكنك إلغاء اشتراكك في أي وقت من خلال google pay",
- "choose_content": "اختار المحتوي",
- "Iam_a": "انا",
- "healthy": "تريد أن تحصل على وصفات صحية بجانب المكونات ومقاطع الفيديو",
- "patient": "تريد أن تحصل علي وصفات علي حسب حالتك الصحية مع مكونات و مقاطع الفيديو",
- "username": "اسم المستخدم",
- "password": "كلمة السر",
- "Forget_your_password": "نسيت كلمة المرور ؟",
- "Sign_in": "تسجيل الدخول",
- "no_account": "ليس لديك حساب ؟",
- "Sign_up": "سجل الآن",
- "have_an_account": "هل لديك حساب ؟",
- "terms1": "من خلال إنشاء حساب ، فإنك توافق بالفعل على",
- "terms2": "الأحكام والشروط",
- "notfications": "إشعارات",
- "ask_me_how_i_feel": "اسالني كيف اشعر كل يوم",
- "continue_as_guest": "سجل كضيف",
- "change_password": "تغيير كلمة المرور",
- "enter_token": "أدخل الرمز الخاص بك",
- "validate_token": "التحقق من صحة الرمز",
- "Reset_pass": "إعادة تعيين كلمة المرور",
- "pass_confirm": "تأكيد كلمة المرور",
- "per_situation": "حالة معينة",
- "Favorites": "المفضلة",
- "delete_account": "حذف الحساب",
- "account": "الحساب",
- "update": "تحديث",
- "livine": "ليفين",
- "About_Livine": "عن ليفين"
-}
\ No newline at end of file
diff --git a/assets/translations/en.json b/assets/translations/en.json
deleted file mode 100644
index 1d9ada1..0000000
--- a/assets/translations/en.json
+++ /dev/null
@@ -1,85 +0,0 @@
-{
- "Welcome": "Welcome,",
- "Settings": "Settings",
- "Logout": "Logout",
- "Profile": "Profile",
- "Languages": "Languages",
- "Theme": "Theme",
- "Feedback": "Feedback",
- "Report_a_bug": "Report a bug ",
- "Misc": "Misc",
- "Terms_and_conditions": "Terms and Conditions",
- "Privacy_Policy": "Privacy Policy",
- "Info": "Info",
- "Version": "Version",
- "Language": "Language",
- "General": "General",
- "Breakfast": "Breakfast",
- "Dinner": "Dinner",
- "Lunch": "Lunch",
- "Snacks": "Snacks",
- "Ingridents": "Ingridents",
- "Video": "Video",
- "Shakshuka": "Shakshuka",
- "Crustless_Quiche": "Crustless Quiche",
- "Burrito": "Burrito",
- "Baked_Oatmeal": "Baked Oatmeal",
- "Apple_Cinnamon_Oat": "Apple Cinnamon Oat",
- "Banana_Bread": "Banana Bread",
- "Waffles": "Waffles",
- "Wild_Mushroom_Risotto": "Wild Mushroom Risotto",
- "Grilled_Steak_Tortilla_Salad": "Grilled Steak Tortilla Salad",
- "Feta_Shrimp_and_Polenta": "Feta Shrimp and Polenta",
- "Black_Bean_Soup": "Black Bean Soup",
- "Bass_With_Radish_Salsa": "Bass With Radish Salsa",
- "Eggplant_Parmesan": "Eggplant Parmesan",
- "Roasted_Cauliflower_Tacos": "Roasted Cauliflower Tacos",
- "Carrot_with_Radish_Salad": "Carrot with Radish Salad",
- "Caesar_Salad": "Caesar Salad",
- "Salmon_Salad": "Salmon Salad",
- "Panzanella": "Panzanella",
- "Mixed_Nuts": "Mixed Nuts",
- "Red_pepper_guacamole": "Red pepper guacamole",
- "Yogurt_with_mixed_berries": "Yogurt with mixed berries",
- "Apple_slices_with_peanut": "Apple slices with peanut",
- "Cottage_cheese": "Cottage cheese",
- "Celery_sticks_with_Cheese": "Celery sticks with Cheese",
- "System_Prefrence": "System preference",
- "Light_Mode": "Light Mode",
- "Dark_Mode": "Dark Mode",
- "life_pristine": "Make your life Pristine",
- "Pristine_access": "Pristine give u access to our full expensive features",
- "gateway": "Choose Gateway",
- "three_months": "3 months",
- "total_price": "total price",
- "monthly": "Monthly",
- "cancel_sub": "You can cancel your subscription at any time through google pay",
- "choose_content": "Choose your content",
- "Iam_a": "I'm a",
- "healthy": "You want to be provided by healthy recipes that you should consume to remain healthy",
- "patient": "You want to be provided per your health situation",
- "username": "Username",
- "password": "Password",
- "Forget_your_password": "Forget your password ?",
- "Sign_in": "Sign In",
- "no_account": "Don't Have an account ?",
- "Sign_up": "Sign Up",
- "have_an_account": "Already have an account ?",
- "terms1": "By creating an account , you already agree on",
- "terms2": "Terms and Conditions",
- "notfications": "Notfications",
- "ask_me_how_i_feel": "Ask me how I feel everyday",
- "continue_as_guest": "Continue as GUEST",
- "change_password": "Change your password",
- "enter_token": "Enter Your Code",
- "validate_token": "Validate Code",
- "Reset_pass": "Reset password",
- "pass_confirm": "Password Confirmation",
- "per_situation": "Per Situation",
- "Favorites": "Favorites",
- "delete_account": "Delete account",
- "account": "Account",
- "update": "Update",
- "livine": "Livine",
- "About_Livine": "About Livine"
-}
\ No newline at end of file
diff --git a/debug/app.android-arm.symbols b/debug/app.android-arm.symbols
new file mode 100644
index 0000000..5032a32
Binary files /dev/null and b/debug/app.android-arm.symbols differ
diff --git a/debug/app.android-arm64.symbols b/debug/app.android-arm64.symbols
new file mode 100644
index 0000000..9ef43f7
Binary files /dev/null and b/debug/app.android-arm64.symbols differ
diff --git a/debug/app.android-x64.symbols b/debug/app.android-x64.symbols
new file mode 100644
index 0000000..524c435
Binary files /dev/null and b/debug/app.android-x64.symbols differ
diff --git a/l10n.yaml b/l10n.yaml
new file mode 100644
index 0000000..db9756a
--- /dev/null
+++ b/l10n.yaml
@@ -0,0 +1,3 @@
+arb-dir: lib/src/l10n
+template-arb-file: app_en.arb
+output-localization-file: app_localizations.dart
diff --git a/lib/main.dart b/lib/main.dart
index 9157ef4..3071bf7 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -1,9 +1,8 @@
import 'dart:io';
-import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/foundation.dart';
+import 'package:livine/src/shared/device_info/device_info.dart';
-import 'package:google_mobile_ads/google_mobile_ads.dart';
import 'package:livine/src/shared/error_django/error_django.dart';
import 'package:window_manager/window_manager.dart';
@@ -15,7 +14,6 @@ import 'package:shared_preferences/shared_preferences.dart';
import 'src/constants/constants.dart';
import 'src/shared/cache/cache_helper.dart';
import 'src/features/get_recipes/application/vegan_service.dart';
-import 'src/translations/codegen_loader.g.dart';
import 'package:device_preview/device_preview.dart';
Future main() async {
@@ -63,22 +61,15 @@ Future main() async {
tools: [
...DevicePreview.defaultTools,
],
- builder: (context) => EasyLocalization(
- supportedLocales: const [Locale('en'), Locale('ar')],
- path: 'assets/translations',
- fallbackLocale: const Locale('en'),
- assetLoader: const CodegenLoader(),
- child: const MyApp()),
+ builder: (context) => const MyApp(),
),
),
);
- await EasyLocalization.ensureInitialized();
await CacheHelper.init();
-
+ await GetDeviceInfo.init();
final isVegan = await container.read(veganServiceProvider).getIsVegan();
container.read(isVeganProvider.notifier).state = isVegan;
if (Platform.isAndroid) {
- MobileAds.instance.initialize();
notificationControl.init();
}
}
diff --git a/lib/src/app.dart b/lib/src/app.dart
index 96a8aa1..fa454ac 100644
--- a/lib/src/app.dart
+++ b/lib/src/app.dart
@@ -1,15 +1,18 @@
import 'dart:io';
import 'dart:ui' as ui;
-import 'package:easy_localization/easy_localization.dart';
+import 'package:dynamic_color/dynamic_color.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:responsive_framework/responsive_framework.dart';
-
+import '../src/features/settings/presentation/theme/domain/theme_notifier.dart';
import 'features/settings/data/theme.dart';
import 'routing/routes.dart';
import 'shared/styles/lib_color_schemes.g.dart';
import 'shared/windows/title_bar.dart';
+import 'package:flutter_gen/gen_l10n/app_localizations.dart';
+
+import 'translations/domain/translation_provider.dart';
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@@ -26,34 +29,50 @@ class MaterialAppWithTheme extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final theme = ref.watch(themeProvider);
-
final router = baseRoutes;
-
+ Color themeSeed = ref.watch(themeSeedProvider) as Color;
+ bool isDynamic = ref.watch(dynamicThemeProvider) as bool;
+ final localeNotifier = ref.watch(localeNotifierProvider);
return _App(
theme: theme,
enableCustomTitleBar: Platform.isWindows == true,
- builder: (context) => MaterialApp.router(
- showPerformanceOverlay: kProfileMode == true,
- routeInformationProvider: router.routeInformationProvider,
- useInheritedMediaQuery: true,
- routeInformationParser: router.routeInformationParser,
- routerDelegate: router.routerDelegate,
- localizationsDelegates: context.localizationDelegates,
- supportedLocales: context.supportedLocales,
- locale: context.locale,
- builder: (context, widget) => ResponsiveWrapper.builder(
- ClampingScrollWrapper.builder(context, widget!),
- breakpoints: const [
- ResponsiveBreakpoint.resize(480, name: MOBILE),
- ResponsiveBreakpoint.autoScale(1000, name: TABLET),
- ResponsiveBreakpoint.resize(1200, name: DESKTOP),
- ]),
- themeMode: theme.themeMode,
- theme: ThemeData(
- useMaterial3: true,
- colorScheme: lightColorScheme,
- ),
- darkTheme: ThemeData(useMaterial3: true, colorScheme: darkColorScheme),
+ builder: (context) => DynamicColorBuilder(
+ builder: (ColorScheme? lightDynamic, ColorScheme? darkDynamic) {
+ print(lightDynamic.toString());
+
+ return MaterialApp.router(
+ showPerformanceOverlay: kProfileMode == true,
+ routeInformationProvider: router.routeInformationProvider,
+ routeInformationParser: router.routeInformationParser,
+ routerDelegate: router.routerDelegate,
+ locale: localeNotifier,
+ localizationsDelegates: AppLocalizations.localizationsDelegates,
+ supportedLocales: TranslationRepo.supportedLocales,
+ debugShowCheckedModeBanner: false,
+ builder: (context, child) => ResponsiveBreakpoints.builder(
+ child: child!,
+ breakpoints: [
+ const Breakpoint(start: 0, end: 480, name: MOBILE),
+ const Breakpoint(start: 481, end: 1280, name: TABLET),
+ const Breakpoint(start: 1281, end: 1920, name: DESKTOP),
+ ],
+ ),
+ themeMode: theme.themeMode,
+ theme: ThemeData(
+ fontFamily: 'Kine',
+ useMaterial3: true,
+ colorSchemeSeed:
+ isDynamic ? lightDynamic?.primary ?? themeSeed : themeSeed,
+ ),
+ darkTheme: ThemeData(
+ fontFamily: 'Kine',
+ useMaterial3: true,
+ colorSchemeSeed:
+ isDynamic ? darkDynamic?.primary ?? themeSeed : themeSeed,
+ brightness: Brightness.dark,
+ ),
+ );
+ },
),
);
}
@@ -70,7 +89,6 @@ class _App extends StatelessWidget {
final ThemeNotifer theme;
@override
Widget build(BuildContext context) {
-
if (!enableCustomTitleBar) {
return builder(context);
}
@@ -82,18 +100,18 @@ class _App extends StatelessWidget {
lightDynamic: lightColorScheme,
child: Stack(
children: [
- MediaQuery.fromWindow(
- child: Builder(builder: (context) {
- final mediaQueryData = MediaQuery.of(context);
- return MediaQuery(
- data: mediaQueryData.copyWith(
- viewPadding: mediaQueryData.padding
- .copyWith(top: mediaQueryData.viewPadding.top + 50),
- ),
- child: builder(context),
- );
- }),
- ),
+ // MediaQuery.fromWindow(
+ // child: Builder(builder: (context) {
+ // final mediaQueryData = MediaQuery.of(context);
+ // return MediaQuery(
+ // data: mediaQueryData.copyWith(
+ // viewPadding: mediaQueryData.padding
+ // .copyWith(top: mediaQueryData.viewPadding.top + 50),
+ // ),
+ // child: builder(context),
+ // );
+ // }),
+ // ),
const Align(
alignment: Alignment.topCenter,
child: TitleBar(),
diff --git a/lib/src/common_widgets/auth/auth_widget.dart b/lib/src/common_widgets/auth/auth_widget.dart
index 0a46c3f..400a6ba 100644
--- a/lib/src/common_widgets/auth/auth_widget.dart
+++ b/lib/src/common_widgets/auth/auth_widget.dart
@@ -1,14 +1,14 @@
-import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
-import 'package:google_fonts/google_fonts.dart';
-Widget authButton({
+Widget CustomButton({
required void Function() onPressed,
required bool isLoading,
required String text,
Color? color,
Color? textColor,
+ double width = 350,
+ Widget? icon,
required BuildContext context,
}) {
final theme = Theme.of(context).colorScheme;
@@ -18,7 +18,7 @@ Widget authButton({
onPressed: onPressed,
color: color ?? theme.primaryContainer,
elevation: 0,
- minWidth: 350,
+ minWidth: width,
height: 60,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15),
@@ -27,14 +27,17 @@ Widget authButton({
? const CircularProgressIndicator(
color: Colors.white,
)
- : Text(
- text,
- style: TextStyle(
- fontSize: 15,
- fontFamily: context.locale.languageCode == "en"
- ? 'Kine'
- : GoogleFonts.notoKufiArabic().fontFamily,
- color: textColor ?? theme.onPrimaryContainer),
+ : Row(
+ mainAxisAlignment: MainAxisAlignment.spaceEvenly,
+ children: [
+ Text(
+ text,
+ style: TextStyle(
+ fontSize: 15,
+ color: textColor ?? theme.onPrimaryContainer),
+ ),
+ icon ?? const SizedBox(),
+ ],
),
),
);
diff --git a/lib/src/common_widgets/no_connection.dart b/lib/src/common_widgets/no_connection.dart
index addc98f..b373ecd 100644
--- a/lib/src/common_widgets/no_connection.dart
+++ b/lib/src/common_widgets/no_connection.dart
@@ -1,8 +1,6 @@
-import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
-import 'package:livine/src/common_widgets/auth/auth_widget.dart';
import 'package:livine/src/constants/constants.dart';
import 'package:responsive_framework/responsive_framework.dart';
@@ -53,11 +51,29 @@ class NoConnection extends ConsumerWidget {
ResponsiveRowColumnItem(
child: Consumer(
builder: (context, watch, child) {
- return authButton(
- context: context,
- isLoading: false,
- text: "Try again",
- onPressed: () => ref.refresh(checkNetworkProvider));
+ final theme = Theme.of(context).colorScheme;
+ return Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 20.0),
+ child: MaterialButton(
+ onPressed: () => ref.refresh(checkNetworkProvider),
+ color: (null) ?? theme.primaryContainer,
+ elevation: 0,
+ minWidth: 350,
+ height: 60,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(15),
+ ),
+ child: Text(
+ "Try again",
+ style: TextStyle(
+ fontSize: 15,
+ // fontFamily: context.locale.languageCode == "en"
+ // ? 'Kine'
+ // : GoogleFonts.notoKufiArabic().fontFamily,
+ color: (null) ?? theme.onPrimaryContainer),
+ ),
+ ),
+ );
},
),
),
diff --git a/lib/src/common_widgets/recipe/food_category_widget.dart b/lib/src/common_widgets/recipe/food_category_widget.dart
index dbbc589..6bfd06c 100644
--- a/lib/src/common_widgets/recipe/food_category_widget.dart
+++ b/lib/src/common_widgets/recipe/food_category_widget.dart
@@ -1,8 +1,6 @@
import 'package:cached_network_image/cached_network_image.dart';
-import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
-import 'package:google_fonts/google_fonts.dart';
class FoodCategory extends StatelessWidget {
const FoodCategory({
@@ -49,9 +47,9 @@ class FoodCategory extends StatelessWidget {
style: TextStyle(
fontSize: 20.0,
color: theme.onSurface,
- fontFamily: context.locale.languageCode == "en"
- ? 'Kine'
- : GoogleFonts.notoKufiArabic().fontFamily,
+ // fontFamily: context.locale.languageCode == "en"
+ // ? 'Kine'
+ // : GoogleFonts.notoKufiArabic().fontFamily,
letterSpacing: 1.0),
),
)
diff --git a/lib/src/common_widgets/recipe/recipe_card_widget.dart b/lib/src/common_widgets/recipe/recipe_card_widget.dart
index 2c83c54..2a9d179 100644
--- a/lib/src/common_widgets/recipe/recipe_card_widget.dart
+++ b/lib/src/common_widgets/recipe/recipe_card_widget.dart
@@ -1,9 +1,7 @@
import 'dart:ui';
import 'package:cached_network_image/cached_network_image.dart';
-import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
-import 'package:google_fonts/google_fonts.dart';
import '../../constants/constants.dart';
@@ -86,11 +84,7 @@ class _RecipeCardNormalState extends State {
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 15.0,
- fontFamily:
- context.locale.languageCode == "en"
- ? 'Kine'
- : GoogleFonts.notoKufiArabic()
- .fontFamily,
+ fontFamily: 'Kine',
color: Theme.of(context)
.colorScheme
.onPrimaryContainer),
@@ -109,12 +103,7 @@ class _RecipeCardNormalState extends State {
widget.time.toUpperCase(),
style: TextStyle(
fontSize: 12.0,
- fontFamily:
- context.locale.languageCode ==
- "en"
- ? 'Kine'
- : GoogleFonts.notoKufiArabic()
- .fontFamily,
+ fontFamily: 'Kine',
color: Theme.of(context)
.colorScheme
.onPrimaryContainer),
@@ -136,12 +125,7 @@ class _RecipeCardNormalState extends State {
widget.difficulty.toUpperCase(),
style: TextStyle(
fontSize: 12.0,
- fontFamily:
- context.locale.languageCode ==
- "en"
- ? 'Kine'
- : GoogleFonts.notoKufiArabic()
- .fontFamily,
+ fontFamily: 'Kine',
color: Theme.of(context)
.colorScheme
.onPrimaryContainer),
diff --git a/lib/src/common_widgets/recipe/recipe_details_widgets.dart b/lib/src/common_widgets/recipe/recipe_details_widgets.dart
index 3306be8..56655c8 100644
--- a/lib/src/common_widgets/recipe/recipe_details_widgets.dart
+++ b/lib/src/common_widgets/recipe/recipe_details_widgets.dart
@@ -1,3 +1,4 @@
+import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
class IconCard extends StatelessWidget {
@@ -7,6 +8,7 @@ class IconCard extends StatelessWidget {
required this.color,
required this.name,
this.takeColor = false,
+ this.isNetworkImage = false,
this.calAmount})
: super(key: key);
@@ -14,6 +16,7 @@ class IconCard extends StatelessWidget {
final Color color;
final bool takeColor;
final String name;
+ final bool isNetworkImage;
final String? calAmount;
@@ -33,10 +36,15 @@ class IconCard extends StatelessWidget {
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
- Image.asset(
- image,
- width: 60,
- ),
+ isNetworkImage
+ ? CachedNetworkImage(
+ imageUrl: image,
+ width: 60,
+ )
+ : Image.asset(
+ image,
+ width: 60,
+ ),
if (calAmount != null) Text(calAmount.toString()),
FittedBox(
child: Text(
diff --git a/lib/src/common_widgets/recipe/recipe_grid_view.dart b/lib/src/common_widgets/recipe/recipe_grid_view.dart
index 9b36c5e..0fa2252 100644
--- a/lib/src/common_widgets/recipe/recipe_grid_view.dart
+++ b/lib/src/common_widgets/recipe/recipe_grid_view.dart
@@ -1,7 +1,6 @@
import 'dart:developer';
import 'package:animations/animations.dart';
-import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
@@ -29,7 +28,7 @@ class RecipesGridView extends ConsumerStatefulWidget {
}
class _RecipesGridViewState extends ConsumerState {
- static const _pageSize = 6;
+ static const _pageSize = 10;
final PagingController _pagingController = PagingController(firstPageKey: 1);
@override
@@ -47,6 +46,7 @@ class _RecipesGridViewState extends ConsumerState {
bool guest = ref.watch(guestProvider);
final guestRecipes = await ref.watch(getRecipesProvider(
+ context: context,
id: recipesTypeData == 0 ? patientID : recipesTypeData,
pageKey: pageKey)
.future);
@@ -54,10 +54,12 @@ class _RecipesGridViewState extends ConsumerState {
final newItems = isGuest == false && guest == false
? await ref.watch(isUserVegan == true
? getVegRecipesProvider(
+ context: context,
id: recipesTypeData == 0 ? patientID : recipesTypeData,
pageKey: pageKey)
.future
: getRecipesProvider(
+ context: context,
id: recipesTypeData == 0 ? patientID : recipesTypeData,
pageKey: pageKey)
.future)
@@ -99,7 +101,6 @@ class _RecipesGridViewState extends ConsumerState {
firstPageProgressIndicatorBuilder: (context) => LoadingGridView(),
itemBuilder: (context, item, index) {
final recipe = item as Recipe;
-
return OpenContainer(
openElevation: 0,
closedElevation: 0,
@@ -110,18 +111,12 @@ class _RecipesGridViewState extends ConsumerState {
transitionDuration: const Duration(milliseconds: 500),
closedBuilder: (context, action) => RecipeCardNormal(
id: recipe.id,
- name: context.locale.languageCode == "en"
- ? recipe.name
- : recipe.name_in_arabic,
+ name: recipe.name,
foodImage: '${item.imageURL}',
- type: context.locale.languageCode == "en"
- ? recipe.patient
- : recipe.patient_in_arabic,
- difficulty: changeDiffName(item.diff, context),
- time: context.locale.languageCode == "en"
- ? "${recipe.time_taken} min"
- : "${recipe.time_taken} دقيقة",
- dImage: changeDiffImage(difficulty: recipe.diff),
+ type: recipe.patient,
+ difficulty: recipe.difficulty,
+ time: "${recipe.time_taken} min",
+ dImage: "$restAPIMedia/${recipe.difficulty_image}",
),
);
},
diff --git a/lib/src/common_widgets/recipe/web_view_widget.dart b/lib/src/common_widgets/recipe/web_view_widget.dart
index 2fa2248..86c040f 100644
--- a/lib/src/common_widgets/recipe/web_view_widget.dart
+++ b/lib/src/common_widgets/recipe/web_view_widget.dart
@@ -1,38 +1,33 @@
-import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:webview_flutter/webview_flutter.dart';
class RecipeVideoWidget extends StatelessWidget {
- RecipeVideoWidget({Key? key, required this.url}) : super(key: key);
final String url;
-
- final 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 request) {
- if (request.url.startsWith('https://www.youtube.com/')) {
- return NavigationDecision.prevent;
- }
- return NavigationDecision.navigate;
- },
- ),
- )
- ..loadRequest(Uri.parse('https://flutter.dev'));
+ RecipeVideoWidget({Key? key, required this.url}) : super(key: key);
@override
Widget build(BuildContext context) {
+ print(url);
+ final 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) {
+ print(error.description);
+ },
+ ),
+ )
+ ..loadRequest(Uri.parse("https://www.youtube.com/watch?v=-B-usxlRJj"));
return Scaffold(
appBar: AppBar(
- title: Text(context.locale.languageCode == "en" ? "Video" : "فيديو"),
+ title: Text("Video"),
leading: IconButton(
onPressed: () => context.go('/navigate'),
icon: const Icon(Icons.arrow_back)),
diff --git a/lib/src/constants/constants.dart b/lib/src/constants/constants.dart
index a34257b..789c8ef 100644
--- a/lib/src/constants/constants.dart
+++ b/lib/src/constants/constants.dart
@@ -1,18 +1,13 @@
import 'package:flutter/material.dart';
import 'package:livine/src/shared/notification_control/notifications_control.dart';
-import '../shared/ads/ads_help.dart';
-import '../features/scan_food/presentation/controllers/image_controller.dart';
-import '../features/scan_food/presentation/controllers/model_controller.dart';
import '../shared/responsive/responsive_controller.dart';
ResponsiveHelper rh = ResponsiveHelper();
-final adHelper = AdHelper();
+// final modelTF = ModelTFLite();
-final modelTF = ModelTFLite();
-
-final imageController = ImageController();
+// final imageController = ImageController();
final notificationControl = NotificationControl();
@@ -20,7 +15,8 @@ const restAPIURL = "https://livine2.pythonanywhere.com/api";
const restAPIMedia = "https://livine2.pythonanywhere.com";
-ColorScheme getColorScheme(BuildContext context) {
+
+
+ColorScheme colorScheme(BuildContext context) {
return Theme.of(context).colorScheme;
}
-
diff --git a/lib/src/constants/shared_constants.dart b/lib/src/constants/shared_constants.dart
index 0618086..225870c 100644
--- a/lib/src/constants/shared_constants.dart
+++ b/lib/src/constants/shared_constants.dart
@@ -1,3 +1,5 @@
+import 'package:flutter/material.dart';
+
import '../shared/cache/cache_helper.dart';
int patientID = CacheHelper.getInt("patientID") ?? 0;
@@ -8,3 +10,5 @@ bool username = CacheHelper.getBool("username") ?? false;
bool isGuest = CacheHelper.getBool("isGuest") ?? false;
bool isBoarded = CacheHelper.getBool("isBoarded") ?? false;
+
+Object themeColor = CacheHelper.getString("themeColor") ?? Colors.green;
diff --git a/lib/src/features/auth/application/auth_service.dart b/lib/src/features/auth/application/auth_service.dart
index 67fca1f..765e04e 100644
--- a/lib/src/features/auth/application/auth_service.dart
+++ b/lib/src/features/auth/application/auth_service.dart
@@ -1,5 +1,7 @@
+
// ignore_for_file: use_build_context_synchronously
+import 'dart:async';
import 'dart:convert';
import 'dart:developer';
import 'dart:io';
@@ -7,13 +9,13 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
+import 'package:livine/src/features/auth/profiles/data/get_user_data.dart';
import 'package:livine/src/shared/cache/cache_helper.dart';
import '../data/user.dart';
import '../../../constants/constants.dart';
import '../../../constants/shared_constants.dart';
import '../../get_recipes/domain/recipe/recipe.dart';
-import '../profiles/data/get_user_data.dart';
final authHelperProvider = Provider(AuthService.new);
@@ -55,7 +57,7 @@ class AuthService {
GoRouter.of(context).go('/navigate');
}
} else {
- GoRouter.of(context).go('/navigate');
+ GoRouter.of(context).go('/navigate');
}
} else {
if (!mounted) return null;
@@ -117,10 +119,7 @@ class AuthService {
context.go('/login');
} else {
- log(error: "Error in logout", response.body);
- ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
- content: Text("Error logging out"),
- ));
+ logOutAsGuest(context);
}
}
@@ -186,10 +185,9 @@ class AuthService {
}
}
- Future getUserUsername() async {
+ Future getUserUsername() async{
final userData = await ref.watch(userDataProvider.future);
- log(error: "Username", userData.toString());
-
+ // log(error: "Username", userData.toString());
return userData.username ?? "";
}
}
diff --git a/lib/src/features/auth/domain/user.dart b/lib/src/features/auth/domain/user.dart
index d749bfd..ef10329 100644
--- a/lib/src/features/auth/domain/user.dart
+++ b/lib/src/features/auth/domain/user.dart
@@ -6,7 +6,7 @@ part 'user.g.dart';
@freezed
class UserData with _$UserData {
const factory UserData(int? id, String? username, String? email, int? patient,
- bool? isVegan) = _UserData;
+ bool? isVegan, int? points) = _UserData;
factory UserData.fromJson(Map json) =>
_$UserDataFromJson(json);
}
diff --git a/lib/src/features/auth/domain/user.freezed.dart b/lib/src/features/auth/domain/user.freezed.dart
index 3c505bf..d4bdafb 100644
--- a/lib/src/features/auth/domain/user.freezed.dart
+++ b/lib/src/features/auth/domain/user.freezed.dart
@@ -1,7 +1,7 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
-// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
+// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'user.dart';
@@ -25,6 +25,7 @@ mixin _$UserData {
String? get email => throw _privateConstructorUsedError;
int? get patient => throw _privateConstructorUsedError;
bool? get isVegan => throw _privateConstructorUsedError;
+ int? get points => throw _privateConstructorUsedError;
Map toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
@@ -35,19 +36,28 @@ mixin _$UserData {
/// @nodoc
abstract class $UserDataCopyWith<$Res> {
factory $UserDataCopyWith(UserData value, $Res Function(UserData) then) =
- _$UserDataCopyWithImpl<$Res>;
+ _$UserDataCopyWithImpl<$Res, UserData>;
+ @useResult
$Res call(
- {int? id, String? username, String? email, int? patient, bool? isVegan});
+ {int? id,
+ String? username,
+ String? email,
+ int? patient,
+ bool? isVegan,
+ int? points});
}
/// @nodoc
-class _$UserDataCopyWithImpl<$Res> implements $UserDataCopyWith<$Res> {
+class _$UserDataCopyWithImpl<$Res, $Val extends UserData>
+ implements $UserDataCopyWith<$Res> {
_$UserDataCopyWithImpl(this._value, this._then);
- final UserData _value;
// ignore: unused_field
- final $Res Function(UserData) _then;
+ final $Val _value;
+ // ignore: unused_field
+ final $Res Function($Val) _then;
+ @pragma('vm:prefer-inline')
@override
$Res call({
Object? id = freezed,
@@ -55,29 +65,34 @@ class _$UserDataCopyWithImpl<$Res> implements $UserDataCopyWith<$Res> {
Object? email = freezed,
Object? patient = freezed,
Object? isVegan = freezed,
+ Object? points = freezed,
}) {
return _then(_value.copyWith(
- id: id == freezed
+ id: freezed == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int?,
- username: username == freezed
+ username: freezed == username
? _value.username
: username // ignore: cast_nullable_to_non_nullable
as String?,
- email: email == freezed
+ email: freezed == email
? _value.email
: email // ignore: cast_nullable_to_non_nullable
as String?,
- patient: patient == freezed
+ patient: freezed == patient
? _value.patient
: patient // ignore: cast_nullable_to_non_nullable
as int?,
- isVegan: isVegan == freezed
+ isVegan: freezed == isVegan
? _value.isVegan
: isVegan // ignore: cast_nullable_to_non_nullable
as bool?,
- ));
+ points: freezed == points
+ ? _value.points
+ : points // ignore: cast_nullable_to_non_nullable
+ as int?,
+ ) as $Val);
}
}
@@ -87,20 +102,25 @@ abstract class _$$_UserDataCopyWith<$Res> implements $UserDataCopyWith<$Res> {
_$_UserData value, $Res Function(_$_UserData) then) =
__$$_UserDataCopyWithImpl<$Res>;
@override
+ @useResult
$Res call(
- {int? id, String? username, String? email, int? patient, bool? isVegan});
+ {int? id,
+ String? username,
+ String? email,
+ int? patient,
+ bool? isVegan,
+ int? points});
}
/// @nodoc
-class __$$_UserDataCopyWithImpl<$Res> extends _$UserDataCopyWithImpl<$Res>
+class __$$_UserDataCopyWithImpl<$Res>
+ extends _$UserDataCopyWithImpl<$Res, _$_UserData>
implements _$$_UserDataCopyWith<$Res> {
__$$_UserDataCopyWithImpl(
_$_UserData _value, $Res Function(_$_UserData) _then)
- : super(_value, (v) => _then(v as _$_UserData));
-
- @override
- _$_UserData get _value => super._value as _$_UserData;
+ : super(_value, _then);
+ @pragma('vm:prefer-inline')
@override
$Res call({
Object? id = freezed,
@@ -108,28 +128,33 @@ class __$$_UserDataCopyWithImpl<$Res> extends _$UserDataCopyWithImpl<$Res>
Object? email = freezed,
Object? patient = freezed,
Object? isVegan = freezed,
+ Object? points = freezed,
}) {
return _then(_$_UserData(
- id == freezed
+ freezed == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int?,
- username == freezed
+ freezed == username
? _value.username
: username // ignore: cast_nullable_to_non_nullable
as String?,
- email == freezed
+ freezed == email
? _value.email
: email // ignore: cast_nullable_to_non_nullable
as String?,
- patient == freezed
+ freezed == patient
? _value.patient
: patient // ignore: cast_nullable_to_non_nullable
as int?,
- isVegan == freezed
+ freezed == isVegan
? _value.isVegan
: isVegan // ignore: cast_nullable_to_non_nullable
as bool?,
+ freezed == points
+ ? _value.points
+ : points // ignore: cast_nullable_to_non_nullable
+ as int?,
));
}
}
@@ -137,8 +162,8 @@ class __$$_UserDataCopyWithImpl<$Res> extends _$UserDataCopyWithImpl<$Res>
/// @nodoc
@JsonSerializable()
class _$_UserData implements _UserData {
- const _$_UserData(
- this.id, this.username, this.email, this.patient, this.isVegan);
+ const _$_UserData(this.id, this.username, this.email, this.patient,
+ this.isVegan, this.points);
factory _$_UserData.fromJson(Map json) =>
_$$_UserDataFromJson(json);
@@ -153,10 +178,12 @@ class _$_UserData implements _UserData {
final int? patient;
@override
final bool? isVegan;
+ @override
+ final int? points;
@override
String toString() {
- return 'UserData(id: $id, username: $username, email: $email, patient: $patient, isVegan: $isVegan)';
+ return 'UserData(id: $id, username: $username, email: $email, patient: $patient, isVegan: $isVegan, points: $points)';
}
@override
@@ -164,25 +191,23 @@ class _$_UserData implements _UserData {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$_UserData &&
- const DeepCollectionEquality().equals(other.id, id) &&
- const DeepCollectionEquality().equals(other.username, username) &&
- const DeepCollectionEquality().equals(other.email, email) &&
- const DeepCollectionEquality().equals(other.patient, patient) &&
- const DeepCollectionEquality().equals(other.isVegan, isVegan));
+ (identical(other.id, id) || other.id == id) &&
+ (identical(other.username, username) ||
+ other.username == username) &&
+ (identical(other.email, email) || other.email == email) &&
+ (identical(other.patient, patient) || other.patient == patient) &&
+ (identical(other.isVegan, isVegan) || other.isVegan == isVegan) &&
+ (identical(other.points, points) || other.points == points));
}
@JsonKey(ignore: true)
@override
- int get hashCode => Object.hash(
- runtimeType,
- const DeepCollectionEquality().hash(id),
- const DeepCollectionEquality().hash(username),
- const DeepCollectionEquality().hash(email),
- const DeepCollectionEquality().hash(patient),
- const DeepCollectionEquality().hash(isVegan));
+ int get hashCode =>
+ Object.hash(runtimeType, id, username, email, patient, isVegan, points);
@JsonKey(ignore: true)
@override
+ @pragma('vm:prefer-inline')
_$$_UserDataCopyWith<_$_UserData> get copyWith =>
__$$_UserDataCopyWithImpl<_$_UserData>(this, _$identity);
@@ -200,7 +225,8 @@ abstract class _UserData implements UserData {
final String? username,
final String? email,
final int? patient,
- final bool? isVegan) = _$_UserData;
+ final bool? isVegan,
+ final int? points) = _$_UserData;
factory _UserData.fromJson(Map json) = _$_UserData.fromJson;
@@ -215,6 +241,8 @@ abstract class _UserData implements UserData {
@override
bool? get isVegan;
@override
+ int? get points;
+ @override
@JsonKey(ignore: true)
_$$_UserDataCopyWith<_$_UserData> get copyWith =>
throw _privateConstructorUsedError;
diff --git a/lib/src/features/auth/domain/user.g.dart b/lib/src/features/auth/domain/user.g.dart
index 0096f66..f95eb80 100644
--- a/lib/src/features/auth/domain/user.g.dart
+++ b/lib/src/features/auth/domain/user.g.dart
@@ -12,6 +12,7 @@ _$_UserData _$$_UserDataFromJson(Map json) => _$_UserData(
json['email'] as String?,
json['patient'] as int?,
json['isVegan'] as bool?,
+ json['points'] as int?,
);
Map _$$_UserDataToJson(_$_UserData instance) =>
@@ -21,4 +22,5 @@ Map _$$_UserDataToJson(_$_UserData instance) =>
'email': instance.email,
'patient': instance.patient,
'isVegan': instance.isVegan,
+ 'points': instance.points,
};
diff --git a/lib/src/features/auth/favorites/data/favorites.dart b/lib/src/features/auth/favorites/data/favorites.dart
index bd55b5d..e6cf2f5 100644
--- a/lib/src/features/auth/favorites/data/favorites.dart
+++ b/lib/src/features/auth/favorites/data/favorites.dart
@@ -3,25 +3,32 @@ import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
+import 'package:riverpod_annotation/riverpod_annotation.dart';
+import '../../../../translations/domain/translation_provider.dart';
import '../../application/auth_service.dart';
import '../../../../constants/constants.dart';
import '../../../get_recipes/domain/recipe/recipe.dart';
import '../domain/favorites.dart';
-final FutureProvider getFavoritesProvider =
- FutureProvider((ref) async {
- final url = '$restAPIURL/user/favorite/';
+part 'favorites.g.dart';
+
+@riverpod
+Future getFavorites(Ref ref,{required BuildContext context}) async{
+ final url = '$restAPIURL/user/favorite/';
final response = await client.get(
Uri.parse(url),
headers: {
+ 'Accept-Language': ref.watch(localeNotifierProvider).languageCode,
'Authorization': 'Token ${ref.read(authHelperProvider).getToken()}',
},
);
final responseDe = utf8.decode(response.bodyBytes);
final responseJson = json.decode(responseDe);
return FavoritesData.fromJson(responseJson["favorites"]);
-});
+
+}
+
Future addFavorite({
required WidgetRef ref,
diff --git a/lib/src/features/auth/favorites/data/favorites.g.dart b/lib/src/features/auth/favorites/data/favorites.g.dart
new file mode 100644
index 0000000..c3b7ee7
--- /dev/null
+++ b/lib/src/features/auth/favorites/data/favorites.g.dart
@@ -0,0 +1,159 @@
+// GENERATED CODE - DO NOT MODIFY BY HAND
+
+part of 'favorites.dart';
+
+// **************************************************************************
+// RiverpodGenerator
+// **************************************************************************
+
+String _$getFavoritesHash() => r'25ef05d5eb37798fca37568e88253517a425806c';
+
+/// Copied from Dart SDK
+class _SystemHash {
+ _SystemHash._();
+
+ static int combine(int hash, int value) {
+ // ignore: parameter_assignments
+ hash = 0x1fffffff & (hash + value);
+ // ignore: parameter_assignments
+ hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10));
+ return hash ^ (hash >> 6);
+ }
+
+ static int finish(int hash) {
+ // ignore: parameter_assignments
+ hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3));
+ // ignore: parameter_assignments
+ hash = hash ^ (hash >> 11);
+ return 0x1fffffff & (hash + ((0x00003fff & hash) << 15));
+ }
+}
+
+/// See also [getFavorites].
+@ProviderFor(getFavorites)
+const getFavoritesProvider = GetFavoritesFamily();
+
+/// See also [getFavorites].
+class GetFavoritesFamily extends Family> {
+ /// See also [getFavorites].
+ const GetFavoritesFamily();
+
+ /// See also [getFavorites].
+ GetFavoritesProvider call({
+ required BuildContext context,
+ }) {
+ return GetFavoritesProvider(
+ context: context,
+ );
+ }
+
+ @override
+ GetFavoritesProvider getProviderOverride(
+ covariant GetFavoritesProvider provider,
+ ) {
+ return call(
+ context: provider.context,
+ );
+ }
+
+ static const Iterable? _dependencies = null;
+
+ @override
+ Iterable? get dependencies => _dependencies;
+
+ static const Iterable? _allTransitiveDependencies = null;
+
+ @override
+ Iterable? get allTransitiveDependencies =>
+ _allTransitiveDependencies;
+
+ @override
+ String? get name => r'getFavoritesProvider';
+}
+
+/// See also [getFavorites].
+class GetFavoritesProvider extends AutoDisposeFutureProvider {
+ /// See also [getFavorites].
+ GetFavoritesProvider({
+ required BuildContext context,
+ }) : this._internal(
+ (ref) => getFavorites(
+ ref as GetFavoritesRef,
+ context: context,
+ ),
+ from: getFavoritesProvider,
+ name: r'getFavoritesProvider',
+ debugGetCreateSourceHash:
+ const bool.fromEnvironment('dart.vm.product')
+ ? null
+ : _$getFavoritesHash,
+ dependencies: GetFavoritesFamily._dependencies,
+ allTransitiveDependencies:
+ GetFavoritesFamily._allTransitiveDependencies,
+ context: context,
+ );
+
+ GetFavoritesProvider._internal(
+ super._createNotifier, {
+ required super.name,
+ required super.dependencies,
+ required super.allTransitiveDependencies,
+ required super.debugGetCreateSourceHash,
+ required super.from,
+ required this.context,
+ }) : super.internal();
+
+ final BuildContext context;
+
+ @override
+ Override overrideWith(
+ FutureOr Function(GetFavoritesRef provider) create,
+ ) {
+ return ProviderOverride(
+ origin: this,
+ override: GetFavoritesProvider._internal(
+ (ref) => create(ref as GetFavoritesRef),
+ from: from,
+ name: null,
+ dependencies: null,
+ allTransitiveDependencies: null,
+ debugGetCreateSourceHash: null,
+ context: context,
+ ),
+ );
+ }
+
+ @override
+ AutoDisposeFutureProviderElement createElement() {
+ return _GetFavoritesProviderElement(this);
+ }
+
+ @override
+ bool operator ==(Object other) {
+ return other is GetFavoritesProvider && other.context == context;
+ }
+
+ @override
+ int get hashCode {
+ var hash = _SystemHash.combine(0, runtimeType.hashCode);
+ hash = _SystemHash.combine(hash, context.hashCode);
+
+ return _SystemHash.finish(hash);
+ }
+}
+
+mixin GetFavoritesRef on AutoDisposeFutureProviderRef {
+ /// The parameter `context` of this provider.
+ BuildContext get context;
+}
+
+class _GetFavoritesProviderElement
+ extends AutoDisposeFutureProviderElement
+ with GetFavoritesRef {
+ _GetFavoritesProviderElement(super.provider);
+
+ @override
+ BuildContext get context => (origin as GetFavoritesProvider).context;
+}
+// ignore_for_file: type=lint
+// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member
diff --git a/lib/src/features/auth/favorites/domain/favorites.dart b/lib/src/features/auth/favorites/domain/favorites.dart
index 0f6d77b..ef9a63d 100644
--- a/lib/src/features/auth/favorites/domain/favorites.dart
+++ b/lib/src/features/auth/favorites/domain/favorites.dart
@@ -8,7 +8,7 @@ part 'favorites.g.dart';
@freezed
class FavoritesData with _$FavoritesData {
const factory FavoritesData(
- List id, List name, List name_in_arabic, List imageURL) = _FavoritesData;
+ List id, List name, List imageURL) = _FavoritesData;
factory FavoritesData.fromJson(Map json) =>
_$FavoritesDataFromJson(json);
}
diff --git a/lib/src/features/auth/favorites/domain/favorites.freezed.dart b/lib/src/features/auth/favorites/domain/favorites.freezed.dart
index e50074a..bfa2871 100644
--- a/lib/src/features/auth/favorites/domain/favorites.freezed.dart
+++ b/lib/src/features/auth/favorites/domain/favorites.freezed.dart
@@ -1,7 +1,7 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
-// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
+// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'favorites.dart';
@@ -22,7 +22,6 @@ FavoritesData _$FavoritesDataFromJson(Map json) {
mixin _$FavoritesData {
List get id => throw _privateConstructorUsedError;
List get name => throw _privateConstructorUsedError;
- List get name_in_arabic => throw _privateConstructorUsedError;
List get imageURL => throw _privateConstructorUsedError;
Map toJson() => throw _privateConstructorUsedError;
@@ -35,48 +34,42 @@ mixin _$FavoritesData {
abstract class $FavoritesDataCopyWith<$Res> {
factory $FavoritesDataCopyWith(
FavoritesData value, $Res Function(FavoritesData) then) =
- _$FavoritesDataCopyWithImpl<$Res>;
- $Res call(
- {List id,
- List name,
- List name_in_arabic,
- List imageURL});
+ _$FavoritesDataCopyWithImpl<$Res, FavoritesData>;
+ @useResult
+ $Res call({List id, List name, List imageURL});
}
/// @nodoc
-class _$FavoritesDataCopyWithImpl<$Res>
+class _$FavoritesDataCopyWithImpl<$Res, $Val extends FavoritesData>
implements $FavoritesDataCopyWith<$Res> {
_$FavoritesDataCopyWithImpl(this._value, this._then);
- final FavoritesData _value;
// ignore: unused_field
- final $Res Function(FavoritesData) _then;
+ final $Val _value;
+ // ignore: unused_field
+ final $Res Function($Val) _then;
+ @pragma('vm:prefer-inline')
@override
$Res call({
- Object? id = freezed,
- Object? name = freezed,
- Object? name_in_arabic = freezed,
- Object? imageURL = freezed,
+ Object? id = null,
+ Object? name = null,
+ Object? imageURL = null,
}) {
return _then(_value.copyWith(
- id: id == freezed
+ id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as List,
- name: name == freezed
+ name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as List,
- name_in_arabic: name_in_arabic == freezed
- ? _value.name_in_arabic
- : name_in_arabic // ignore: cast_nullable_to_non_nullable
- as List,
- imageURL: imageURL == freezed
+ imageURL: null == imageURL
? _value.imageURL
: imageURL // ignore: cast_nullable_to_non_nullable
as List,
- ));
+ ) as $Val);
}
}
@@ -87,45 +80,35 @@ abstract class _$$_FavoritesDataCopyWith<$Res>
_$_FavoritesData value, $Res Function(_$_FavoritesData) then) =
__$$_FavoritesDataCopyWithImpl<$Res>;
@override
- $Res call(
- {List id,
- List name,
- List name_in_arabic,
- List imageURL});
+ @useResult
+ $Res call({List id, List name, List imageURL});
}
/// @nodoc
class __$$_FavoritesDataCopyWithImpl<$Res>
- extends _$FavoritesDataCopyWithImpl<$Res>
+ extends _$FavoritesDataCopyWithImpl<$Res, _$_FavoritesData>
implements _$$_FavoritesDataCopyWith<$Res> {
__$$_FavoritesDataCopyWithImpl(
_$_FavoritesData _value, $Res Function(_$_FavoritesData) _then)
- : super(_value, (v) => _then(v as _$_FavoritesData));
-
- @override
- _$_FavoritesData get _value => super._value as _$_FavoritesData;
+ : super(_value, _then);
+ @pragma('vm:prefer-inline')
@override
$Res call({
- Object? id = freezed,
- Object? name = freezed,
- Object? name_in_arabic = freezed,
- Object? imageURL = freezed,
+ Object? id = null,
+ Object? name = null,
+ Object? imageURL = null,
}) {
return _then(_$_FavoritesData(
- id == freezed
+ null == id
? _value._id
: id // ignore: cast_nullable_to_non_nullable
as List,
- name == freezed
+ null == name
? _value._name
: name // ignore: cast_nullable_to_non_nullable
as List,
- name_in_arabic == freezed
- ? _value._name_in_arabic
- : name_in_arabic // ignore: cast_nullable_to_non_nullable
- as List,
- imageURL == freezed
+ null == imageURL
? _value._imageURL
: imageURL // ignore: cast_nullable_to_non_nullable
as List,
@@ -137,10 +120,9 @@ class __$$_FavoritesDataCopyWithImpl<$Res>
@JsonSerializable()
class _$_FavoritesData implements _FavoritesData {
const _$_FavoritesData(final List id, final List name,
- final List name_in_arabic, final List imageURL)
+ final List imageURL)
: _id = id,
_name = name,
- _name_in_arabic = name_in_arabic,
_imageURL = imageURL;
factory _$_FavoritesData.fromJson(Map json) =>
@@ -149,6 +131,7 @@ class _$_FavoritesData implements _FavoritesData {
final List _id;
@override
List get id {
+ if (_id is EqualUnmodifiableListView) return _id;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_id);
}
@@ -156,27 +139,22 @@ class _$_FavoritesData implements _FavoritesData {
final List _name;
@override
List get name {
+ if (_name is EqualUnmodifiableListView) return _name;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_name);
}
- final List _name_in_arabic;
- @override
- List get name_in_arabic {
- // ignore: implicit_dynamic_type
- return EqualUnmodifiableListView(_name_in_arabic);
- }
-
final List _imageURL;
@override
List get imageURL {
+ if (_imageURL is EqualUnmodifiableListView) return _imageURL;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_imageURL);
}
@override
String toString() {
- return 'FavoritesData(id: $id, name: $name, name_in_arabic: $name_in_arabic, imageURL: $imageURL)';
+ return 'FavoritesData(id: $id, name: $name, imageURL: $imageURL)';
}
@override
@@ -186,8 +164,6 @@ class _$_FavoritesData implements _FavoritesData {
other is _$_FavoritesData &&
const DeepCollectionEquality().equals(other._id, _id) &&
const DeepCollectionEquality().equals(other._name, _name) &&
- const DeepCollectionEquality()
- .equals(other._name_in_arabic, _name_in_arabic) &&
const DeepCollectionEquality().equals(other._imageURL, _imageURL));
}
@@ -197,11 +173,11 @@ class _$_FavoritesData implements _FavoritesData {
runtimeType,
const DeepCollectionEquality().hash(_id),
const DeepCollectionEquality().hash(_name),
- const DeepCollectionEquality().hash(_name_in_arabic),
const DeepCollectionEquality().hash(_imageURL));
@JsonKey(ignore: true)
@override
+ @pragma('vm:prefer-inline')
_$$_FavoritesDataCopyWith<_$_FavoritesData> get copyWith =>
__$$_FavoritesDataCopyWithImpl<_$_FavoritesData>(this, _$identity);
@@ -214,10 +190,7 @@ class _$_FavoritesData implements _FavoritesData {
}
abstract class _FavoritesData implements FavoritesData {
- const factory _FavoritesData(
- final List id,
- final List name,
- final List name_in_arabic,
+ const factory _FavoritesData(final List id, final List name,
final List imageURL) = _$_FavoritesData;
factory _FavoritesData.fromJson(Map json) =
@@ -228,8 +201,6 @@ abstract class _FavoritesData implements FavoritesData {
@override
List get name;
@override
- List get name_in_arabic;
- @override
List get imageURL;
@override
@JsonKey(ignore: true)
diff --git a/lib/src/features/auth/favorites/domain/favorites.g.dart b/lib/src/features/auth/favorites/domain/favorites.g.dart
index ea63bcb..a985368 100644
--- a/lib/src/features/auth/favorites/domain/favorites.g.dart
+++ b/lib/src/features/auth/favorites/domain/favorites.g.dart
@@ -10,7 +10,6 @@ _$_FavoritesData _$$_FavoritesDataFromJson(Map json) =>
_$_FavoritesData(
json['id'] as List,
json['name'] as List,
- json['name_in_arabic'] as List,
json['imageURL'] as List,
);
@@ -18,6 +17,5 @@ Map _$$_FavoritesDataToJson(_$_FavoritesData instance) =>
{
'id': instance.id,
'name': instance.name,
- 'name_in_arabic': instance.name_in_arabic,
'imageURL': instance.imageURL,
};
diff --git a/lib/src/features/auth/favorites/presentation/favorites.dart b/lib/src/features/auth/favorites/presentation/favorites.dart
index 5607eef..8b5d767 100644
--- a/lib/src/features/auth/favorites/presentation/favorites.dart
+++ b/lib/src/features/auth/favorites/presentation/favorites.dart
@@ -1,14 +1,13 @@
import 'dart:developer';
import 'package:cached_network_image/cached_network_image.dart';
-import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:livine/src/constants/constants.dart';
+import '../../../../translations/domain/translation_provider.dart';
import '../data/favorites.dart';
import '../../../loading/loading.dart';
-import '../../../../translations/locale_keys.g.dart';
class Favorites extends ConsumerStatefulWidget {
const Favorites({Key? key}) : super(key: key);
@@ -20,21 +19,21 @@ class Favorites extends ConsumerStatefulWidget {
class _FavoritesState extends ConsumerState {
@override
Widget build(BuildContext context) {
- final favorites = ref.watch(getFavoritesProvider);
-
+ final favorites = ref.watch(getFavoritesProvider(context: context));
+ final word = TranslationRepo.translate(context);
return RefreshIndicator(
onRefresh: () async {
return Future.delayed(const Duration(seconds: 2))
- .then((_) => ref.refresh(getFavoritesProvider));
+ .then((_) => ref.refresh(getFavoritesProvider(context: context)));
},
- backgroundColor: getColorScheme(context).surface,
+ backgroundColor: colorScheme(context).surface,
child: Scaffold(
appBar: AppBar(
- title: Text(LocaleKeys.Favorites.tr()),
+ title: Text(word?.favorites ?? ""),
),
body: favorites.when(
data: (data) => RawScrollbar(
- thumbColor: getColorScheme(context).tertiary,
+ thumbColor: colorScheme(context).tertiary,
thickness: 5,
radius: const Radius.circular(10),
child: ListView.builder(
@@ -51,8 +50,8 @@ class _FavoritesState extends ConsumerState {
recipeID: data.id[index],
mounted: mounted,
context: context)
- .then((value) =>
- ref.refresh(getFavoritesProvider));
+ .then((value) => ref.refresh(
+ getFavoritesProvider(context: context)));
},
background: Container(
color: Colors.red,
@@ -75,9 +74,7 @@ class _FavoritesState extends ConsumerState {
fit: BoxFit.cover,
),
Text(
- context.locale.languageCode == "en"
- ? data.name[index]
- : data.name_in_arabic[index],
+ data.name[index],
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
diff --git a/lib/src/features/auth/login/presentation/login.dart b/lib/src/features/auth/login/presentation/login.dart
index 13b5b70..673c3b8 100644
--- a/lib/src/features/auth/login/presentation/login.dart
+++ b/lib/src/features/auth/login/presentation/login.dart
@@ -2,19 +2,17 @@
import 'dart:io';
-import 'package:easy_localization/easy_localization.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart';
import 'package:http/http.dart' as http;
-import 'package:iconsax/iconsax.dart';
+import 'package:livine/src/constants/constants.dart';
import 'package:livine/src/features/auth/application/auth_service.dart';
import 'package:livine/src/shared/cache/cache_helper.dart';
+import 'package:livine/src/translations/domain/translation_provider.dart';
-import '../../../../common_widgets/auth/auth_widget.dart';
-import '../../../../translations/locale_keys.g.dart';
import '../../data/user.dart';
class Login extends ConsumerStatefulWidget {
@@ -71,162 +69,234 @@ class _LoginState extends ConsumerState {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context).colorScheme;
-
+ final word = TranslationRepo.translate(context);
return Scaffold(
- body: Row(
- children: [
- Expanded(
- child: Form(
- key: _formKey,
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Padding(
- padding: const EdgeInsets.all(20.0),
- child: TextFormField(
- textInputAction: TextInputAction.next,
- validator: (u) {
- if (u!.isEmpty) {
- return context.locale.languageCode == "en"
- ? "Please enter your username"
- : "من فضلك ادخل اسم المستخدم";
- }
- if (u.contains(" ")) {
- return context.locale.languageCode == "en"
- ? "No space allowed in username"
- : "يجب ان لا يكون هناك مسافة في اسم المستخدم";
- }
- return null;
- },
- controller: _username,
- decoration: InputDecoration(
- border: const OutlineInputBorder(
- borderRadius:
- BorderRadius.all(Radius.circular(10.0))),
- labelText: LocaleKeys.username.tr(),
- labelStyle: const TextStyle(fontSize: 15),
- ),
- ),
- ),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 20.0),
- child: TextFormField(
- validator: (p) {
- if (p!.length < 6 && p.isNotEmpty) {
- return context.locale.languageCode == "en"
- ? "Password needs to be atleast 9 characters "
- : "يجب أن تتكون كلمة المرور من 9 أحرف على الأقل";
- } else if (p.isEmpty) {
- return context.locale.languageCode == "en"
- ? "Please enter your password "
- : "من فضلك أدخل كلمة السر";
- }
- return null;
- },
- controller: _password,
- obscureText: _obscureText,
- onFieldSubmitted: (_) => validateLoginForm(),
- decoration: InputDecoration(
- border: const OutlineInputBorder(
- borderRadius:
- BorderRadius.all(Radius.circular(10.0))),
- suffixIcon: IconButton(
- icon: Icon(
- _obscureText ? Iconsax.eye_slash5 : Iconsax.eye,
+ body: SingleChildScrollView(
+ child: SafeArea(
+ child: Padding(
+ padding: EdgeInsets.only(top: rh.deviceHeight(context) * 0.1),
+ child: Row(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ Expanded(
+ child: Form(
+ key: _formKey,
+ child: Column(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ Padding(
+ padding: const EdgeInsets.all(20.0),
+ child: TextFormField(
+ textInputAction: TextInputAction.next,
+ validator: (u) {
+ if (u!.isEmpty) {
+ return "Please enter your username";
+ }
+ if (u.contains(" ")) {
+ return "No space allowed in username";
+ }
+ return null;
+ },
+ controller: _username,
+ decoration: InputDecoration(
+ border: const OutlineInputBorder(
+ borderRadius:
+ BorderRadius.all(Radius.circular(10.0))),
+ labelText: word?.username ?? "Username",
+ labelStyle: const TextStyle(fontSize: 15),
+ ),
),
- onPressed: () {
- setState(() {
- _obscureText = !_obscureText;
- });
- },
- ),
- labelText: LocaleKeys.password.tr(),
- labelStyle: const TextStyle(fontSize: 15),
- ),
- ),
- ),
- Padding(
- padding: const EdgeInsets.only(top: 20, bottom: 5),
- child: GestureDetector(
- onTap: () => context.push('/reset_password'),
- child: Text(
- LocaleKeys.Forget_your_password.tr(),
- textAlign: TextAlign.right,
- style: TextStyle(
- fontSize: 15,
- fontFamily: 'Kine',
- color: theme.tertiary,
),
- ),
- ),
- ),
- SizedBox(
- height: 10,
- ),
- authButton(
- isLoading: isLoading,
- text: LocaleKeys.Sign_in.tr(),
- onPressed: validateLoginForm,
- context: context),
- Padding(
- padding: const EdgeInsets.only(top: 30),
- child: Center(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Text(
- LocaleKeys.no_account.tr(),
- style: const TextStyle(
- fontFamily: 'Kine', fontWeight: FontWeight.w100),
- ),
- const SizedBox(
- width: 10,
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 20.0),
+ child: TextFormField(
+ validator: (p) {
+ if (p!.length < 6 && p.isNotEmpty) {
+ return "Password needs to be atleast 9 characters ";
+ } else if (p.isEmpty) {
+ return "Please enter your password ";
+ }
+ return null;
+ },
+ controller: _password,
+ obscureText: _obscureText,
+ onFieldSubmitted: (_) => validateLoginForm(),
+ decoration: InputDecoration(
+ border: const OutlineInputBorder(
+ borderRadius:
+ BorderRadius.all(Radius.circular(10.0))),
+ suffixIcon: IconButton(
+ icon: Icon(
+ _obscureText
+ ? Icons.visibility_off
+ : Icons.visibility,
+ ),
+ onPressed: () {
+ setState(() {
+ _obscureText = !_obscureText;
+ });
+ },
+ ),
+ labelText: word?.password ?? "Password",
+ labelStyle: const TextStyle(fontSize: 15),
+ ),
),
- GestureDetector(
- onTap: () => context.push('/register'),
+ ),
+ Padding(
+ padding: const EdgeInsets.only(top: 20, bottom: 5),
+ child: GestureDetector(
+ onTap: () => context.push('/reset_password'),
child: Text(
- LocaleKeys.Sign_up.tr(),
+ word?.forget_your_password ?? "Forgot Password?",
+ textAlign: TextAlign.right,
style: TextStyle(
- fontSize: 15.0,
- color: theme.tertiary,
+ fontSize: 15,
fontFamily: 'Kine',
- fontWeight: FontWeight.bold,
+ color: theme.tertiary,
+ ),
+ ),
+ ),
+ ),
+ SizedBox(
+ height: 10,
+ ),
+ ({
+ required void Function() onPressed,
+ required bool isLoading,
+ required String text,
+ Color? color,
+ Color? textColor,
+ double width = 350,
+ required BuildContext context,
+ }) {
+ final theme = Theme.of(context).colorScheme;
+ return Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 20.0),
+ child: MaterialButton(
+ onPressed: onPressed,
+ color: color ?? theme.primaryContainer,
+ elevation: 0,
+ minWidth: width,
+ height: 60,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(15),
),
+ child: isLoading
+ ? const CircularProgressIndicator(
+ color: Colors.white,
+ )
+ : Text(
+ text,
+ style: TextStyle(
+ fontSize: 15,
+ color: textColor ??
+ theme.onPrimaryContainer),
+ ),
+ ),
+ );
+ }(
+ isLoading: isLoading,
+ text: word?.sign_in ?? "Sign In",
+ onPressed: validateLoginForm,
+ context: context),
+ Padding(
+ padding: const EdgeInsets.only(top: 30),
+ child: Center(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ Text(
+ word?.no_account ?? "No account yet?",
+ style: const TextStyle(
+ fontFamily: 'Kine',
+ fontWeight: FontWeight.w100),
+ ),
+ const SizedBox(
+ width: 10,
+ ),
+ GestureDetector(
+ onTap: () => context.push('/register'),
+ child: Text(
+ word?.sign_up ?? "Sign Up",
+ style: TextStyle(
+ fontSize: 15.0,
+ color: theme.tertiary,
+ fontFamily: 'Kine',
+ fontWeight: FontWeight.bold,
+ ),
+ ),
+ ),
+ ],
),
),
- ],
- ),
+ ),
+ SizedBox(
+ height: 10,
+ ),
+ // ({
+ // required void Function() onPressed,
+ // required bool isLoading,
+ // required String text,
+ // Color? color,
+ // Color? textColor,
+ // double width = 350,
+ // required BuildContext context,
+ // }) {
+ // final theme = Theme.of(context).colorScheme;
+ // return Padding(
+ // padding: const EdgeInsets.symmetric(horizontal: 20.0),
+ // child: MaterialButton(
+ // onPressed: onPressed,
+ // color: color ?? theme.primaryContainer,
+ // elevation: 0,
+ // minWidth: width,
+ // height: 60,
+ // shape: RoundedRectangleBorder(
+ // borderRadius: BorderRadius.circular(15),
+ // ),
+ // child: isLoading
+ // ? const CircularProgressIndicator(
+ // color: Colors.white,
+ // )
+ // : Text(
+ // text,
+ // style: TextStyle(
+ // fontSize: 15,
+ // color: textColor ??
+ // theme.onPrimaryContainer),
+ // ),
+ // ),
+ // );
+ // }(
+ // isLoading: false,
+ // text: word?.continue_as_guest ?? "Continue as Guest",
+ // textColor: theme.onSecondaryContainer,
+ // onPressed: validateGuest,
+ // context: context,
+ // color: theme.secondaryContainer),
+ ],
),
),
- SizedBox(
- height: 10,
- ),
- authButton(
- isLoading: false,
- text: LocaleKeys.continue_as_guest.tr(),
- textColor: theme.onSecondaryContainer,
- onPressed: validateGuest,
- context: context,
- color: theme.secondaryContainer),
- ],
- ),
+ ),
+ Visibility(
+ visible: Platform.isWindows,
+ child: Expanded(
+ flex: 2,
+ child: ClipRRect(
+ borderRadius: const BorderRadius.only(
+ topLeft: Radius.circular(20),
+ bottomLeft: Radius.circular(20)),
+ child: Image.asset(
+ 'assets/images/windows/login.webp',
+ fit: BoxFit.cover,
+ ),
+ )),
+ ),
+ ],
),
),
- Visibility(
- visible: Platform.isWindows,
- child: Expanded(
- flex: 2,
- child: ClipRRect(
- borderRadius: const BorderRadius.only(
- topLeft: Radius.circular(20),
- bottomLeft: Radius.circular(20)),
- child: Image.asset(
- 'assets/images/windows/login.webp',
- fit: BoxFit.cover,
- ),
- )),
- ),
- ],
+ ),
));
}
}
diff --git a/lib/src/features/auth/profiles/data/get_user_data.dart b/lib/src/features/auth/profiles/data/get_user_data.dart
index 3025cbb..19e864e 100644
--- a/lib/src/features/auth/profiles/data/get_user_data.dart
+++ b/lib/src/features/auth/profiles/data/get_user_data.dart
@@ -7,15 +7,41 @@ import '../../application/auth_service.dart';
import '../../../../constants/constants.dart';
import '../../../get_recipes/domain/recipe/recipe.dart';
-final FutureProvider userDataProvider =
- FutureProvider((ref) async {
+final userDataProvider = FutureProvider((ref) async {
final url = Uri.parse('$restAPIURL/user/?format=json');
- final token = ref.watch(authHelperProvider).getToken();
-
- final response = await client.get(
- url,
- headers: token != '' ? {'Authorization': 'Token ${token}'} : {},
- );
+ final token = await ref.watch(authHelperProvider).getToken();
+ Map headers = {};
+ if (token != '') {
+ headers["Authorization"] = 'Token ${token}';
+ }
+ final response = await client.get(url, headers: headers);
return UserData.fromJson(json.decode(response.body));
});
+
+// getUserData({required WidgetRef ref}) async{
+// final url = Uri.parse('$restAPIURL/user/?format=json');
+// final token = await ref.watch(authHelperProvider).getToken();
+// Map headers = {};
+// if (token != '') {
+// headers["Authorization"] = 'Token ${token}';
+// }
+// final response = await client.get(url, headers: headers);
+
+// return UserData.fromJson(json.decode(response.body));
+// }
+
+final userDataStreamProvider = StreamProvider((ref) async* {
+ while (true) {
+ await Future.delayed(Duration(seconds: 3));
+ final url = Uri.parse('$restAPIURL/user/?format=json');
+ final token = await ref.watch(authHelperProvider).getToken();
+ Map headers = {};
+ if (token != '') {
+ headers["Authorization"] = 'Token ${token}';
+ }
+ final response = await client.get(url, headers: headers);
+
+ yield UserData.fromJson(json.decode(response.body));
+ }
+});
diff --git a/lib/src/features/auth/profiles/presentation/profile.dart b/lib/src/features/auth/profiles/presentation/profile.dart
index c1c9530..0f5a261 100644
--- a/lib/src/features/auth/profiles/presentation/profile.dart
+++ b/lib/src/features/auth/profiles/presentation/profile.dart
@@ -1,38 +1,31 @@
import 'dart:developer';
-import 'package:easy_localization/easy_localization.dart';
-import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
-import 'package:flutter_switch/flutter_switch.dart';
import 'package:go_router/go_router.dart';
-import 'package:google_fonts/google_fonts.dart';
-import 'package:iconsax/iconsax.dart';
import 'package:livine/src/common_widgets/no_connection.dart';
+import 'package:livine/src/translations/domain/translation_provider.dart';
+import 'package:sliding_up_panel2/sliding_up_panel2.dart';
-import '../../../../constants/constants.dart';
import '../../../../constants/shared_constants.dart';
import '../../../../shared/connectivity/check_network.dart';
-import '../../../loading/loading.dart';
import '../../../get_recipes/application/vegan_service.dart';
-import '../../../../shared/styles/lib_color_schemes.g.dart';
-import '../../../../translations/locale_keys.g.dart';
import '../../application/auth_service.dart';
-import '../../data/user.dart';
-import '../../domain/user.dart';
import '../data/get_user_data.dart';
+import 'package:percent_indicator/percent_indicator.dart';
class Profile extends ConsumerWidget {
const Profile({Key? key}) : super(key: key);
@override
Widget build(BuildContext context, WidgetRef ref) {
- bool guest = ref.watch(guestProvider);
+ // bool guest = ref.watch(guestProvider);
ConnectivityStatus network = ref.watch(checkNetworkProvider);
+ bool isVeg = ref.watch(isVeganProvider);
- AsyncValue userData = ref.watch(userDataProvider);
-
+ final userData = ref.watch(userDataStreamProvider);
+ final word = TranslationRepo.translate(context);
userData.whenOrNull(
error: (error, stack) {
log("PROFILE ERROR $error");
@@ -40,50 +33,114 @@ class Profile extends ConsumerWidget {
},
);
+ int? userPoints =
+ userData.maybeWhen(data: (data) => data.points, orElse: () => 0);
return network == ConnectivityStatus.On
? Scaffold(
appBar: AppBar(
- backgroundColor: Theme.of(context).brightness == Brightness.dark
- ? darkColorScheme.background
- : lightColorScheme.secondaryContainer,
title: Text(
- LocaleKeys.Profile.tr(),
+ word?.profile ?? "",
style: TextStyle(
- fontFamily: context.locale.languageCode == "en"
- ? 'Kine'
- : GoogleFonts.notoKufiArabic().fontFamily,
+ color: Theme.of(context).colorScheme.onPrimary,
),
),
centerTitle: true,
+ backgroundColor: Theme.of(context).colorScheme.primary,
elevation: 0,
),
- body: SingleChildScrollView(
- child: Column(children: [
- userData.when(
- data: (data) {
- String guestChange() {
- if (data.username ==
- "GUEST") if (context.locale.languageCode == "en")
- return "Guest";
- else
- return "ضيف";
- return data.username ?? "";
- }
-
- final isVeg = ref.watch(isVeganProvider);
-
- return Column(
- crossAxisAlignment: CrossAxisAlignment.start,
+ body: SlidingUpPanel(
+ body: Container(
+ color: Theme.of(context).colorScheme.primary,
+ child: Column(
+ children: [
+ SizedBox(
+ height: 15,
+ ),
+ CircularPercentIndicator(
+ percent: userPoints! / 100 > 1 ? 1 : userPoints / 100,
+ radius: 60,
+ curve: Curves.easeInCirc,
+ lineWidth: 5,
+ animation: true,
+ center: CircleAvatar(
+ backgroundImage: AssetImage(
+ 'assets/images/profile/default.png',
+ ),
+ radius: 50,
+ ),
+ circularStrokeCap: CircularStrokeCap.round,
+ backgroundColor: Theme.of(context).colorScheme.primary,
+ progressColor: Theme.of(context).colorScheme.onPrimary,
+ ),
+ SizedBox(
+ height: 15,
+ ),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
- UserInfo(
- name: guestChange(),
- image: 'assets/images/profile/default.png',
+ CircleAvatar(
+ radius: 30,
+ backgroundColor:
+ Theme.of(context).colorScheme.secondary,
+ child: Icon(
+ Icons.emoji_events_rounded,
+ color: Theme.of(context).colorScheme.onSecondary,
+ size: 35.0,
+ ),
),
- Visibility(
- visible: isGuest == false && guest == false,
- child: FlutterSwitch(
+ Column(
+ children: [
+ Text(
+ "$userPoints",
+ style: TextStyle(
+ color: Theme.of(context).colorScheme.surface),
+ ),
+ Text(
+ word!.points,
+ style: TextStyle(
+ color: Theme.of(context).colorScheme.surface),
+ )
+ ],
+ ),
+ ],
+ )
+ ],
+ ),
+ ),
+ borderRadius: BorderRadius.only(
+ topLeft: Radius.circular(30), topRight: Radius.circular(30)),
+ minHeight: MediaQuery.of(context).size.height * 0.5,
+ isDraggable: true,
+ color: Theme.of(context).colorScheme.surface,
+ boxShadow: [],
+ panelBuilder: () => Padding(
+ padding: const EdgeInsets.only(top: 15.0),
+ child: Column(
+ children: [
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 20),
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Row(
+ children: [
+ CircleAvatar(
+ backgroundColor:
+ Theme.of(context).colorScheme.secondary,
+ child: Icon(Icons.eco,
+ color: Theme.of(context)
+ .colorScheme
+ .onSecondary),
+ ),
+ SizedBox(
+ width: 10,
+ ),
+ Text(word.vegetarian),
+ ],
+ ),
+ Switch.adaptive(
value: isVeg,
- onToggle: (v) async {
+ onChanged: (v) async {
ref
.read(isVeganProvider.notifier)
.update((state) => v);
@@ -91,120 +148,243 @@ class Profile extends ConsumerWidget {
.read(veganServiceProvider)
.updateIsVegan(v);
},
- inactiveColor: Colors.brown[300]!,
- inactiveIcon: Image.asset(
- 'assets/images/icons/meat.png',
- color: Colors.brown,
- ),
- activeColor: getColorScheme(context).secondary,
- activeToggleColor:
- getColorScheme(context).onSecondary,
- activeIcon: Image.asset(
- "assets/images/icons/vegan.png",
- color: getColorScheme(context).secondary,
- ),
),
- ),
- ],
- );
- },
- error: (e, s) {
- log('$e\n$s');
-
- return kDebugMode ? Text(e.toString()) : const Loading();
- },
- loading: () => const Loading(),
- ),
- GridView.count(
- shrinkWrap: true,
- physics: NeverScrollableScrollPhysics(),
- crossAxisCount: rh.deviceWidth(context) * 0.4 > 300 ? 4 : 3,
- childAspectRatio: 1,
- children: [
- if (isGuest == false && guest == false)
- ProfileMenu(
- bgColor: getColorScheme(context).primaryContainer,
- icon: Iconsax.heart5,
- color: getColorScheme(context).onPrimaryContainer,
- press: () => context.push('/favorites'),
+ ],
),
- ProfileMenu(
- bgColor: getColorScheme(context).secondaryContainer,
- color: getColorScheme(context).onSecondaryContainer,
- icon: Icons.grass_rounded,
- press: () => context.push('/choose_content'),
),
- ProfileMenu(
- bgColor: getColorScheme(context).inverseSurface,
- color: getColorScheme(context).onInverseSurface,
- icon: Iconsax.logout,
- press: () => guest == false && isGuest == false
- ? showDialog(
- context: context,
- builder: (context) => AlertDialog(
- title: Text("Logout"),
- content: Text(
- "Are you sure you want to log out?"),
- actions: [
- TextButton(
- onPressed: () =>
- Navigator.pop(context),
- child: Text("Cancel")),
- TextButton(
- onPressed: () => ref
- .read(authHelperProvider)
- .logOutfromDjango(context),
- child: Text("Logout")),
- ],
- ))
- : ref.read(authHelperProvider).logOutAsGuest(context),
+ SizedBox(
+ height: 20,
),
- if (isGuest == false && guest == false)
- ProfileMenu(
- bgColor: getColorScheme(context).errorContainer,
- color: getColorScheme(context).onErrorContainer,
- icon: Iconsax.profile_delete,
- press: () => showDialog(
- context: context,
- builder: (context) => AlertDialog(
- title: Text("Delete Account"),
- content: Text(
- "Are you sure you want to delete your account?"),
- actions: [
- TextButton(
- onPressed: () => Navigator.pop(context),
- child: Text("Cancel")),
- TextButton(
- onPressed: () => ref
- .read(authHelperProvider)
- .deleteUser(context),
- child: Text(
- "Delete",
- style: TextStyle(
- color: getColorScheme(context)
- .error),
- )),
- ],
- )),
- ),
+ ProfileListTile(
+ onTap: () => context.push("/update_profile"),
+ icon: Icons.edit,
+ name: word.edit_profile),
+ SizedBox(
+ height: 20,
+ ),
+ ProfileListTile(
+ onTap: () => context.push('/choose_content'),
+ icon: Icons.change_circle,
+ name: word.choose_content),
+ SizedBox(
+ height: 20,
+ ),
+ ProfileListTile(
+ onTap: () => context.push('/favorites'),
+ icon: Icons.favorite,
+ name: word.favorites),
+ SizedBox(
+ height: 20,
+ ),
+ ProfileListTile(
+ onTap: () => context.push('/settings'),
+ icon: Icons.settings,
+ name: word.settings),
+ SizedBox(
+ height: 20,
+ ),
+ ProfileListTile(
+ onTap: () => isGuest == false
+ ? showDialog(
+ context: context,
+ builder: (context) => AlertDialog(
+ title: Text(word.logout),
+ content: Text(word.sure_to_logout),
+ actions: [
+ TextButton(
+ onPressed: () =>
+ Navigator.pop(context),
+ child: Text(word.cancel)),
+ TextButton(
+ onPressed: () => ref
+ .read(authHelperProvider)
+ .logOutfromDjango(context),
+ child: Text(word.logout)),
+ ],
+ ))
+ : ref
+ .read(authHelperProvider)
+ .logOutAsGuest(context),
+ icon: Icons.logout,
+ name: word.logout),
],
- )
- ]),
- ),
- floatingActionButton: Visibility(
- visible: isGuest == false && guest == false,
- child: FloatingActionButton(
- onPressed: () => context.push(
- "/update_profile",
),
- child: const Icon(Iconsax.edit),
),
- ),
- )
+ )
+ // SingleChildScrollView(
+ // child: Column(children: [
+ // userData.when(
+ // data: (data) {
+ // String guestChange() {
+ // // if (data.username ==
+ // // "GUEST") if (.languageCode == "en")
+ // // return "Guest";
+ // // else
+ // // return "ضيف";
+ // return data.username ?? "";
+ // }
+
+ // final isVeg = ref.watch(isVeganProvider);
+
+ // return Column(
+ // crossAxisAlignment: CrossAxisAlignment.start,
+ // children: [
+ // UserInfo(
+ // name: guestChange(),
+ // image: 'assets/images/profile/default.png',
+ // ),
+ // Visibility(
+ // visible: isGuest == false && guest == false,
+ // child: FlutterSwitch(
+ // value: isVeg,
+ // onToggle: (v) async {
+ // ref
+ // .read(isVeganProvider.notifier)
+ // .update((state) => v);
+ // await ref
+ // .read(veganServiceProvider)
+ // .updateIsVegan(v);
+ // },
+ // inactiveColor: Colors.brown[300]!,
+ // inactiveIcon: Image.asset(
+ // 'assets/images/icons/meat.png',
+ // color: Colors.brown,
+ // ),
+ // activeColor: colorScheme(context).secondary,
+ // activeToggleColor: colorScheme(context).onSecondary,
+ // activeIcon: Image.asset(
+ // "assets/images/icons/vegan.png",
+ // color: colorScheme(context).secondary,
+ // ),
+ // ),
+ // ),
+ // ],
+ // );
+ // },
+ // error: (e, s) {
+ // log('$e\n$s');
+
+ // return kDebugMode ? Text(e.toString()) : const Loading();
+ // },
+ // loading: () => const Loading(),
+ // ),
+ // GridView.count(
+ // shrinkWrap: true,
+ // physics: NeverScrollableScrollPhysics(),
+ // crossAxisCount: rh.deviceWidth(context) * 0.4 > 300 ? 4 : 3,
+ // childAspectRatio: 1,
+ // children: [
+ // if (isGuest == false && guest == false)
+ // ProfileMenu(
+ // bgColor: colorScheme(context).primaryContainer,
+ // icon: Icons.favorite_rounded,
+ // color: colorScheme(context).onPrimaryContainer,
+ // press: () => context.push('/favorites'),
+ // ),
+ // ProfileMenu(
+ // bgColor: colorScheme(context).tertiaryContainer,
+ // color: colorScheme(context).onTertiaryContainer,
+ // icon: Icons.grass_rounded,
+ // press: () => context.push('/choose_content'),
+ // ),
+ // ProfileMenu(
+ // bgColor: colorScheme(context).inverseSurface,
+ // color: colorScheme(context).onInverseSurface,
+ // icon: Icons.logout,
+ // press: () => guest == false && isGuest == false
+ // ? showDialog(
+ // context: context,
+ // builder: (context) => AlertDialog(
+ // title: Text(word?.logout ?? ""),
+ // content: Text(word?.sure_to_logout ?? ""),
+ // actions: [
+ // TextButton(
+ // onPressed: () =>
+ // Navigator.pop(context),
+ // child: Text(word?.cancel ?? "")),
+ // TextButton(
+ // onPressed: () => ref
+ // .read(authHelperProvider)
+ // .logOutfromDjango(context),
+ // child: Text(word?.logout ?? "")),
+ // ],
+ // ))
+ // : ref.read(authHelperProvider).logOutAsGuest(context),
+ // ),
+ // if (isGuest == false && guest == false)
+ // ProfileMenu(
+ // bgColor: colorScheme(context).errorContainer,
+ // color: colorScheme(context).onErrorContainer,
+ // icon: Icons.delete_forever,
+ // press: () => showDialog(
+ // context: context,
+ // builder: (context) => AlertDialog(
+ // title: Text(word?.delete_account ?? ""),
+ // content: Text(word?.sure_to_delete ?? ""),
+ // actions: [
+ // TextButton(
+ // onPressed: () => Navigator.pop(context),
+ // child: Text(word?.cancel ?? "")),
+ // TextButton(
+ // onPressed: () => ref
+ // .read(authHelperProvider)
+ // .deleteUser(context),
+ // child: Text(
+ // word?.delete ?? "",
+ // style: TextStyle(
+ // color:
+ // colorScheme(context).error),
+ // )),
+ // ],
+ // )),
+ // ),
+ // ],
+ // )
+ // ]),
+ // ),
+ // floatingActionButton: Visibility(
+ // visible: isGuest == false && guest == false,
+ // child: FloatingActionButton(
+ // onPressed: () => context.push(
+ // "/update_profile",
+ // ),
+ // child: const Icon(Icons.edit),
+ // ),
+ // ),
+ )
: NoConnection();
}
}
+class ProfileListTile extends StatelessWidget {
+ const ProfileListTile({
+ super.key,
+ this.onTap,
+ required this.name,
+ required this.icon,
+ this.trailingIcon = const Icon(Icons.arrow_forward),
+ });
+ final Function()? onTap;
+ final String name;
+ final IconData icon;
+ final Widget trailingIcon;
+
+ @override
+ Widget build(BuildContext context) {
+ return ListTile(
+ onTap: onTap,
+ leading: CircleAvatar(
+ backgroundColor: Theme.of(context).colorScheme.secondary,
+ child: Icon(
+ icon,
+ color: Theme.of(context).colorScheme.onSecondary,
+ ),
+ ),
+ title: Text(name),
+ trailing: trailingIcon);
+ }
+}
+
class ProfileMenu extends StatelessWidget {
const ProfileMenu({
Key? key,
@@ -253,29 +433,28 @@ class UserInfo extends StatelessWidget {
ClipPath(
clipper: CustomShape(),
child: Container(
- height: 150,
- color: Theme.of(context).brightness == Brightness.dark
- ? darkColorScheme.background
- : lightColorScheme.secondaryContainer,
- ),
+ height: 150,
+ color: Theme.of(context).colorScheme.secondaryContainer),
),
Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
- Container(
- margin: const EdgeInsets.only(bottom: 10),
- height: 140,
- width: 140,
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- border: Border.all(
- color: Colors.white,
- width: 8,
- ),
- image: DecorationImage(
- image: AssetImage(image),
- fit: BoxFit.cover,
+ SafeArea(
+ child: Container(
+ margin: const EdgeInsets.only(bottom: 10),
+ height: 140,
+ width: 140,
+ decoration: BoxDecoration(
+ shape: BoxShape.circle,
+ border: Border.all(
+ color: Colors.white,
+ width: 8,
+ ),
+ image: DecorationImage(
+ image: AssetImage(image),
+ fit: BoxFit.cover,
+ ),
),
),
),
@@ -283,9 +462,6 @@ class UserInfo extends StatelessWidget {
name,
style: TextStyle(
fontSize: 22,
- fontFamily: context.locale.languageCode == "en"
- ? 'Kine'
- : GoogleFonts.notoKufiArabic().fontFamily,
),
),
],
diff --git a/lib/src/features/auth/profiles/presentation/update_profile.dart b/lib/src/features/auth/profiles/presentation/update_profile.dart
index ffa3e0a..1c44a1c 100644
--- a/lib/src/features/auth/profiles/presentation/update_profile.dart
+++ b/lib/src/features/auth/profiles/presentation/update_profile.dart
@@ -1,18 +1,14 @@
-import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
-import 'package:google_fonts/google_fonts.dart';
import 'package:http/http.dart';
import 'package:http/http.dart' as http;
-import 'package:iconsax/iconsax.dart';
import 'package:livine/src/features/auth/profiles/presentation/profile.dart';
import 'package:livine/src/common_widgets/auth/auth_widget.dart';
-import 'package:livine/src/translations/locale_keys.g.dart';
+import '../../../../translations/domain/translation_provider.dart';
import '../../application/auth_service.dart';
import '../../../get_recipes/application/vegan_service.dart';
-import '../../../../shared/styles/lib_color_schemes.g.dart';
import '../data/get_user_data.dart';
class UpdateProfile extends ConsumerStatefulWidget {
@@ -39,19 +35,11 @@ class _UpdateProfileState extends ConsumerState {
username.text = data?.username ?? "";
email.text = data?.email ?? "";
-
+ final word = TranslationRepo.translate(context);
return Scaffold(
appBar: AppBar(
- title: Text(LocaleKeys.update.tr(),
- style: TextStyle(
- fontFamily: context.locale.languageCode == "en"
- ? 'Kine'
- : GoogleFonts.notoKufiArabic().fontFamily,
- )),
- centerTitle: true,
- backgroundColor: Theme.of(context).brightness == Brightness.dark
- ? darkColorScheme.background
- : lightColorScheme.secondaryContainer,
+ title: Text(word!.edit_profile),
+ backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
),
body: Column(children: [
UserInfo(
@@ -67,7 +55,7 @@ class _UpdateProfileState extends ConsumerState {
authFormField(
context: context,
controller: username,
- text: LocaleKeys.username.tr(),
+ text: word.username,
setState: setState,
validator: (u) {
if (u!.isEmpty) {
@@ -84,15 +72,11 @@ class _UpdateProfileState extends ConsumerState {
authFormField(
context: context,
controller: email,
- text: context.locale.languageCode == "en"
- ? "Email"
- : "البريد الإلكتروني",
+ text: "Email",
setState: setState,
validator: (e) {
if (e!.isEmpty) {
- return context.locale.languageCode == "en"
- ? "Please enter your email"
- : "من فضلك ادخل البريد الاكتروني";
+ return "Please enter your email";
}
return null;
@@ -112,7 +96,7 @@ class _UpdateProfileState extends ConsumerState {
context, username.text, email.text, data?.patient ?? 5, isVeg)
.then((value) => context.pop());
},
- child: const Icon(Iconsax.arrow_up),
+ child: const Icon(Icons.save),
),
);
}
diff --git a/lib/src/features/auth/register/presentation/register.dart b/lib/src/features/auth/register/presentation/register.dart
index e22f942..8c406ee 100644
--- a/lib/src/features/auth/register/presentation/register.dart
+++ b/lib/src/features/auth/register/presentation/register.dart
@@ -3,18 +3,16 @@
import 'dart:convert';
import 'dart:io';
-import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:http/http.dart';
import 'package:http/http.dart' as http;
-import 'package:iconsax/iconsax.dart';
+import 'package:livine/src/constants/constants.dart';
import 'package:livine/src/features/auth/application/auth_service.dart';
-import '../../../../common_widgets/auth/auth_widget.dart';
-import '../../../../translations/locale_keys.g.dart';
+import '../../../../translations/domain/translation_provider.dart';
class Register extends ConsumerStatefulWidget {
const Register({Key? key}) : super(key: key);
@@ -67,196 +65,233 @@ class _RegisterState extends ConsumerState {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context).colorScheme;
-
+ final word = TranslationRepo.translate(context);
return Scaffold(
- body: Row(
- children: [
- Visibility(
- visible: Platform.isWindows,
- child: Expanded(
- flex: 2,
- child: ClipRRect(
- borderRadius: const BorderRadius.only(
- topRight: Radius.circular(20),
- bottomRight: Radius.circular(20)),
- child: Image.asset(
- 'assets/images/windows/register.webp',
- fit: BoxFit.cover,
- ),
- )),
- ),
- Expanded(
- child: Form(
- key: _formKey,
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 20),
- child: TextFormField(
- textInputAction: TextInputAction.next,
- maxLength: 20,
- validator: (u) {
- if (u!.isEmpty) {
- return "Please enter your username";
- } else if (u.length >= 20) {
- return "Username shouldn't be more than 20 characters";
- }
- return null;
- },
- controller: _username,
- decoration: InputDecoration(
- errorText: usernameError is List
- ? usernameError.first
- : usernameError,
- errorMaxLines: 2,
- border: const OutlineInputBorder(
- borderRadius:
- BorderRadius.all(Radius.circular(10.0))),
- labelText: LocaleKeys.username.tr(),
- labelStyle: const TextStyle(
- fontSize: 15,
- ),
+ body: SafeArea(
+ child: Padding(
+ padding: EdgeInsets.only(top: rh.deviceHeight(context) * 0.1),
+ child: Row(
+ children: [
+ Visibility(
+ visible: Platform.isWindows,
+ child: Expanded(
+ flex: 2,
+ child: ClipRRect(
+ borderRadius: const BorderRadius.only(
+ topRight: Radius.circular(20),
+ bottomRight: Radius.circular(20)),
+ child: Image.asset(
+ 'assets/images/windows/register.webp',
+ fit: BoxFit.cover,
),
- ),
- ),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 20),
- child: TextFormField(
- textInputAction: TextInputAction.next,
- validator: (e) {
- if (e!.isEmpty) {
- return context.locale.languageCode == "en"
- ? "Please enter your email"
- : "من فضلك ادخل البريد الاكتروني";
- }
+ )),
+ ),
+ Expanded(
+ child: Form(
+ key: _formKey,
+ child: SingleChildScrollView(
+ child: Column(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 20),
+ child: TextFormField(
+ textInputAction: TextInputAction.next,
+ maxLength: 20,
+ validator: (u) {
+ if (u!.isEmpty) {
+ return "Please enter your username";
+ } else if (u.length >= 20) {
+ return "Username shouldn't be more than 20 characters";
+ }
+ return null;
+ },
+ controller: _username,
+ decoration: InputDecoration(
+ errorText: usernameError is List
+ ? usernameError.first
+ : usernameError,
+ errorMaxLines: 2,
+ border: const OutlineInputBorder(
+ borderRadius:
+ BorderRadius.all(Radius.circular(10.0))),
+ labelText: word?.username,
+ labelStyle: const TextStyle(
+ fontSize: 15,
+ ),
+ ),
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 20),
+ child: TextFormField(
+ textInputAction: TextInputAction.next,
+ validator: (e) {
+ if (e!.isEmpty) {
+ return "Please enter your email";
+ }
- return null;
- },
- controller: _email,
- decoration: InputDecoration(
- errorText: emailError,
- border: const OutlineInputBorder(
- borderRadius:
- BorderRadius.all(Radius.circular(10.0))),
- labelText: context.locale.languageCode == "en"
- ? 'Email'
- : "البريد الاكتروني",
- labelStyle: const TextStyle(
- fontSize: 15,
+ return null;
+ },
+ controller: _email,
+ decoration: InputDecoration(
+ errorText: emailError,
+ border: const OutlineInputBorder(
+ borderRadius:
+ BorderRadius.all(Radius.circular(10.0))),
+ labelText: word?.email_address,
+ labelStyle: const TextStyle(
+ fontSize: 15,
+ ),
+ ),
+ ),
),
- ),
- ),
- ),
- SizedBox(
- height: 20,
- ),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 20),
- child: TextFormField(
- validator: (passwordValue) {
- if (passwordValue!.length < 9 &&
- passwordValue.isNotEmpty) {
- return context.locale.languageCode == "en"
- ? "Password needs to be atleast 9 characters "
- : "يجب أن تتكون كلمة المرور من 9 أحرف على الأقل";
- } else if (passwordValue.isEmpty) {
- return context.locale.languageCode == "en"
- ? "Please enter your password "
- : "من فضلك أدخل كلمة السر";
- }
- return null;
- },
- controller: _password,
- obscureText: _obscureText,
- onFieldSubmitted: (_) => validateForm(),
- decoration: InputDecoration(
- suffixIcon: IconButton(
- icon: Icon(
- _obscureText ? Iconsax.eye_slash5 : Iconsax.eye,
+ SizedBox(
+ height: 20,
+ ),
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 20),
+ child: TextFormField(
+ validator: (passwordValue) {
+ if (passwordValue!.length < 9 &&
+ passwordValue.isNotEmpty) {
+ return "Password needs to be atleast 9 characters ";
+ } else if (passwordValue.isEmpty) {
+ return "Please enter your password ";
+ }
+ return null;
+ },
+ controller: _password,
+ obscureText: _obscureText,
+ onFieldSubmitted: (_) => validateForm(),
+ decoration: InputDecoration(
+ suffixIcon: IconButton(
+ icon: Icon(
+ _obscureText
+ ? Icons.visibility_off
+ : Icons.visibility,
+ ),
+ onPressed: () {
+ setState(() {
+ _obscureText = !_obscureText;
+ });
+ },
+ ),
+ border: const OutlineInputBorder(
+ borderRadius:
+ BorderRadius.all(Radius.circular(10.0))),
+ labelText: word?.password,
+ labelStyle: const TextStyle(fontSize: 15),
+ ),
),
- onPressed: () {
- setState(() {
- _obscureText = !_obscureText;
- });
- },
),
- border: const OutlineInputBorder(
- borderRadius:
- BorderRadius.all(Radius.circular(10.0))),
- labelText: LocaleKeys.password.tr(),
- labelStyle: const TextStyle(fontSize: 15),
- ),
- ),
- ),
- const SizedBox(
- height: 20,
- ),
- authButton(
- onPressed: validateForm,
- isLoading: isLoading,
- text: LocaleKeys.Sign_up.tr(),
- context: context),
- const SizedBox(
- height: 20,
- ),
- Center(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Text(
- LocaleKeys.have_an_account.tr(),
- style: const TextStyle(fontFamily: 'Kine'),
+ const SizedBox(
+ height: 20,
),
+ ({
+ required void Function() onPressed,
+ required bool isLoading,
+ required String text,
+ Color? color,
+ Color? textColor,
+ double width = 350,
+ required BuildContext context,
+ }) {
+ final theme = Theme.of(context).colorScheme;
+ return Padding(
+ padding:
+ const EdgeInsets.symmetric(horizontal: 20.0),
+ child: MaterialButton(
+ onPressed: onPressed,
+ color: color ?? theme.primaryContainer,
+ elevation: 0,
+ minWidth: width,
+ height: 60,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(15),
+ ),
+ child: isLoading
+ ? const CircularProgressIndicator(
+ color: Colors.white,
+ )
+ : Text(
+ text,
+ style: TextStyle(
+ fontSize: 15,
+ color: textColor ??
+ theme.onPrimaryContainer),
+ ),
+ ),
+ );
+ }(
+ onPressed: validateForm,
+ isLoading: isLoading,
+ text: word?.sign_up ?? 'Sign Up',
+ context: context),
const SizedBox(
- width: 10,
+ height: 20,
),
- GestureDetector(
- onTap: () => context.go('/login'),
- child: Text(
- LocaleKeys.Sign_in.tr(),
- style: TextStyle(
- fontSize: 16.0,
- color: theme.tertiary,
- fontFamily: 'Kine'),
+ Center(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ Text(
+ word?.have_an_account ?? 'Have an account?',
+ style: const TextStyle(fontFamily: 'Kine'),
+ ),
+ const SizedBox(
+ width: 10,
+ ),
+ GestureDetector(
+ onTap: () => context.go('/login'),
+ child: Text(
+ word?.sign_in ?? 'Sign In',
+ style: TextStyle(
+ fontSize: 16.0,
+ color: theme.tertiary,
+ fontFamily: 'Kine'),
+ ),
+ ),
+ ],
),
),
- ],
- ),
- ),
- const SizedBox(
- height: 10.0,
- ),
- RichText(
- textAlign: TextAlign.center,
- text: TextSpan(
- children: [
- TextSpan(
- text: LocaleKeys.terms1.tr(),
- style: TextStyle(
- fontSize: 15.0, color: theme.inverseSurface)),
- const WidgetSpan(
- child: Padding(
- padding: EdgeInsets.only(left: 10.0),
+ const SizedBox(
+ height: 10.0,
+ ),
+ RichText(
+ textAlign: TextAlign.center,
+ text: TextSpan(
+ children: [
+ TextSpan(
+ text: word?.terms1,
+ style: TextStyle(
+ fontSize: 15.0,
+ color: theme.inverseSurface)),
+ const WidgetSpan(
+ child: Padding(
+ padding: EdgeInsets.only(left: 10.0),
+ ),
+ ),
+ TextSpan(
+ text: word?.terms2,
+ recognizer: TapGestureRecognizer()
+ ..onTap = () => context.push('/terms'),
+ style: TextStyle(
+ fontSize: 15.0,
+ fontWeight: FontWeight.bold,
+ fontFamily: 'Kine',
+ color: theme.tertiary)),
+ ],
),
),
- TextSpan(
- text: LocaleKeys.terms2.tr(),
- recognizer: TapGestureRecognizer()
- ..onTap = () => context.push('/terms'),
- style: TextStyle(
- fontSize: 15.0,
- fontWeight: FontWeight.bold,
- fontFamily: 'Kine',
- color: theme.tertiary)),
],
),
),
- ],
+ ),
),
- ),
+ ],
),
- ],
+ ),
),
);
}
diff --git a/lib/src/features/auth/reset_password/presentation/reset_password.dart b/lib/src/features/auth/reset_password/presentation/reset_password.dart
index 21454fa..bea3c09 100644
--- a/lib/src/features/auth/reset_password/presentation/reset_password.dart
+++ b/lib/src/features/auth/reset_password/presentation/reset_password.dart
@@ -1,14 +1,12 @@
import 'dart:developer';
-import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:http/http.dart';
import 'package:http/http.dart' as http;
+import 'package:livine/src/translations/domain/translation_provider.dart';
import '../../../../constants/constants.dart';
-import '../../../../common_widgets/auth/auth_widget.dart';
-import '../../../../translations/locale_keys.g.dart';
class ResetPassword extends StatefulWidget {
const ResetPassword({Key? key}) : super(key: key);
@@ -31,9 +29,7 @@ class _ResetPasswordState extends State {
if (response.statusCode == 200) {
if (!mounted) return;
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
- content: Text(context.locale.languageCode == "en"
- ? "Please check your email"
- : "من فضلك تفقد بريدك الالكتروني"),
+ content: Text("Please check your email"),
));
setState(() {
isLoading = false;
@@ -60,9 +56,10 @@ class _ResetPasswordState extends State {
@override
Widget build(BuildContext context) {
+ final word = TranslationRepo.translate(context);
return Scaffold(
appBar: AppBar(
- title: Text(LocaleKeys.Reset_pass.tr()),
+ title: Text(word?.reset_pass ?? "Reset Password"),
),
body: Column(
children: [
@@ -76,9 +73,7 @@ class _ResetPasswordState extends State {
textInputAction: TextInputAction.next,
validator: (e) {
if (e!.isEmpty) {
- return context.locale.languageCode == "en"
- ? "Please enter your email"
- : "من فضلك ادخل البريد الاكتروني";
+ return "Please enter your email";
}
return null;
@@ -88,18 +83,50 @@ class _ResetPasswordState extends State {
border: const OutlineInputBorder(
borderRadius:
BorderRadius.all(Radius.circular(10.0))),
- labelText: context.locale.languageCode == "en"
- ? 'Email'
- : "البريد الاكتروني",
+ labelText: word?.email_address,
labelStyle: const TextStyle(
fontSize: 15,
),
),
),
- authButton(
+ ({
+ required void Function() onPressed,
+ required bool isLoading,
+ required String text,
+ Color? color,
+ Color? textColor,
+ double width = 350,
+ required BuildContext context,
+ }) {
+ final theme = Theme.of(context).colorScheme;
+ return Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 20.0),
+ child: MaterialButton(
+ onPressed: onPressed,
+ color: color ?? theme.primaryContainer,
+ elevation: 0,
+ minWidth: width,
+ height: 60,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(15),
+ ),
+ child: isLoading
+ ? const CircularProgressIndicator(
+ color: Colors.white,
+ )
+ : Text(
+ text,
+ style: TextStyle(
+ fontSize: 15,
+ color: textColor ??
+ theme.onPrimaryContainer),
+ ),
+ ),
+ );
+ }(
onPressed: validateRPForm,
isLoading: isLoading,
- text: LocaleKeys.Reset_pass.tr(),
+ text: word?.reset_pass ?? "Reset Password",
context: context)
],
),
diff --git a/lib/src/features/auth/reset_password/presentation/reset_password_confirm.dart b/lib/src/features/auth/reset_password/presentation/reset_password_confirm.dart
index 78745ef..73876a3 100644
--- a/lib/src/features/auth/reset_password/presentation/reset_password_confirm.dart
+++ b/lib/src/features/auth/reset_password/presentation/reset_password_confirm.dart
@@ -1,15 +1,12 @@
import 'dart:developer';
-import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:http/http.dart';
import 'package:http/http.dart' as http;
+import 'package:livine/src/translations/domain/translation_provider.dart';
import '../../../../constants/constants.dart';
-import '../../../../shared/styles/colors.dart';
-import '../../../../common_widgets/auth/auth_widget.dart';
-import '../../../../translations/locale_keys.g.dart';
class PasswordConfirmation extends StatefulWidget {
const PasswordConfirmation({Key? key, required this.token}) : super(key: key);
@@ -41,11 +38,8 @@ class _PasswordConfirmationState extends State {
if (response.statusCode == 200) {
if (!mounted) return;
- ScaffoldMessenger.of(context).showSnackBar(SnackBar(
- content: Text(context.locale.languageCode == "en"
- ? "Your password have succesfully changed"
- : "تم تغيير كلمة السر بنجاح"),
- ));
+ ScaffoldMessenger.of(context).showSnackBar(
+ SnackBar(content: Text("Your password have succesfully changed")));
setState(() {
isLoading = false;
});
@@ -71,9 +65,10 @@ class _PasswordConfirmationState extends State {
@override
Widget build(BuildContext context) {
+ final word = TranslationRepo.translate(context);
return Scaffold(
appBar: AppBar(
- title: Text(LocaleKeys.pass_confirm.tr()),
+ title: Text(word?.pass_confirm ?? ""),
centerTitle: true,
),
body: Column(
@@ -88,24 +83,19 @@ class _PasswordConfirmationState extends State {
textInputAction: TextInputAction.next,
validator: (e) {
if (e!.isEmpty) {
- return context.locale.languageCode == "en"
- ? "Please enter your token"
- : "من فضلك ادخل الرمز الخاص بك";
+ return "Please enter your token";
}
return null;
},
controller: _token,
decoration: InputDecoration(
- helperText: context.locale.languageCode == " en "
- ? "Enter the token that has been sent to your email"
- : " أدخل الرمز المميز الذي تم إرساله إلى بريدك الإلكتروني الخاص بك",
+ helperText:
+ "Enter the token that has been sent to your email",
enabledBorder: const UnderlineInputBorder(
borderSide: BorderSide(),
),
- labelText: context.locale.languageCode == "en"
- ? 'Token'
- : "الرمز",
+ labelText: 'Token',
labelStyle: const TextStyle(
fontSize: 15,
color: Colors.black,
@@ -116,9 +106,7 @@ class _PasswordConfirmationState extends State {
textInputAction: TextInputAction.next,
validator: (e) {
if (e!.isEmpty) {
- return context.locale.languageCode == "en"
- ? "Please enter your new password"
- : "من فضلك ادخل كلمة السر الجديدة";
+ return "Please enter your new password";
}
return null;
@@ -131,8 +119,7 @@ class _PasswordConfirmationState extends State {
_obscureText
? Icons.visibility_off
: Icons.visibility,
- color:
- _obscureText ? Colors.grey : secondaryColor),
+ color: _obscureText ? Colors.grey : Colors.green),
onPressed: () {
setState(() {
_obscureText = !_obscureText;
@@ -142,18 +129,50 @@ class _PasswordConfirmationState extends State {
border: const OutlineInputBorder(
borderRadius:
BorderRadius.all(Radius.circular(10.0))),
- labelText: context.locale.languageCode == "en"
- ? 'New Password'
- : "كلمة المرور الجديدة",
+ labelText: 'New Password',
labelStyle: const TextStyle(
fontSize: 15,
),
),
),
- authButton(
+ ({
+ required void Function() onPressed,
+ required bool isLoading,
+ required String text,
+ Color? color,
+ Color? textColor,
+ double width = 350,
+ required BuildContext context,
+ }) {
+ final theme = Theme.of(context).colorScheme;
+ return Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 20.0),
+ child: MaterialButton(
+ onPressed: onPressed,
+ color: color ?? theme.primaryContainer,
+ elevation: 0,
+ minWidth: width,
+ height: 60,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(15),
+ ),
+ child: isLoading
+ ? const CircularProgressIndicator(
+ color: Colors.white,
+ )
+ : Text(
+ text,
+ style: TextStyle(
+ fontSize: 15,
+ color: textColor ??
+ theme.onPrimaryContainer),
+ ),
+ ),
+ );
+ }(
onPressed: validatePasswordForm,
isLoading: isLoading,
- text: LocaleKeys.change_password.tr(),
+ text: word?.change_password ?? "",
context: context)
],
),
diff --git a/lib/src/features/auth/reset_password/presentation/token_validate.dart b/lib/src/features/auth/reset_password/presentation/token_validate.dart
index 0bb196e..6228b59 100644
--- a/lib/src/features/auth/reset_password/presentation/token_validate.dart
+++ b/lib/src/features/auth/reset_password/presentation/token_validate.dart
@@ -1,14 +1,12 @@
import 'dart:developer';
-import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:http/http.dart';
import 'package:http/http.dart' as http;
+import 'package:livine/src/translations/domain/translation_provider.dart';
import '../../../../constants/constants.dart';
-import '../../../../common_widgets/auth/auth_widget.dart';
-import '../../../../translations/locale_keys.g.dart';
class TokenValidate extends StatefulWidget {
const TokenValidate({Key? key}) : super(key: key);
@@ -55,9 +53,10 @@ class _TokenValidateState extends State {
@override
Widget build(BuildContext context) {
+ final word = TranslationRepo.translate(context);
return Scaffold(
appBar: AppBar(
- title: Text(LocaleKeys.enter_token.tr()),
+ title: Text(word?.validate_token ?? "Validate Token"),
centerTitle: true,
),
body: Column(
@@ -72,33 +71,61 @@ class _TokenValidateState extends State {
textInputAction: TextInputAction.next,
validator: (e) {
if (e!.isEmpty) {
- return context.locale.languageCode == "en"
- ? "Please enter your token"
- : "من فضلك ادخل الرمز الخاص بك";
+ return "Please enter your token";
}
return null;
},
controller: _token,
decoration: InputDecoration(
- helperText: context.locale.languageCode == "en"
- ? "Enter the token that has been sent to your email"
- : " أدخل الرمز المميز الذي تم إرساله إلى بريدك الإلكتروني الخاص بك",
+ helperText: word?.enter_token_has_sent,
border: const OutlineInputBorder(
borderRadius:
BorderRadius.all(Radius.circular(10.0))),
- labelText: context.locale.languageCode == "en"
- ? 'Code'
- : "الرمز",
+ labelText: word?.code,
labelStyle: const TextStyle(
fontSize: 15,
),
),
),
- authButton(
+ ({
+ required void Function() onPressed,
+ required bool isLoading,
+ required String text,
+ Color? color,
+ Color? textColor,
+ double width = 350,
+ required BuildContext context,
+ }) {
+ final theme = Theme.of(context).colorScheme;
+ return Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 20.0),
+ child: MaterialButton(
+ onPressed: onPressed,
+ color: color ?? theme.primaryContainer,
+ elevation: 0,
+ minWidth: width,
+ height: 60,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(15),
+ ),
+ child: isLoading
+ ? const CircularProgressIndicator(
+ color: Colors.white,
+ )
+ : Text(
+ text,
+ style: TextStyle(
+ fontSize: 15,
+ color: textColor ??
+ theme.onPrimaryContainer),
+ ),
+ ),
+ );
+ }(
onPressed: validateTokenForm,
isLoading: isLoading,
- text: LocaleKeys.validate_token.tr(),
+ text: word?.validate_token ?? "Validate Token",
context: context)
],
),
diff --git a/lib/src/features/auth/welcome/presentation/welcome.dart b/lib/src/features/auth/welcome/presentation/welcome.dart
index 3afe8f0..19ab6cd 100644
--- a/lib/src/features/auth/welcome/presentation/welcome.dart
+++ b/lib/src/features/auth/welcome/presentation/welcome.dart
@@ -3,10 +3,10 @@ import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:go_router/go_router.dart';
-import 'package:responsive_framework/responsive_framework.dart';
+import 'package:responsive_framework/responsive_row_column.dart';
import '../../../../constants/constants.dart';
-import '../../../../common_widgets/auth/auth_widget.dart';
+import '../../../../translations/domain/translation_provider.dart';
class Welcome extends StatelessWidget {
const Welcome({Key? key}) : super(key: key);
@@ -14,15 +14,17 @@ class Welcome extends StatelessWidget {
@override
Widget build(BuildContext context) {
bool isLoading = false;
+ final word = TranslationRepo.translate(context);
log(rh.deviceWidth(context).toString());
return Scaffold(
body: SafeArea(
child: ResponsiveRowColumn(
- layout: rh.deviceWidth(context) <= 800 &&
- rh.deviceWidth(context) > 400 ||
- rh.largerThanMobile(context)
+ layout: rh.largerThanMobile(context) || rh.deviceLandScape(context)
? ResponsiveRowColumnType.ROW
: ResponsiveRowColumnType.COLUMN,
+ columnMainAxisAlignment: MainAxisAlignment.spaceEvenly,
+ rowMainAxisAlignment: MainAxisAlignment.center,
+ rowCrossAxisAlignment: CrossAxisAlignment.center,
children: [
ResponsiveRowColumnItem(
child: Center(
@@ -36,13 +38,10 @@ class Welcome extends StatelessWidget {
),
ResponsiveRowColumnItem(
child: Padding(
- padding: EdgeInsets.symmetric(
- vertical: rh.largerThanMobile(context)
- ? rh.deviceHeight(context) * 0.25
- : rh.deviceHeight(context) * 0.03,
- horizontal: 10),
+ padding: EdgeInsets.symmetric(horizontal: 10),
child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.center,
+ mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
@@ -51,7 +50,7 @@ class Welcome extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
- "Welcome",
+ word?.welcome ?? "Welcome",
style: TextStyle(
fontFamily: 'Kine',
fontSize: 50.0,
@@ -59,14 +58,15 @@ class Welcome extends StatelessWidget {
),
Container(
width: rh.deviceLandScape(context)
- ? rh.deviceHeight(context) * 0.9
- : rh.deviceHeight(context) * 0.4,
+ ? rh.deviceWidth(context) * 0.4
+ : null,
child: Text(
- "Let's live naturally without any type of medications",
+ word?.live_naturally ??
+ "Live naturally, eat healthy, and be happy",
style: TextStyle(
fontFamily: 'Kine',
fontSize: 20.0,
- color: getColorScheme(context)
+ color: colorScheme(context)
.onBackground
.withOpacity(0.3)),
),
@@ -74,34 +74,65 @@ class Welcome extends StatelessWidget {
],
),
),
- SizedBox(
- height: rh.deviceLandScape(context)
- ? rh.deviceWidth(context) * 0.03
- : 80,
- ),
- Column(
- children: [
- authButton(
- onPressed: () {
- context.push("/register");
- },
- isLoading: isLoading,
- text: "Get Started",
- context: context),
- SizedBox(
- height: 20,
- ),
- GestureDetector(
- onTap: () {
- context.push("/login");
- },
- child: Text(
- "I already have an account",
- style:
- TextStyle(fontFamily: 'Kine', fontSize: 18.0),
+ Center(
+ child: ({
+ required void Function() onPressed,
+ required bool isLoading,
+ required String text,
+ Color? color,
+ Color? textColor,
+ double width = 350,
+ required BuildContext context,
+ }) {
+ final theme = Theme.of(context).colorScheme;
+ return Padding(
+ padding:
+ const EdgeInsets.symmetric(horizontal: 20.0),
+ child: MaterialButton(
+ onPressed: onPressed,
+ color: color ?? theme.primaryContainer,
+ elevation: 0,
+ minWidth: width,
+ height: 60,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(15),
+ ),
+ child: isLoading
+ ? const CircularProgressIndicator(
+ color: Colors.white,
+ )
+ : Text(
+ text,
+ style: TextStyle(
+ fontSize: 15,
+ color: textColor ??
+ theme.onPrimaryContainer),
+ ),
),
+ );
+ }(
+ onPressed: () {
+ context.push("/register");
+ },
+ isLoading: isLoading,
+ width: rh.deviceLandScape(context)
+ ? rh.deviceWidth(context) / 2.4
+ : 360,
+ text: word?.get_started ?? "Get Started",
+ context: context),
+ ),
+ SizedBox(height: 20.0),
+ GestureDetector(
+ onTap: () {
+ context.push("/login");
+ },
+ child: Center(
+ child: Text(
+ word?.have_an_account ?? "Have an account?",
+ style:
+ TextStyle(fontFamily: 'Kine', fontSize: 18.0),
),
- ],
+ ),
),
],
),
diff --git a/lib/src/features/content/presentation/content.dart b/lib/src/features/content/presentation/content.dart
index 00a6ba3..468f974 100644
--- a/lib/src/features/content/presentation/content.dart
+++ b/lib/src/features/content/presentation/content.dart
@@ -1,19 +1,16 @@
import 'package:cached_network_image/cached_network_image.dart';
-import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
-import 'package:google_fonts/google_fonts.dart';
import 'package:livine/src/constants/constants.dart';
import 'package:livine/src/features/loading/loading.dart';
import 'package:livine/src/shared/cache/cache_helper.dart';
import 'package:responsive_framework/responsive_framework.dart';
+import '../../../translations/domain/translation_provider.dart';
import '../../auth/data/user.dart';
import '../../auth/application/auth_service.dart';
-import '../../../common_widgets/auth/auth_widget.dart';
-import '../../../translations/locale_keys.g.dart';
import '../../auth/profiles/data/get_user_data.dart';
class ChooseContent extends StatefulWidget {
@@ -26,6 +23,7 @@ class ChooseContent extends StatefulWidget {
class _ChooseContentState extends State {
@override
Widget build(BuildContext context) {
+ final word = TranslationRepo.translate(context);
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.transparent,
@@ -45,8 +43,8 @@ class _ChooseContentState extends State {
ResponsiveRowColumnItem(
rowFlex: 1,
child: Options(
- title: LocaleKeys.General.tr(),
- description: LocaleKeys.healthy.tr(),
+ title: word?.general ?? "",
+ description: word?.healthy ?? "",
networkImage:
'https://media.istockphoto.com/photos/healthy-lifestyle-concept-clean-food-good-health-dietary-in-heart-picture-id953674568?k=20&m=953674568&s=612x612&w=0&h=x_gq29MRpRyhdDIgwF5PVhdXAbINmaBUKMgs27w7i6s=',
onpressed: () async {
@@ -75,8 +73,8 @@ class _ChooseContentState extends State {
ResponsiveRowColumnItem(
rowFlex: 1,
child: Options(
- title: LocaleKeys.per_situation.tr(),
- description: LocaleKeys.patient.tr(),
+ title: word?.per_situation ?? "",
+ description: word?.patient ?? "",
networkImage:
'https://media.istockphoto.com/photos/its-the-season-of-sneezes-picture-id1085020818?b=1&k=20&m=1085020818&s=170667a&w=0&h=d4AbNzh6ztl2XV-oUo36FitS45O1AUraO2wJhOP5Roo=',
onpressed: () => context.push('/content_patient'),
@@ -107,6 +105,8 @@ class Options extends StatelessWidget {
@override
Widget build(BuildContext context) {
+ final word = TranslationRepo.translate(context);
+
return Column(
children: [
ClipRRect(
@@ -125,11 +125,7 @@ class Options extends StatelessWidget {
const SizedBox(height: 20),
Text(
title,
- style: TextStyle(
- fontFamily: context.locale.languageCode == "en"
- ? 'Kine'
- : GoogleFonts.notoKufiArabic().fontFamily,
- fontSize: 20.0),
+ style: TextStyle(fontSize: 20.0),
),
const SizedBox(
height: 10,
@@ -137,20 +133,48 @@ class Options extends StatelessWidget {
Padding(
padding: const EdgeInsets.symmetric(horizontal: 50.0),
child: Text(description,
- textAlign: TextAlign.center,
- style: TextStyle(
- fontFamily: context.locale.languageCode == "en"
- ? 'Kine'
- : GoogleFonts.notoKufiArabic().fontFamily,
- fontSize: 15.0)),
+ textAlign: TextAlign.center, style: TextStyle(fontSize: 15.0)),
),
const SizedBox(
height: 10,
),
- authButton(
+ ({
+ required void Function() onPressed,
+ required bool isLoading,
+ required String text,
+ Color? color,
+ Color? textColor,
+ double width = 350,
+ required BuildContext context,
+ }) {
+ final theme = Theme.of(context).colorScheme;
+ return Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 20.0),
+ child: MaterialButton(
+ onPressed: onPressed,
+ color: color ?? theme.primaryContainer,
+ elevation: 0,
+ minWidth: width,
+ height: 60,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(15),
+ ),
+ child: isLoading
+ ? const CircularProgressIndicator(
+ color: Colors.white,
+ )
+ : Text(
+ text,
+ style: TextStyle(
+ fontSize: 15,
+ color: textColor ?? theme.onPrimaryContainer),
+ ),
+ ),
+ );
+ }(
onPressed: onpressed,
isLoading: false,
- text: context.locale.languageCode == "en" ? "Continue" : "التالي",
+ text: word?.choose ?? "Choose",
context: context)
],
);
diff --git a/lib/src/features/content/presentation/content_patients.dart b/lib/src/features/content/presentation/content_patients.dart
index 7db17b3..0459a75 100644
--- a/lib/src/features/content/presentation/content_patients.dart
+++ b/lib/src/features/content/presentation/content_patients.dart
@@ -2,22 +2,19 @@ import 'dart:developer';
import 'dart:ui';
import 'package:cached_network_image/cached_network_image.dart';
-import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
-import 'package:google_fonts/google_fonts.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:livine/src/constants/constants.dart';
+import 'package:livine/src/translations/domain/translation_provider.dart';
import '../../auth/data/user.dart';
import '../../loading/loading.dart';
import '../../auth/application/auth_service.dart';
import '../../../shared/cache/cache_helper.dart';
-import '../../../common_widgets/auth/auth_widget.dart';
import '../../auth/profiles/data/get_user_data.dart';
-import '../../get_recipes/data/patient_types.dart';
-import '../../../translations/locale_keys.g.dart';
+import '../../get_recipes/data/patients.dart';
class ContentPatient extends StatefulWidget {
const ContentPatient({Key? key}) : super(key: key);
@@ -30,10 +27,11 @@ class _ContentPatientState extends State {
int? checkedIndex;
@override
Widget build(BuildContext context) {
+ final word = TranslationRepo.translate(context);
return Scaffold(
appBar: AppBar(
title: Text(
- LocaleKeys.Iam_a.tr(),
+ word?.choose_content ?? "",
style: const TextStyle(fontFamily: 'Kine'),
),
backgroundColor: Colors.transparent,
@@ -41,7 +39,7 @@ class _ContentPatientState extends State {
),
body: HookConsumer(
builder: ((context, ref, child) {
- final recipesData = ref.watch(patientTypesProvider);
+ final recipesData = ref.watch(getPatientsProvider(context: context));
final guest = ref.watch(guestProvider);
final userData = ref.watch(userDataProvider).asData?.value;
@@ -51,17 +49,19 @@ class _ContentPatientState extends State {
children: [
Expanded(
child: RawScrollbar(
- thumbColor: getColorScheme(context).tertiary,
+ thumbColor: colorScheme(context).tertiary,
thickness: 5,
radius: const Radius.circular(10),
child: GridView.builder(
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
- crossAxisCount: rh.deviceWidth(context) > 600 ? 4 : 2,
+ crossAxisCount:
+ rh.deviceWidth(context) > 600 ? 4 : 2,
childAspectRatio: 0.7,
),
itemCount: data.length,
itemBuilder: (context, index) {
+ print(data[index].image);
return GestureDetector(
onTap: () {
setState(() {
@@ -72,14 +72,14 @@ class _ContentPatientState extends State {
child: Card(
clipBehavior: Clip.antiAliasWithSaveLayer,
color: checkedIndex == index
- ? getColorScheme(context).tertiary
- : getColorScheme(context).surface,
+ ? colorScheme(context).tertiary
+ : colorScheme(context).surface,
child: Stack(
fit: StackFit.expand,
children: [
CachedNetworkImage(
imageUrl:
- "$restAPIMedia/${data[index].imageURL}",
+ "$restAPIMedia/${data[index].image}",
fit: BoxFit.cover,
),
ClipRRect(
@@ -93,7 +93,7 @@ class _ContentPatientState extends State {
),
child: Container(
color: checkedIndex == index
- ? getColorScheme(context)
+ ? colorScheme(context)
.primaryContainer
.withOpacity(0.5)
: Colors.transparent,
@@ -118,25 +118,13 @@ class _ContentPatientState extends State {
: Colors.transparent),
child: Center(
child: Text(
- context.locale
- .languageCode ==
- 'en'
- ? "${data[index].name} Patient"
- : "مريض ${data[index].name_in_arabic}",
+ data[index].name,
textAlign:
TextAlign.center,
style: TextStyle(
- color: getColorScheme(
- context)
- .onSurface,
- fontFamily: context
- .locale
- .languageCode ==
- "en"
- ? 'Kine'
- : GoogleFonts
- .notoKufiArabic()
- .fontFamily,
+ color:
+ colorScheme(context)
+ .onSurface,
),
),
),
@@ -155,7 +143,41 @@ class _ContentPatientState extends State {
),
),
),
- authButton(
+ ({
+ required void Function() onPressed,
+ required bool isLoading,
+ required String text,
+ Color? color,
+ Color? textColor,
+ double width = 350,
+ required BuildContext context,
+ }) {
+ final theme = Theme.of(context).colorScheme;
+ return Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 20.0),
+ child: MaterialButton(
+ onPressed: onPressed,
+ color: color ?? theme.primaryContainer,
+ elevation: 0,
+ minWidth: width,
+ height: 60,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(15),
+ ),
+ child: isLoading
+ ? const CircularProgressIndicator(
+ color: Colors.white,
+ )
+ : Text(
+ text,
+ style: TextStyle(
+ fontSize: 15,
+ color: textColor ??
+ theme.onPrimaryContainer),
+ ),
+ ),
+ );
+ }(
onPressed: () {
if (checkedIndex != null) {
CacheHelper.setInt(
@@ -183,9 +205,7 @@ class _ContentPatientState extends State {
}
},
isLoading: false,
- text: context.locale.languageCode == "en"
- ? "Continue"
- : "التالي",
+ text: word?.choose ?? "Choose",
context: context)
],
);
diff --git a/lib/src/features/cooking/data/cooking_data.dart b/lib/src/features/cooking/data/cooking_data.dart
new file mode 100644
index 0000000..c580a07
--- /dev/null
+++ b/lib/src/features/cooking/data/cooking_data.dart
@@ -0,0 +1,27 @@
+import 'dart:convert';
+
+import 'package:hooks_riverpod/hooks_riverpod.dart';
+
+import '../../../constants/constants.dart';
+import '../../auth/application/auth_service.dart';
+import '../../get_recipes/domain/recipe/recipe.dart';
+
+
+Future addPoints({required WidgetRef ref,required int points})async{
+ final url = '$restAPIURL/user/update/points/';
+
+ final response = await client.put(
+ Uri.parse(url),
+ body: json.encode({"points": points}),
+ headers: {
+ 'Authorization': 'Token ${ref.read(authHelperProvider).getToken()}',
+ 'Content-Type': 'application/json',
+ },
+ );
+ print(response.body);
+ if (response.statusCode == 200) {
+ return "Successfully added points";
+ }
+ return "Error adding points";
+
+}
\ No newline at end of file
diff --git a/lib/src/features/cooking/data/cooking_domain.dart b/lib/src/features/cooking/data/cooking_domain.dart
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/lib/src/features/cooking/data/cooking_domain.dart
@@ -0,0 +1 @@
+
diff --git a/lib/src/features/cooking/presentation/cooking.dart b/lib/src/features/cooking/presentation/cooking.dart
new file mode 100644
index 0000000..8f91f57
--- /dev/null
+++ b/lib/src/features/cooking/presentation/cooking.dart
@@ -0,0 +1,227 @@
+import 'package:flutter/material.dart';
+import 'package:flutter_hooks/flutter_hooks.dart';
+import 'package:go_router/go_router.dart';
+import 'package:hooks_riverpod/hooks_riverpod.dart';
+import 'package:percent_indicator/percent_indicator.dart';
+
+import '../../../translations/domain/translation_provider.dart';
+import '../data/cooking_data.dart';
+
+class Cooking extends HookConsumerWidget {
+ final dynamic data;
+ const Cooking({
+ super.key,
+ required this.data,
+ });
+
+ final int endTimerinSeconds = 5;
+
+ @override
+ Widget build(BuildContext context, WidgetRef ref) {
+ final index = useState(0);
+ final isPaused = useState(false);
+ final startTimer = useState(0.0);
+ final isPlaying = useAnimationController(
+ duration: const Duration(seconds: 1), initialValue: 0.0);
+ final pageController = usePageController();
+ print(startTimer.value);
+ final directions = data["directions"];
+ final video = data["video"];
+
+ useEffect(
+ () {
+ if (isPaused.value) {
+ startTimer.value = startTimer.value;
+ isPlaying.reverse();
+ } else {
+ Future.delayed(Duration(seconds: 1), () async {
+ if (isPaused.value) {
+ startTimer.value = startTimer.value;
+ isPlaying.reverse();
+ }
+ if (startTimer.value == endTimerinSeconds.toDouble() &&
+ index.value == directions.length - 1 &&
+ !isPaused.value) {
+ print("add points");
+ addPoints(ref: ref, points: 10).then((value) {
+ isPaused.value = true;
+ startTimer.value = 0.0;
+ });
+ }
+ if (startTimer.value < endTimerinSeconds) {
+ startTimer.value += 1;
+ isPlaying.forward();
+ } else {
+ if (index.value < directions.length - 1) {
+ isPaused.value = true;
+ startTimer.value = 0.0;
+ pageController.animateToPage(index.value + 1,
+ duration: Duration(milliseconds: 300),
+ curve: Curves.easeInCirc);
+ isPlaying.reverse();
+ }
+ }
+ });
+ }
+ return null;
+ },
+ );
+ return Scaffold(
+ body: PageView.builder(
+ onPageChanged: (value) {
+ isPaused.value = true;
+ startTimer.value = 0;
+ index.value = value;
+ isPlaying.reverse();
+ },
+ itemCount: directions.length,
+ controller: pageController,
+ itemBuilder: (context, _) {
+ return DirectionsWidget(
+ index: index,
+ endTimerinSeconds: endTimerinSeconds,
+ directions: directions,
+ startTimer: startTimer,
+ isPaused: isPaused,
+ video: video,
+ isPlaying: isPlaying);
+ }));
+ }
+}
+
+class DirectionsWidget extends StatelessWidget {
+ const DirectionsWidget({
+ super.key,
+ required this.index,
+ required this.directions,
+ required this.startTimer,
+ required this.isPaused,
+ required this.isPlaying,
+ required this.endTimerinSeconds,
+ required this.video,
+ });
+
+ final ValueNotifier index;
+ final List directions;
+ final ValueNotifier startTimer;
+ final ValueNotifier isPaused;
+ final AnimationController isPlaying;
+ final int endTimerinSeconds;
+ final String video;
+
+ @override
+ Widget build(BuildContext context) {
+ int timeLeftSeconds = endTimerinSeconds - startTimer.value.toInt();
+ int timeLeftMin = timeLeftSeconds ~/ 60;
+ int timeLeftSec = timeLeftSeconds % 60;
+ String timeleftSec = timeLeftSec < 10 ? "0$timeLeftSec" : "$timeLeftSec";
+ final word = TranslationRepo.translate(context);
+
+ return SingleChildScrollView(
+ child: SafeArea(
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 10),
+ child: Column(
+ children: [
+ const SizedBox(
+ height: 20.0,
+ ),
+ Align(
+ alignment: Alignment.topLeft,
+ child: GestureDetector(
+ onTap: () {
+ context.pop();
+ },
+ child: Icon(Icons.arrow_back_outlined))),
+ Align(
+ alignment: Alignment.topRight,
+ child: ElevatedButton.icon(
+ onPressed: () => context.pushNamed('recipeVideo',extra: video),
+ label: Text(word!.watch_video),
+ icon: Icon(Icons.play_arrow_outlined),
+ ),
+ ),
+ const SizedBox(
+ height: 40.0,
+ ),
+ RichText(
+ text: TextSpan(children: [
+ TextSpan(
+ text: "${word.step} ${index.value + 1} ",
+ style: TextStyle(
+ fontSize: 18.0,
+ fontWeight: FontWeight.bold,
+ color: Theme.of(context).colorScheme.primary)),
+ TextSpan(
+ text: "${word.step_of} ${directions.length}",
+ style: TextStyle(
+ fontSize: 18.0, fontWeight: FontWeight.w100)),
+ ]),
+ ),
+ const SizedBox(
+ height: 30.0,
+ ),
+ Padding(
+ padding: const EdgeInsets.all(10.0),
+ child: Text(
+ " \"${directions[index.value]}\"",
+ style: TextStyle(
+ fontSize: 16.0,
+ color: Theme.of(context)
+ .colorScheme
+ .onSurface
+ .withOpacity(0.5)),
+ ),
+ ),
+ const SizedBox(
+ height: 50.0,
+ ),
+ CircularPercentIndicator(
+ radius: 80,
+ center: Icon(
+ Icons.soup_kitchen_outlined,
+ size: 50,
+ ),
+ progressColor: Theme.of(context).colorScheme.primary,
+ percent: startTimer.value / endTimerinSeconds,
+ animation: true,
+ lineWidth: 5,
+ animateFromLastPercent: true,
+ backgroundColor:
+ Theme.of(context).colorScheme.primary.withOpacity(0.1),
+ circularStrokeCap: CircularStrokeCap.round,
+ curve: Curves.easeIn,
+ ),
+ const SizedBox(
+ height: 20.0,
+ ),
+ Text("0${timeLeftMin}:${timeleftSec}",
+ style: TextStyle(
+ fontSize: 18.0,
+ fontWeight: FontWeight.bold,
+ color: Theme.of(context).colorScheme.primary)),
+ const SizedBox(
+ height: 60.0,
+ ),
+ CircleAvatar(
+ radius: 30,
+ child: IconButton(
+ onPressed: () {
+ isPaused.value = !isPaused.value;
+ },
+ selectedIcon: Icon(Icons.pause_outlined),
+ isSelected: !isPaused.value,
+ icon: AnimatedIcon(
+ progress: isPlaying,
+ icon: AnimatedIcons.play_pause,
+ ))),
+ const SizedBox(
+ height: 50.0,
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+}
diff --git a/lib/src/features/get_recipes/data/patient_types.dart b/lib/src/features/get_recipes/data/patient_types.dart
deleted file mode 100644
index 7e525ab..0000000
--- a/lib/src/features/get_recipes/data/patient_types.dart
+++ /dev/null
@@ -1,20 +0,0 @@
-import 'dart:convert';
-
-import 'package:flutter_riverpod/flutter_riverpod.dart';
-
-import '../../../constants/constants.dart';
-import '../domain/recipe/recipe.dart';
-import '../domain/recipe/recipe_types.dart';
-
-final patientTypesProvider =
- FutureProvider>((ref) => patientTypes());
-
-Future> patientTypes() async {
- const url = '$restAPIURL/allPatients/?format=json';
- final response = await client.get(Uri.parse(url));
- final responseDe = utf8.decode(response.bodyBytes);
- final recipeJson = await json.decode(responseDe);
- return recipeJson
- .map((data) => RecipeTypes.fromJson((data)))
- .toList();
-}
diff --git a/lib/src/features/get_recipes/data/patients.dart b/lib/src/features/get_recipes/data/patients.dart
new file mode 100644
index 0000000..0a87d22
--- /dev/null
+++ b/lib/src/features/get_recipes/data/patients.dart
@@ -0,0 +1,23 @@
+import 'dart:convert';
+
+import 'package:flutter/material.dart';
+import 'package:flutter_riverpod/flutter_riverpod.dart';
+import 'package:livine/src/translations/domain/translation_provider.dart';
+
+import '../../../constants/constants.dart';
+import '../domain/recipe/recipe.dart';
+import '../domain/recipe/patients.dart';
+import 'package:riverpod_annotation/riverpod_annotation.dart';
+
+part 'patients.g.dart';
+
+@riverpod
+Future> getPatients(Ref ref,
+ {required BuildContext context}) async {
+ final response = await client.get(
+ Uri.parse('$restAPIURL/allPatients/?format=json'),
+ headers: {"Accept-Language": ref.watch(localeNotifierProvider).languageCode});
+ final responseDe = utf8.decode(response.bodyBytes);
+ final recipeJson = await json.decode(responseDe);
+ return recipeJson.map((data) => Patients.fromJson((data))).toList();
+}
diff --git a/lib/src/features/get_recipes/data/patients.g.dart b/lib/src/features/get_recipes/data/patients.g.dart
new file mode 100644
index 0000000..8732326
--- /dev/null
+++ b/lib/src/features/get_recipes/data/patients.g.dart
@@ -0,0 +1,159 @@
+// GENERATED CODE - DO NOT MODIFY BY HAND
+
+part of 'patients.dart';
+
+// **************************************************************************
+// RiverpodGenerator
+// **************************************************************************
+
+String _$getPatientsHash() => r'193cdeebf7ebd0b814439a567599490c7345ec0d';
+
+/// Copied from Dart SDK
+class _SystemHash {
+ _SystemHash._();
+
+ static int combine(int hash, int value) {
+ // ignore: parameter_assignments
+ hash = 0x1fffffff & (hash + value);
+ // ignore: parameter_assignments
+ hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10));
+ return hash ^ (hash >> 6);
+ }
+
+ static int finish(int hash) {
+ // ignore: parameter_assignments
+ hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3));
+ // ignore: parameter_assignments
+ hash = hash ^ (hash >> 11);
+ return 0x1fffffff & (hash + ((0x00003fff & hash) << 15));
+ }
+}
+
+/// See also [getPatients].
+@ProviderFor(getPatients)
+const getPatientsProvider = GetPatientsFamily();
+
+/// See also [getPatients].
+class GetPatientsFamily extends Family>> {
+ /// See also [getPatients].
+ const GetPatientsFamily();
+
+ /// See also [getPatients].
+ GetPatientsProvider call({
+ required BuildContext context,
+ }) {
+ return GetPatientsProvider(
+ context: context,
+ );
+ }
+
+ @override
+ GetPatientsProvider getProviderOverride(
+ covariant GetPatientsProvider provider,
+ ) {
+ return call(
+ context: provider.context,
+ );
+ }
+
+ static const Iterable? _dependencies = null;
+
+ @override
+ Iterable? get dependencies => _dependencies;
+
+ static const Iterable? _allTransitiveDependencies = null;
+
+ @override
+ Iterable? get allTransitiveDependencies =>
+ _allTransitiveDependencies;
+
+ @override
+ String? get name => r'getPatientsProvider';
+}
+
+/// See also [getPatients].
+class GetPatientsProvider extends AutoDisposeFutureProvider> {
+ /// See also [getPatients].
+ GetPatientsProvider({
+ required BuildContext context,
+ }) : this._internal(
+ (ref) => getPatients(
+ ref as GetPatientsRef,
+ context: context,
+ ),
+ from: getPatientsProvider,
+ name: r'getPatientsProvider',
+ debugGetCreateSourceHash:
+ const bool.fromEnvironment('dart.vm.product')
+ ? null
+ : _$getPatientsHash,
+ dependencies: GetPatientsFamily._dependencies,
+ allTransitiveDependencies:
+ GetPatientsFamily._allTransitiveDependencies,
+ context: context,
+ );
+
+ GetPatientsProvider._internal(
+ super._createNotifier, {
+ required super.name,
+ required super.dependencies,
+ required super.allTransitiveDependencies,
+ required super.debugGetCreateSourceHash,
+ required super.from,
+ required this.context,
+ }) : super.internal();
+
+ final BuildContext context;
+
+ @override
+ Override overrideWith(
+ FutureOr> Function(GetPatientsRef provider) create,
+ ) {
+ return ProviderOverride(
+ origin: this,
+ override: GetPatientsProvider._internal(
+ (ref) => create(ref as GetPatientsRef),
+ from: from,
+ name: null,
+ dependencies: null,
+ allTransitiveDependencies: null,
+ debugGetCreateSourceHash: null,
+ context: context,
+ ),
+ );
+ }
+
+ @override
+ AutoDisposeFutureProviderElement> createElement() {
+ return _GetPatientsProviderElement(this);
+ }
+
+ @override
+ bool operator ==(Object other) {
+ return other is GetPatientsProvider && other.context == context;
+ }
+
+ @override
+ int get hashCode {
+ var hash = _SystemHash.combine(0, runtimeType.hashCode);
+ hash = _SystemHash.combine(hash, context.hashCode);
+
+ return _SystemHash.finish(hash);
+ }
+}
+
+mixin GetPatientsRef on AutoDisposeFutureProviderRef> {
+ /// The parameter `context` of this provider.
+ BuildContext get context;
+}
+
+class _GetPatientsProviderElement
+ extends AutoDisposeFutureProviderElement>
+ with GetPatientsRef {
+ _GetPatientsProviderElement(super.provider);
+
+ @override
+ BuildContext get context => (origin as GetPatientsProvider).context;
+}
+// ignore_for_file: type=lint
+// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member
diff --git a/lib/src/features/get_recipes/data/recipes.dart b/lib/src/features/get_recipes/data/recipes.dart
index 4512645..b285802 100644
--- a/lib/src/features/get_recipes/data/recipes.dart
+++ b/lib/src/features/get_recipes/data/recipes.dart
@@ -1,29 +1,38 @@
import 'dart:convert';
+import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../../constants/constants.dart';
+import '../../../translations/domain/translation_provider.dart';
import '../domain/recipe/recipe.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
part 'recipes.g.dart';
-final FutureProviderFamily recipesProviderID =
- FutureProvider.family((ref, id) async {
+@riverpod
+Future recipesDetails(Ref ref,
+ {required int id, required BuildContext context}) async {
final url = '$restAPIURL/recipe/$id?format=json';
-
- final response = await client.get(Uri.parse(url));
+ final response = await client.get(Uri.parse(url), headers: {
+ 'Accept-Language': ref.watch(localeNotifierProvider).languageCode,
+ });
final responseDe = utf8.decode(response.bodyBytes);
final responseJson = json.decode(responseDe);
return Recipe.fromJson(
Map.from(responseJson as Map));
-});
+}
@riverpod
Future getRecipes(Ref ref,
- {required int id, required int pageKey}) async {
+ {required int id,
+ required int pageKey,
+ required BuildContext context}) async {
final url = '$restAPIURL/patient/$id?format=json&page=$pageKey';
- final response = await client.get(Uri.parse(url));
+ final response = await client.get(Uri.parse(url), headers: {
+ 'Accept-Language': ref.watch(localeNotifierProvider).languageCode
+ });
+
final responseDe = utf8.decode(response.bodyBytes);
var responseJson = json.decode(responseDe);
var recipesList =
@@ -33,9 +42,13 @@ Future getRecipes(Ref ref,
@riverpod
Future getVegRecipes(Ref ref,
- {required int id, required int pageKey}) async {
+ {required int id,
+ required int pageKey,
+ required BuildContext context}) async {
final url = '$restAPIURL/recipe/veg/$id?format=json&page=$pageKey';
- final response = await client.get(Uri.parse(url));
+ final response = await client.get(Uri.parse(url), headers: {
+ 'Accept-Language': ref.watch(localeNotifierProvider).languageCode
+ });
final responseDe = utf8.decode(response.bodyBytes);
var responseJson = json.decode(responseDe);
var recipesList =
diff --git a/lib/src/features/get_recipes/data/recipes.g.dart b/lib/src/features/get_recipes/data/recipes.g.dart
index 15ceaee..b962a72 100644
--- a/lib/src/features/get_recipes/data/recipes.g.dart
+++ b/lib/src/features/get_recipes/data/recipes.g.dart
@@ -6,7 +6,7 @@ part of 'recipes.dart';
// RiverpodGenerator
// **************************************************************************
-// ignore_for_file: avoid_private_typedef_functions, non_constant_identifier_names, subtype_of_sealed_class, invalid_use_of_internal_member, unused_element, constant_identifier_names, unnecessary_raw_strings, library_private_types_in_public_api
+String _$recipesDetailsHash() => r'0f959832e5dee7b167de4ccab7904e32ba923079';
/// Copied from Dart SDK
class _SystemHash {
@@ -29,114 +29,274 @@ class _SystemHash {
}
}
-String $getRecipesHash() => r'90f07d1abe4044a71c4a09065c8f9d33df8d9f40';
+/// See also [recipesDetails].
+@ProviderFor(recipesDetails)
+const recipesDetailsProvider = RecipesDetailsFamily();
-/// See also [getRecipes].
-class GetRecipesProvider extends AutoDisposeFutureProvider {
- GetRecipesProvider({
- required this.id,
- required this.pageKey,
- }) : super(
- (ref) => getRecipes(
- ref,
+/// See also [recipesDetails].
+class RecipesDetailsFamily extends Family> {
+ /// See also [recipesDetails].
+ const RecipesDetailsFamily();
+
+ /// See also [recipesDetails].
+ RecipesDetailsProvider call({
+ required int id,
+ required BuildContext context,
+ }) {
+ return RecipesDetailsProvider(
+ id: id,
+ context: context,
+ );
+ }
+
+ @override
+ RecipesDetailsProvider getProviderOverride(
+ covariant RecipesDetailsProvider provider,
+ ) {
+ return call(
+ id: provider.id,
+ context: provider.context,
+ );
+ }
+
+ static const Iterable? _dependencies = null;
+
+ @override
+ Iterable? get dependencies => _dependencies;
+
+ static const Iterable? _allTransitiveDependencies = null;
+
+ @override
+ Iterable? get allTransitiveDependencies =>
+ _allTransitiveDependencies;
+
+ @override
+ String? get name => r'recipesDetailsProvider';
+}
+
+/// See also [recipesDetails].
+class RecipesDetailsProvider extends AutoDisposeFutureProvider {
+ /// See also [recipesDetails].
+ RecipesDetailsProvider({
+ required int id,
+ required BuildContext context,
+ }) : this._internal(
+ (ref) => recipesDetails(
+ ref as RecipesDetailsRef,
id: id,
- pageKey: pageKey,
+ context: context,
),
- from: getRecipesProvider,
- name: r'getRecipesProvider',
+ from: recipesDetailsProvider,
+ name: r'recipesDetailsProvider',
debugGetCreateSourceHash:
const bool.fromEnvironment('dart.vm.product')
? null
- : $getRecipesHash,
+ : _$recipesDetailsHash,
+ dependencies: RecipesDetailsFamily._dependencies,
+ allTransitiveDependencies:
+ RecipesDetailsFamily._allTransitiveDependencies,
+ id: id,
+ context: context,
);
+ RecipesDetailsProvider._internal(
+ super._createNotifier, {
+ required super.name,
+ required super.dependencies,
+ required super.allTransitiveDependencies,
+ required super.debugGetCreateSourceHash,
+ required super.from,
+ required this.id,
+ required this.context,
+ }) : super.internal();
+
final int id;
- final int pageKey;
+ final BuildContext context;
+
+ @override
+ Override overrideWith(
+ FutureOr Function(RecipesDetailsRef provider) create,
+ ) {
+ return ProviderOverride(
+ origin: this,
+ override: RecipesDetailsProvider._internal(
+ (ref) => create(ref as RecipesDetailsRef),
+ from: from,
+ name: null,
+ dependencies: null,
+ allTransitiveDependencies: null,
+ debugGetCreateSourceHash: null,
+ id: id,
+ context: context,
+ ),
+ );
+ }
+
+ @override
+ AutoDisposeFutureProviderElement createElement() {
+ return _RecipesDetailsProviderElement(this);
+ }
@override
bool operator ==(Object other) {
- return other is GetRecipesProvider &&
+ return other is RecipesDetailsProvider &&
other.id == id &&
- other.pageKey == pageKey;
+ other.context == context;
}
@override
int get hashCode {
var hash = _SystemHash.combine(0, runtimeType.hashCode);
hash = _SystemHash.combine(hash, id.hashCode);
- hash = _SystemHash.combine(hash, pageKey.hashCode);
+ hash = _SystemHash.combine(hash, context.hashCode);
return _SystemHash.finish(hash);
}
}
-typedef GetRecipesRef = AutoDisposeFutureProviderRef;
+mixin RecipesDetailsRef on AutoDisposeFutureProviderRef {
+ /// The parameter `id` of this provider.
+ int get id;
+
+ /// The parameter `context` of this provider.
+ BuildContext get context;
+}
+
+class _RecipesDetailsProviderElement
+ extends AutoDisposeFutureProviderElement with RecipesDetailsRef {
+ _RecipesDetailsProviderElement(super.provider);
+
+ @override
+ int get id => (origin as RecipesDetailsProvider).id;
+ @override
+ BuildContext get context => (origin as RecipesDetailsProvider).context;
+}
+
+String _$getRecipesHash() => r'844c07cc8dc308590cc248d2bc4f5b041a8b9b95';
/// See also [getRecipes].
-final getRecipesProvider = GetRecipesFamily();
+@ProviderFor(getRecipes)
+const getRecipesProvider = GetRecipesFamily();
+/// See also [getRecipes].
class GetRecipesFamily extends Family> {
- GetRecipesFamily();
+ /// See also [getRecipes].
+ const GetRecipesFamily();
+ /// See also [getRecipes].
GetRecipesProvider call({
required int id,
required int pageKey,
+ required BuildContext context,
}) {
return GetRecipesProvider(
id: id,
pageKey: pageKey,
+ context: context,
);
}
@override
- AutoDisposeFutureProvider getProviderOverride(
+ GetRecipesProvider getProviderOverride(
covariant GetRecipesProvider provider,
) {
return call(
id: provider.id,
pageKey: provider.pageKey,
+ context: provider.context,
);
}
+ static const Iterable? _dependencies = null;
+
@override
- List? get allTransitiveDependencies => null;
+ Iterable? get dependencies => _dependencies;
+
+ static const Iterable? _allTransitiveDependencies = null;
@override
- List? get dependencies => null;
+ Iterable? get allTransitiveDependencies =>
+ _allTransitiveDependencies;
@override
String? get name => r'getRecipesProvider';
}
-String $getVegRecipesHash() => r'84718619964ac5f5ff46ec1893252b7c7ef0c21b';
-
-/// See also [getVegRecipes].
-class GetVegRecipesProvider extends AutoDisposeFutureProvider {
- GetVegRecipesProvider({
- required this.id,
- required this.pageKey,
- }) : super(
- (ref) => getVegRecipes(
- ref,
+/// See also [getRecipes].
+class GetRecipesProvider extends AutoDisposeFutureProvider {
+ /// See also [getRecipes].
+ GetRecipesProvider({
+ required int id,
+ required int pageKey,
+ required BuildContext context,
+ }) : this._internal(
+ (ref) => getRecipes(
+ ref as GetRecipesRef,
id: id,
pageKey: pageKey,
+ context: context,
),
- from: getVegRecipesProvider,
- name: r'getVegRecipesProvider',
+ from: getRecipesProvider,
+ name: r'getRecipesProvider',
debugGetCreateSourceHash:
const bool.fromEnvironment('dart.vm.product')
? null
- : $getVegRecipesHash,
+ : _$getRecipesHash,
+ dependencies: GetRecipesFamily._dependencies,
+ allTransitiveDependencies:
+ GetRecipesFamily._allTransitiveDependencies,
+ id: id,
+ pageKey: pageKey,
+ context: context,
);
+ GetRecipesProvider._internal(
+ super._createNotifier, {
+ required super.name,
+ required super.dependencies,
+ required super.allTransitiveDependencies,
+ required super.debugGetCreateSourceHash,
+ required super.from,
+ required this.id,
+ required this.pageKey,
+ required this.context,
+ }) : super.internal();
+
final int id;
final int pageKey;
+ final BuildContext context;
+
+ @override
+ Override overrideWith(
+ FutureOr Function(GetRecipesRef provider) create,
+ ) {
+ return ProviderOverride(
+ origin: this,
+ override: GetRecipesProvider._internal(
+ (ref) => create(ref as GetRecipesRef),
+ from: from,
+ name: null,
+ dependencies: null,
+ allTransitiveDependencies: null,
+ debugGetCreateSourceHash: null,
+ id: id,
+ pageKey: pageKey,
+ context: context,
+ ),
+ );
+ }
+
+ @override
+ AutoDisposeFutureProviderElement createElement() {
+ return _GetRecipesProviderElement(this);
+ }
@override
bool operator ==(Object other) {
- return other is GetVegRecipesProvider &&
+ return other is GetRecipesProvider &&
other.id == id &&
- other.pageKey == pageKey;
+ other.pageKey == pageKey &&
+ other.context == context;
}
@override
@@ -144,45 +304,194 @@ class GetVegRecipesProvider extends AutoDisposeFutureProvider {
var hash = _SystemHash.combine(0, runtimeType.hashCode);
hash = _SystemHash.combine(hash, id.hashCode);
hash = _SystemHash.combine(hash, pageKey.hashCode);
+ hash = _SystemHash.combine(hash, context.hashCode);
return _SystemHash.finish(hash);
}
}
-typedef GetVegRecipesRef = AutoDisposeFutureProviderRef;
+mixin GetRecipesRef on AutoDisposeFutureProviderRef {
+ /// The parameter `id` of this provider.
+ int get id;
+
+ /// The parameter `pageKey` of this provider.
+ int get pageKey;
+
+ /// The parameter `context` of this provider.
+ BuildContext get context;
+}
+
+class _GetRecipesProviderElement
+ extends AutoDisposeFutureProviderElement with GetRecipesRef {
+ _GetRecipesProviderElement(super.provider);
+
+ @override
+ int get id => (origin as GetRecipesProvider).id;
+ @override
+ int get pageKey => (origin as GetRecipesProvider).pageKey;
+ @override
+ BuildContext get context => (origin as GetRecipesProvider).context;
+}
+
+String _$getVegRecipesHash() => r'262d6ac30dc0a18c52405ffd35a85a9137228eb0';
/// See also [getVegRecipes].
-final getVegRecipesProvider = GetVegRecipesFamily();
+@ProviderFor(getVegRecipes)
+const getVegRecipesProvider = GetVegRecipesFamily();
+/// See also [getVegRecipes].
class GetVegRecipesFamily extends Family> {
- GetVegRecipesFamily();
+ /// See also [getVegRecipes].
+ const GetVegRecipesFamily();
+ /// See also [getVegRecipes].
GetVegRecipesProvider call({
required int id,
required int pageKey,
+ required BuildContext context,
}) {
return GetVegRecipesProvider(
id: id,
pageKey: pageKey,
+ context: context,
);
}
@override
- AutoDisposeFutureProvider getProviderOverride(
+ GetVegRecipesProvider getProviderOverride(
covariant GetVegRecipesProvider provider,
) {
return call(
id: provider.id,
pageKey: provider.pageKey,
+ context: provider.context,
);
}
+ static const Iterable? _dependencies = null;
+
@override
- List? get allTransitiveDependencies => null;
+ Iterable? get dependencies => _dependencies;
+
+ static const Iterable? _allTransitiveDependencies = null;
@override
- List? get dependencies => null;
+ Iterable? get allTransitiveDependencies =>
+ _allTransitiveDependencies;
@override
String? get name => r'getVegRecipesProvider';
}
+
+/// See also [getVegRecipes].
+class GetVegRecipesProvider extends AutoDisposeFutureProvider {
+ /// See also [getVegRecipes].
+ GetVegRecipesProvider({
+ required int id,
+ required int pageKey,
+ required BuildContext context,
+ }) : this._internal(
+ (ref) => getVegRecipes(
+ ref as GetVegRecipesRef,
+ id: id,
+ pageKey: pageKey,
+ context: context,
+ ),
+ from: getVegRecipesProvider,
+ name: r'getVegRecipesProvider',
+ debugGetCreateSourceHash:
+ const bool.fromEnvironment('dart.vm.product')
+ ? null
+ : _$getVegRecipesHash,
+ dependencies: GetVegRecipesFamily._dependencies,
+ allTransitiveDependencies:
+ GetVegRecipesFamily._allTransitiveDependencies,
+ id: id,
+ pageKey: pageKey,
+ context: context,
+ );
+
+ GetVegRecipesProvider._internal(
+ super._createNotifier, {
+ required super.name,
+ required super.dependencies,
+ required super.allTransitiveDependencies,
+ required super.debugGetCreateSourceHash,
+ required super.from,
+ required this.id,
+ required this.pageKey,
+ required this.context,
+ }) : super.internal();
+
+ final int id;
+ final int pageKey;
+ final BuildContext context;
+
+ @override
+ Override overrideWith(
+ FutureOr Function(GetVegRecipesRef provider) create,
+ ) {
+ return ProviderOverride(
+ origin: this,
+ override: GetVegRecipesProvider._internal(
+ (ref) => create(ref as GetVegRecipesRef),
+ from: from,
+ name: null,
+ dependencies: null,
+ allTransitiveDependencies: null,
+ debugGetCreateSourceHash: null,
+ id: id,
+ pageKey: pageKey,
+ context: context,
+ ),
+ );
+ }
+
+ @override
+ AutoDisposeFutureProviderElement createElement() {
+ return _GetVegRecipesProviderElement(this);
+ }
+
+ @override
+ bool operator ==(Object other) {
+ return other is GetVegRecipesProvider &&
+ other.id == id &&
+ other.pageKey == pageKey &&
+ other.context == context;
+ }
+
+ @override
+ int get hashCode {
+ var hash = _SystemHash.combine(0, runtimeType.hashCode);
+ hash = _SystemHash.combine(hash, id.hashCode);
+ hash = _SystemHash.combine(hash, pageKey.hashCode);
+ hash = _SystemHash.combine(hash, context.hashCode);
+
+ return _SystemHash.finish(hash);
+ }
+}
+
+mixin GetVegRecipesRef on AutoDisposeFutureProviderRef {
+ /// The parameter `id` of this provider.
+ int get id;
+
+ /// The parameter `pageKey` of this provider.
+ int get pageKey;
+
+ /// The parameter `context` of this provider.
+ BuildContext get context;
+}
+
+class _GetVegRecipesProviderElement
+ extends AutoDisposeFutureProviderElement with GetVegRecipesRef {
+ _GetVegRecipesProviderElement(super.provider);
+
+ @override
+ int get id => (origin as GetVegRecipesProvider).id;
+ @override
+ int get pageKey => (origin as GetVegRecipesProvider).pageKey;
+ @override
+ BuildContext get context => (origin as GetVegRecipesProvider).context;
+}
+// ignore_for_file: type=lint
+// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member
diff --git a/lib/src/features/get_recipes/domain/recipe/patients.dart b/lib/src/features/get_recipes/domain/recipe/patients.dart
new file mode 100644
index 0000000..10a1cd0
--- /dev/null
+++ b/lib/src/features/get_recipes/domain/recipe/patients.dart
@@ -0,0 +1,17 @@
+// ignore_for_file: non_constant_identifier_names
+
+import 'package:freezed_annotation/freezed_annotation.dart';
+
+part 'patients.freezed.dart';
+part 'patients.g.dart';
+
+@freezed
+class Patients with _$Patients {
+ const factory Patients(
+ int id,
+ String name,
+ String image,
+ ) = _Patients;
+ factory Patients.fromJson(Map json) =>
+ _$PatientsFromJson(json);
+}
diff --git a/lib/src/features/get_recipes/domain/recipe/patients.freezed.dart b/lib/src/features/get_recipes/domain/recipe/patients.freezed.dart
new file mode 100644
index 0000000..32afe82
--- /dev/null
+++ b/lib/src/features/get_recipes/domain/recipe/patients.freezed.dart
@@ -0,0 +1,181 @@
+// coverage:ignore-file
+// GENERATED CODE - DO NOT MODIFY BY HAND
+// ignore_for_file: type=lint
+// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
+
+part of 'patients.dart';
+
+// **************************************************************************
+// FreezedGenerator
+// **************************************************************************
+
+T _$identity(T value) => value;
+
+final _privateConstructorUsedError = UnsupportedError(
+ 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
+
+Patients _$PatientsFromJson(Map json) {
+ return _Patients.fromJson(json);
+}
+
+/// @nodoc
+mixin _$Patients {
+ int get id => throw _privateConstructorUsedError;
+ String get name => throw _privateConstructorUsedError;
+ String get image => throw _privateConstructorUsedError;
+
+ Map toJson() => throw _privateConstructorUsedError;
+ @JsonKey(ignore: true)
+ $PatientsCopyWith get copyWith =>
+ throw _privateConstructorUsedError;
+}
+
+/// @nodoc
+abstract class $PatientsCopyWith<$Res> {
+ factory $PatientsCopyWith(Patients value, $Res Function(Patients) then) =
+ _$PatientsCopyWithImpl<$Res, Patients>;
+ @useResult
+ $Res call({int id, String name, String image});
+}
+
+/// @nodoc
+class _$PatientsCopyWithImpl<$Res, $Val extends Patients>
+ implements $PatientsCopyWith<$Res> {
+ _$PatientsCopyWithImpl(this._value, this._then);
+
+ // ignore: unused_field
+ final $Val _value;
+ // ignore: unused_field
+ final $Res Function($Val) _then;
+
+ @pragma('vm:prefer-inline')
+ @override
+ $Res call({
+ Object? id = null,
+ Object? name = null,
+ Object? image = null,
+ }) {
+ return _then(_value.copyWith(
+ id: null == id
+ ? _value.id
+ : id // ignore: cast_nullable_to_non_nullable
+ as int,
+ name: null == name
+ ? _value.name
+ : name // ignore: cast_nullable_to_non_nullable
+ as String,
+ image: null == image
+ ? _value.image
+ : image // ignore: cast_nullable_to_non_nullable
+ as String,
+ ) as $Val);
+ }
+}
+
+/// @nodoc
+abstract class _$$_PatientsCopyWith<$Res> implements $PatientsCopyWith<$Res> {
+ factory _$$_PatientsCopyWith(
+ _$_Patients value, $Res Function(_$_Patients) then) =
+ __$$_PatientsCopyWithImpl<$Res>;
+ @override
+ @useResult
+ $Res call({int id, String name, String image});
+}
+
+/// @nodoc
+class __$$_PatientsCopyWithImpl<$Res>
+ extends _$PatientsCopyWithImpl<$Res, _$_Patients>
+ implements _$$_PatientsCopyWith<$Res> {
+ __$$_PatientsCopyWithImpl(
+ _$_Patients _value, $Res Function(_$_Patients) _then)
+ : super(_value, _then);
+
+ @pragma('vm:prefer-inline')
+ @override
+ $Res call({
+ Object? id = null,
+ Object? name = null,
+ Object? image = null,
+ }) {
+ return _then(_$_Patients(
+ null == id
+ ? _value.id
+ : id // ignore: cast_nullable_to_non_nullable
+ as int,
+ null == name
+ ? _value.name
+ : name // ignore: cast_nullable_to_non_nullable
+ as String,
+ null == image
+ ? _value.image
+ : image // ignore: cast_nullable_to_non_nullable
+ as String,
+ ));
+ }
+}
+
+/// @nodoc
+@JsonSerializable()
+class _$_Patients implements _Patients {
+ const _$_Patients(this.id, this.name, this.image);
+
+ factory _$_Patients.fromJson(Map json) =>
+ _$$_PatientsFromJson(json);
+
+ @override
+ final int id;
+ @override
+ final String name;
+ @override
+ final String image;
+
+ @override
+ String toString() {
+ return 'Patients(id: $id, name: $name, image: $image)';
+ }
+
+ @override
+ bool operator ==(dynamic other) {
+ return identical(this, other) ||
+ (other.runtimeType == runtimeType &&
+ other is _$_Patients &&
+ (identical(other.id, id) || other.id == id) &&
+ (identical(other.name, name) || other.name == name) &&
+ (identical(other.image, image) || other.image == image));
+ }
+
+ @JsonKey(ignore: true)
+ @override
+ int get hashCode => Object.hash(runtimeType, id, name, image);
+
+ @JsonKey(ignore: true)
+ @override
+ @pragma('vm:prefer-inline')
+ _$$_PatientsCopyWith<_$_Patients> get copyWith =>
+ __$$_PatientsCopyWithImpl<_$_Patients>(this, _$identity);
+
+ @override
+ Map toJson() {
+ return _$$_PatientsToJson(
+ this,
+ );
+ }
+}
+
+abstract class _Patients implements Patients {
+ const factory _Patients(final int id, final String name, final String image) =
+ _$_Patients;
+
+ factory _Patients.fromJson(Map json) = _$_Patients.fromJson;
+
+ @override
+ int get id;
+ @override
+ String get name;
+ @override
+ String get image;
+ @override
+ @JsonKey(ignore: true)
+ _$$_PatientsCopyWith<_$_Patients> get copyWith =>
+ throw _privateConstructorUsedError;
+}
diff --git a/lib/src/features/get_recipes/domain/recipe/recipe_types.g.dart b/lib/src/features/get_recipes/domain/recipe/patients.g.dart
similarity index 51%
rename from lib/src/features/get_recipes/domain/recipe/recipe_types.g.dart
rename to lib/src/features/get_recipes/domain/recipe/patients.g.dart
index f8212e1..be6da8e 100644
--- a/lib/src/features/get_recipes/domain/recipe/recipe_types.g.dart
+++ b/lib/src/features/get_recipes/domain/recipe/patients.g.dart
@@ -1,23 +1,20 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
-part of 'recipe_types.dart';
+part of 'patients.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
-_$_RecipeTypes _$$_RecipeTypesFromJson(Map json) =>
- _$_RecipeTypes(
+_$_Patients _$$_PatientsFromJson(Map json) => _$_Patients(
json['id'] as int,
json['name'] as String,
- json['name_in_arabic'] as String,
- json['imageURL'] as String,
+ json['image'] as String,
);
-Map _$$_RecipeTypesToJson(_$_RecipeTypes instance) =>
+Map _$$_PatientsToJson(_$_Patients instance) =>
{
'id': instance.id,
'name': instance.name,
- 'name_in_arabic': instance.name_in_arabic,
- 'imageURL': instance.imageURL,
+ 'image': instance.image,
};
diff --git a/lib/src/features/get_recipes/domain/recipe/recipe.dart b/lib/src/features/get_recipes/domain/recipe/recipe.dart
index be4b93c..0b5b94e 100644
--- a/lib/src/features/get_recipes/domain/recipe/recipe.dart
+++ b/lib/src/features/get_recipes/domain/recipe/recipe.dart
@@ -1,7 +1,5 @@
// ignore_for_file: non_constant_identifier_names
-import 'package:easy_localization/easy_localization.dart';
-import 'package:flutter/cupertino.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:http/http.dart' as http;
import 'package:http/http.dart';
@@ -14,57 +12,19 @@ Client client = http.Client();
@freezed
class Recipe with _$Recipe {
const factory Recipe(
- int id,
- List ingridents,
- List ingridents_in_arabic,
- List directions,
- String patient,
- String patient_in_arabic,
- List directions_in_arabic,
- String name,
- String name_in_arabic,
- String imageURL,
- String diff,
- bool isVegetarian,
- int time_taken,
- int calories,
- String video,
- String video_in_arabic,
- String created_at
- ) = _Recipe;
+ int id,
+ List ingridents,
+ List directions,
+ String patient,
+ String name,
+ String imageURL,
+ String difficulty,
+ bool isVegetarian,
+ String difficulty_image,
+ int time_taken,
+ int calories,
+ String video,
+ String created_at) = _Recipe;
factory Recipe.fromJson(Map json) => _$RecipeFromJson(json);
}
-String changeDiffName(String difficulty, BuildContext context) {
- if (context.locale.languageCode == "ar") {
- if (difficulty.toUpperCase() == "EASY") {
- return "سهل";
- }
- if (difficulty.toUpperCase() == "MEDIUM") {
- return "وسط";
- }
- if (difficulty.toUpperCase() == "HARD") {
- return "صعب";
- }
- }
- return difficulty;
-}
-
-String changeDiffImage({String difficulty = '', bool isArabic = false}) {
- switch (difficulty.toUpperCase()) {
- case "EASY":
- difficulty = 'assets/images/difficulty/smile.png';
- return difficulty;
-
- case "MEDIUM":
- difficulty = 'assets/images/difficulty/wow.png';
- return difficulty;
-
- case "HARD":
- difficulty = 'assets/images/difficulty/sad.png';
- return difficulty;
-
- default:
- return difficulty;
- }
-}
diff --git a/lib/src/features/get_recipes/domain/recipe/recipe.freezed.dart b/lib/src/features/get_recipes/domain/recipe/recipe.freezed.dart
index 229bdb4..0ff8a51 100644
--- a/lib/src/features/get_recipes/domain/recipe/recipe.freezed.dart
+++ b/lib/src/features/get_recipes/domain/recipe/recipe.freezed.dart
@@ -1,7 +1,7 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
-// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
+// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'recipe.dart';
@@ -22,20 +22,16 @@ Recipe _$RecipeFromJson(Map json) {
mixin _$Recipe {
int get id => throw _privateConstructorUsedError;
List get ingridents => throw _privateConstructorUsedError;
- List get ingridents_in_arabic => throw _privateConstructorUsedError;
List get directions => throw _privateConstructorUsedError;
String get patient => throw _privateConstructorUsedError;
- String get patient_in_arabic => throw _privateConstructorUsedError;
- List get directions_in_arabic => throw _privateConstructorUsedError;
String get name => throw _privateConstructorUsedError;
- String get name_in_arabic => throw _privateConstructorUsedError;
String get imageURL => throw _privateConstructorUsedError;
- String get diff => throw _privateConstructorUsedError;
+ String get difficulty => throw _privateConstructorUsedError;
bool get isVegetarian => throw _privateConstructorUsedError;
+ String get difficulty_image => throw _privateConstructorUsedError;
int get time_taken => throw _privateConstructorUsedError;
int get calories => throw _privateConstructorUsedError;
String get video => throw _privateConstructorUsedError;
- String get video_in_arabic => throw _privateConstructorUsedError;
String get created_at => throw _privateConstructorUsedError;
Map toJson() => throw _privateConstructorUsedError;
@@ -46,125 +42,105 @@ mixin _$Recipe {
/// @nodoc
abstract class $RecipeCopyWith<$Res> {
factory $RecipeCopyWith(Recipe value, $Res Function(Recipe) then) =
- _$RecipeCopyWithImpl<$Res>;
+ _$RecipeCopyWithImpl<$Res, Recipe>;
+ @useResult
$Res call(
{int id,
List ingridents,
- List ingridents_in_arabic,
List directions,
String patient,
- String patient_in_arabic,
- List directions_in_arabic,
String name,
- String name_in_arabic,
String imageURL,
- String diff,
+ String difficulty,
bool isVegetarian,
+ String difficulty_image,
int time_taken,
int calories,
String video,
- String video_in_arabic,
String created_at});
}
/// @nodoc
-class _$RecipeCopyWithImpl<$Res> implements $RecipeCopyWith<$Res> {
+class _$RecipeCopyWithImpl<$Res, $Val extends Recipe>
+ implements $RecipeCopyWith<$Res> {
_$RecipeCopyWithImpl(this._value, this._then);
- final Recipe _value;
// ignore: unused_field
- final $Res Function(Recipe) _then;
+ final $Val _value;
+ // ignore: unused_field
+ final $Res Function($Val) _then;
+ @pragma('vm:prefer-inline')
@override
$Res call({
- Object? id = freezed,
- Object? ingridents = freezed,
- Object? ingridents_in_arabic = freezed,
- Object? directions = freezed,
- Object? patient = freezed,
- Object? patient_in_arabic = freezed,
- Object? directions_in_arabic = freezed,
- Object? name = freezed,
- Object? name_in_arabic = freezed,
- Object? imageURL = freezed,
- Object? diff = freezed,
- Object? isVegetarian = freezed,
- Object? time_taken = freezed,
- Object? calories = freezed,
- Object? video = freezed,
- Object? video_in_arabic = freezed,
- Object? created_at = freezed,
+ Object? id = null,
+ Object? ingridents = null,
+ Object? directions = null,
+ Object? patient = null,
+ Object? name = null,
+ Object? imageURL = null,
+ Object? difficulty = null,
+ Object? isVegetarian = null,
+ Object? difficulty_image = null,
+ Object? time_taken = null,
+ Object? calories = null,
+ Object? video = null,
+ Object? created_at = null,
}) {
return _then(_value.copyWith(
- id: id == freezed
+ id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
- ingridents: ingridents == freezed
+ ingridents: null == ingridents
? _value.ingridents
: ingridents // ignore: cast_nullable_to_non_nullable
as List,
- ingridents_in_arabic: ingridents_in_arabic == freezed
- ? _value.ingridents_in_arabic
- : ingridents_in_arabic // ignore: cast_nullable_to_non_nullable
- as List,
- directions: directions == freezed
+ directions: null == directions
? _value.directions
: directions // ignore: cast_nullable_to_non_nullable
as List,
- patient: patient == freezed
+ patient: null == patient
? _value.patient
: patient // ignore: cast_nullable_to_non_nullable
as String,
- patient_in_arabic: patient_in_arabic == freezed
- ? _value.patient_in_arabic
- : patient_in_arabic // ignore: cast_nullable_to_non_nullable
- as String,
- directions_in_arabic: directions_in_arabic == freezed
- ? _value.directions_in_arabic
- : directions_in_arabic // ignore: cast_nullable_to_non_nullable
- as List,
- name: name == freezed
+ name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
- name_in_arabic: name_in_arabic == freezed
- ? _value.name_in_arabic
- : name_in_arabic // ignore: cast_nullable_to_non_nullable
- as String,
- imageURL: imageURL == freezed
+ imageURL: null == imageURL
? _value.imageURL
: imageURL // ignore: cast_nullable_to_non_nullable
as String,
- diff: diff == freezed
- ? _value.diff
- : diff // ignore: cast_nullable_to_non_nullable
+ difficulty: null == difficulty
+ ? _value.difficulty
+ : difficulty // ignore: cast_nullable_to_non_nullable
as String,
- isVegetarian: isVegetarian == freezed
+ isVegetarian: null == isVegetarian
? _value.isVegetarian
: isVegetarian // ignore: cast_nullable_to_non_nullable
as bool,
- time_taken: time_taken == freezed
+ difficulty_image: null == difficulty_image
+ ? _value.difficulty_image
+ : difficulty_image // ignore: cast_nullable_to_non_nullable
+ as String,
+ time_taken: null == time_taken
? _value.time_taken
: time_taken // ignore: cast_nullable_to_non_nullable
as int,
- calories: calories == freezed
+ calories: null == calories
? _value.calories
: calories // ignore: cast_nullable_to_non_nullable
as int,
- video: video == freezed
+ video: null == video
? _value.video
: video // ignore: cast_nullable_to_non_nullable
as String,
- video_in_arabic: video_in_arabic == freezed
- ? _value.video_in_arabic
- : video_in_arabic // ignore: cast_nullable_to_non_nullable
- as String,
- created_at: created_at == freezed
+ created_at: null == created_at
? _value.created_at
: created_at // ignore: cast_nullable_to_non_nullable
as String,
- ));
+ ) as $Val);
}
}
@@ -173,121 +149,97 @@ abstract class _$$_RecipeCopyWith<$Res> implements $RecipeCopyWith<$Res> {
factory _$$_RecipeCopyWith(_$_Recipe value, $Res Function(_$_Recipe) then) =
__$$_RecipeCopyWithImpl<$Res>;
@override
+ @useResult
$Res call(
{int id,
List ingridents,
- List ingridents_in_arabic,
List directions,
String patient,
- String patient_in_arabic,
- List directions_in_arabic,
String name,
- String name_in_arabic,
String imageURL,
- String diff,
+ String difficulty,
bool isVegetarian,
+ String difficulty_image,
int time_taken,
int calories,
String video,
- String video_in_arabic,
String created_at});
}
/// @nodoc
-class __$$_RecipeCopyWithImpl<$Res> extends _$RecipeCopyWithImpl<$Res>
+class __$$_RecipeCopyWithImpl<$Res>
+ extends _$RecipeCopyWithImpl<$Res, _$_Recipe>
implements _$$_RecipeCopyWith<$Res> {
__$$_RecipeCopyWithImpl(_$_Recipe _value, $Res Function(_$_Recipe) _then)
- : super(_value, (v) => _then(v as _$_Recipe));
-
- @override
- _$_Recipe get _value => super._value as _$_Recipe;
+ : super(_value, _then);
+ @pragma('vm:prefer-inline')
@override
$Res call({
- Object? id = freezed,
- Object? ingridents = freezed,
- Object? ingridents_in_arabic = freezed,
- Object? directions = freezed,
- Object? patient = freezed,
- Object? patient_in_arabic = freezed,
- Object? directions_in_arabic = freezed,
- Object? name = freezed,
- Object? name_in_arabic = freezed,
- Object? imageURL = freezed,
- Object? diff = freezed,
- Object? isVegetarian = freezed,
- Object? time_taken = freezed,
- Object? calories = freezed,
- Object? video = freezed,
- Object? video_in_arabic = freezed,
- Object? created_at = freezed,
+ Object? id = null,
+ Object? ingridents = null,
+ Object? directions = null,
+ Object? patient = null,
+ Object? name = null,
+ Object? imageURL = null,
+ Object? difficulty = null,
+ Object? isVegetarian = null,
+ Object? difficulty_image = null,
+ Object? time_taken = null,
+ Object? calories = null,
+ Object? video = null,
+ Object? created_at = null,
}) {
return _then(_$_Recipe(
- id == freezed
+ null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
- ingridents == freezed
+ null == ingridents
? _value._ingridents
: ingridents // ignore: cast_nullable_to_non_nullable
as List,
- ingridents_in_arabic == freezed
- ? _value._ingridents_in_arabic
- : ingridents_in_arabic // ignore: cast_nullable_to_non_nullable
- as List,
- directions == freezed
+ null == directions
? _value._directions
: directions // ignore: cast_nullable_to_non_nullable
as List,
- patient == freezed
+ null == patient
? _value.patient
: patient // ignore: cast_nullable_to_non_nullable
as String,
- patient_in_arabic == freezed
- ? _value.patient_in_arabic
- : patient_in_arabic // ignore: cast_nullable_to_non_nullable
- as String,
- directions_in_arabic == freezed
- ? _value._directions_in_arabic
- : directions_in_arabic // ignore: cast_nullable_to_non_nullable
- as List,
- name == freezed
+ null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
- name_in_arabic == freezed
- ? _value.name_in_arabic
- : name_in_arabic // ignore: cast_nullable_to_non_nullable
- as String,
- imageURL == freezed
+ null == imageURL
? _value.imageURL
: imageURL // ignore: cast_nullable_to_non_nullable
as String,
- diff == freezed
- ? _value.diff
- : diff // ignore: cast_nullable_to_non_nullable
+ null == difficulty
+ ? _value.difficulty
+ : difficulty // ignore: cast_nullable_to_non_nullable
as String,
- isVegetarian == freezed
+ null == isVegetarian
? _value.isVegetarian
: isVegetarian // ignore: cast_nullable_to_non_nullable
as bool,
- time_taken == freezed
+ null == difficulty_image
+ ? _value.difficulty_image
+ : difficulty_image // ignore: cast_nullable_to_non_nullable
+ as String,
+ null == time_taken
? _value.time_taken
: time_taken // ignore: cast_nullable_to_non_nullable
as int,
- calories == freezed
+ null == calories
? _value.calories
: calories // ignore: cast_nullable_to_non_nullable
as int,
- video == freezed
+ null == video
? _value.video
: video // ignore: cast_nullable_to_non_nullable
as String,
- video_in_arabic == freezed
- ? _value.video_in_arabic
- : video_in_arabic // ignore: cast_nullable_to_non_nullable
- as String,
- created_at == freezed
+ null == created_at
? _value.created_at
: created_at // ignore: cast_nullable_to_non_nullable
as String,
@@ -301,25 +253,19 @@ class _$_Recipe implements _Recipe {
const _$_Recipe(
this.id,
final List ingridents,
- final List ingridents_in_arabic,
final List directions,
this.patient,
- this.patient_in_arabic,
- final List directions_in_arabic,
this.name,
- this.name_in_arabic,
this.imageURL,
- this.diff,
+ this.difficulty,
this.isVegetarian,
+ this.difficulty_image,
this.time_taken,
this.calories,
this.video,
- this.video_in_arabic,
this.created_at)
: _ingridents = ingridents,
- _ingridents_in_arabic = ingridents_in_arabic,
- _directions = directions,
- _directions_in_arabic = directions_in_arabic;
+ _directions = directions;
factory _$_Recipe.fromJson(Map json) =>
_$$_RecipeFromJson(json);
@@ -329,59 +275,43 @@ class _$_Recipe implements _Recipe {
final List _ingridents;
@override
List get ingridents {
+ if (_ingridents is EqualUnmodifiableListView) return _ingridents;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_ingridents);
}
- final List _ingridents_in_arabic;
- @override
- List get ingridents_in_arabic {
- // ignore: implicit_dynamic_type
- return EqualUnmodifiableListView(_ingridents_in_arabic);
- }
-
final List _directions;
@override
List get directions {
+ if (_directions is EqualUnmodifiableListView) return _directions;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_directions);
}
@override
final String patient;
- @override
- final String patient_in_arabic;
- final List _directions_in_arabic;
- @override
- List get directions_in_arabic {
- // ignore: implicit_dynamic_type
- return EqualUnmodifiableListView(_directions_in_arabic);
- }
-
@override
final String name;
@override
- final String name_in_arabic;
- @override
final String imageURL;
@override
- final String diff;
+ final String difficulty;
@override
final bool isVegetarian;
@override
+ final String difficulty_image;
+ @override
final int time_taken;
@override
final int calories;
@override
final String video;
@override
- final String video_in_arabic;
- @override
final String created_at;
@override
String toString() {
- return 'Recipe(id: $id, ingridents: $ingridents, ingridents_in_arabic: $ingridents_in_arabic, directions: $directions, patient: $patient, patient_in_arabic: $patient_in_arabic, directions_in_arabic: $directions_in_arabic, name: $name, name_in_arabic: $name_in_arabic, imageURL: $imageURL, diff: $diff, isVegetarian: $isVegetarian, time_taken: $time_taken, calories: $calories, video: $video, video_in_arabic: $video_in_arabic, created_at: $created_at)';
+ return 'Recipe(id: $id, ingridents: $ingridents, directions: $directions, patient: $patient, name: $name, imageURL: $imageURL, difficulty: $difficulty, isVegetarian: $isVegetarian, difficulty_image: $difficulty_image, time_taken: $time_taken, calories: $calories, video: $video, created_at: $created_at)';
}
@override
@@ -389,59 +319,51 @@ class _$_Recipe implements _Recipe {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$_Recipe &&
- const DeepCollectionEquality().equals(other.id, id) &&
+ (identical(other.id, id) || other.id == id) &&
const DeepCollectionEquality()
.equals(other._ingridents, _ingridents) &&
- const DeepCollectionEquality()
- .equals(other._ingridents_in_arabic, _ingridents_in_arabic) &&
const DeepCollectionEquality()
.equals(other._directions, _directions) &&
- const DeepCollectionEquality().equals(other.patient, patient) &&
- const DeepCollectionEquality()
- .equals(other.patient_in_arabic, patient_in_arabic) &&
- const DeepCollectionEquality()
- .equals(other._directions_in_arabic, _directions_in_arabic) &&
- const DeepCollectionEquality().equals(other.name, name) &&
- const DeepCollectionEquality()
- .equals(other.name_in_arabic, name_in_arabic) &&
- const DeepCollectionEquality().equals(other.imageURL, imageURL) &&
- const DeepCollectionEquality().equals(other.diff, diff) &&
- const DeepCollectionEquality()
- .equals(other.isVegetarian, isVegetarian) &&
- const DeepCollectionEquality()
- .equals(other.time_taken, time_taken) &&
- const DeepCollectionEquality().equals(other.calories, calories) &&
- const DeepCollectionEquality().equals(other.video, video) &&
- const DeepCollectionEquality()
- .equals(other.video_in_arabic, video_in_arabic) &&
- const DeepCollectionEquality()
- .equals(other.created_at, created_at));
+ (identical(other.patient, patient) || other.patient == patient) &&
+ (identical(other.name, name) || other.name == name) &&
+ (identical(other.imageURL, imageURL) ||
+ other.imageURL == imageURL) &&
+ (identical(other.difficulty, difficulty) ||
+ other.difficulty == difficulty) &&
+ (identical(other.isVegetarian, isVegetarian) ||
+ other.isVegetarian == isVegetarian) &&
+ (identical(other.difficulty_image, difficulty_image) ||
+ other.difficulty_image == difficulty_image) &&
+ (identical(other.time_taken, time_taken) ||
+ other.time_taken == time_taken) &&
+ (identical(other.calories, calories) ||
+ other.calories == calories) &&
+ (identical(other.video, video) || other.video == video) &&
+ (identical(other.created_at, created_at) ||
+ other.created_at == created_at));
}
@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(
runtimeType,
- const DeepCollectionEquality().hash(id),
+ id,
const DeepCollectionEquality().hash(_ingridents),
- const DeepCollectionEquality().hash(_ingridents_in_arabic),
const DeepCollectionEquality().hash(_directions),
- const DeepCollectionEquality().hash(patient),
- const DeepCollectionEquality().hash(patient_in_arabic),
- const DeepCollectionEquality().hash(_directions_in_arabic),
- const DeepCollectionEquality().hash(name),
- const DeepCollectionEquality().hash(name_in_arabic),
- const DeepCollectionEquality().hash(imageURL),
- const DeepCollectionEquality().hash(diff),
- const DeepCollectionEquality().hash(isVegetarian),
- const DeepCollectionEquality().hash(time_taken),
- const DeepCollectionEquality().hash(calories),
- const DeepCollectionEquality().hash(video),
- const DeepCollectionEquality().hash(video_in_arabic),
- const DeepCollectionEquality().hash(created_at));
+ patient,
+ name,
+ imageURL,
+ difficulty,
+ isVegetarian,
+ difficulty_image,
+ time_taken,
+ calories,
+ video,
+ created_at);
@JsonKey(ignore: true)
@override
+ @pragma('vm:prefer-inline')
_$$_RecipeCopyWith<_$_Recipe> get copyWith =>
__$$_RecipeCopyWithImpl<_$_Recipe>(this, _$identity);
@@ -457,20 +379,16 @@ abstract class _Recipe implements Recipe {
const factory _Recipe(
final int id,
final List ingridents,
- final List