diff --git a/client-mobile/.gitignore b/client-mobile/.gitignore new file mode 100644 index 0000000..24476c5 --- /dev/null +++ b/client-mobile/.gitignore @@ -0,0 +1,44 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +/build/ + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/client-mobile/.metadata b/client-mobile/.metadata new file mode 100644 index 0000000..0b450df --- /dev/null +++ b/client-mobile/.metadata @@ -0,0 +1,20 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: 5f120583730cedfc49a0e0872e3e1ac7a0a3c8eb + channel: stable + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 5f120583730cedfc49a0e0872e3e1ac7a0a3c8eb + base_revision: 5f120583730cedfc49a0e0872e3e1ac7a0a3c8eb + - platform: android + create_revision: 5f120583730cedfc49a0e0872e3e1ac7a0a3c8eb + base_revision: 5f120583730cedfc49a0e0872e3e1ac7a0a3c8eb diff --git a/client-mobile/GETTING_STARTED.md b/client-mobile/GETTING_STARTED.md new file mode 100644 index 0000000..995429f --- /dev/null +++ b/client-mobile/GETTING_STARTED.md @@ -0,0 +1,125 @@ +# Инструкция по запуску проекта + +## Предварительные требования + +1. **Flutter SDK** (версия 3.0.0 или выше) + - Установите Flutter: https://docs.flutter.dev/get-started/install + - Проверьте установку: `flutter doctor` + +2. **Android Studio** или **VS Code** с Flutter плагином + +3. **Android SDK** (для сборки под Android) + - MinSDK: 21 + - TargetSDK: 34 + - CompileSDK: 34 + +## Установка зависимостей + +```bash +cd client-mobile +flutter pub get +``` + +## Генерация кода + +Проект использует code generation для: +- Freezed (immutable модели) +- AutoRoute (навигация) +- Isar (база данных) + +```bash +dart run build_runner build --delete-conflicting-outputs +``` + +Для автоматической генерации при изменениях: +```bash +dart run build_runner watch --delete-conflicting-outputs +``` + +## Запуск приложения + +### Android +```bash +flutter run +``` + +### Сборка релиза +```bash +flutter build apk --release +``` + +## Структура проекта + +``` +lib/ +├── core/ # Общие компоненты +│ ├── constants/ # Константы приложения +│ ├── errors/ # Обработка ошибок +│ ├── network/ # Сетевой клиент (Dio) +│ └── theme/ # Темы оформления +├── features/ # Функциональные модули +│ ├── auth/ # Аутентификация +│ │ ├── data/ # Data layer +│ │ ├── domain/ # Domain layer +│ │ └── presentation/ # UI layer (BLoC, страницы) +│ ├── chat/ # Чаты +│ ├── profile/ # Профиль +│ └── settings/ # Настройки +└── internal/ # Внутренняя конфигурация + ├── di/ # Dependency Injection (GetIt) + └── router/ # Навигация +``` + +## Архитектура + +Проект следует принципам **Clean Architecture**: + +- **Domain Layer**: Бизнес-логика, entities, use cases, repository interfaces +- **Data Layer**: Реализации репозиториев, datasources, модели +- **Presentation Layer**: UI, BLoC, страницы, виджеты + +## State Management + +Используется **flutter_bloc** для управления состоянием: +- Каждый feature имеет свой BLoC +- События и состояния генерируются через Freezed +- DI через GetIt + +## Навигация + +Используется **auto_route** для декларативной навигации. + +## База данных + +Используется **Isar** - быстрая NoSQL база данных для Flutter. + +## Сетевые запросы + +- **Dio** для REST API запросов +- **SignalR** для real-time обновлений + +## Тестирование + +```bash +flutter test +``` + +## Полезные команды + +```bash +# Анализ кода +flutter analyze + +# Форматирование +dart format . + +# Очистка +flutter clean + +# Проверка зависимостей +flutter pub outdated +``` + +## Контакты + +Для вопросов и предложений обращайтесь к команде разработки. diff --git a/client-mobile/README.md b/client-mobile/README.md new file mode 100644 index 0000000..711e161 --- /dev/null +++ b/client-mobile/README.md @@ -0,0 +1,51 @@ +# Messenger App + +A Telegram-like mobile messenger application built with Flutter using Clean Architecture. + +## Architecture + +This project follows Clean Architecture principles with the following structure: + +``` +lib/ +├── core/ # Core utilities, network, errors, theme +├── features/ # Feature modules (auth, chat, profile, settings) +│ └── [feature]/ +│ ├── data/ # Data layer (repositories, datasources) +│ ├── domain/ # Domain layer (entities, usecases, repository interfaces) +│ └── presentation/ # UI layer (bloc, pages, widgets) +└── internal/ # App configuration, DI, routing +``` + +## Dependencies + +- **State Management**: flutter_bloc, bloc +- **Architecture & DI**: get_it, injectable, freezed_annotation +- **Network & Real-time**: dio, signalr_netcore +- **Navigation**: auto_route +- **Database**: isar, isar_flutter_libs + +## Setup + +1. Install Flutter dependencies: + ```bash + flutter pub get + ``` + +2. Generate code: + ```bash + dart run build_runner build --delete-conflicting-outputs + ``` + +3. Run the app: + ```bash + flutter run + ``` + +## Features + +- Authentication (Login/Register) +- Real-time Chat +- Contacts +- Profile Management +- Settings diff --git a/client-mobile/analysis_options.yaml b/client-mobile/analysis_options.yaml new file mode 100644 index 0000000..30e5539 --- /dev/null +++ b/client-mobile/analysis_options.yaml @@ -0,0 +1,8 @@ +include: package:flutter_lints/flutter.yaml + +linter: + rules: + prefer_const_constructors: true + prefer_const_declarations: true + avoid_print: false + prefer_single_quotes: true diff --git a/client-mobile/android/.gitignore b/client-mobile/android/.gitignore new file mode 100644 index 0000000..bc2100d --- /dev/null +++ b/client-mobile/android/.gitignore @@ -0,0 +1,7 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java diff --git a/client-mobile/android/app/build.gradle b/client-mobile/android/app/build.gradle new file mode 100644 index 0000000..ce1ce77 --- /dev/null +++ b/client-mobile/android/app/build.gradle @@ -0,0 +1,69 @@ +plugins { + id "com.android.application" + id "kotlin-android" + id "dev.flutter.flutter-gradle-plugin" +} + +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +android { + namespace "com.example.messenger_app" + compileSdkVersion 35 + ndkVersion flutter.ndkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 + } + + kotlinOptions { + jvmTarget = '17' + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + + defaultConfig { + applicationId "com.example.messenger_app" + minSdkVersion flutter.minSdkVersion + targetSdkVersion 35 + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + multiDexEnabled true + } + + packagingOptions { + resources { + excludes += '/META-INF/{AL2.0,LGPL2.1}' + } + } + + buildTypes { + release { + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} + +dependencies {} diff --git a/client-mobile/android/app/src/main/AndroidManifest.xml b/client-mobile/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7aa4ea5 --- /dev/null +++ b/client-mobile/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + diff --git a/client-mobile/android/app/src/main/kotlin/com/example/messenger_app/MainActivity.kt b/client-mobile/android/app/src/main/kotlin/com/example/messenger_app/MainActivity.kt new file mode 100644 index 0000000..cacc070 --- /dev/null +++ b/client-mobile/android/app/src/main/kotlin/com/example/messenger_app/MainActivity.kt @@ -0,0 +1,5 @@ +package com.example.messenger_app + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() diff --git a/client-mobile/android/app/src/main/res/drawable/launch_background.xml b/client-mobile/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 0000000..5782842 --- /dev/null +++ b/client-mobile/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,4 @@ + + + + diff --git a/client-mobile/android/app/src/main/res/mipmap-hdpi/ic_launcher.xml b/client-mobile/android/app/src/main/res/mipmap-hdpi/ic_launcher.xml new file mode 100644 index 0000000..a917906 --- /dev/null +++ b/client-mobile/android/app/src/main/res/mipmap-hdpi/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + diff --git a/client-mobile/android/app/src/main/res/mipmap-mdpi/ic_launcher.xml b/client-mobile/android/app/src/main/res/mipmap-mdpi/ic_launcher.xml new file mode 100644 index 0000000..a917906 --- /dev/null +++ b/client-mobile/android/app/src/main/res/mipmap-mdpi/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + diff --git a/client-mobile/android/app/src/main/res/mipmap-xhdpi/ic_launcher.xml b/client-mobile/android/app/src/main/res/mipmap-xhdpi/ic_launcher.xml new file mode 100644 index 0000000..a917906 --- /dev/null +++ b/client-mobile/android/app/src/main/res/mipmap-xhdpi/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + diff --git a/client-mobile/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.xml b/client-mobile/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.xml new file mode 100644 index 0000000..a917906 --- /dev/null +++ b/client-mobile/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + diff --git a/client-mobile/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.xml b/client-mobile/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.xml new file mode 100644 index 0000000..a917906 --- /dev/null +++ b/client-mobile/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + diff --git a/client-mobile/android/app/src/main/res/values/styles.xml b/client-mobile/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..ff81bae --- /dev/null +++ b/client-mobile/android/app/src/main/res/values/styles.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/client-mobile/android/build.gradle b/client-mobile/android/build.gradle new file mode 100644 index 0000000..619f1e0 --- /dev/null +++ b/client-mobile/android/build.gradle @@ -0,0 +1,25 @@ +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = '../build' + +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" + afterEvaluate { project -> + if (project.hasProperty("android")) { + project.android { + if (namespace == null) { + namespace project.group + } + } + } + } +} + +tasks.register("clean", Delete) { + delete rootProject.buildDir +} diff --git a/client-mobile/android/gradle.properties b/client-mobile/android/gradle.properties new file mode 100644 index 0000000..2597170 --- /dev/null +++ b/client-mobile/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError +android.useAndroidX=true +android.enableJetifier=true diff --git a/client-mobile/android/gradle/wrapper/gradle-wrapper.properties b/client-mobile/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..3c85cfe --- /dev/null +++ b/client-mobile/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip diff --git a/client-mobile/android/settings.gradle b/client-mobile/android/settings.gradle new file mode 100644 index 0000000..4f52071 --- /dev/null +++ b/client-mobile/android/settings.gradle @@ -0,0 +1,25 @@ +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + }() + + includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") + + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + +plugins { + id "dev.flutter.flutter-plugin-loader" version "1.0.0" + id "com.android.application" version "8.6.0" apply false + id "org.jetbrains.kotlin.android" version "2.1.0" apply false +} + +include ":app" diff --git a/client-mobile/ios/Flutter/Generated.xcconfig b/client-mobile/ios/Flutter/Generated.xcconfig new file mode 100644 index 0000000..e2bb368 --- /dev/null +++ b/client-mobile/ios/Flutter/Generated.xcconfig @@ -0,0 +1,14 @@ +// This is a generated file; do not edit or check into version control. +FLUTTER_ROOT=C:\src\flutter +FLUTTER_APPLICATION_PATH=E:\GIT\forkmessager\client-mobile +COCOAPODS_PARALLEL_CODE_SIGN=true +FLUTTER_TARGET=lib\main.dart +FLUTTER_BUILD_DIR=build +FLUTTER_BUILD_NAME=1.0.0 +FLUTTER_BUILD_NUMBER=1 +EXCLUDED_ARCHS[sdk=iphonesimulator*]=i386 +EXCLUDED_ARCHS[sdk=iphoneos*]=armv7 +DART_OBFUSCATION=false +TRACK_WIDGET_CREATION=true +TREE_SHAKE_ICONS=false +PACKAGE_CONFIG=.dart_tool/package_config.json diff --git a/client-mobile/ios/Flutter/ephemeral/flutter_lldb_helper.py b/client-mobile/ios/Flutter/ephemeral/flutter_lldb_helper.py new file mode 100644 index 0000000..a88caf9 --- /dev/null +++ b/client-mobile/ios/Flutter/ephemeral/flutter_lldb_helper.py @@ -0,0 +1,32 @@ +# +# Generated file, do not edit. +# + +import lldb + +def handle_new_rx_page(frame: lldb.SBFrame, bp_loc, extra_args, intern_dict): + """Intercept NOTIFY_DEBUGGER_ABOUT_RX_PAGES and touch the pages.""" + base = frame.register["x0"].GetValueAsAddress() + page_len = frame.register["x1"].GetValueAsUnsigned() + + # Note: NOTIFY_DEBUGGER_ABOUT_RX_PAGES will check contents of the + # first page to see if handled it correctly. This makes diagnosing + # misconfiguration (e.g. missing breakpoint) easier. + data = bytearray(page_len) + data[0:8] = b'IHELPED!' + + error = lldb.SBError() + frame.GetThread().GetProcess().WriteMemory(base, data, error) + if not error.Success(): + print(f'Failed to write into {base}[+{page_len}]', error) + return + +def __lldb_init_module(debugger: lldb.SBDebugger, _): + target = debugger.GetDummyTarget() + # Caveat: must use BreakpointCreateByRegEx here and not + # BreakpointCreateByName. For some reasons callback function does not + # get carried over from dummy target for the later. + bp = target.BreakpointCreateByRegex("^NOTIFY_DEBUGGER_ABOUT_RX_PAGES$") + bp.SetScriptCallbackFunction('{}.handle_new_rx_page'.format(__name__)) + bp.SetAutoContinue(True) + print("-- LLDB integration loaded --") diff --git a/client-mobile/ios/Flutter/ephemeral/flutter_lldbinit b/client-mobile/ios/Flutter/ephemeral/flutter_lldbinit new file mode 100644 index 0000000..e3ba6fb --- /dev/null +++ b/client-mobile/ios/Flutter/ephemeral/flutter_lldbinit @@ -0,0 +1,5 @@ +# +# Generated file, do not edit. +# + +command script import --relative-to-command-file flutter_lldb_helper.py diff --git a/client-mobile/ios/Flutter/flutter_export_environment.sh b/client-mobile/ios/Flutter/flutter_export_environment.sh new file mode 100644 index 0000000..be71c03 --- /dev/null +++ b/client-mobile/ios/Flutter/flutter_export_environment.sh @@ -0,0 +1,13 @@ +#!/bin/sh +# This is a generated file; do not edit or check into version control. +export "FLUTTER_ROOT=C:\src\flutter" +export "FLUTTER_APPLICATION_PATH=E:\GIT\forkmessager\client-mobile" +export "COCOAPODS_PARALLEL_CODE_SIGN=true" +export "FLUTTER_TARGET=lib\main.dart" +export "FLUTTER_BUILD_DIR=build" +export "FLUTTER_BUILD_NAME=1.0.0" +export "FLUTTER_BUILD_NUMBER=1" +export "DART_OBFUSCATION=false" +export "TRACK_WIDGET_CREATION=true" +export "TREE_SHAKE_ICONS=false" +export "PACKAGE_CONFIG=.dart_tool/package_config.json" diff --git a/client-mobile/ios/Runner/AppDelegate.swift b/client-mobile/ios/Runner/AppDelegate.swift new file mode 100644 index 0000000..70693e4 --- /dev/null +++ b/client-mobile/ios/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import UIKit +import Flutter + +@UIApplicationMain +@objc class AppDelegate: FlutterAppDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } +} diff --git a/client-mobile/ios/Runner/GeneratedPluginRegistrant.h b/client-mobile/ios/Runner/GeneratedPluginRegistrant.h new file mode 100644 index 0000000..7a89092 --- /dev/null +++ b/client-mobile/ios/Runner/GeneratedPluginRegistrant.h @@ -0,0 +1,19 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GeneratedPluginRegistrant_h +#define GeneratedPluginRegistrant_h + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface GeneratedPluginRegistrant : NSObject ++ (void)registerWithRegistry:(NSObject*)registry; +@end + +NS_ASSUME_NONNULL_END +#endif /* GeneratedPluginRegistrant_h */ diff --git a/client-mobile/ios/Runner/GeneratedPluginRegistrant.m b/client-mobile/ios/Runner/GeneratedPluginRegistrant.m new file mode 100644 index 0000000..35361ae --- /dev/null +++ b/client-mobile/ios/Runner/GeneratedPluginRegistrant.m @@ -0,0 +1,28 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#import "GeneratedPluginRegistrant.h" + +#if __has_include() +#import +#else +@import isar_flutter_libs; +#endif + +#if __has_include() +#import +#else +@import shared_preferences_foundation; +#endif + +@implementation GeneratedPluginRegistrant + ++ (void)registerWithRegistry:(NSObject*)registry { + [IsarFlutterLibsPlugin registerWithRegistrar:[registry registrarForPlugin:@"IsarFlutterLibsPlugin"]]; + [SharedPreferencesPlugin registerWithRegistrar:[registry registrarForPlugin:@"SharedPreferencesPlugin"]]; +} + +@end diff --git a/client-mobile/l10n.yaml b/client-mobile/l10n.yaml new file mode 100644 index 0000000..3a803ff --- /dev/null +++ b/client-mobile/l10n.yaml @@ -0,0 +1,4 @@ +arb-dir: l10n +template-arb-file: app_ru.arb +output-localization-file: app_localizations.dart +output-class: AppLocalizations diff --git a/client-mobile/l10n/app_en.arb b/client-mobile/l10n/app_en.arb new file mode 100644 index 0000000..ae47019 --- /dev/null +++ b/client-mobile/l10n/app_en.arb @@ -0,0 +1,51 @@ +{ + "@@locale": "en", + "appTitle": "Messenger", + "chats": "Chats", + "contacts": "Contacts", + "settings": "Settings", + "login": "Login", + "email": "Email", + "password": "Password", + "name": "Name", + "loginButton": "Sign In", + "register": "Register", + "noAccount": "No account? Sign up", + "logout": "Sign Out", + "serverSettings": "Server Settings", + "apiUrl": "API URL", + "apiUrlHint": "https://api.example.com", + "save": "Save", + "serverConfig": "Server Configuration", + "system": "System", + "stories": "Stories", + "chatsModule": "Chats", + "messages": "Messages", + "calls": "Calls", + "klipy": "Klipy", + "import": "Import", + "federation": "Federation", + "domainUrl": "Domain", + "enableRegistration": "Registration Enabled", + "enabled": "Enabled", + "disabled": "Disabled", + "language": "Language", + "russian": "Русский", + "english": "English", + "notifications": "Notifications", + "privacy": "Privacy", + "soundsAndVibration": "Sounds & Vibration", + "dataAndStorage": "Data & Storage", + "aboutApp": "About App", + "help": "Help", + "version": "Version", + "loading": "Loading...", + "error": "Error", + "retry": "Retry", + "noChats": "No chats yet", + "inDevelopment": "In development", + "user": "User", + "edit": "Edit", + "serverConnectionError": "Server connection error", + "settingsSaved": "Settings saved" +} diff --git a/client-mobile/l10n/app_localizations.dart b/client-mobile/l10n/app_localizations.dart new file mode 100644 index 0000000..044ad11 --- /dev/null +++ b/client-mobile/l10n/app_localizations.dart @@ -0,0 +1,421 @@ +import 'dart:async'; + +import 'package:flutter/foundation.dart'; +import 'package:flutter/widgets.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; +import 'package:intl/intl.dart' as intl; + +import 'app_localizations_en.dart'; +import 'app_localizations_ru.dart'; + +// ignore_for_file: type=lint + +/// Callers can lookup localized strings with an instance of AppLocalizations +/// returned by `AppLocalizations.of(context)`. +/// +/// Applications need to include `AppLocalizations.delegate()` in their app's +/// `localizationDelegates` list, and the locales they support in the app's +/// `supportedLocales` list. For example: +/// +/// ```dart +/// import 'l10n/app_localizations.dart'; +/// +/// return MaterialApp( +/// localizationsDelegates: AppLocalizations.localizationsDelegates, +/// supportedLocales: AppLocalizations.supportedLocales, +/// home: MyApplicationHome(), +/// ); +/// ``` +/// +/// ## Update pubspec.yaml +/// +/// Please make sure to update your pubspec.yaml to include the following +/// packages: +/// +/// ```yaml +/// dependencies: +/// # Internationalization support. +/// flutter_localizations: +/// sdk: flutter +/// intl: any # Use the pinned version from flutter_localizations +/// +/// # Rest of dependencies +/// ``` +/// +/// ## iOS Applications +/// +/// iOS applications define key application metadata, including supported +/// locales, in an Info.plist file that is built into the application bundle. +/// To configure the locales supported by your app, you’ll need to edit this +/// file. +/// +/// First, open your project’s ios/Runner.xcworkspace Xcode workspace file. +/// Then, in the Project Navigator, open the Info.plist file under the Runner +/// project’s Runner folder. +/// +/// Next, select the Information Property List item, select Add Item from the +/// Editor menu, then select Localizations from the pop-up menu. +/// +/// Select and expand the newly-created Localizations item then, for each +/// locale your application supports, add a new item and select the locale +/// you wish to add from the pop-up menu in the Value field. This list should +/// be consistent with the languages listed in the AppLocalizations.supportedLocales +/// property. +abstract class AppLocalizations { + AppLocalizations(String locale) + : localeName = intl.Intl.canonicalizedLocale(locale.toString()); + + final String localeName; + + static AppLocalizations? of(BuildContext context) { + return Localizations.of(context, AppLocalizations); + } + + static const LocalizationsDelegate delegate = + _AppLocalizationsDelegate(); + + /// A list of this localizations delegate along with the default localizations + /// delegates. + /// + /// Returns a list of localizations delegates containing this delegate along with + /// GlobalMaterialLocalizations.delegate, GlobalCupertinoLocalizations.delegate, + /// and GlobalWidgetsLocalizations.delegate. + /// + /// Additional delegates can be added by appending to this list in + /// MaterialApp. This list does not have to be used at all if a custom list + /// of delegates is preferred or required. + static const List> localizationsDelegates = + >[ + delegate, + GlobalMaterialLocalizations.delegate, + GlobalCupertinoLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + ]; + + /// A list of this localizations delegate's supported locales. + static const List supportedLocales = [ + Locale('en'), + Locale('ru') + ]; + + /// No description provided for @appTitle. + /// + /// In ru, this message translates to: + /// **'Мессенджер'** + String get appTitle; + + /// No description provided for @chats. + /// + /// In ru, this message translates to: + /// **'Чаты'** + String get chats; + + /// No description provided for @contacts. + /// + /// In ru, this message translates to: + /// **'Контакты'** + String get contacts; + + /// No description provided for @settings. + /// + /// In ru, this message translates to: + /// **'Настройки'** + String get settings; + + /// No description provided for @login. + /// + /// In ru, this message translates to: + /// **'Вход'** + String get login; + + /// No description provided for @email. + /// + /// In ru, this message translates to: + /// **'Email'** + String get email; + + /// No description provided for @password. + /// + /// In ru, this message translates to: + /// **'Пароль'** + String get password; + + /// No description provided for @name. + /// + /// In ru, this message translates to: + /// **'Имя'** + String get name; + + /// No description provided for @loginButton. + /// + /// In ru, this message translates to: + /// **'Войти'** + String get loginButton; + + /// No description provided for @register. + /// + /// In ru, this message translates to: + /// **'Зарегистрироваться'** + String get register; + + /// No description provided for @noAccount. + /// + /// In ru, this message translates to: + /// **'Нет аккаунта? Зарегистрироваться'** + String get noAccount; + + /// No description provided for @logout. + /// + /// In ru, this message translates to: + /// **'Выйти из аккаунта'** + String get logout; + + /// No description provided for @serverSettings. + /// + /// In ru, this message translates to: + /// **'Настройки сервера'** + String get serverSettings; + + /// No description provided for @apiUrl. + /// + /// In ru, this message translates to: + /// **'Адрес API'** + String get apiUrl; + + /// No description provided for @apiUrlHint. + /// + /// In ru, this message translates to: + /// **'https://api.example.com'** + String get apiUrlHint; + + /// No description provided for @save. + /// + /// In ru, this message translates to: + /// **'Сохранить'** + String get save; + + /// No description provided for @serverConfig. + /// + /// In ru, this message translates to: + /// **'Конфигурация сервера'** + String get serverConfig; + + /// No description provided for @system. + /// + /// In ru, this message translates to: + /// **'Система'** + String get system; + + /// No description provided for @stories. + /// + /// In ru, this message translates to: + /// **'Истории'** + String get stories; + + /// No description provided for @chatsModule. + /// + /// In ru, this message translates to: + /// **'Чаты'** + String get chatsModule; + + /// No description provided for @messages. + /// + /// In ru, this message translates to: + /// **'Сообщения'** + String get messages; + + /// No description provided for @calls. + /// + /// In ru, this message translates to: + /// **'Звонки'** + String get calls; + + /// No description provided for @klipy. + /// + /// In ru, this message translates to: + /// **'Клипы'** + String get klipy; + + /// No description provided for @import. + /// + /// In ru, this message translates to: + /// **'Импорт'** + String get import; + + /// No description provided for @federation. + /// + /// In ru, this message translates to: + /// **'Федерация'** + String get federation; + + /// No description provided for @domainUrl. + /// + /// In ru, this message translates to: + /// **'Домен'** + String get domainUrl; + + /// No description provided for @enableRegistration. + /// + /// In ru, this message translates to: + /// **'Регистрация включена'** + String get enableRegistration; + + /// No description provided for @enabled. + /// + /// In ru, this message translates to: + /// **'Включено'** + String get enabled; + + /// No description provided for @disabled. + /// + /// In ru, this message translates to: + /// **'Отключено'** + String get disabled; + + /// No description provided for @language. + /// + /// In ru, this message translates to: + /// **'Язык'** + String get language; + + /// No description provided for @russian. + /// + /// In ru, this message translates to: + /// **'Русский'** + String get russian; + + /// No description provided for @english. + /// + /// In ru, this message translates to: + /// **'English'** + String get english; + + /// No description provided for @notifications. + /// + /// In ru, this message translates to: + /// **'Уведомления'** + String get notifications; + + /// No description provided for @privacy. + /// + /// In ru, this message translates to: + /// **'Конфиденциальность'** + String get privacy; + + /// No description provided for @soundsAndVibration. + /// + /// In ru, this message translates to: + /// **'Звуки и вибрация'** + String get soundsAndVibration; + + /// No description provided for @dataAndStorage. + /// + /// In ru, this message translates to: + /// **'Данные и память'** + String get dataAndStorage; + + /// No description provided for @aboutApp. + /// + /// In ru, this message translates to: + /// **'О приложении'** + String get aboutApp; + + /// No description provided for @help. + /// + /// In ru, this message translates to: + /// **'Помощь'** + String get help; + + /// No description provided for @version. + /// + /// In ru, this message translates to: + /// **'Версия'** + String get version; + + /// No description provided for @loading. + /// + /// In ru, this message translates to: + /// **'Загрузка...'** + String get loading; + + /// No description provided for @error. + /// + /// In ru, this message translates to: + /// **'Ошибка'** + String get error; + + /// No description provided for @retry. + /// + /// In ru, this message translates to: + /// **'Повторить'** + String get retry; + + /// No description provided for @noChats. + /// + /// In ru, this message translates to: + /// **'У вас пока нет чатов'** + String get noChats; + + /// No description provided for @inDevelopment. + /// + /// In ru, this message translates to: + /// **'Функция в разработке'** + String get inDevelopment; + + /// No description provided for @user. + /// + /// In ru, this message translates to: + /// **'Пользователь'** + String get user; + + /// No description provided for @edit. + /// + /// In ru, this message translates to: + /// **'Редактировать'** + String get edit; + + /// No description provided for @serverConnectionError. + /// + /// In ru, this message translates to: + /// **'Ошибка подключения к серверу'** + String get serverConnectionError; + + /// No description provided for @settingsSaved. + /// + /// In ru, this message translates to: + /// **'Настройки сохранены'** + String get settingsSaved; +} + +class _AppLocalizationsDelegate + extends LocalizationsDelegate { + const _AppLocalizationsDelegate(); + + @override + Future load(Locale locale) { + return SynchronousFuture(lookupAppLocalizations(locale)); + } + + @override + bool isSupported(Locale locale) => + ['en', 'ru'].contains(locale.languageCode); + + @override + bool shouldReload(_AppLocalizationsDelegate old) => false; +} + +AppLocalizations lookupAppLocalizations(Locale locale) { + // Lookup logic when only language code is specified. + switch (locale.languageCode) { + case 'en': + return AppLocalizationsEn(); + case 'ru': + return AppLocalizationsRu(); + } + + throw FlutterError( + 'AppLocalizations.delegate failed to load unsupported locale "$locale". This is likely ' + 'an issue with the localizations generation tool. Please file an issue ' + 'on GitHub with a reproducible sample app and the gen-l10n configuration ' + 'that was used.'); +} diff --git a/client-mobile/l10n/app_localizations_en.dart b/client-mobile/l10n/app_localizations_en.dart new file mode 100644 index 0000000..25720e4 --- /dev/null +++ b/client-mobile/l10n/app_localizations_en.dart @@ -0,0 +1,154 @@ +// ignore: unused_import +import 'package:intl/intl.dart' as intl; +import 'app_localizations.dart'; + +// ignore_for_file: type=lint + +/// The translations for English (`en`). +class AppLocalizationsEn extends AppLocalizations { + AppLocalizationsEn([String locale = 'en']) : super(locale); + + @override + String get appTitle => 'Messenger'; + + @override + String get chats => 'Chats'; + + @override + String get contacts => 'Contacts'; + + @override + String get settings => 'Settings'; + + @override + String get login => 'Login'; + + @override + String get email => 'Email'; + + @override + String get password => 'Password'; + + @override + String get name => 'Name'; + + @override + String get loginButton => 'Sign In'; + + @override + String get register => 'Register'; + + @override + String get noAccount => 'No account? Sign up'; + + @override + String get logout => 'Sign Out'; + + @override + String get serverSettings => 'Server Settings'; + + @override + String get apiUrl => 'API URL'; + + @override + String get apiUrlHint => 'https://api.example.com'; + + @override + String get save => 'Save'; + + @override + String get serverConfig => 'Server Configuration'; + + @override + String get system => 'System'; + + @override + String get stories => 'Stories'; + + @override + String get chatsModule => 'Chats'; + + @override + String get messages => 'Messages'; + + @override + String get calls => 'Calls'; + + @override + String get klipy => 'Klipy'; + + @override + String get import => 'Import'; + + @override + String get federation => 'Federation'; + + @override + String get domainUrl => 'Domain'; + + @override + String get enableRegistration => 'Registration Enabled'; + + @override + String get enabled => 'Enabled'; + + @override + String get disabled => 'Disabled'; + + @override + String get language => 'Language'; + + @override + String get russian => 'Русский'; + + @override + String get english => 'English'; + + @override + String get notifications => 'Notifications'; + + @override + String get privacy => 'Privacy'; + + @override + String get soundsAndVibration => 'Sounds & Vibration'; + + @override + String get dataAndStorage => 'Data & Storage'; + + @override + String get aboutApp => 'About App'; + + @override + String get help => 'Help'; + + @override + String get version => 'Version'; + + @override + String get loading => 'Loading...'; + + @override + String get error => 'Error'; + + @override + String get retry => 'Retry'; + + @override + String get noChats => 'No chats yet'; + + @override + String get inDevelopment => 'In development'; + + @override + String get user => 'User'; + + @override + String get edit => 'Edit'; + + @override + String get serverConnectionError => 'Server connection error'; + + @override + String get settingsSaved => 'Settings saved'; +} diff --git a/client-mobile/l10n/app_localizations_ru.dart b/client-mobile/l10n/app_localizations_ru.dart new file mode 100644 index 0000000..d3fab57 --- /dev/null +++ b/client-mobile/l10n/app_localizations_ru.dart @@ -0,0 +1,154 @@ +// ignore: unused_import +import 'package:intl/intl.dart' as intl; +import 'app_localizations.dart'; + +// ignore_for_file: type=lint + +/// The translations for Russian (`ru`). +class AppLocalizationsRu extends AppLocalizations { + AppLocalizationsRu([String locale = 'ru']) : super(locale); + + @override + String get appTitle => 'Мессенджер'; + + @override + String get chats => 'Чаты'; + + @override + String get contacts => 'Контакты'; + + @override + String get settings => 'Настройки'; + + @override + String get login => 'Вход'; + + @override + String get email => 'Email'; + + @override + String get password => 'Пароль'; + + @override + String get name => 'Имя'; + + @override + String get loginButton => 'Войти'; + + @override + String get register => 'Зарегистрироваться'; + + @override + String get noAccount => 'Нет аккаунта? Зарегистрироваться'; + + @override + String get logout => 'Выйти из аккаунта'; + + @override + String get serverSettings => 'Настройки сервера'; + + @override + String get apiUrl => 'Адрес API'; + + @override + String get apiUrlHint => 'https://api.example.com'; + + @override + String get save => 'Сохранить'; + + @override + String get serverConfig => 'Конфигурация сервера'; + + @override + String get system => 'Система'; + + @override + String get stories => 'Истории'; + + @override + String get chatsModule => 'Чаты'; + + @override + String get messages => 'Сообщения'; + + @override + String get calls => 'Звонки'; + + @override + String get klipy => 'Клипы'; + + @override + String get import => 'Импорт'; + + @override + String get federation => 'Федерация'; + + @override + String get domainUrl => 'Домен'; + + @override + String get enableRegistration => 'Регистрация включена'; + + @override + String get enabled => 'Включено'; + + @override + String get disabled => 'Отключено'; + + @override + String get language => 'Язык'; + + @override + String get russian => 'Русский'; + + @override + String get english => 'English'; + + @override + String get notifications => 'Уведомления'; + + @override + String get privacy => 'Конфиденциальность'; + + @override + String get soundsAndVibration => 'Звуки и вибрация'; + + @override + String get dataAndStorage => 'Данные и память'; + + @override + String get aboutApp => 'О приложении'; + + @override + String get help => 'Помощь'; + + @override + String get version => 'Версия'; + + @override + String get loading => 'Загрузка...'; + + @override + String get error => 'Ошибка'; + + @override + String get retry => 'Повторить'; + + @override + String get noChats => 'У вас пока нет чатов'; + + @override + String get inDevelopment => 'Функция в разработке'; + + @override + String get user => 'Пользователь'; + + @override + String get edit => 'Редактировать'; + + @override + String get serverConnectionError => 'Ошибка подключения к серверу'; + + @override + String get settingsSaved => 'Настройки сохранены'; +} diff --git a/client-mobile/l10n/app_ru.arb b/client-mobile/l10n/app_ru.arb new file mode 100644 index 0000000..af3143b --- /dev/null +++ b/client-mobile/l10n/app_ru.arb @@ -0,0 +1,51 @@ +{ + "@@locale": "ru", + "appTitle": "Мессенджер", + "chats": "Чаты", + "contacts": "Контакты", + "settings": "Настройки", + "login": "Вход", + "email": "Email", + "password": "Пароль", + "name": "Имя", + "loginButton": "Войти", + "register": "Зарегистрироваться", + "noAccount": "Нет аккаунта? Зарегистрироваться", + "logout": "Выйти из аккаунта", + "serverSettings": "Настройки сервера", + "apiUrl": "Адрес API", + "apiUrlHint": "https://api.example.com", + "save": "Сохранить", + "serverConfig": "Конфигурация сервера", + "system": "Система", + "stories": "Истории", + "chatsModule": "Чаты", + "messages": "Сообщения", + "calls": "Звонки", + "klipy": "Клипы", + "import": "Импорт", + "federation": "Федерация", + "domainUrl": "Домен", + "enableRegistration": "Регистрация включена", + "enabled": "Включено", + "disabled": "Отключено", + "language": "Язык", + "russian": "Русский", + "english": "English", + "notifications": "Уведомления", + "privacy": "Конфиденциальность", + "soundsAndVibration": "Звуки и вибрация", + "dataAndStorage": "Данные и память", + "aboutApp": "О приложении", + "help": "Помощь", + "version": "Версия", + "loading": "Загрузка...", + "error": "Ошибка", + "retry": "Повторить", + "noChats": "У вас пока нет чатов", + "inDevelopment": "Функция в разработке", + "user": "Пользователь", + "edit": "Редактировать", + "serverConnectionError": "Ошибка подключения к серверу", + "settingsSaved": "Настройки сохранены" +} diff --git a/client-mobile/lib/app.dart b/client-mobile/lib/app.dart new file mode 100644 index 0000000..9cf15ca --- /dev/null +++ b/client-mobile/lib/app.dart @@ -0,0 +1,56 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'core/theme/app_theme.dart'; +import 'features/auth/presentation/bloc/auth_bloc.dart'; +import 'features/auth/presentation/bloc/auth_event.dart'; +import 'features/chat/presentation/bloc/chat_bloc.dart'; +import 'features/chat/presentation/bloc/chat_event.dart'; +import 'features/settings/presentation/bloc/settings_bloc.dart'; +import 'features/settings/presentation/bloc/settings_event.dart'; +import 'features/settings/presentation/bloc/settings_state.dart'; +import 'features/settings/presentation/l10n/app_localizations.dart'; +import 'internal/di/injection_container.dart' as di; +import 'internal/router/main_screen.dart'; + +class MessengerApp extends StatelessWidget { + const MessengerApp({super.key}); + + @override + Widget build(BuildContext context) { + return MultiBlocProvider( + providers: [ + BlocProvider( + create: (_) => di.sl()..add(const SettingsEvent.started()), + ), + BlocProvider( + create: (_) => di.sl()..add(const AuthEvent.authChecked()), + ), + BlocProvider( + create: (_) => di.sl()..add(const ChatEvent.started()), + ), + ], + child: BlocBuilder( + builder: (context, settingsState) { + final languageCode = settingsState is SettingsLoaded + ? settingsState.languageCode + : 'ru'; + + return MaterialApp( + title: 'Messenger', + debugShowCheckedModeBanner: false, + theme: AppTheme.lightTheme, + darkTheme: AppTheme.darkTheme, + themeMode: ThemeMode.system, + locale: Locale(languageCode), + supportedLocales: const [ + Locale('ru'), + Locale('en'), + ], + localizationsDelegates: AppLocalizations.localizationsDelegates, + home: const MainScreen(), + ); + }, + ), + ); + } +} diff --git a/client-mobile/lib/core/constants/app_constants.dart b/client-mobile/lib/core/constants/app_constants.dart new file mode 100644 index 0000000..042673e --- /dev/null +++ b/client-mobile/lib/core/constants/app_constants.dart @@ -0,0 +1,25 @@ +class AppConstants { + AppConstants._(); + + // API + static const String apiBaseUrl = 'https://api.messenger.app'; + static const int apiTimeout = 30; + + // Storage + static const String sharedPrefsName = 'messenger_prefs'; + static const String tokenKey = 'auth_token'; + static const String refreshTokenKey = 'refresh_token'; + static const String userIdKey = 'user_id'; + + // Pagination + static const int pageSize = 20; + static const int defaultPageSize = 50; + + // Chat + static const int maxMessageLength = 4096; + static const int typingIndicatorTimeout = 3000; + + // Media + static const int maxImageSize = 10 * 1024 * 1024; // 10MB + static const int maxVideoSize = 100 * 1024 * 1024; // 100MB +} diff --git a/client-mobile/lib/core/constants/storage_keys.dart b/client-mobile/lib/core/constants/storage_keys.dart new file mode 100644 index 0000000..bac0c4b --- /dev/null +++ b/client-mobile/lib/core/constants/storage_keys.dart @@ -0,0 +1,9 @@ +class StorageKeys { + StorageKeys._(); + + static const String apiUrl = 'api_url'; + static const String languageCode = 'language_code'; + static const String serverConfig = 'server_config'; + static const String authToken = 'auth_token'; + static const String refreshToken = 'refresh_token'; +} diff --git a/client-mobile/lib/core/errors/errors.dart b/client-mobile/lib/core/errors/errors.dart new file mode 100644 index 0000000..642547a --- /dev/null +++ b/client-mobile/lib/core/errors/errors.dart @@ -0,0 +1,15 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'errors.freezed.dart'; + +@freezed +class AppError with _$AppError { + const factory AppError.unknown({String? message}) = UnknownError; + const factory AppError.network({String? message}) = NetworkError; + const factory AppError.unauthorized({String? message}) = UnauthorizedError; + const factory AppError.forbidden({String? message}) = ForbiddenError; + const factory AppError.notFound({String? message}) = NotFoundError; + const factory AppError.server({int? statusCode, String? message}) = ServerError; + const factory AppError.database({String? message}) = DatabaseError; + const factory AppError.validation({Map? fieldErrors}) = ValidationError; +} diff --git a/client-mobile/lib/core/errors/errors.freezed.dart b/client-mobile/lib/core/errors/errors.freezed.dart new file mode 100644 index 0000000..cfa537d --- /dev/null +++ b/client-mobile/lib/core/errors/errors.freezed.dart @@ -0,0 +1,1488 @@ +// 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 'errors.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#adding-getters-and-methods-to-our-models'); + +/// @nodoc +mixin _$AppError { + @optionalTypeArgs + TResult when({ + required TResult Function(String? message) unknown, + required TResult Function(String? message) network, + required TResult Function(String? message) unauthorized, + required TResult Function(String? message) forbidden, + required TResult Function(String? message) notFound, + required TResult Function(int? statusCode, String? message) server, + required TResult Function(String? message) database, + required TResult Function(Map? fieldErrors) validation, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String? message)? unknown, + TResult? Function(String? message)? network, + TResult? Function(String? message)? unauthorized, + TResult? Function(String? message)? forbidden, + TResult? Function(String? message)? notFound, + TResult? Function(int? statusCode, String? message)? server, + TResult? Function(String? message)? database, + TResult? Function(Map? fieldErrors)? validation, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String? message)? unknown, + TResult Function(String? message)? network, + TResult Function(String? message)? unauthorized, + TResult Function(String? message)? forbidden, + TResult Function(String? message)? notFound, + TResult Function(int? statusCode, String? message)? server, + TResult Function(String? message)? database, + TResult Function(Map? fieldErrors)? validation, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(UnknownError value) unknown, + required TResult Function(NetworkError value) network, + required TResult Function(UnauthorizedError value) unauthorized, + required TResult Function(ForbiddenError value) forbidden, + required TResult Function(NotFoundError value) notFound, + required TResult Function(ServerError value) server, + required TResult Function(DatabaseError value) database, + required TResult Function(ValidationError value) validation, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(UnknownError value)? unknown, + TResult? Function(NetworkError value)? network, + TResult? Function(UnauthorizedError value)? unauthorized, + TResult? Function(ForbiddenError value)? forbidden, + TResult? Function(NotFoundError value)? notFound, + TResult? Function(ServerError value)? server, + TResult? Function(DatabaseError value)? database, + TResult? Function(ValidationError value)? validation, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(UnknownError value)? unknown, + TResult Function(NetworkError value)? network, + TResult Function(UnauthorizedError value)? unauthorized, + TResult Function(ForbiddenError value)? forbidden, + TResult Function(NotFoundError value)? notFound, + TResult Function(ServerError value)? server, + TResult Function(DatabaseError value)? database, + TResult Function(ValidationError value)? validation, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $AppErrorCopyWith<$Res> { + factory $AppErrorCopyWith(AppError value, $Res Function(AppError) then) = + _$AppErrorCopyWithImpl<$Res, AppError>; +} + +/// @nodoc +class _$AppErrorCopyWithImpl<$Res, $Val extends AppError> + implements $AppErrorCopyWith<$Res> { + _$AppErrorCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; +} + +/// @nodoc +abstract class _$$UnknownErrorImplCopyWith<$Res> { + factory _$$UnknownErrorImplCopyWith( + _$UnknownErrorImpl value, $Res Function(_$UnknownErrorImpl) then) = + __$$UnknownErrorImplCopyWithImpl<$Res>; + @useResult + $Res call({String? message}); +} + +/// @nodoc +class __$$UnknownErrorImplCopyWithImpl<$Res> + extends _$AppErrorCopyWithImpl<$Res, _$UnknownErrorImpl> + implements _$$UnknownErrorImplCopyWith<$Res> { + __$$UnknownErrorImplCopyWithImpl( + _$UnknownErrorImpl _value, $Res Function(_$UnknownErrorImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? message = freezed, + }) { + return _then(_$UnknownErrorImpl( + message: freezed == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc + +class _$UnknownErrorImpl implements UnknownError { + const _$UnknownErrorImpl({this.message}); + + @override + final String? message; + + @override + String toString() { + return 'AppError.unknown(message: $message)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$UnknownErrorImpl && + (identical(other.message, message) || other.message == message)); + } + + @override + int get hashCode => Object.hash(runtimeType, message); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$UnknownErrorImplCopyWith<_$UnknownErrorImpl> get copyWith => + __$$UnknownErrorImplCopyWithImpl<_$UnknownErrorImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String? message) unknown, + required TResult Function(String? message) network, + required TResult Function(String? message) unauthorized, + required TResult Function(String? message) forbidden, + required TResult Function(String? message) notFound, + required TResult Function(int? statusCode, String? message) server, + required TResult Function(String? message) database, + required TResult Function(Map? fieldErrors) validation, + }) { + return unknown(message); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String? message)? unknown, + TResult? Function(String? message)? network, + TResult? Function(String? message)? unauthorized, + TResult? Function(String? message)? forbidden, + TResult? Function(String? message)? notFound, + TResult? Function(int? statusCode, String? message)? server, + TResult? Function(String? message)? database, + TResult? Function(Map? fieldErrors)? validation, + }) { + return unknown?.call(message); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String? message)? unknown, + TResult Function(String? message)? network, + TResult Function(String? message)? unauthorized, + TResult Function(String? message)? forbidden, + TResult Function(String? message)? notFound, + TResult Function(int? statusCode, String? message)? server, + TResult Function(String? message)? database, + TResult Function(Map? fieldErrors)? validation, + required TResult orElse(), + }) { + if (unknown != null) { + return unknown(message); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(UnknownError value) unknown, + required TResult Function(NetworkError value) network, + required TResult Function(UnauthorizedError value) unauthorized, + required TResult Function(ForbiddenError value) forbidden, + required TResult Function(NotFoundError value) notFound, + required TResult Function(ServerError value) server, + required TResult Function(DatabaseError value) database, + required TResult Function(ValidationError value) validation, + }) { + return unknown(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(UnknownError value)? unknown, + TResult? Function(NetworkError value)? network, + TResult? Function(UnauthorizedError value)? unauthorized, + TResult? Function(ForbiddenError value)? forbidden, + TResult? Function(NotFoundError value)? notFound, + TResult? Function(ServerError value)? server, + TResult? Function(DatabaseError value)? database, + TResult? Function(ValidationError value)? validation, + }) { + return unknown?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(UnknownError value)? unknown, + TResult Function(NetworkError value)? network, + TResult Function(UnauthorizedError value)? unauthorized, + TResult Function(ForbiddenError value)? forbidden, + TResult Function(NotFoundError value)? notFound, + TResult Function(ServerError value)? server, + TResult Function(DatabaseError value)? database, + TResult Function(ValidationError value)? validation, + required TResult orElse(), + }) { + if (unknown != null) { + return unknown(this); + } + return orElse(); + } +} + +abstract class UnknownError implements AppError { + const factory UnknownError({final String? message}) = _$UnknownErrorImpl; + + String? get message; + @JsonKey(ignore: true) + _$$UnknownErrorImplCopyWith<_$UnknownErrorImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$NetworkErrorImplCopyWith<$Res> { + factory _$$NetworkErrorImplCopyWith( + _$NetworkErrorImpl value, $Res Function(_$NetworkErrorImpl) then) = + __$$NetworkErrorImplCopyWithImpl<$Res>; + @useResult + $Res call({String? message}); +} + +/// @nodoc +class __$$NetworkErrorImplCopyWithImpl<$Res> + extends _$AppErrorCopyWithImpl<$Res, _$NetworkErrorImpl> + implements _$$NetworkErrorImplCopyWith<$Res> { + __$$NetworkErrorImplCopyWithImpl( + _$NetworkErrorImpl _value, $Res Function(_$NetworkErrorImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? message = freezed, + }) { + return _then(_$NetworkErrorImpl( + message: freezed == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc + +class _$NetworkErrorImpl implements NetworkError { + const _$NetworkErrorImpl({this.message}); + + @override + final String? message; + + @override + String toString() { + return 'AppError.network(message: $message)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$NetworkErrorImpl && + (identical(other.message, message) || other.message == message)); + } + + @override + int get hashCode => Object.hash(runtimeType, message); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$NetworkErrorImplCopyWith<_$NetworkErrorImpl> get copyWith => + __$$NetworkErrorImplCopyWithImpl<_$NetworkErrorImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String? message) unknown, + required TResult Function(String? message) network, + required TResult Function(String? message) unauthorized, + required TResult Function(String? message) forbidden, + required TResult Function(String? message) notFound, + required TResult Function(int? statusCode, String? message) server, + required TResult Function(String? message) database, + required TResult Function(Map? fieldErrors) validation, + }) { + return network(message); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String? message)? unknown, + TResult? Function(String? message)? network, + TResult? Function(String? message)? unauthorized, + TResult? Function(String? message)? forbidden, + TResult? Function(String? message)? notFound, + TResult? Function(int? statusCode, String? message)? server, + TResult? Function(String? message)? database, + TResult? Function(Map? fieldErrors)? validation, + }) { + return network?.call(message); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String? message)? unknown, + TResult Function(String? message)? network, + TResult Function(String? message)? unauthorized, + TResult Function(String? message)? forbidden, + TResult Function(String? message)? notFound, + TResult Function(int? statusCode, String? message)? server, + TResult Function(String? message)? database, + TResult Function(Map? fieldErrors)? validation, + required TResult orElse(), + }) { + if (network != null) { + return network(message); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(UnknownError value) unknown, + required TResult Function(NetworkError value) network, + required TResult Function(UnauthorizedError value) unauthorized, + required TResult Function(ForbiddenError value) forbidden, + required TResult Function(NotFoundError value) notFound, + required TResult Function(ServerError value) server, + required TResult Function(DatabaseError value) database, + required TResult Function(ValidationError value) validation, + }) { + return network(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(UnknownError value)? unknown, + TResult? Function(NetworkError value)? network, + TResult? Function(UnauthorizedError value)? unauthorized, + TResult? Function(ForbiddenError value)? forbidden, + TResult? Function(NotFoundError value)? notFound, + TResult? Function(ServerError value)? server, + TResult? Function(DatabaseError value)? database, + TResult? Function(ValidationError value)? validation, + }) { + return network?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(UnknownError value)? unknown, + TResult Function(NetworkError value)? network, + TResult Function(UnauthorizedError value)? unauthorized, + TResult Function(ForbiddenError value)? forbidden, + TResult Function(NotFoundError value)? notFound, + TResult Function(ServerError value)? server, + TResult Function(DatabaseError value)? database, + TResult Function(ValidationError value)? validation, + required TResult orElse(), + }) { + if (network != null) { + return network(this); + } + return orElse(); + } +} + +abstract class NetworkError implements AppError { + const factory NetworkError({final String? message}) = _$NetworkErrorImpl; + + String? get message; + @JsonKey(ignore: true) + _$$NetworkErrorImplCopyWith<_$NetworkErrorImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$UnauthorizedErrorImplCopyWith<$Res> { + factory _$$UnauthorizedErrorImplCopyWith(_$UnauthorizedErrorImpl value, + $Res Function(_$UnauthorizedErrorImpl) then) = + __$$UnauthorizedErrorImplCopyWithImpl<$Res>; + @useResult + $Res call({String? message}); +} + +/// @nodoc +class __$$UnauthorizedErrorImplCopyWithImpl<$Res> + extends _$AppErrorCopyWithImpl<$Res, _$UnauthorizedErrorImpl> + implements _$$UnauthorizedErrorImplCopyWith<$Res> { + __$$UnauthorizedErrorImplCopyWithImpl(_$UnauthorizedErrorImpl _value, + $Res Function(_$UnauthorizedErrorImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? message = freezed, + }) { + return _then(_$UnauthorizedErrorImpl( + message: freezed == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc + +class _$UnauthorizedErrorImpl implements UnauthorizedError { + const _$UnauthorizedErrorImpl({this.message}); + + @override + final String? message; + + @override + String toString() { + return 'AppError.unauthorized(message: $message)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$UnauthorizedErrorImpl && + (identical(other.message, message) || other.message == message)); + } + + @override + int get hashCode => Object.hash(runtimeType, message); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$UnauthorizedErrorImplCopyWith<_$UnauthorizedErrorImpl> get copyWith => + __$$UnauthorizedErrorImplCopyWithImpl<_$UnauthorizedErrorImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String? message) unknown, + required TResult Function(String? message) network, + required TResult Function(String? message) unauthorized, + required TResult Function(String? message) forbidden, + required TResult Function(String? message) notFound, + required TResult Function(int? statusCode, String? message) server, + required TResult Function(String? message) database, + required TResult Function(Map? fieldErrors) validation, + }) { + return unauthorized(message); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String? message)? unknown, + TResult? Function(String? message)? network, + TResult? Function(String? message)? unauthorized, + TResult? Function(String? message)? forbidden, + TResult? Function(String? message)? notFound, + TResult? Function(int? statusCode, String? message)? server, + TResult? Function(String? message)? database, + TResult? Function(Map? fieldErrors)? validation, + }) { + return unauthorized?.call(message); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String? message)? unknown, + TResult Function(String? message)? network, + TResult Function(String? message)? unauthorized, + TResult Function(String? message)? forbidden, + TResult Function(String? message)? notFound, + TResult Function(int? statusCode, String? message)? server, + TResult Function(String? message)? database, + TResult Function(Map? fieldErrors)? validation, + required TResult orElse(), + }) { + if (unauthorized != null) { + return unauthorized(message); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(UnknownError value) unknown, + required TResult Function(NetworkError value) network, + required TResult Function(UnauthorizedError value) unauthorized, + required TResult Function(ForbiddenError value) forbidden, + required TResult Function(NotFoundError value) notFound, + required TResult Function(ServerError value) server, + required TResult Function(DatabaseError value) database, + required TResult Function(ValidationError value) validation, + }) { + return unauthorized(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(UnknownError value)? unknown, + TResult? Function(NetworkError value)? network, + TResult? Function(UnauthorizedError value)? unauthorized, + TResult? Function(ForbiddenError value)? forbidden, + TResult? Function(NotFoundError value)? notFound, + TResult? Function(ServerError value)? server, + TResult? Function(DatabaseError value)? database, + TResult? Function(ValidationError value)? validation, + }) { + return unauthorized?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(UnknownError value)? unknown, + TResult Function(NetworkError value)? network, + TResult Function(UnauthorizedError value)? unauthorized, + TResult Function(ForbiddenError value)? forbidden, + TResult Function(NotFoundError value)? notFound, + TResult Function(ServerError value)? server, + TResult Function(DatabaseError value)? database, + TResult Function(ValidationError value)? validation, + required TResult orElse(), + }) { + if (unauthorized != null) { + return unauthorized(this); + } + return orElse(); + } +} + +abstract class UnauthorizedError implements AppError { + const factory UnauthorizedError({final String? message}) = + _$UnauthorizedErrorImpl; + + String? get message; + @JsonKey(ignore: true) + _$$UnauthorizedErrorImplCopyWith<_$UnauthorizedErrorImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$ForbiddenErrorImplCopyWith<$Res> { + factory _$$ForbiddenErrorImplCopyWith(_$ForbiddenErrorImpl value, + $Res Function(_$ForbiddenErrorImpl) then) = + __$$ForbiddenErrorImplCopyWithImpl<$Res>; + @useResult + $Res call({String? message}); +} + +/// @nodoc +class __$$ForbiddenErrorImplCopyWithImpl<$Res> + extends _$AppErrorCopyWithImpl<$Res, _$ForbiddenErrorImpl> + implements _$$ForbiddenErrorImplCopyWith<$Res> { + __$$ForbiddenErrorImplCopyWithImpl( + _$ForbiddenErrorImpl _value, $Res Function(_$ForbiddenErrorImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? message = freezed, + }) { + return _then(_$ForbiddenErrorImpl( + message: freezed == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc + +class _$ForbiddenErrorImpl implements ForbiddenError { + const _$ForbiddenErrorImpl({this.message}); + + @override + final String? message; + + @override + String toString() { + return 'AppError.forbidden(message: $message)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ForbiddenErrorImpl && + (identical(other.message, message) || other.message == message)); + } + + @override + int get hashCode => Object.hash(runtimeType, message); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$ForbiddenErrorImplCopyWith<_$ForbiddenErrorImpl> get copyWith => + __$$ForbiddenErrorImplCopyWithImpl<_$ForbiddenErrorImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String? message) unknown, + required TResult Function(String? message) network, + required TResult Function(String? message) unauthorized, + required TResult Function(String? message) forbidden, + required TResult Function(String? message) notFound, + required TResult Function(int? statusCode, String? message) server, + required TResult Function(String? message) database, + required TResult Function(Map? fieldErrors) validation, + }) { + return forbidden(message); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String? message)? unknown, + TResult? Function(String? message)? network, + TResult? Function(String? message)? unauthorized, + TResult? Function(String? message)? forbidden, + TResult? Function(String? message)? notFound, + TResult? Function(int? statusCode, String? message)? server, + TResult? Function(String? message)? database, + TResult? Function(Map? fieldErrors)? validation, + }) { + return forbidden?.call(message); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String? message)? unknown, + TResult Function(String? message)? network, + TResult Function(String? message)? unauthorized, + TResult Function(String? message)? forbidden, + TResult Function(String? message)? notFound, + TResult Function(int? statusCode, String? message)? server, + TResult Function(String? message)? database, + TResult Function(Map? fieldErrors)? validation, + required TResult orElse(), + }) { + if (forbidden != null) { + return forbidden(message); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(UnknownError value) unknown, + required TResult Function(NetworkError value) network, + required TResult Function(UnauthorizedError value) unauthorized, + required TResult Function(ForbiddenError value) forbidden, + required TResult Function(NotFoundError value) notFound, + required TResult Function(ServerError value) server, + required TResult Function(DatabaseError value) database, + required TResult Function(ValidationError value) validation, + }) { + return forbidden(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(UnknownError value)? unknown, + TResult? Function(NetworkError value)? network, + TResult? Function(UnauthorizedError value)? unauthorized, + TResult? Function(ForbiddenError value)? forbidden, + TResult? Function(NotFoundError value)? notFound, + TResult? Function(ServerError value)? server, + TResult? Function(DatabaseError value)? database, + TResult? Function(ValidationError value)? validation, + }) { + return forbidden?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(UnknownError value)? unknown, + TResult Function(NetworkError value)? network, + TResult Function(UnauthorizedError value)? unauthorized, + TResult Function(ForbiddenError value)? forbidden, + TResult Function(NotFoundError value)? notFound, + TResult Function(ServerError value)? server, + TResult Function(DatabaseError value)? database, + TResult Function(ValidationError value)? validation, + required TResult orElse(), + }) { + if (forbidden != null) { + return forbidden(this); + } + return orElse(); + } +} + +abstract class ForbiddenError implements AppError { + const factory ForbiddenError({final String? message}) = _$ForbiddenErrorImpl; + + String? get message; + @JsonKey(ignore: true) + _$$ForbiddenErrorImplCopyWith<_$ForbiddenErrorImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$NotFoundErrorImplCopyWith<$Res> { + factory _$$NotFoundErrorImplCopyWith( + _$NotFoundErrorImpl value, $Res Function(_$NotFoundErrorImpl) then) = + __$$NotFoundErrorImplCopyWithImpl<$Res>; + @useResult + $Res call({String? message}); +} + +/// @nodoc +class __$$NotFoundErrorImplCopyWithImpl<$Res> + extends _$AppErrorCopyWithImpl<$Res, _$NotFoundErrorImpl> + implements _$$NotFoundErrorImplCopyWith<$Res> { + __$$NotFoundErrorImplCopyWithImpl( + _$NotFoundErrorImpl _value, $Res Function(_$NotFoundErrorImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? message = freezed, + }) { + return _then(_$NotFoundErrorImpl( + message: freezed == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc + +class _$NotFoundErrorImpl implements NotFoundError { + const _$NotFoundErrorImpl({this.message}); + + @override + final String? message; + + @override + String toString() { + return 'AppError.notFound(message: $message)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$NotFoundErrorImpl && + (identical(other.message, message) || other.message == message)); + } + + @override + int get hashCode => Object.hash(runtimeType, message); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$NotFoundErrorImplCopyWith<_$NotFoundErrorImpl> get copyWith => + __$$NotFoundErrorImplCopyWithImpl<_$NotFoundErrorImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String? message) unknown, + required TResult Function(String? message) network, + required TResult Function(String? message) unauthorized, + required TResult Function(String? message) forbidden, + required TResult Function(String? message) notFound, + required TResult Function(int? statusCode, String? message) server, + required TResult Function(String? message) database, + required TResult Function(Map? fieldErrors) validation, + }) { + return notFound(message); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String? message)? unknown, + TResult? Function(String? message)? network, + TResult? Function(String? message)? unauthorized, + TResult? Function(String? message)? forbidden, + TResult? Function(String? message)? notFound, + TResult? Function(int? statusCode, String? message)? server, + TResult? Function(String? message)? database, + TResult? Function(Map? fieldErrors)? validation, + }) { + return notFound?.call(message); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String? message)? unknown, + TResult Function(String? message)? network, + TResult Function(String? message)? unauthorized, + TResult Function(String? message)? forbidden, + TResult Function(String? message)? notFound, + TResult Function(int? statusCode, String? message)? server, + TResult Function(String? message)? database, + TResult Function(Map? fieldErrors)? validation, + required TResult orElse(), + }) { + if (notFound != null) { + return notFound(message); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(UnknownError value) unknown, + required TResult Function(NetworkError value) network, + required TResult Function(UnauthorizedError value) unauthorized, + required TResult Function(ForbiddenError value) forbidden, + required TResult Function(NotFoundError value) notFound, + required TResult Function(ServerError value) server, + required TResult Function(DatabaseError value) database, + required TResult Function(ValidationError value) validation, + }) { + return notFound(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(UnknownError value)? unknown, + TResult? Function(NetworkError value)? network, + TResult? Function(UnauthorizedError value)? unauthorized, + TResult? Function(ForbiddenError value)? forbidden, + TResult? Function(NotFoundError value)? notFound, + TResult? Function(ServerError value)? server, + TResult? Function(DatabaseError value)? database, + TResult? Function(ValidationError value)? validation, + }) { + return notFound?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(UnknownError value)? unknown, + TResult Function(NetworkError value)? network, + TResult Function(UnauthorizedError value)? unauthorized, + TResult Function(ForbiddenError value)? forbidden, + TResult Function(NotFoundError value)? notFound, + TResult Function(ServerError value)? server, + TResult Function(DatabaseError value)? database, + TResult Function(ValidationError value)? validation, + required TResult orElse(), + }) { + if (notFound != null) { + return notFound(this); + } + return orElse(); + } +} + +abstract class NotFoundError implements AppError { + const factory NotFoundError({final String? message}) = _$NotFoundErrorImpl; + + String? get message; + @JsonKey(ignore: true) + _$$NotFoundErrorImplCopyWith<_$NotFoundErrorImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$ServerErrorImplCopyWith<$Res> { + factory _$$ServerErrorImplCopyWith( + _$ServerErrorImpl value, $Res Function(_$ServerErrorImpl) then) = + __$$ServerErrorImplCopyWithImpl<$Res>; + @useResult + $Res call({int? statusCode, String? message}); +} + +/// @nodoc +class __$$ServerErrorImplCopyWithImpl<$Res> + extends _$AppErrorCopyWithImpl<$Res, _$ServerErrorImpl> + implements _$$ServerErrorImplCopyWith<$Res> { + __$$ServerErrorImplCopyWithImpl( + _$ServerErrorImpl _value, $Res Function(_$ServerErrorImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? statusCode = freezed, + Object? message = freezed, + }) { + return _then(_$ServerErrorImpl( + statusCode: freezed == statusCode + ? _value.statusCode + : statusCode // ignore: cast_nullable_to_non_nullable + as int?, + message: freezed == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc + +class _$ServerErrorImpl implements ServerError { + const _$ServerErrorImpl({this.statusCode, this.message}); + + @override + final int? statusCode; + @override + final String? message; + + @override + String toString() { + return 'AppError.server(statusCode: $statusCode, message: $message)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ServerErrorImpl && + (identical(other.statusCode, statusCode) || + other.statusCode == statusCode) && + (identical(other.message, message) || other.message == message)); + } + + @override + int get hashCode => Object.hash(runtimeType, statusCode, message); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$ServerErrorImplCopyWith<_$ServerErrorImpl> get copyWith => + __$$ServerErrorImplCopyWithImpl<_$ServerErrorImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String? message) unknown, + required TResult Function(String? message) network, + required TResult Function(String? message) unauthorized, + required TResult Function(String? message) forbidden, + required TResult Function(String? message) notFound, + required TResult Function(int? statusCode, String? message) server, + required TResult Function(String? message) database, + required TResult Function(Map? fieldErrors) validation, + }) { + return server(statusCode, message); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String? message)? unknown, + TResult? Function(String? message)? network, + TResult? Function(String? message)? unauthorized, + TResult? Function(String? message)? forbidden, + TResult? Function(String? message)? notFound, + TResult? Function(int? statusCode, String? message)? server, + TResult? Function(String? message)? database, + TResult? Function(Map? fieldErrors)? validation, + }) { + return server?.call(statusCode, message); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String? message)? unknown, + TResult Function(String? message)? network, + TResult Function(String? message)? unauthorized, + TResult Function(String? message)? forbidden, + TResult Function(String? message)? notFound, + TResult Function(int? statusCode, String? message)? server, + TResult Function(String? message)? database, + TResult Function(Map? fieldErrors)? validation, + required TResult orElse(), + }) { + if (server != null) { + return server(statusCode, message); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(UnknownError value) unknown, + required TResult Function(NetworkError value) network, + required TResult Function(UnauthorizedError value) unauthorized, + required TResult Function(ForbiddenError value) forbidden, + required TResult Function(NotFoundError value) notFound, + required TResult Function(ServerError value) server, + required TResult Function(DatabaseError value) database, + required TResult Function(ValidationError value) validation, + }) { + return server(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(UnknownError value)? unknown, + TResult? Function(NetworkError value)? network, + TResult? Function(UnauthorizedError value)? unauthorized, + TResult? Function(ForbiddenError value)? forbidden, + TResult? Function(NotFoundError value)? notFound, + TResult? Function(ServerError value)? server, + TResult? Function(DatabaseError value)? database, + TResult? Function(ValidationError value)? validation, + }) { + return server?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(UnknownError value)? unknown, + TResult Function(NetworkError value)? network, + TResult Function(UnauthorizedError value)? unauthorized, + TResult Function(ForbiddenError value)? forbidden, + TResult Function(NotFoundError value)? notFound, + TResult Function(ServerError value)? server, + TResult Function(DatabaseError value)? database, + TResult Function(ValidationError value)? validation, + required TResult orElse(), + }) { + if (server != null) { + return server(this); + } + return orElse(); + } +} + +abstract class ServerError implements AppError { + const factory ServerError({final int? statusCode, final String? message}) = + _$ServerErrorImpl; + + int? get statusCode; + String? get message; + @JsonKey(ignore: true) + _$$ServerErrorImplCopyWith<_$ServerErrorImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$DatabaseErrorImplCopyWith<$Res> { + factory _$$DatabaseErrorImplCopyWith( + _$DatabaseErrorImpl value, $Res Function(_$DatabaseErrorImpl) then) = + __$$DatabaseErrorImplCopyWithImpl<$Res>; + @useResult + $Res call({String? message}); +} + +/// @nodoc +class __$$DatabaseErrorImplCopyWithImpl<$Res> + extends _$AppErrorCopyWithImpl<$Res, _$DatabaseErrorImpl> + implements _$$DatabaseErrorImplCopyWith<$Res> { + __$$DatabaseErrorImplCopyWithImpl( + _$DatabaseErrorImpl _value, $Res Function(_$DatabaseErrorImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? message = freezed, + }) { + return _then(_$DatabaseErrorImpl( + message: freezed == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc + +class _$DatabaseErrorImpl implements DatabaseError { + const _$DatabaseErrorImpl({this.message}); + + @override + final String? message; + + @override + String toString() { + return 'AppError.database(message: $message)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$DatabaseErrorImpl && + (identical(other.message, message) || other.message == message)); + } + + @override + int get hashCode => Object.hash(runtimeType, message); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$DatabaseErrorImplCopyWith<_$DatabaseErrorImpl> get copyWith => + __$$DatabaseErrorImplCopyWithImpl<_$DatabaseErrorImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String? message) unknown, + required TResult Function(String? message) network, + required TResult Function(String? message) unauthorized, + required TResult Function(String? message) forbidden, + required TResult Function(String? message) notFound, + required TResult Function(int? statusCode, String? message) server, + required TResult Function(String? message) database, + required TResult Function(Map? fieldErrors) validation, + }) { + return database(message); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String? message)? unknown, + TResult? Function(String? message)? network, + TResult? Function(String? message)? unauthorized, + TResult? Function(String? message)? forbidden, + TResult? Function(String? message)? notFound, + TResult? Function(int? statusCode, String? message)? server, + TResult? Function(String? message)? database, + TResult? Function(Map? fieldErrors)? validation, + }) { + return database?.call(message); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String? message)? unknown, + TResult Function(String? message)? network, + TResult Function(String? message)? unauthorized, + TResult Function(String? message)? forbidden, + TResult Function(String? message)? notFound, + TResult Function(int? statusCode, String? message)? server, + TResult Function(String? message)? database, + TResult Function(Map? fieldErrors)? validation, + required TResult orElse(), + }) { + if (database != null) { + return database(message); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(UnknownError value) unknown, + required TResult Function(NetworkError value) network, + required TResult Function(UnauthorizedError value) unauthorized, + required TResult Function(ForbiddenError value) forbidden, + required TResult Function(NotFoundError value) notFound, + required TResult Function(ServerError value) server, + required TResult Function(DatabaseError value) database, + required TResult Function(ValidationError value) validation, + }) { + return database(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(UnknownError value)? unknown, + TResult? Function(NetworkError value)? network, + TResult? Function(UnauthorizedError value)? unauthorized, + TResult? Function(ForbiddenError value)? forbidden, + TResult? Function(NotFoundError value)? notFound, + TResult? Function(ServerError value)? server, + TResult? Function(DatabaseError value)? database, + TResult? Function(ValidationError value)? validation, + }) { + return database?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(UnknownError value)? unknown, + TResult Function(NetworkError value)? network, + TResult Function(UnauthorizedError value)? unauthorized, + TResult Function(ForbiddenError value)? forbidden, + TResult Function(NotFoundError value)? notFound, + TResult Function(ServerError value)? server, + TResult Function(DatabaseError value)? database, + TResult Function(ValidationError value)? validation, + required TResult orElse(), + }) { + if (database != null) { + return database(this); + } + return orElse(); + } +} + +abstract class DatabaseError implements AppError { + const factory DatabaseError({final String? message}) = _$DatabaseErrorImpl; + + String? get message; + @JsonKey(ignore: true) + _$$DatabaseErrorImplCopyWith<_$DatabaseErrorImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$ValidationErrorImplCopyWith<$Res> { + factory _$$ValidationErrorImplCopyWith(_$ValidationErrorImpl value, + $Res Function(_$ValidationErrorImpl) then) = + __$$ValidationErrorImplCopyWithImpl<$Res>; + @useResult + $Res call({Map? fieldErrors}); +} + +/// @nodoc +class __$$ValidationErrorImplCopyWithImpl<$Res> + extends _$AppErrorCopyWithImpl<$Res, _$ValidationErrorImpl> + implements _$$ValidationErrorImplCopyWith<$Res> { + __$$ValidationErrorImplCopyWithImpl( + _$ValidationErrorImpl _value, $Res Function(_$ValidationErrorImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? fieldErrors = freezed, + }) { + return _then(_$ValidationErrorImpl( + fieldErrors: freezed == fieldErrors + ? _value._fieldErrors + : fieldErrors // ignore: cast_nullable_to_non_nullable + as Map?, + )); + } +} + +/// @nodoc + +class _$ValidationErrorImpl implements ValidationError { + const _$ValidationErrorImpl({final Map? fieldErrors}) + : _fieldErrors = fieldErrors; + + final Map? _fieldErrors; + @override + Map? get fieldErrors { + final value = _fieldErrors; + if (value == null) return null; + if (_fieldErrors is EqualUnmodifiableMapView) return _fieldErrors; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(value); + } + + @override + String toString() { + return 'AppError.validation(fieldErrors: $fieldErrors)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ValidationErrorImpl && + const DeepCollectionEquality() + .equals(other._fieldErrors, _fieldErrors)); + } + + @override + int get hashCode => Object.hash( + runtimeType, const DeepCollectionEquality().hash(_fieldErrors)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$ValidationErrorImplCopyWith<_$ValidationErrorImpl> get copyWith => + __$$ValidationErrorImplCopyWithImpl<_$ValidationErrorImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String? message) unknown, + required TResult Function(String? message) network, + required TResult Function(String? message) unauthorized, + required TResult Function(String? message) forbidden, + required TResult Function(String? message) notFound, + required TResult Function(int? statusCode, String? message) server, + required TResult Function(String? message) database, + required TResult Function(Map? fieldErrors) validation, + }) { + return validation(fieldErrors); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String? message)? unknown, + TResult? Function(String? message)? network, + TResult? Function(String? message)? unauthorized, + TResult? Function(String? message)? forbidden, + TResult? Function(String? message)? notFound, + TResult? Function(int? statusCode, String? message)? server, + TResult? Function(String? message)? database, + TResult? Function(Map? fieldErrors)? validation, + }) { + return validation?.call(fieldErrors); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String? message)? unknown, + TResult Function(String? message)? network, + TResult Function(String? message)? unauthorized, + TResult Function(String? message)? forbidden, + TResult Function(String? message)? notFound, + TResult Function(int? statusCode, String? message)? server, + TResult Function(String? message)? database, + TResult Function(Map? fieldErrors)? validation, + required TResult orElse(), + }) { + if (validation != null) { + return validation(fieldErrors); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(UnknownError value) unknown, + required TResult Function(NetworkError value) network, + required TResult Function(UnauthorizedError value) unauthorized, + required TResult Function(ForbiddenError value) forbidden, + required TResult Function(NotFoundError value) notFound, + required TResult Function(ServerError value) server, + required TResult Function(DatabaseError value) database, + required TResult Function(ValidationError value) validation, + }) { + return validation(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(UnknownError value)? unknown, + TResult? Function(NetworkError value)? network, + TResult? Function(UnauthorizedError value)? unauthorized, + TResult? Function(ForbiddenError value)? forbidden, + TResult? Function(NotFoundError value)? notFound, + TResult? Function(ServerError value)? server, + TResult? Function(DatabaseError value)? database, + TResult? Function(ValidationError value)? validation, + }) { + return validation?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(UnknownError value)? unknown, + TResult Function(NetworkError value)? network, + TResult Function(UnauthorizedError value)? unauthorized, + TResult Function(ForbiddenError value)? forbidden, + TResult Function(NotFoundError value)? notFound, + TResult Function(ServerError value)? server, + TResult Function(DatabaseError value)? database, + TResult Function(ValidationError value)? validation, + required TResult orElse(), + }) { + if (validation != null) { + return validation(this); + } + return orElse(); + } +} + +abstract class ValidationError implements AppError { + const factory ValidationError({final Map? fieldErrors}) = + _$ValidationErrorImpl; + + Map? get fieldErrors; + @JsonKey(ignore: true) + _$$ValidationErrorImplCopyWith<_$ValidationErrorImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/client-mobile/lib/core/errors/result.dart b/client-mobile/lib/core/errors/result.dart new file mode 100644 index 0000000..b214d68 --- /dev/null +++ b/client-mobile/lib/core/errors/result.dart @@ -0,0 +1,30 @@ +import 'errors.dart'; + +/// A generic class for handling success/failure results +class Result { + final T? data; + final AppError? error; + + const Result.success(this.data) : error = null; + const Result.failure(this.error) : data = null; + + bool get isSuccess => error == null; + bool get isFailure => error != null; + + R when({ + required R Function(T data) onSuccess, + required R Function(AppError error) onFailure, + }) { + if (isSuccess) { + return onSuccess(data as T); + } + return onFailure(error!); + } + + T getOrThrow() { + if (isFailure) { + throw error!; + } + return data as T; + } +} diff --git a/client-mobile/lib/core/network/api_client.dart b/client-mobile/lib/core/network/api_client.dart new file mode 100644 index 0000000..ccb100d --- /dev/null +++ b/client-mobile/lib/core/network/api_client.dart @@ -0,0 +1,135 @@ +import 'package:dio/dio.dart'; +import '../errors/errors.dart'; +import '../errors/result.dart'; + +class ApiClient { + final Dio _dio; + + ApiClient(this._dio); + + Future> get( + String path, { + Map? queryParameters, + Options? options, + }) async { + try { + final response = await _dio.get( + path, + queryParameters: queryParameters, + options: options, + ); + return Result.success(response.data as T); + } on DioException catch (e) { + return Result.failure(_handleDioError(e)); + } catch (e) { + return Result.failure(const AppError.unknown(message: 'Unknown error occurred')); + } + } + + Future> post( + String path, { + dynamic data, + Map? queryParameters, + Options? options, + }) async { + try { + final response = await _dio.post( + path, + data: data, + queryParameters: queryParameters, + options: options, + ); + return Result.success(response.data as T); + } on DioException catch (e) { + return Result.failure(_handleDioError(e)); + } catch (e) { + return Result.failure(const AppError.unknown(message: 'Unknown error occurred')); + } + } + + Future> put( + String path, { + dynamic data, + Map? queryParameters, + Options? options, + }) async { + try { + final response = await _dio.put( + path, + data: data, + queryParameters: queryParameters, + options: options, + ); + return Result.success(response.data as T); + } on DioException catch (e) { + return Result.failure(_handleDioError(e)); + } catch (e) { + return Result.failure(const AppError.unknown(message: 'Unknown error occurred')); + } + } + + Future> delete( + String path, { + dynamic data, + Map? queryParameters, + Options? options, + }) async { + try { + final response = await _dio.delete( + path, + data: data, + queryParameters: queryParameters, + options: options, + ); + return Result.success(response.data as T); + } on DioException catch (e) { + return Result.failure(_handleDioError(e)); + } catch (e) { + return Result.failure(const AppError.unknown(message: 'Unknown error occurred')); + } + } + + AppError _handleDioError(DioException error) { + switch (error.type) { + case DioExceptionType.connectionTimeout: + case DioExceptionType.sendTimeout: + case DioExceptionType.receiveTimeout: + return const AppError.network(message: 'Connection timeout'); + case DioExceptionType.connectionError: + return const AppError.network(message: 'No internet connection'); + case DioExceptionType.badResponse: + final statusCode = error.response?.statusCode; + switch (statusCode) { + case 401: + return const AppError.unauthorized(); + case 403: + return const AppError.forbidden(); + case 404: + return const AppError.notFound(); + case 422: + return AppError.validation(fieldErrors: _extractValidationErrors(error.response?.data)); + case int s when s >= 500: + return AppError.server(statusCode: statusCode, message: 'Server error'); + default: + return AppError.server(statusCode: statusCode, message: 'Request failed'); + } + case DioExceptionType.cancel: + return const AppError.unknown(message: 'Request cancelled'); + default: + return const AppError.unknown(); + } + } + + Map? _extractValidationErrors(dynamic data) { + if (data is Map && data.containsKey('errors')) { + final errors = data['errors'] as Map; + return errors.map((key, value) { + if (value is List && value.isNotEmpty) { + return MapEntry(key, value.first.toString()); + } + return MapEntry(key, 'Invalid'); + }); + } + return null; + } +} \ No newline at end of file diff --git a/client-mobile/lib/core/theme/app_theme.dart b/client-mobile/lib/core/theme/app_theme.dart new file mode 100644 index 0000000..69186d3 --- /dev/null +++ b/client-mobile/lib/core/theme/app_theme.dart @@ -0,0 +1,134 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +class AppTheme { + AppTheme._(); + + static const _primaryColor = Color(0xFF2481CC); + static const _primaryContainerColor = Color(0xFFD3E4FD); + static const _secondaryColor = Color(0xFF5F6AC4); + static const _tertiaryColor = Color(0xFFFFD700); + + static const _lightSurfaceColor = Color(0xFFFFFBFE); + static const _darkSurfaceColor = Color(0xFF1C1B1F); + + static ThemeData get lightTheme { + return ThemeData( + useMaterial3: true, + brightness: Brightness.light, + colorScheme: const ColorScheme.light( + primary: _primaryColor, + primaryContainer: _primaryContainerColor, + secondary: _secondaryColor, + tertiary: _tertiaryColor, + surface: _lightSurfaceColor, + onPrimary: Colors.white, + onSecondary: Colors.white, + onSurface: Colors.black87, + error: Color(0xFFBA1A1A), + ), + appBarTheme: const AppBarTheme( + centerTitle: true, + elevation: 0, + backgroundColor: _primaryColor, + foregroundColor: Colors.white, + systemOverlayStyle: SystemUiOverlayStyle.light, + ), + bottomNavigationBarTheme: const BottomNavigationBarThemeData( + type: BottomNavigationBarType.fixed, + backgroundColor: Colors.white, + selectedItemColor: _primaryColor, + unselectedItemColor: Colors.grey, + elevation: 8, + ), + cardTheme: CardThemeData( + elevation: 2, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + ), + inputDecorationTheme: InputDecorationTheme( + filled: true, + fillColor: Colors.grey[100], + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + borderSide: BorderSide.none, + ), + contentPadding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 12, + ), + ), + elevatedButtonTheme: ElevatedButtonThemeData( + style: ElevatedButton.styleFrom( + backgroundColor: _primaryColor, + foregroundColor: Colors.white, + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + ), + ), + ); + } + + static ThemeData get darkTheme { + return ThemeData( + useMaterial3: true, + brightness: Brightness.dark, + colorScheme: const ColorScheme.dark( + primary: _primaryColor, + primaryContainer: _primaryContainerColor, + secondary: _secondaryColor, + tertiary: _tertiaryColor, + surface: _darkSurfaceColor, + onPrimary: Colors.white, + onSecondary: Colors.white, + onSurface: const Color(0xFFE6E1E5), + error: Color(0xFFFFB4AB), + ), + appBarTheme: const AppBarTheme( + centerTitle: true, + elevation: 0, + backgroundColor: Color(0xFF1F1F1F), + foregroundColor: Colors.white, + systemOverlayStyle: SystemUiOverlayStyle.light, + ), + bottomNavigationBarTheme: const BottomNavigationBarThemeData( + type: BottomNavigationBarType.fixed, + backgroundColor: Color(0xFF1F1F1F), + selectedItemColor: _primaryColor, + unselectedItemColor: Colors.grey, + elevation: 8, + ), + cardTheme: CardThemeData( + elevation: 2, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + ), + inputDecorationTheme: InputDecorationTheme( + filled: true, + fillColor: const Color(0xFF2D2D2D), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + borderSide: BorderSide.none, + ), + contentPadding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 12, + ), + ), + elevatedButtonTheme: ElevatedButtonThemeData( + style: ElevatedButton.styleFrom( + backgroundColor: _primaryColor, + foregroundColor: Colors.white, + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + ), + ), + ); + } +} diff --git a/client-mobile/lib/features/auth/data/datasources/auth_local_datasource.dart b/client-mobile/lib/features/auth/data/datasources/auth_local_datasource.dart new file mode 100644 index 0000000..02af6d7 --- /dev/null +++ b/client-mobile/lib/features/auth/data/datasources/auth_local_datasource.dart @@ -0,0 +1,8 @@ +abstract class AuthLocalDataSource { + Future getToken(); + Future saveToken(String token); + Future removeToken(); + Future getUserId(); + Future saveUserId(String userId); + Future removeUserId(); +} diff --git a/client-mobile/lib/features/auth/data/datasources/auth_remote_datasource.dart b/client-mobile/lib/features/auth/data/datasources/auth_remote_datasource.dart new file mode 100644 index 0000000..707bc63 --- /dev/null +++ b/client-mobile/lib/features/auth/data/datasources/auth_remote_datasource.dart @@ -0,0 +1,10 @@ +import '../../../../core/errors/result.dart'; +import '../../domain/entities/user.dart'; + +abstract class AuthRemoteDataSource { + Future> login(String email, String password); + Future> register(String email, String password, String name); + Future> logout(); + Future> getCurrentUser(); + Future> refreshToken(); +} diff --git a/client-mobile/lib/features/auth/data/repositories/auth_repository_impl.dart b/client-mobile/lib/features/auth/data/repositories/auth_repository_impl.dart new file mode 100644 index 0000000..683576f --- /dev/null +++ b/client-mobile/lib/features/auth/data/repositories/auth_repository_impl.dart @@ -0,0 +1,47 @@ +import '../../../../core/errors/errors.dart'; +import '../../../../core/errors/result.dart'; +import '../../domain/entities/user.dart'; +import '../../domain/repositories/auth_repository.dart'; + +class AuthRepositoryImpl implements AuthRepository { + @override + bool get isLoggedIn => false; + + @override + Future> getCurrentUser() async { + return const Result.failure(AppError.unauthorized(message: 'Not logged in')); + } + + @override + Future> login(String email, String password) async { + // TODO: Implement real login + return Result.success( + User( + id: '1', + email: email, + name: 'Test User', + ), + ); + } + + @override + Future> logout() async { + return const Result.success(null); + } + + @override + Future> register(String email, String password, String name) async { + return Result.success( + User( + id: '1', + email: email, + name: name, + ), + ); + } + + @override + Future> refreshToken() async { + return const Result.success(null); + } +} diff --git a/client-mobile/lib/features/auth/domain/entities/user.dart b/client-mobile/lib/features/auth/domain/entities/user.dart new file mode 100644 index 0000000..4b41608 --- /dev/null +++ b/client-mobile/lib/features/auth/domain/entities/user.dart @@ -0,0 +1,19 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'user.freezed.dart'; +// part 'user.g.dart'; + +@freezed +class User with _$User { + const factory User({ + required String id, + required String email, + required String name, + String? avatarUrl, + String? phoneNumber, + DateTime? lastSeen, + bool? isOnline, + }) = _User; + + // factory User.fromJson(Map json) => _$UserFromJson(json); +} diff --git a/client-mobile/lib/features/auth/domain/entities/user.freezed.dart b/client-mobile/lib/features/auth/domain/entities/user.freezed.dart new file mode 100644 index 0000000..d81a2ee --- /dev/null +++ b/client-mobile/lib/features/auth/domain/entities/user.freezed.dart @@ -0,0 +1,257 @@ +// 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 'user.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#adding-getters-and-methods-to-our-models'); + +/// @nodoc +mixin _$User { + String get id => throw _privateConstructorUsedError; + String get email => throw _privateConstructorUsedError; + String get name => throw _privateConstructorUsedError; + String? get avatarUrl => throw _privateConstructorUsedError; + String? get phoneNumber => throw _privateConstructorUsedError; + DateTime? get lastSeen => throw _privateConstructorUsedError; + bool? get isOnline => throw _privateConstructorUsedError; + + @JsonKey(ignore: true) + $UserCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $UserCopyWith<$Res> { + factory $UserCopyWith(User value, $Res Function(User) then) = + _$UserCopyWithImpl<$Res, User>; + @useResult + $Res call( + {String id, + String email, + String name, + String? avatarUrl, + String? phoneNumber, + DateTime? lastSeen, + bool? isOnline}); +} + +/// @nodoc +class _$UserCopyWithImpl<$Res, $Val extends User> + implements $UserCopyWith<$Res> { + _$UserCopyWithImpl(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? email = null, + Object? name = null, + Object? avatarUrl = freezed, + Object? phoneNumber = freezed, + Object? lastSeen = freezed, + Object? isOnline = freezed, + }) { + return _then(_value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + email: null == email + ? _value.email + : email // ignore: cast_nullable_to_non_nullable + as String, + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + avatarUrl: freezed == avatarUrl + ? _value.avatarUrl + : avatarUrl // ignore: cast_nullable_to_non_nullable + as String?, + phoneNumber: freezed == phoneNumber + ? _value.phoneNumber + : phoneNumber // ignore: cast_nullable_to_non_nullable + as String?, + lastSeen: freezed == lastSeen + ? _value.lastSeen + : lastSeen // ignore: cast_nullable_to_non_nullable + as DateTime?, + isOnline: freezed == isOnline + ? _value.isOnline + : isOnline // ignore: cast_nullable_to_non_nullable + as bool?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$UserImplCopyWith<$Res> implements $UserCopyWith<$Res> { + factory _$$UserImplCopyWith( + _$UserImpl value, $Res Function(_$UserImpl) then) = + __$$UserImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String id, + String email, + String name, + String? avatarUrl, + String? phoneNumber, + DateTime? lastSeen, + bool? isOnline}); +} + +/// @nodoc +class __$$UserImplCopyWithImpl<$Res> + extends _$UserCopyWithImpl<$Res, _$UserImpl> + implements _$$UserImplCopyWith<$Res> { + __$$UserImplCopyWithImpl(_$UserImpl _value, $Res Function(_$UserImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? email = null, + Object? name = null, + Object? avatarUrl = freezed, + Object? phoneNumber = freezed, + Object? lastSeen = freezed, + Object? isOnline = freezed, + }) { + return _then(_$UserImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + email: null == email + ? _value.email + : email // ignore: cast_nullable_to_non_nullable + as String, + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + avatarUrl: freezed == avatarUrl + ? _value.avatarUrl + : avatarUrl // ignore: cast_nullable_to_non_nullable + as String?, + phoneNumber: freezed == phoneNumber + ? _value.phoneNumber + : phoneNumber // ignore: cast_nullable_to_non_nullable + as String?, + lastSeen: freezed == lastSeen + ? _value.lastSeen + : lastSeen // ignore: cast_nullable_to_non_nullable + as DateTime?, + isOnline: freezed == isOnline + ? _value.isOnline + : isOnline // ignore: cast_nullable_to_non_nullable + as bool?, + )); + } +} + +/// @nodoc + +class _$UserImpl implements _User { + const _$UserImpl( + {required this.id, + required this.email, + required this.name, + this.avatarUrl, + this.phoneNumber, + this.lastSeen, + this.isOnline}); + + @override + final String id; + @override + final String email; + @override + final String name; + @override + final String? avatarUrl; + @override + final String? phoneNumber; + @override + final DateTime? lastSeen; + @override + final bool? isOnline; + + @override + String toString() { + return 'User(id: $id, email: $email, name: $name, avatarUrl: $avatarUrl, phoneNumber: $phoneNumber, lastSeen: $lastSeen, isOnline: $isOnline)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$UserImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.email, email) || other.email == email) && + (identical(other.name, name) || other.name == name) && + (identical(other.avatarUrl, avatarUrl) || + other.avatarUrl == avatarUrl) && + (identical(other.phoneNumber, phoneNumber) || + other.phoneNumber == phoneNumber) && + (identical(other.lastSeen, lastSeen) || + other.lastSeen == lastSeen) && + (identical(other.isOnline, isOnline) || + other.isOnline == isOnline)); + } + + @override + int get hashCode => Object.hash( + runtimeType, id, email, name, avatarUrl, phoneNumber, lastSeen, isOnline); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$UserImplCopyWith<_$UserImpl> get copyWith => + __$$UserImplCopyWithImpl<_$UserImpl>(this, _$identity); +} + +abstract class _User implements User { + const factory _User( + {required final String id, + required final String email, + required final String name, + final String? avatarUrl, + final String? phoneNumber, + final DateTime? lastSeen, + final bool? isOnline}) = _$UserImpl; + + @override + String get id; + @override + String get email; + @override + String get name; + @override + String? get avatarUrl; + @override + String? get phoneNumber; + @override + DateTime? get lastSeen; + @override + bool? get isOnline; + @override + @JsonKey(ignore: true) + _$$UserImplCopyWith<_$UserImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/client-mobile/lib/features/auth/domain/repositories/auth_repository.dart b/client-mobile/lib/features/auth/domain/repositories/auth_repository.dart new file mode 100644 index 0000000..6b32ebe --- /dev/null +++ b/client-mobile/lib/features/auth/domain/repositories/auth_repository.dart @@ -0,0 +1,11 @@ +import '../../../../core/errors/result.dart'; +import '../entities/user.dart'; + +abstract class AuthRepository { + Future> login(String email, String password); + Future> register(String email, String password, String name); + Future> logout(); + Future> getCurrentUser(); + Future> refreshToken(); + bool get isLoggedIn; +} diff --git a/client-mobile/lib/features/auth/domain/usecases/login.dart b/client-mobile/lib/features/auth/domain/usecases/login.dart new file mode 100644 index 0000000..eb09709 --- /dev/null +++ b/client-mobile/lib/features/auth/domain/usecases/login.dart @@ -0,0 +1,13 @@ +import '../../../../core/errors/result.dart'; +import '../repositories/auth_repository.dart'; +import '../entities/user.dart'; + +class LoginUseCase { + final AuthRepository _repository; + + LoginUseCase(this._repository); + + Future> execute(String email, String password) { + return _repository.login(email, password); + } +} diff --git a/client-mobile/lib/features/auth/presentation/bloc/auth_bloc.dart b/client-mobile/lib/features/auth/presentation/bloc/auth_bloc.dart new file mode 100644 index 0000000..498183d --- /dev/null +++ b/client-mobile/lib/features/auth/presentation/bloc/auth_bloc.dart @@ -0,0 +1,36 @@ +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'auth_event.dart'; +import 'auth_state.dart'; + +class AuthBloc extends Bloc { + AuthBloc() : super(const AuthState.initial()) { + on(_onStarted); + on(_onLoginRequested); + on(_onRegisterRequested); + on(_onLogoutRequested); + on(_onAuthChecked); + on(_onEmailChanged); + on(_onPasswordChanged); + on(_onNameChanged); + } + + Future _onStarted(AuthEventStarted event, emit) async {} + + Future _onLoginRequested(AuthEventLoginRequested event, emit) async { + emit(const AuthState.loading()); + emit(const AuthState.authenticated('user_123')); + } + + Future _onRegisterRequested(AuthEventRegisterRequested event, emit) async { + emit(const AuthState.loading()); + } + + Future _onLogoutRequested(AuthEventLogoutRequested event, emit) async { + emit(const AuthState.unauthenticated()); + } + + Future _onAuthChecked(AuthEventAuthChecked event, emit) async {} + void _onEmailChanged(AuthEventEmailChanged event, emit) {} + void _onPasswordChanged(AuthEventPasswordChanged event, emit) {} + void _onNameChanged(AuthEventNameChanged event, emit) {} +} diff --git a/client-mobile/lib/features/auth/presentation/bloc/auth_event.dart b/client-mobile/lib/features/auth/presentation/bloc/auth_event.dart new file mode 100644 index 0000000..7c46efc --- /dev/null +++ b/client-mobile/lib/features/auth/presentation/bloc/auth_event.dart @@ -0,0 +1,15 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'auth_event.freezed.dart'; + +@freezed +class AuthEvent with _$AuthEvent { + const factory AuthEvent.started() = AuthEventStarted; + const factory AuthEvent.loginRequested(String email, String password) = AuthEventLoginRequested; + const factory AuthEvent.registerRequested(String email, String password, String name) = AuthEventRegisterRequested; + const factory AuthEvent.logoutRequested() = AuthEventLogoutRequested; + const factory AuthEvent.authChecked() = AuthEventAuthChecked; + const factory AuthEvent.emailChanged(String email) = AuthEventEmailChanged; + const factory AuthEvent.passwordChanged(String password) = AuthEventPasswordChanged; + const factory AuthEvent.nameChanged(String name) = AuthEventNameChanged; +} diff --git a/client-mobile/lib/features/auth/presentation/bloc/auth_event.freezed.dart b/client-mobile/lib/features/auth/presentation/bloc/auth_event.freezed.dart new file mode 100644 index 0000000..e936ce4 --- /dev/null +++ b/client-mobile/lib/features/auth/presentation/bloc/auth_event.freezed.dart @@ -0,0 +1,1459 @@ +// 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 'auth_event.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#adding-getters-and-methods-to-our-models'); + +/// @nodoc +mixin _$AuthEvent { + @optionalTypeArgs + TResult when({ + required TResult Function() started, + required TResult Function(String email, String password) loginRequested, + required TResult Function(String email, String password, String name) + registerRequested, + required TResult Function() logoutRequested, + required TResult Function() authChecked, + required TResult Function(String email) emailChanged, + required TResult Function(String password) passwordChanged, + required TResult Function(String name) nameChanged, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? started, + TResult? Function(String email, String password)? loginRequested, + TResult? Function(String email, String password, String name)? + registerRequested, + TResult? Function()? logoutRequested, + TResult? Function()? authChecked, + TResult? Function(String email)? emailChanged, + TResult? Function(String password)? passwordChanged, + TResult? Function(String name)? nameChanged, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? started, + TResult Function(String email, String password)? loginRequested, + TResult Function(String email, String password, String name)? + registerRequested, + TResult Function()? logoutRequested, + TResult Function()? authChecked, + TResult Function(String email)? emailChanged, + TResult Function(String password)? passwordChanged, + TResult Function(String name)? nameChanged, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(AuthEventStarted value) started, + required TResult Function(AuthEventLoginRequested value) loginRequested, + required TResult Function(AuthEventRegisterRequested value) + registerRequested, + required TResult Function(AuthEventLogoutRequested value) logoutRequested, + required TResult Function(AuthEventAuthChecked value) authChecked, + required TResult Function(AuthEventEmailChanged value) emailChanged, + required TResult Function(AuthEventPasswordChanged value) passwordChanged, + required TResult Function(AuthEventNameChanged value) nameChanged, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(AuthEventStarted value)? started, + TResult? Function(AuthEventLoginRequested value)? loginRequested, + TResult? Function(AuthEventRegisterRequested value)? registerRequested, + TResult? Function(AuthEventLogoutRequested value)? logoutRequested, + TResult? Function(AuthEventAuthChecked value)? authChecked, + TResult? Function(AuthEventEmailChanged value)? emailChanged, + TResult? Function(AuthEventPasswordChanged value)? passwordChanged, + TResult? Function(AuthEventNameChanged value)? nameChanged, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(AuthEventStarted value)? started, + TResult Function(AuthEventLoginRequested value)? loginRequested, + TResult Function(AuthEventRegisterRequested value)? registerRequested, + TResult Function(AuthEventLogoutRequested value)? logoutRequested, + TResult Function(AuthEventAuthChecked value)? authChecked, + TResult Function(AuthEventEmailChanged value)? emailChanged, + TResult Function(AuthEventPasswordChanged value)? passwordChanged, + TResult Function(AuthEventNameChanged value)? nameChanged, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $AuthEventCopyWith<$Res> { + factory $AuthEventCopyWith(AuthEvent value, $Res Function(AuthEvent) then) = + _$AuthEventCopyWithImpl<$Res, AuthEvent>; +} + +/// @nodoc +class _$AuthEventCopyWithImpl<$Res, $Val extends AuthEvent> + implements $AuthEventCopyWith<$Res> { + _$AuthEventCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; +} + +/// @nodoc +abstract class _$$AuthEventStartedImplCopyWith<$Res> { + factory _$$AuthEventStartedImplCopyWith(_$AuthEventStartedImpl value, + $Res Function(_$AuthEventStartedImpl) then) = + __$$AuthEventStartedImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$AuthEventStartedImplCopyWithImpl<$Res> + extends _$AuthEventCopyWithImpl<$Res, _$AuthEventStartedImpl> + implements _$$AuthEventStartedImplCopyWith<$Res> { + __$$AuthEventStartedImplCopyWithImpl(_$AuthEventStartedImpl _value, + $Res Function(_$AuthEventStartedImpl) _then) + : super(_value, _then); +} + +/// @nodoc + +class _$AuthEventStartedImpl implements AuthEventStarted { + const _$AuthEventStartedImpl(); + + @override + String toString() { + return 'AuthEvent.started()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$AuthEventStartedImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() started, + required TResult Function(String email, String password) loginRequested, + required TResult Function(String email, String password, String name) + registerRequested, + required TResult Function() logoutRequested, + required TResult Function() authChecked, + required TResult Function(String email) emailChanged, + required TResult Function(String password) passwordChanged, + required TResult Function(String name) nameChanged, + }) { + return started(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? started, + TResult? Function(String email, String password)? loginRequested, + TResult? Function(String email, String password, String name)? + registerRequested, + TResult? Function()? logoutRequested, + TResult? Function()? authChecked, + TResult? Function(String email)? emailChanged, + TResult? Function(String password)? passwordChanged, + TResult? Function(String name)? nameChanged, + }) { + return started?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? started, + TResult Function(String email, String password)? loginRequested, + TResult Function(String email, String password, String name)? + registerRequested, + TResult Function()? logoutRequested, + TResult Function()? authChecked, + TResult Function(String email)? emailChanged, + TResult Function(String password)? passwordChanged, + TResult Function(String name)? nameChanged, + required TResult orElse(), + }) { + if (started != null) { + return started(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(AuthEventStarted value) started, + required TResult Function(AuthEventLoginRequested value) loginRequested, + required TResult Function(AuthEventRegisterRequested value) + registerRequested, + required TResult Function(AuthEventLogoutRequested value) logoutRequested, + required TResult Function(AuthEventAuthChecked value) authChecked, + required TResult Function(AuthEventEmailChanged value) emailChanged, + required TResult Function(AuthEventPasswordChanged value) passwordChanged, + required TResult Function(AuthEventNameChanged value) nameChanged, + }) { + return started(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(AuthEventStarted value)? started, + TResult? Function(AuthEventLoginRequested value)? loginRequested, + TResult? Function(AuthEventRegisterRequested value)? registerRequested, + TResult? Function(AuthEventLogoutRequested value)? logoutRequested, + TResult? Function(AuthEventAuthChecked value)? authChecked, + TResult? Function(AuthEventEmailChanged value)? emailChanged, + TResult? Function(AuthEventPasswordChanged value)? passwordChanged, + TResult? Function(AuthEventNameChanged value)? nameChanged, + }) { + return started?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(AuthEventStarted value)? started, + TResult Function(AuthEventLoginRequested value)? loginRequested, + TResult Function(AuthEventRegisterRequested value)? registerRequested, + TResult Function(AuthEventLogoutRequested value)? logoutRequested, + TResult Function(AuthEventAuthChecked value)? authChecked, + TResult Function(AuthEventEmailChanged value)? emailChanged, + TResult Function(AuthEventPasswordChanged value)? passwordChanged, + TResult Function(AuthEventNameChanged value)? nameChanged, + required TResult orElse(), + }) { + if (started != null) { + return started(this); + } + return orElse(); + } +} + +abstract class AuthEventStarted implements AuthEvent { + const factory AuthEventStarted() = _$AuthEventStartedImpl; +} + +/// @nodoc +abstract class _$$AuthEventLoginRequestedImplCopyWith<$Res> { + factory _$$AuthEventLoginRequestedImplCopyWith( + _$AuthEventLoginRequestedImpl value, + $Res Function(_$AuthEventLoginRequestedImpl) then) = + __$$AuthEventLoginRequestedImplCopyWithImpl<$Res>; + @useResult + $Res call({String email, String password}); +} + +/// @nodoc +class __$$AuthEventLoginRequestedImplCopyWithImpl<$Res> + extends _$AuthEventCopyWithImpl<$Res, _$AuthEventLoginRequestedImpl> + implements _$$AuthEventLoginRequestedImplCopyWith<$Res> { + __$$AuthEventLoginRequestedImplCopyWithImpl( + _$AuthEventLoginRequestedImpl _value, + $Res Function(_$AuthEventLoginRequestedImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? email = null, + Object? password = null, + }) { + return _then(_$AuthEventLoginRequestedImpl( + null == email + ? _value.email + : email // ignore: cast_nullable_to_non_nullable + as String, + null == password + ? _value.password + : password // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$AuthEventLoginRequestedImpl implements AuthEventLoginRequested { + const _$AuthEventLoginRequestedImpl(this.email, this.password); + + @override + final String email; + @override + final String password; + + @override + String toString() { + return 'AuthEvent.loginRequested(email: $email, password: $password)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$AuthEventLoginRequestedImpl && + (identical(other.email, email) || other.email == email) && + (identical(other.password, password) || + other.password == password)); + } + + @override + int get hashCode => Object.hash(runtimeType, email, password); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$AuthEventLoginRequestedImplCopyWith<_$AuthEventLoginRequestedImpl> + get copyWith => __$$AuthEventLoginRequestedImplCopyWithImpl< + _$AuthEventLoginRequestedImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() started, + required TResult Function(String email, String password) loginRequested, + required TResult Function(String email, String password, String name) + registerRequested, + required TResult Function() logoutRequested, + required TResult Function() authChecked, + required TResult Function(String email) emailChanged, + required TResult Function(String password) passwordChanged, + required TResult Function(String name) nameChanged, + }) { + return loginRequested(email, password); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? started, + TResult? Function(String email, String password)? loginRequested, + TResult? Function(String email, String password, String name)? + registerRequested, + TResult? Function()? logoutRequested, + TResult? Function()? authChecked, + TResult? Function(String email)? emailChanged, + TResult? Function(String password)? passwordChanged, + TResult? Function(String name)? nameChanged, + }) { + return loginRequested?.call(email, password); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? started, + TResult Function(String email, String password)? loginRequested, + TResult Function(String email, String password, String name)? + registerRequested, + TResult Function()? logoutRequested, + TResult Function()? authChecked, + TResult Function(String email)? emailChanged, + TResult Function(String password)? passwordChanged, + TResult Function(String name)? nameChanged, + required TResult orElse(), + }) { + if (loginRequested != null) { + return loginRequested(email, password); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(AuthEventStarted value) started, + required TResult Function(AuthEventLoginRequested value) loginRequested, + required TResult Function(AuthEventRegisterRequested value) + registerRequested, + required TResult Function(AuthEventLogoutRequested value) logoutRequested, + required TResult Function(AuthEventAuthChecked value) authChecked, + required TResult Function(AuthEventEmailChanged value) emailChanged, + required TResult Function(AuthEventPasswordChanged value) passwordChanged, + required TResult Function(AuthEventNameChanged value) nameChanged, + }) { + return loginRequested(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(AuthEventStarted value)? started, + TResult? Function(AuthEventLoginRequested value)? loginRequested, + TResult? Function(AuthEventRegisterRequested value)? registerRequested, + TResult? Function(AuthEventLogoutRequested value)? logoutRequested, + TResult? Function(AuthEventAuthChecked value)? authChecked, + TResult? Function(AuthEventEmailChanged value)? emailChanged, + TResult? Function(AuthEventPasswordChanged value)? passwordChanged, + TResult? Function(AuthEventNameChanged value)? nameChanged, + }) { + return loginRequested?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(AuthEventStarted value)? started, + TResult Function(AuthEventLoginRequested value)? loginRequested, + TResult Function(AuthEventRegisterRequested value)? registerRequested, + TResult Function(AuthEventLogoutRequested value)? logoutRequested, + TResult Function(AuthEventAuthChecked value)? authChecked, + TResult Function(AuthEventEmailChanged value)? emailChanged, + TResult Function(AuthEventPasswordChanged value)? passwordChanged, + TResult Function(AuthEventNameChanged value)? nameChanged, + required TResult orElse(), + }) { + if (loginRequested != null) { + return loginRequested(this); + } + return orElse(); + } +} + +abstract class AuthEventLoginRequested implements AuthEvent { + const factory AuthEventLoginRequested( + final String email, final String password) = + _$AuthEventLoginRequestedImpl; + + String get email; + String get password; + @JsonKey(ignore: true) + _$$AuthEventLoginRequestedImplCopyWith<_$AuthEventLoginRequestedImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$AuthEventRegisterRequestedImplCopyWith<$Res> { + factory _$$AuthEventRegisterRequestedImplCopyWith( + _$AuthEventRegisterRequestedImpl value, + $Res Function(_$AuthEventRegisterRequestedImpl) then) = + __$$AuthEventRegisterRequestedImplCopyWithImpl<$Res>; + @useResult + $Res call({String email, String password, String name}); +} + +/// @nodoc +class __$$AuthEventRegisterRequestedImplCopyWithImpl<$Res> + extends _$AuthEventCopyWithImpl<$Res, _$AuthEventRegisterRequestedImpl> + implements _$$AuthEventRegisterRequestedImplCopyWith<$Res> { + __$$AuthEventRegisterRequestedImplCopyWithImpl( + _$AuthEventRegisterRequestedImpl _value, + $Res Function(_$AuthEventRegisterRequestedImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? email = null, + Object? password = null, + Object? name = null, + }) { + return _then(_$AuthEventRegisterRequestedImpl( + null == email + ? _value.email + : email // ignore: cast_nullable_to_non_nullable + as String, + null == password + ? _value.password + : password // ignore: cast_nullable_to_non_nullable + as String, + null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$AuthEventRegisterRequestedImpl implements AuthEventRegisterRequested { + const _$AuthEventRegisterRequestedImpl(this.email, this.password, this.name); + + @override + final String email; + @override + final String password; + @override + final String name; + + @override + String toString() { + return 'AuthEvent.registerRequested(email: $email, password: $password, name: $name)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$AuthEventRegisterRequestedImpl && + (identical(other.email, email) || other.email == email) && + (identical(other.password, password) || + other.password == password) && + (identical(other.name, name) || other.name == name)); + } + + @override + int get hashCode => Object.hash(runtimeType, email, password, name); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$AuthEventRegisterRequestedImplCopyWith<_$AuthEventRegisterRequestedImpl> + get copyWith => __$$AuthEventRegisterRequestedImplCopyWithImpl< + _$AuthEventRegisterRequestedImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() started, + required TResult Function(String email, String password) loginRequested, + required TResult Function(String email, String password, String name) + registerRequested, + required TResult Function() logoutRequested, + required TResult Function() authChecked, + required TResult Function(String email) emailChanged, + required TResult Function(String password) passwordChanged, + required TResult Function(String name) nameChanged, + }) { + return registerRequested(email, password, name); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? started, + TResult? Function(String email, String password)? loginRequested, + TResult? Function(String email, String password, String name)? + registerRequested, + TResult? Function()? logoutRequested, + TResult? Function()? authChecked, + TResult? Function(String email)? emailChanged, + TResult? Function(String password)? passwordChanged, + TResult? Function(String name)? nameChanged, + }) { + return registerRequested?.call(email, password, name); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? started, + TResult Function(String email, String password)? loginRequested, + TResult Function(String email, String password, String name)? + registerRequested, + TResult Function()? logoutRequested, + TResult Function()? authChecked, + TResult Function(String email)? emailChanged, + TResult Function(String password)? passwordChanged, + TResult Function(String name)? nameChanged, + required TResult orElse(), + }) { + if (registerRequested != null) { + return registerRequested(email, password, name); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(AuthEventStarted value) started, + required TResult Function(AuthEventLoginRequested value) loginRequested, + required TResult Function(AuthEventRegisterRequested value) + registerRequested, + required TResult Function(AuthEventLogoutRequested value) logoutRequested, + required TResult Function(AuthEventAuthChecked value) authChecked, + required TResult Function(AuthEventEmailChanged value) emailChanged, + required TResult Function(AuthEventPasswordChanged value) passwordChanged, + required TResult Function(AuthEventNameChanged value) nameChanged, + }) { + return registerRequested(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(AuthEventStarted value)? started, + TResult? Function(AuthEventLoginRequested value)? loginRequested, + TResult? Function(AuthEventRegisterRequested value)? registerRequested, + TResult? Function(AuthEventLogoutRequested value)? logoutRequested, + TResult? Function(AuthEventAuthChecked value)? authChecked, + TResult? Function(AuthEventEmailChanged value)? emailChanged, + TResult? Function(AuthEventPasswordChanged value)? passwordChanged, + TResult? Function(AuthEventNameChanged value)? nameChanged, + }) { + return registerRequested?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(AuthEventStarted value)? started, + TResult Function(AuthEventLoginRequested value)? loginRequested, + TResult Function(AuthEventRegisterRequested value)? registerRequested, + TResult Function(AuthEventLogoutRequested value)? logoutRequested, + TResult Function(AuthEventAuthChecked value)? authChecked, + TResult Function(AuthEventEmailChanged value)? emailChanged, + TResult Function(AuthEventPasswordChanged value)? passwordChanged, + TResult Function(AuthEventNameChanged value)? nameChanged, + required TResult orElse(), + }) { + if (registerRequested != null) { + return registerRequested(this); + } + return orElse(); + } +} + +abstract class AuthEventRegisterRequested implements AuthEvent { + const factory AuthEventRegisterRequested( + final String email, final String password, final String name) = + _$AuthEventRegisterRequestedImpl; + + String get email; + String get password; + String get name; + @JsonKey(ignore: true) + _$$AuthEventRegisterRequestedImplCopyWith<_$AuthEventRegisterRequestedImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$AuthEventLogoutRequestedImplCopyWith<$Res> { + factory _$$AuthEventLogoutRequestedImplCopyWith( + _$AuthEventLogoutRequestedImpl value, + $Res Function(_$AuthEventLogoutRequestedImpl) then) = + __$$AuthEventLogoutRequestedImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$AuthEventLogoutRequestedImplCopyWithImpl<$Res> + extends _$AuthEventCopyWithImpl<$Res, _$AuthEventLogoutRequestedImpl> + implements _$$AuthEventLogoutRequestedImplCopyWith<$Res> { + __$$AuthEventLogoutRequestedImplCopyWithImpl( + _$AuthEventLogoutRequestedImpl _value, + $Res Function(_$AuthEventLogoutRequestedImpl) _then) + : super(_value, _then); +} + +/// @nodoc + +class _$AuthEventLogoutRequestedImpl implements AuthEventLogoutRequested { + const _$AuthEventLogoutRequestedImpl(); + + @override + String toString() { + return 'AuthEvent.logoutRequested()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$AuthEventLogoutRequestedImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() started, + required TResult Function(String email, String password) loginRequested, + required TResult Function(String email, String password, String name) + registerRequested, + required TResult Function() logoutRequested, + required TResult Function() authChecked, + required TResult Function(String email) emailChanged, + required TResult Function(String password) passwordChanged, + required TResult Function(String name) nameChanged, + }) { + return logoutRequested(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? started, + TResult? Function(String email, String password)? loginRequested, + TResult? Function(String email, String password, String name)? + registerRequested, + TResult? Function()? logoutRequested, + TResult? Function()? authChecked, + TResult? Function(String email)? emailChanged, + TResult? Function(String password)? passwordChanged, + TResult? Function(String name)? nameChanged, + }) { + return logoutRequested?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? started, + TResult Function(String email, String password)? loginRequested, + TResult Function(String email, String password, String name)? + registerRequested, + TResult Function()? logoutRequested, + TResult Function()? authChecked, + TResult Function(String email)? emailChanged, + TResult Function(String password)? passwordChanged, + TResult Function(String name)? nameChanged, + required TResult orElse(), + }) { + if (logoutRequested != null) { + return logoutRequested(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(AuthEventStarted value) started, + required TResult Function(AuthEventLoginRequested value) loginRequested, + required TResult Function(AuthEventRegisterRequested value) + registerRequested, + required TResult Function(AuthEventLogoutRequested value) logoutRequested, + required TResult Function(AuthEventAuthChecked value) authChecked, + required TResult Function(AuthEventEmailChanged value) emailChanged, + required TResult Function(AuthEventPasswordChanged value) passwordChanged, + required TResult Function(AuthEventNameChanged value) nameChanged, + }) { + return logoutRequested(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(AuthEventStarted value)? started, + TResult? Function(AuthEventLoginRequested value)? loginRequested, + TResult? Function(AuthEventRegisterRequested value)? registerRequested, + TResult? Function(AuthEventLogoutRequested value)? logoutRequested, + TResult? Function(AuthEventAuthChecked value)? authChecked, + TResult? Function(AuthEventEmailChanged value)? emailChanged, + TResult? Function(AuthEventPasswordChanged value)? passwordChanged, + TResult? Function(AuthEventNameChanged value)? nameChanged, + }) { + return logoutRequested?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(AuthEventStarted value)? started, + TResult Function(AuthEventLoginRequested value)? loginRequested, + TResult Function(AuthEventRegisterRequested value)? registerRequested, + TResult Function(AuthEventLogoutRequested value)? logoutRequested, + TResult Function(AuthEventAuthChecked value)? authChecked, + TResult Function(AuthEventEmailChanged value)? emailChanged, + TResult Function(AuthEventPasswordChanged value)? passwordChanged, + TResult Function(AuthEventNameChanged value)? nameChanged, + required TResult orElse(), + }) { + if (logoutRequested != null) { + return logoutRequested(this); + } + return orElse(); + } +} + +abstract class AuthEventLogoutRequested implements AuthEvent { + const factory AuthEventLogoutRequested() = _$AuthEventLogoutRequestedImpl; +} + +/// @nodoc +abstract class _$$AuthEventAuthCheckedImplCopyWith<$Res> { + factory _$$AuthEventAuthCheckedImplCopyWith(_$AuthEventAuthCheckedImpl value, + $Res Function(_$AuthEventAuthCheckedImpl) then) = + __$$AuthEventAuthCheckedImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$AuthEventAuthCheckedImplCopyWithImpl<$Res> + extends _$AuthEventCopyWithImpl<$Res, _$AuthEventAuthCheckedImpl> + implements _$$AuthEventAuthCheckedImplCopyWith<$Res> { + __$$AuthEventAuthCheckedImplCopyWithImpl(_$AuthEventAuthCheckedImpl _value, + $Res Function(_$AuthEventAuthCheckedImpl) _then) + : super(_value, _then); +} + +/// @nodoc + +class _$AuthEventAuthCheckedImpl implements AuthEventAuthChecked { + const _$AuthEventAuthCheckedImpl(); + + @override + String toString() { + return 'AuthEvent.authChecked()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$AuthEventAuthCheckedImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() started, + required TResult Function(String email, String password) loginRequested, + required TResult Function(String email, String password, String name) + registerRequested, + required TResult Function() logoutRequested, + required TResult Function() authChecked, + required TResult Function(String email) emailChanged, + required TResult Function(String password) passwordChanged, + required TResult Function(String name) nameChanged, + }) { + return authChecked(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? started, + TResult? Function(String email, String password)? loginRequested, + TResult? Function(String email, String password, String name)? + registerRequested, + TResult? Function()? logoutRequested, + TResult? Function()? authChecked, + TResult? Function(String email)? emailChanged, + TResult? Function(String password)? passwordChanged, + TResult? Function(String name)? nameChanged, + }) { + return authChecked?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? started, + TResult Function(String email, String password)? loginRequested, + TResult Function(String email, String password, String name)? + registerRequested, + TResult Function()? logoutRequested, + TResult Function()? authChecked, + TResult Function(String email)? emailChanged, + TResult Function(String password)? passwordChanged, + TResult Function(String name)? nameChanged, + required TResult orElse(), + }) { + if (authChecked != null) { + return authChecked(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(AuthEventStarted value) started, + required TResult Function(AuthEventLoginRequested value) loginRequested, + required TResult Function(AuthEventRegisterRequested value) + registerRequested, + required TResult Function(AuthEventLogoutRequested value) logoutRequested, + required TResult Function(AuthEventAuthChecked value) authChecked, + required TResult Function(AuthEventEmailChanged value) emailChanged, + required TResult Function(AuthEventPasswordChanged value) passwordChanged, + required TResult Function(AuthEventNameChanged value) nameChanged, + }) { + return authChecked(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(AuthEventStarted value)? started, + TResult? Function(AuthEventLoginRequested value)? loginRequested, + TResult? Function(AuthEventRegisterRequested value)? registerRequested, + TResult? Function(AuthEventLogoutRequested value)? logoutRequested, + TResult? Function(AuthEventAuthChecked value)? authChecked, + TResult? Function(AuthEventEmailChanged value)? emailChanged, + TResult? Function(AuthEventPasswordChanged value)? passwordChanged, + TResult? Function(AuthEventNameChanged value)? nameChanged, + }) { + return authChecked?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(AuthEventStarted value)? started, + TResult Function(AuthEventLoginRequested value)? loginRequested, + TResult Function(AuthEventRegisterRequested value)? registerRequested, + TResult Function(AuthEventLogoutRequested value)? logoutRequested, + TResult Function(AuthEventAuthChecked value)? authChecked, + TResult Function(AuthEventEmailChanged value)? emailChanged, + TResult Function(AuthEventPasswordChanged value)? passwordChanged, + TResult Function(AuthEventNameChanged value)? nameChanged, + required TResult orElse(), + }) { + if (authChecked != null) { + return authChecked(this); + } + return orElse(); + } +} + +abstract class AuthEventAuthChecked implements AuthEvent { + const factory AuthEventAuthChecked() = _$AuthEventAuthCheckedImpl; +} + +/// @nodoc +abstract class _$$AuthEventEmailChangedImplCopyWith<$Res> { + factory _$$AuthEventEmailChangedImplCopyWith( + _$AuthEventEmailChangedImpl value, + $Res Function(_$AuthEventEmailChangedImpl) then) = + __$$AuthEventEmailChangedImplCopyWithImpl<$Res>; + @useResult + $Res call({String email}); +} + +/// @nodoc +class __$$AuthEventEmailChangedImplCopyWithImpl<$Res> + extends _$AuthEventCopyWithImpl<$Res, _$AuthEventEmailChangedImpl> + implements _$$AuthEventEmailChangedImplCopyWith<$Res> { + __$$AuthEventEmailChangedImplCopyWithImpl(_$AuthEventEmailChangedImpl _value, + $Res Function(_$AuthEventEmailChangedImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? email = null, + }) { + return _then(_$AuthEventEmailChangedImpl( + null == email + ? _value.email + : email // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$AuthEventEmailChangedImpl implements AuthEventEmailChanged { + const _$AuthEventEmailChangedImpl(this.email); + + @override + final String email; + + @override + String toString() { + return 'AuthEvent.emailChanged(email: $email)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$AuthEventEmailChangedImpl && + (identical(other.email, email) || other.email == email)); + } + + @override + int get hashCode => Object.hash(runtimeType, email); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$AuthEventEmailChangedImplCopyWith<_$AuthEventEmailChangedImpl> + get copyWith => __$$AuthEventEmailChangedImplCopyWithImpl< + _$AuthEventEmailChangedImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() started, + required TResult Function(String email, String password) loginRequested, + required TResult Function(String email, String password, String name) + registerRequested, + required TResult Function() logoutRequested, + required TResult Function() authChecked, + required TResult Function(String email) emailChanged, + required TResult Function(String password) passwordChanged, + required TResult Function(String name) nameChanged, + }) { + return emailChanged(email); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? started, + TResult? Function(String email, String password)? loginRequested, + TResult? Function(String email, String password, String name)? + registerRequested, + TResult? Function()? logoutRequested, + TResult? Function()? authChecked, + TResult? Function(String email)? emailChanged, + TResult? Function(String password)? passwordChanged, + TResult? Function(String name)? nameChanged, + }) { + return emailChanged?.call(email); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? started, + TResult Function(String email, String password)? loginRequested, + TResult Function(String email, String password, String name)? + registerRequested, + TResult Function()? logoutRequested, + TResult Function()? authChecked, + TResult Function(String email)? emailChanged, + TResult Function(String password)? passwordChanged, + TResult Function(String name)? nameChanged, + required TResult orElse(), + }) { + if (emailChanged != null) { + return emailChanged(email); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(AuthEventStarted value) started, + required TResult Function(AuthEventLoginRequested value) loginRequested, + required TResult Function(AuthEventRegisterRequested value) + registerRequested, + required TResult Function(AuthEventLogoutRequested value) logoutRequested, + required TResult Function(AuthEventAuthChecked value) authChecked, + required TResult Function(AuthEventEmailChanged value) emailChanged, + required TResult Function(AuthEventPasswordChanged value) passwordChanged, + required TResult Function(AuthEventNameChanged value) nameChanged, + }) { + return emailChanged(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(AuthEventStarted value)? started, + TResult? Function(AuthEventLoginRequested value)? loginRequested, + TResult? Function(AuthEventRegisterRequested value)? registerRequested, + TResult? Function(AuthEventLogoutRequested value)? logoutRequested, + TResult? Function(AuthEventAuthChecked value)? authChecked, + TResult? Function(AuthEventEmailChanged value)? emailChanged, + TResult? Function(AuthEventPasswordChanged value)? passwordChanged, + TResult? Function(AuthEventNameChanged value)? nameChanged, + }) { + return emailChanged?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(AuthEventStarted value)? started, + TResult Function(AuthEventLoginRequested value)? loginRequested, + TResult Function(AuthEventRegisterRequested value)? registerRequested, + TResult Function(AuthEventLogoutRequested value)? logoutRequested, + TResult Function(AuthEventAuthChecked value)? authChecked, + TResult Function(AuthEventEmailChanged value)? emailChanged, + TResult Function(AuthEventPasswordChanged value)? passwordChanged, + TResult Function(AuthEventNameChanged value)? nameChanged, + required TResult orElse(), + }) { + if (emailChanged != null) { + return emailChanged(this); + } + return orElse(); + } +} + +abstract class AuthEventEmailChanged implements AuthEvent { + const factory AuthEventEmailChanged(final String email) = + _$AuthEventEmailChangedImpl; + + String get email; + @JsonKey(ignore: true) + _$$AuthEventEmailChangedImplCopyWith<_$AuthEventEmailChangedImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$AuthEventPasswordChangedImplCopyWith<$Res> { + factory _$$AuthEventPasswordChangedImplCopyWith( + _$AuthEventPasswordChangedImpl value, + $Res Function(_$AuthEventPasswordChangedImpl) then) = + __$$AuthEventPasswordChangedImplCopyWithImpl<$Res>; + @useResult + $Res call({String password}); +} + +/// @nodoc +class __$$AuthEventPasswordChangedImplCopyWithImpl<$Res> + extends _$AuthEventCopyWithImpl<$Res, _$AuthEventPasswordChangedImpl> + implements _$$AuthEventPasswordChangedImplCopyWith<$Res> { + __$$AuthEventPasswordChangedImplCopyWithImpl( + _$AuthEventPasswordChangedImpl _value, + $Res Function(_$AuthEventPasswordChangedImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? password = null, + }) { + return _then(_$AuthEventPasswordChangedImpl( + null == password + ? _value.password + : password // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$AuthEventPasswordChangedImpl implements AuthEventPasswordChanged { + const _$AuthEventPasswordChangedImpl(this.password); + + @override + final String password; + + @override + String toString() { + return 'AuthEvent.passwordChanged(password: $password)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$AuthEventPasswordChangedImpl && + (identical(other.password, password) || + other.password == password)); + } + + @override + int get hashCode => Object.hash(runtimeType, password); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$AuthEventPasswordChangedImplCopyWith<_$AuthEventPasswordChangedImpl> + get copyWith => __$$AuthEventPasswordChangedImplCopyWithImpl< + _$AuthEventPasswordChangedImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() started, + required TResult Function(String email, String password) loginRequested, + required TResult Function(String email, String password, String name) + registerRequested, + required TResult Function() logoutRequested, + required TResult Function() authChecked, + required TResult Function(String email) emailChanged, + required TResult Function(String password) passwordChanged, + required TResult Function(String name) nameChanged, + }) { + return passwordChanged(password); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? started, + TResult? Function(String email, String password)? loginRequested, + TResult? Function(String email, String password, String name)? + registerRequested, + TResult? Function()? logoutRequested, + TResult? Function()? authChecked, + TResult? Function(String email)? emailChanged, + TResult? Function(String password)? passwordChanged, + TResult? Function(String name)? nameChanged, + }) { + return passwordChanged?.call(password); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? started, + TResult Function(String email, String password)? loginRequested, + TResult Function(String email, String password, String name)? + registerRequested, + TResult Function()? logoutRequested, + TResult Function()? authChecked, + TResult Function(String email)? emailChanged, + TResult Function(String password)? passwordChanged, + TResult Function(String name)? nameChanged, + required TResult orElse(), + }) { + if (passwordChanged != null) { + return passwordChanged(password); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(AuthEventStarted value) started, + required TResult Function(AuthEventLoginRequested value) loginRequested, + required TResult Function(AuthEventRegisterRequested value) + registerRequested, + required TResult Function(AuthEventLogoutRequested value) logoutRequested, + required TResult Function(AuthEventAuthChecked value) authChecked, + required TResult Function(AuthEventEmailChanged value) emailChanged, + required TResult Function(AuthEventPasswordChanged value) passwordChanged, + required TResult Function(AuthEventNameChanged value) nameChanged, + }) { + return passwordChanged(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(AuthEventStarted value)? started, + TResult? Function(AuthEventLoginRequested value)? loginRequested, + TResult? Function(AuthEventRegisterRequested value)? registerRequested, + TResult? Function(AuthEventLogoutRequested value)? logoutRequested, + TResult? Function(AuthEventAuthChecked value)? authChecked, + TResult? Function(AuthEventEmailChanged value)? emailChanged, + TResult? Function(AuthEventPasswordChanged value)? passwordChanged, + TResult? Function(AuthEventNameChanged value)? nameChanged, + }) { + return passwordChanged?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(AuthEventStarted value)? started, + TResult Function(AuthEventLoginRequested value)? loginRequested, + TResult Function(AuthEventRegisterRequested value)? registerRequested, + TResult Function(AuthEventLogoutRequested value)? logoutRequested, + TResult Function(AuthEventAuthChecked value)? authChecked, + TResult Function(AuthEventEmailChanged value)? emailChanged, + TResult Function(AuthEventPasswordChanged value)? passwordChanged, + TResult Function(AuthEventNameChanged value)? nameChanged, + required TResult orElse(), + }) { + if (passwordChanged != null) { + return passwordChanged(this); + } + return orElse(); + } +} + +abstract class AuthEventPasswordChanged implements AuthEvent { + const factory AuthEventPasswordChanged(final String password) = + _$AuthEventPasswordChangedImpl; + + String get password; + @JsonKey(ignore: true) + _$$AuthEventPasswordChangedImplCopyWith<_$AuthEventPasswordChangedImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$AuthEventNameChangedImplCopyWith<$Res> { + factory _$$AuthEventNameChangedImplCopyWith(_$AuthEventNameChangedImpl value, + $Res Function(_$AuthEventNameChangedImpl) then) = + __$$AuthEventNameChangedImplCopyWithImpl<$Res>; + @useResult + $Res call({String name}); +} + +/// @nodoc +class __$$AuthEventNameChangedImplCopyWithImpl<$Res> + extends _$AuthEventCopyWithImpl<$Res, _$AuthEventNameChangedImpl> + implements _$$AuthEventNameChangedImplCopyWith<$Res> { + __$$AuthEventNameChangedImplCopyWithImpl(_$AuthEventNameChangedImpl _value, + $Res Function(_$AuthEventNameChangedImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? name = null, + }) { + return _then(_$AuthEventNameChangedImpl( + null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$AuthEventNameChangedImpl implements AuthEventNameChanged { + const _$AuthEventNameChangedImpl(this.name); + + @override + final String name; + + @override + String toString() { + return 'AuthEvent.nameChanged(name: $name)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$AuthEventNameChangedImpl && + (identical(other.name, name) || other.name == name)); + } + + @override + int get hashCode => Object.hash(runtimeType, name); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$AuthEventNameChangedImplCopyWith<_$AuthEventNameChangedImpl> + get copyWith => + __$$AuthEventNameChangedImplCopyWithImpl<_$AuthEventNameChangedImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() started, + required TResult Function(String email, String password) loginRequested, + required TResult Function(String email, String password, String name) + registerRequested, + required TResult Function() logoutRequested, + required TResult Function() authChecked, + required TResult Function(String email) emailChanged, + required TResult Function(String password) passwordChanged, + required TResult Function(String name) nameChanged, + }) { + return nameChanged(name); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? started, + TResult? Function(String email, String password)? loginRequested, + TResult? Function(String email, String password, String name)? + registerRequested, + TResult? Function()? logoutRequested, + TResult? Function()? authChecked, + TResult? Function(String email)? emailChanged, + TResult? Function(String password)? passwordChanged, + TResult? Function(String name)? nameChanged, + }) { + return nameChanged?.call(name); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? started, + TResult Function(String email, String password)? loginRequested, + TResult Function(String email, String password, String name)? + registerRequested, + TResult Function()? logoutRequested, + TResult Function()? authChecked, + TResult Function(String email)? emailChanged, + TResult Function(String password)? passwordChanged, + TResult Function(String name)? nameChanged, + required TResult orElse(), + }) { + if (nameChanged != null) { + return nameChanged(name); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(AuthEventStarted value) started, + required TResult Function(AuthEventLoginRequested value) loginRequested, + required TResult Function(AuthEventRegisterRequested value) + registerRequested, + required TResult Function(AuthEventLogoutRequested value) logoutRequested, + required TResult Function(AuthEventAuthChecked value) authChecked, + required TResult Function(AuthEventEmailChanged value) emailChanged, + required TResult Function(AuthEventPasswordChanged value) passwordChanged, + required TResult Function(AuthEventNameChanged value) nameChanged, + }) { + return nameChanged(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(AuthEventStarted value)? started, + TResult? Function(AuthEventLoginRequested value)? loginRequested, + TResult? Function(AuthEventRegisterRequested value)? registerRequested, + TResult? Function(AuthEventLogoutRequested value)? logoutRequested, + TResult? Function(AuthEventAuthChecked value)? authChecked, + TResult? Function(AuthEventEmailChanged value)? emailChanged, + TResult? Function(AuthEventPasswordChanged value)? passwordChanged, + TResult? Function(AuthEventNameChanged value)? nameChanged, + }) { + return nameChanged?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(AuthEventStarted value)? started, + TResult Function(AuthEventLoginRequested value)? loginRequested, + TResult Function(AuthEventRegisterRequested value)? registerRequested, + TResult Function(AuthEventLogoutRequested value)? logoutRequested, + TResult Function(AuthEventAuthChecked value)? authChecked, + TResult Function(AuthEventEmailChanged value)? emailChanged, + TResult Function(AuthEventPasswordChanged value)? passwordChanged, + TResult Function(AuthEventNameChanged value)? nameChanged, + required TResult orElse(), + }) { + if (nameChanged != null) { + return nameChanged(this); + } + return orElse(); + } +} + +abstract class AuthEventNameChanged implements AuthEvent { + const factory AuthEventNameChanged(final String name) = + _$AuthEventNameChangedImpl; + + String get name; + @JsonKey(ignore: true) + _$$AuthEventNameChangedImplCopyWith<_$AuthEventNameChangedImpl> + get copyWith => throw _privateConstructorUsedError; +} diff --git a/client-mobile/lib/features/auth/presentation/bloc/auth_state.dart b/client-mobile/lib/features/auth/presentation/bloc/auth_state.dart new file mode 100644 index 0000000..a0751f7 --- /dev/null +++ b/client-mobile/lib/features/auth/presentation/bloc/auth_state.dart @@ -0,0 +1,12 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'auth_state.freezed.dart'; + +@freezed +class AuthState with _$AuthState { + const factory AuthState.initial() = AuthInitial; + const factory AuthState.loading() = AuthLoading; + const factory AuthState.authenticated(String userId) = AuthAuthenticated; + const factory AuthState.unauthenticated() = AuthUnauthenticated; + const factory AuthState.error(String message) = AuthError; +} diff --git a/client-mobile/lib/features/auth/presentation/bloc/auth_state.freezed.dart b/client-mobile/lib/features/auth/presentation/bloc/auth_state.freezed.dart new file mode 100644 index 0000000..ff1c054 --- /dev/null +++ b/client-mobile/lib/features/auth/presentation/bloc/auth_state.freezed.dart @@ -0,0 +1,757 @@ +// 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 'auth_state.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#adding-getters-and-methods-to-our-models'); + +/// @nodoc +mixin _$AuthState { + @optionalTypeArgs + TResult when({ + required TResult Function() initial, + required TResult Function() loading, + required TResult Function(String userId) authenticated, + required TResult Function() unauthenticated, + required TResult Function(String message) error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? initial, + TResult? Function()? loading, + TResult? Function(String userId)? authenticated, + TResult? Function()? unauthenticated, + TResult? Function(String message)? error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? initial, + TResult Function()? loading, + TResult Function(String userId)? authenticated, + TResult Function()? unauthenticated, + TResult Function(String message)? error, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(AuthInitial value) initial, + required TResult Function(AuthLoading value) loading, + required TResult Function(AuthAuthenticated value) authenticated, + required TResult Function(AuthUnauthenticated value) unauthenticated, + required TResult Function(AuthError value) error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(AuthInitial value)? initial, + TResult? Function(AuthLoading value)? loading, + TResult? Function(AuthAuthenticated value)? authenticated, + TResult? Function(AuthUnauthenticated value)? unauthenticated, + TResult? Function(AuthError value)? error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(AuthInitial value)? initial, + TResult Function(AuthLoading value)? loading, + TResult Function(AuthAuthenticated value)? authenticated, + TResult Function(AuthUnauthenticated value)? unauthenticated, + TResult Function(AuthError value)? error, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $AuthStateCopyWith<$Res> { + factory $AuthStateCopyWith(AuthState value, $Res Function(AuthState) then) = + _$AuthStateCopyWithImpl<$Res, AuthState>; +} + +/// @nodoc +class _$AuthStateCopyWithImpl<$Res, $Val extends AuthState> + implements $AuthStateCopyWith<$Res> { + _$AuthStateCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; +} + +/// @nodoc +abstract class _$$AuthInitialImplCopyWith<$Res> { + factory _$$AuthInitialImplCopyWith( + _$AuthInitialImpl value, $Res Function(_$AuthInitialImpl) then) = + __$$AuthInitialImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$AuthInitialImplCopyWithImpl<$Res> + extends _$AuthStateCopyWithImpl<$Res, _$AuthInitialImpl> + implements _$$AuthInitialImplCopyWith<$Res> { + __$$AuthInitialImplCopyWithImpl( + _$AuthInitialImpl _value, $Res Function(_$AuthInitialImpl) _then) + : super(_value, _then); +} + +/// @nodoc + +class _$AuthInitialImpl implements AuthInitial { + const _$AuthInitialImpl(); + + @override + String toString() { + return 'AuthState.initial()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$AuthInitialImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() initial, + required TResult Function() loading, + required TResult Function(String userId) authenticated, + required TResult Function() unauthenticated, + required TResult Function(String message) error, + }) { + return initial(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? initial, + TResult? Function()? loading, + TResult? Function(String userId)? authenticated, + TResult? Function()? unauthenticated, + TResult? Function(String message)? error, + }) { + return initial?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? initial, + TResult Function()? loading, + TResult Function(String userId)? authenticated, + TResult Function()? unauthenticated, + TResult Function(String message)? error, + required TResult orElse(), + }) { + if (initial != null) { + return initial(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(AuthInitial value) initial, + required TResult Function(AuthLoading value) loading, + required TResult Function(AuthAuthenticated value) authenticated, + required TResult Function(AuthUnauthenticated value) unauthenticated, + required TResult Function(AuthError value) error, + }) { + return initial(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(AuthInitial value)? initial, + TResult? Function(AuthLoading value)? loading, + TResult? Function(AuthAuthenticated value)? authenticated, + TResult? Function(AuthUnauthenticated value)? unauthenticated, + TResult? Function(AuthError value)? error, + }) { + return initial?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(AuthInitial value)? initial, + TResult Function(AuthLoading value)? loading, + TResult Function(AuthAuthenticated value)? authenticated, + TResult Function(AuthUnauthenticated value)? unauthenticated, + TResult Function(AuthError value)? error, + required TResult orElse(), + }) { + if (initial != null) { + return initial(this); + } + return orElse(); + } +} + +abstract class AuthInitial implements AuthState { + const factory AuthInitial() = _$AuthInitialImpl; +} + +/// @nodoc +abstract class _$$AuthLoadingImplCopyWith<$Res> { + factory _$$AuthLoadingImplCopyWith( + _$AuthLoadingImpl value, $Res Function(_$AuthLoadingImpl) then) = + __$$AuthLoadingImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$AuthLoadingImplCopyWithImpl<$Res> + extends _$AuthStateCopyWithImpl<$Res, _$AuthLoadingImpl> + implements _$$AuthLoadingImplCopyWith<$Res> { + __$$AuthLoadingImplCopyWithImpl( + _$AuthLoadingImpl _value, $Res Function(_$AuthLoadingImpl) _then) + : super(_value, _then); +} + +/// @nodoc + +class _$AuthLoadingImpl implements AuthLoading { + const _$AuthLoadingImpl(); + + @override + String toString() { + return 'AuthState.loading()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$AuthLoadingImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() initial, + required TResult Function() loading, + required TResult Function(String userId) authenticated, + required TResult Function() unauthenticated, + required TResult Function(String message) error, + }) { + return loading(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? initial, + TResult? Function()? loading, + TResult? Function(String userId)? authenticated, + TResult? Function()? unauthenticated, + TResult? Function(String message)? error, + }) { + return loading?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? initial, + TResult Function()? loading, + TResult Function(String userId)? authenticated, + TResult Function()? unauthenticated, + TResult Function(String message)? error, + required TResult orElse(), + }) { + if (loading != null) { + return loading(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(AuthInitial value) initial, + required TResult Function(AuthLoading value) loading, + required TResult Function(AuthAuthenticated value) authenticated, + required TResult Function(AuthUnauthenticated value) unauthenticated, + required TResult Function(AuthError value) error, + }) { + return loading(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(AuthInitial value)? initial, + TResult? Function(AuthLoading value)? loading, + TResult? Function(AuthAuthenticated value)? authenticated, + TResult? Function(AuthUnauthenticated value)? unauthenticated, + TResult? Function(AuthError value)? error, + }) { + return loading?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(AuthInitial value)? initial, + TResult Function(AuthLoading value)? loading, + TResult Function(AuthAuthenticated value)? authenticated, + TResult Function(AuthUnauthenticated value)? unauthenticated, + TResult Function(AuthError value)? error, + required TResult orElse(), + }) { + if (loading != null) { + return loading(this); + } + return orElse(); + } +} + +abstract class AuthLoading implements AuthState { + const factory AuthLoading() = _$AuthLoadingImpl; +} + +/// @nodoc +abstract class _$$AuthAuthenticatedImplCopyWith<$Res> { + factory _$$AuthAuthenticatedImplCopyWith(_$AuthAuthenticatedImpl value, + $Res Function(_$AuthAuthenticatedImpl) then) = + __$$AuthAuthenticatedImplCopyWithImpl<$Res>; + @useResult + $Res call({String userId}); +} + +/// @nodoc +class __$$AuthAuthenticatedImplCopyWithImpl<$Res> + extends _$AuthStateCopyWithImpl<$Res, _$AuthAuthenticatedImpl> + implements _$$AuthAuthenticatedImplCopyWith<$Res> { + __$$AuthAuthenticatedImplCopyWithImpl(_$AuthAuthenticatedImpl _value, + $Res Function(_$AuthAuthenticatedImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? userId = null, + }) { + return _then(_$AuthAuthenticatedImpl( + null == userId + ? _value.userId + : userId // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$AuthAuthenticatedImpl implements AuthAuthenticated { + const _$AuthAuthenticatedImpl(this.userId); + + @override + final String userId; + + @override + String toString() { + return 'AuthState.authenticated(userId: $userId)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$AuthAuthenticatedImpl && + (identical(other.userId, userId) || other.userId == userId)); + } + + @override + int get hashCode => Object.hash(runtimeType, userId); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$AuthAuthenticatedImplCopyWith<_$AuthAuthenticatedImpl> get copyWith => + __$$AuthAuthenticatedImplCopyWithImpl<_$AuthAuthenticatedImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() initial, + required TResult Function() loading, + required TResult Function(String userId) authenticated, + required TResult Function() unauthenticated, + required TResult Function(String message) error, + }) { + return authenticated(userId); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? initial, + TResult? Function()? loading, + TResult? Function(String userId)? authenticated, + TResult? Function()? unauthenticated, + TResult? Function(String message)? error, + }) { + return authenticated?.call(userId); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? initial, + TResult Function()? loading, + TResult Function(String userId)? authenticated, + TResult Function()? unauthenticated, + TResult Function(String message)? error, + required TResult orElse(), + }) { + if (authenticated != null) { + return authenticated(userId); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(AuthInitial value) initial, + required TResult Function(AuthLoading value) loading, + required TResult Function(AuthAuthenticated value) authenticated, + required TResult Function(AuthUnauthenticated value) unauthenticated, + required TResult Function(AuthError value) error, + }) { + return authenticated(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(AuthInitial value)? initial, + TResult? Function(AuthLoading value)? loading, + TResult? Function(AuthAuthenticated value)? authenticated, + TResult? Function(AuthUnauthenticated value)? unauthenticated, + TResult? Function(AuthError value)? error, + }) { + return authenticated?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(AuthInitial value)? initial, + TResult Function(AuthLoading value)? loading, + TResult Function(AuthAuthenticated value)? authenticated, + TResult Function(AuthUnauthenticated value)? unauthenticated, + TResult Function(AuthError value)? error, + required TResult orElse(), + }) { + if (authenticated != null) { + return authenticated(this); + } + return orElse(); + } +} + +abstract class AuthAuthenticated implements AuthState { + const factory AuthAuthenticated(final String userId) = + _$AuthAuthenticatedImpl; + + String get userId; + @JsonKey(ignore: true) + _$$AuthAuthenticatedImplCopyWith<_$AuthAuthenticatedImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$AuthUnauthenticatedImplCopyWith<$Res> { + factory _$$AuthUnauthenticatedImplCopyWith(_$AuthUnauthenticatedImpl value, + $Res Function(_$AuthUnauthenticatedImpl) then) = + __$$AuthUnauthenticatedImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$AuthUnauthenticatedImplCopyWithImpl<$Res> + extends _$AuthStateCopyWithImpl<$Res, _$AuthUnauthenticatedImpl> + implements _$$AuthUnauthenticatedImplCopyWith<$Res> { + __$$AuthUnauthenticatedImplCopyWithImpl(_$AuthUnauthenticatedImpl _value, + $Res Function(_$AuthUnauthenticatedImpl) _then) + : super(_value, _then); +} + +/// @nodoc + +class _$AuthUnauthenticatedImpl implements AuthUnauthenticated { + const _$AuthUnauthenticatedImpl(); + + @override + String toString() { + return 'AuthState.unauthenticated()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$AuthUnauthenticatedImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() initial, + required TResult Function() loading, + required TResult Function(String userId) authenticated, + required TResult Function() unauthenticated, + required TResult Function(String message) error, + }) { + return unauthenticated(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? initial, + TResult? Function()? loading, + TResult? Function(String userId)? authenticated, + TResult? Function()? unauthenticated, + TResult? Function(String message)? error, + }) { + return unauthenticated?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? initial, + TResult Function()? loading, + TResult Function(String userId)? authenticated, + TResult Function()? unauthenticated, + TResult Function(String message)? error, + required TResult orElse(), + }) { + if (unauthenticated != null) { + return unauthenticated(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(AuthInitial value) initial, + required TResult Function(AuthLoading value) loading, + required TResult Function(AuthAuthenticated value) authenticated, + required TResult Function(AuthUnauthenticated value) unauthenticated, + required TResult Function(AuthError value) error, + }) { + return unauthenticated(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(AuthInitial value)? initial, + TResult? Function(AuthLoading value)? loading, + TResult? Function(AuthAuthenticated value)? authenticated, + TResult? Function(AuthUnauthenticated value)? unauthenticated, + TResult? Function(AuthError value)? error, + }) { + return unauthenticated?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(AuthInitial value)? initial, + TResult Function(AuthLoading value)? loading, + TResult Function(AuthAuthenticated value)? authenticated, + TResult Function(AuthUnauthenticated value)? unauthenticated, + TResult Function(AuthError value)? error, + required TResult orElse(), + }) { + if (unauthenticated != null) { + return unauthenticated(this); + } + return orElse(); + } +} + +abstract class AuthUnauthenticated implements AuthState { + const factory AuthUnauthenticated() = _$AuthUnauthenticatedImpl; +} + +/// @nodoc +abstract class _$$AuthErrorImplCopyWith<$Res> { + factory _$$AuthErrorImplCopyWith( + _$AuthErrorImpl value, $Res Function(_$AuthErrorImpl) then) = + __$$AuthErrorImplCopyWithImpl<$Res>; + @useResult + $Res call({String message}); +} + +/// @nodoc +class __$$AuthErrorImplCopyWithImpl<$Res> + extends _$AuthStateCopyWithImpl<$Res, _$AuthErrorImpl> + implements _$$AuthErrorImplCopyWith<$Res> { + __$$AuthErrorImplCopyWithImpl( + _$AuthErrorImpl _value, $Res Function(_$AuthErrorImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? message = null, + }) { + return _then(_$AuthErrorImpl( + null == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$AuthErrorImpl implements AuthError { + const _$AuthErrorImpl(this.message); + + @override + final String message; + + @override + String toString() { + return 'AuthState.error(message: $message)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$AuthErrorImpl && + (identical(other.message, message) || other.message == message)); + } + + @override + int get hashCode => Object.hash(runtimeType, message); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$AuthErrorImplCopyWith<_$AuthErrorImpl> get copyWith => + __$$AuthErrorImplCopyWithImpl<_$AuthErrorImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() initial, + required TResult Function() loading, + required TResult Function(String userId) authenticated, + required TResult Function() unauthenticated, + required TResult Function(String message) error, + }) { + return error(message); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? initial, + TResult? Function()? loading, + TResult? Function(String userId)? authenticated, + TResult? Function()? unauthenticated, + TResult? Function(String message)? error, + }) { + return error?.call(message); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? initial, + TResult Function()? loading, + TResult Function(String userId)? authenticated, + TResult Function()? unauthenticated, + TResult Function(String message)? error, + required TResult orElse(), + }) { + if (error != null) { + return error(message); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(AuthInitial value) initial, + required TResult Function(AuthLoading value) loading, + required TResult Function(AuthAuthenticated value) authenticated, + required TResult Function(AuthUnauthenticated value) unauthenticated, + required TResult Function(AuthError value) error, + }) { + return error(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(AuthInitial value)? initial, + TResult? Function(AuthLoading value)? loading, + TResult? Function(AuthAuthenticated value)? authenticated, + TResult? Function(AuthUnauthenticated value)? unauthenticated, + TResult? Function(AuthError value)? error, + }) { + return error?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(AuthInitial value)? initial, + TResult Function(AuthLoading value)? loading, + TResult Function(AuthAuthenticated value)? authenticated, + TResult Function(AuthUnauthenticated value)? unauthenticated, + TResult Function(AuthError value)? error, + required TResult orElse(), + }) { + if (error != null) { + return error(this); + } + return orElse(); + } +} + +abstract class AuthError implements AuthState { + const factory AuthError(final String message) = _$AuthErrorImpl; + + String get message; + @JsonKey(ignore: true) + _$$AuthErrorImplCopyWith<_$AuthErrorImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/client-mobile/lib/features/auth/presentation/pages/login_page.dart b/client-mobile/lib/features/auth/presentation/pages/login_page.dart new file mode 100644 index 0000000..c9dc41f --- /dev/null +++ b/client-mobile/lib/features/auth/presentation/pages/login_page.dart @@ -0,0 +1,134 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import '../bloc/auth_bloc.dart'; +import '../bloc/auth_event.dart'; +import '../bloc/auth_state.dart'; + +class LoginPage extends StatefulWidget { + const LoginPage({super.key}); + + @override + State createState() => _LoginPageState(); +} + +class _LoginPageState extends State { + final _formKey = GlobalKey(); + final _emailController = TextEditingController(); + final _passwordController = TextEditingController(); + + @override + void dispose() { + _emailController.dispose(); + _passwordController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Вход'), + ), + body: BlocListener( + listener: (context, state) { + state.whenOrNull( + authenticated: (userId) { + Navigator.of(context).popUntil((route) => route.isFirst); + }, + error: (message) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text(message)), + ); + }, + ); + }, + child: Center( + child: Padding( + padding: const EdgeInsets.all(24.0), + child: Form( + key: _formKey, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + const Icon( + Icons.chat_bubble_outline, + size: 80, + color: Color(0xFF2481CC), + ), + const SizedBox(height: 32), + TextFormField( + controller: _emailController, + decoration: const InputDecoration( + labelText: 'Email', + prefixIcon: Icon(Icons.email_outlined), + ), + keyboardType: TextInputType.emailAddress, + validator: (value) { + if (value == null || value.isEmpty) { + return 'Введите email'; + } + if (!value.contains('@')) { + return 'Введите корректный email'; + } + return null; + }, + ), + const SizedBox(height: 16), + TextFormField( + controller: _passwordController, + decoration: const InputDecoration( + labelText: 'Пароль', + prefixIcon: Icon(Icons.lock_outlined), + ), + obscureText: true, + validator: (value) { + if (value == null || value.isEmpty) { + return 'Введите пароль'; + } + if (value.length < 6) { + return 'Пароль должен быть не менее 6 символов'; + } + return null; + }, + ), + const SizedBox(height: 32), + BlocBuilder( + builder: (context, state) { + if (state is AuthLoading) { + return const Center(child: CircularProgressIndicator()); + } + return ElevatedButton( + onPressed: () { + if (_formKey.currentState?.validate() ?? false) { + context.read().add( + AuthEvent.loginRequested( + _emailController.text, + _passwordController.text, + ), + ); + } + }, + child: const Padding( + padding: EdgeInsets.symmetric(vertical: 12), + child: Text('Войти', style: TextStyle(fontSize: 16)), + ), + ); + }, + ), + const SizedBox(height: 16), + TextButton( + onPressed: () { + // Navigate to register page + }, + child: const Text('Нет аккаунта? Зарегистрироваться'), + ), + ], + ), + ), + ), + ), + ), + ); + } +} diff --git a/client-mobile/lib/features/chat/data/datasources/chat_local_datasource.dart b/client-mobile/lib/features/chat/data/datasources/chat_local_datasource.dart new file mode 100644 index 0000000..769a8cd --- /dev/null +++ b/client-mobile/lib/features/chat/data/datasources/chat_local_datasource.dart @@ -0,0 +1,13 @@ +import '../../../../core/errors/result.dart'; +import '../../domain/entities/chat.dart'; +import '../../domain/entities/message.dart'; + +abstract class ChatLocalDataSource { + Future>> getCachedChats(); + Future> cacheChats(List chats); + Future> getChatFromCache(String chatId); + Future> cacheChat(Chat chat); + Future>> getMessagesFromCache(String chatId); + Future> cacheMessages(String chatId, List messages); + Future> clearCache(); +} diff --git a/client-mobile/lib/features/chat/data/datasources/chat_remote_datasource.dart b/client-mobile/lib/features/chat/data/datasources/chat_remote_datasource.dart new file mode 100644 index 0000000..23a115f --- /dev/null +++ b/client-mobile/lib/features/chat/data/datasources/chat_remote_datasource.dart @@ -0,0 +1,12 @@ +import '../../../../core/errors/result.dart'; +import '../../domain/entities/chat.dart'; +import '../../domain/entities/message.dart'; + +abstract class ChatRemoteDataSource { + Future>> getChats(); + Future> getChatById(String chatId); + Future> createChat(String title, List participantIds); + Future> sendMessage(String chatId, Message message); + Future>> getMessages(String chatId, {int? limit, String? lastMessageId}); + Stream> listenToMessages(String chatId); +} diff --git a/client-mobile/lib/features/chat/data/repositories/chat_repository_impl.dart b/client-mobile/lib/features/chat/data/repositories/chat_repository_impl.dart new file mode 100644 index 0000000..f774b90 --- /dev/null +++ b/client-mobile/lib/features/chat/data/repositories/chat_repository_impl.dart @@ -0,0 +1,47 @@ +import '../../../../core/errors/errors.dart'; +import '../../../../core/errors/result.dart'; +import '../../domain/entities/chat.dart'; +import '../../domain/entities/message.dart'; +import '../../domain/repositories/chat_repository.dart'; + +class ChatRepositoryImpl implements ChatRepository { + @override + Future> createChat(String title, List participantIds) async { + return const Result.success(null); + } + + @override + Future> deleteChat(String chatId) async { + return const Result.success(null); + } + + @override + Future> getChatById(String chatId) async { + return const Result.failure(AppError.notFound(message: 'Chat not found')); + } + + @override + Future>> getChats() async { + // Return empty list for now + return const Result.success([]); + } + + @override + Future>> getMessages( + String chatId, { + int? limit, + String? lastMessageId, + }) async { + return const Result.success([]); + } + + @override + Future> sendMessage(String chatId, Message message) async { + return const Result.success(null); + } + + @override + Future> updateChat(String chatId, String title) async { + return const Result.success(null); + } +} diff --git a/client-mobile/lib/features/chat/domain/entities/chat.dart b/client-mobile/lib/features/chat/domain/entities/chat.dart new file mode 100644 index 0000000..3e02beb --- /dev/null +++ b/client-mobile/lib/features/chat/domain/entities/chat.dart @@ -0,0 +1,21 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'user.dart'; +import 'message.dart'; + +part 'chat.freezed.dart'; + +@freezed +class Chat with _$Chat { + const factory Chat({ + required String id, + required String type, + required String title, + String? avatarUrl, + List? participants, + @Default(null) Message? lastMessage, + DateTime? lastMessageTime, + @Default(0) int unreadCount, + @Default(false) bool isMuted, + @Default(false) bool isPinned, + }) = _Chat; +} diff --git a/client-mobile/lib/features/chat/domain/entities/chat.freezed.dart b/client-mobile/lib/features/chat/domain/entities/chat.freezed.dart new file mode 100644 index 0000000..5a9944b --- /dev/null +++ b/client-mobile/lib/features/chat/domain/entities/chat.freezed.dart @@ -0,0 +1,359 @@ +// 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 'chat.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#adding-getters-and-methods-to-our-models'); + +/// @nodoc +mixin _$Chat { + String get id => throw _privateConstructorUsedError; + String get type => throw _privateConstructorUsedError; + String get title => throw _privateConstructorUsedError; + String? get avatarUrl => throw _privateConstructorUsedError; + List? get participants => throw _privateConstructorUsedError; + Message? get lastMessage => throw _privateConstructorUsedError; + DateTime? get lastMessageTime => throw _privateConstructorUsedError; + int get unreadCount => throw _privateConstructorUsedError; + bool get isMuted => throw _privateConstructorUsedError; + bool get isPinned => throw _privateConstructorUsedError; + + @JsonKey(ignore: true) + $ChatCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ChatCopyWith<$Res> { + factory $ChatCopyWith(Chat value, $Res Function(Chat) then) = + _$ChatCopyWithImpl<$Res, Chat>; + @useResult + $Res call( + {String id, + String type, + String title, + String? avatarUrl, + List? participants, + Message? lastMessage, + DateTime? lastMessageTime, + int unreadCount, + bool isMuted, + bool isPinned}); + + $MessageCopyWith<$Res>? get lastMessage; +} + +/// @nodoc +class _$ChatCopyWithImpl<$Res, $Val extends Chat> + implements $ChatCopyWith<$Res> { + _$ChatCopyWithImpl(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? type = null, + Object? title = null, + Object? avatarUrl = freezed, + Object? participants = freezed, + Object? lastMessage = freezed, + Object? lastMessageTime = freezed, + Object? unreadCount = null, + Object? isMuted = null, + Object? isPinned = null, + }) { + return _then(_value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + type: null == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as String, + title: null == title + ? _value.title + : title // ignore: cast_nullable_to_non_nullable + as String, + avatarUrl: freezed == avatarUrl + ? _value.avatarUrl + : avatarUrl // ignore: cast_nullable_to_non_nullable + as String?, + participants: freezed == participants + ? _value.participants + : participants // ignore: cast_nullable_to_non_nullable + as List?, + lastMessage: freezed == lastMessage + ? _value.lastMessage + : lastMessage // ignore: cast_nullable_to_non_nullable + as Message?, + lastMessageTime: freezed == lastMessageTime + ? _value.lastMessageTime + : lastMessageTime // ignore: cast_nullable_to_non_nullable + as DateTime?, + unreadCount: null == unreadCount + ? _value.unreadCount + : unreadCount // ignore: cast_nullable_to_non_nullable + as int, + isMuted: null == isMuted + ? _value.isMuted + : isMuted // ignore: cast_nullable_to_non_nullable + as bool, + isPinned: null == isPinned + ? _value.isPinned + : isPinned // ignore: cast_nullable_to_non_nullable + as bool, + ) as $Val); + } + + @override + @pragma('vm:prefer-inline') + $MessageCopyWith<$Res>? get lastMessage { + if (_value.lastMessage == null) { + return null; + } + + return $MessageCopyWith<$Res>(_value.lastMessage!, (value) { + return _then(_value.copyWith(lastMessage: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$ChatImplCopyWith<$Res> implements $ChatCopyWith<$Res> { + factory _$$ChatImplCopyWith( + _$ChatImpl value, $Res Function(_$ChatImpl) then) = + __$$ChatImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String id, + String type, + String title, + String? avatarUrl, + List? participants, + Message? lastMessage, + DateTime? lastMessageTime, + int unreadCount, + bool isMuted, + bool isPinned}); + + @override + $MessageCopyWith<$Res>? get lastMessage; +} + +/// @nodoc +class __$$ChatImplCopyWithImpl<$Res> + extends _$ChatCopyWithImpl<$Res, _$ChatImpl> + implements _$$ChatImplCopyWith<$Res> { + __$$ChatImplCopyWithImpl(_$ChatImpl _value, $Res Function(_$ChatImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? type = null, + Object? title = null, + Object? avatarUrl = freezed, + Object? participants = freezed, + Object? lastMessage = freezed, + Object? lastMessageTime = freezed, + Object? unreadCount = null, + Object? isMuted = null, + Object? isPinned = null, + }) { + return _then(_$ChatImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + type: null == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as String, + title: null == title + ? _value.title + : title // ignore: cast_nullable_to_non_nullable + as String, + avatarUrl: freezed == avatarUrl + ? _value.avatarUrl + : avatarUrl // ignore: cast_nullable_to_non_nullable + as String?, + participants: freezed == participants + ? _value._participants + : participants // ignore: cast_nullable_to_non_nullable + as List?, + lastMessage: freezed == lastMessage + ? _value.lastMessage + : lastMessage // ignore: cast_nullable_to_non_nullable + as Message?, + lastMessageTime: freezed == lastMessageTime + ? _value.lastMessageTime + : lastMessageTime // ignore: cast_nullable_to_non_nullable + as DateTime?, + unreadCount: null == unreadCount + ? _value.unreadCount + : unreadCount // ignore: cast_nullable_to_non_nullable + as int, + isMuted: null == isMuted + ? _value.isMuted + : isMuted // ignore: cast_nullable_to_non_nullable + as bool, + isPinned: null == isPinned + ? _value.isPinned + : isPinned // ignore: cast_nullable_to_non_nullable + as bool, + )); + } +} + +/// @nodoc + +class _$ChatImpl implements _Chat { + const _$ChatImpl( + {required this.id, + required this.type, + required this.title, + this.avatarUrl, + final List? participants, + this.lastMessage = null, + this.lastMessageTime, + this.unreadCount = 0, + this.isMuted = false, + this.isPinned = false}) + : _participants = participants; + + @override + final String id; + @override + final String type; + @override + final String title; + @override + final String? avatarUrl; + final List? _participants; + @override + List? get participants { + final value = _participants; + if (value == null) return null; + if (_participants is EqualUnmodifiableListView) return _participants; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + @override + @JsonKey() + final Message? lastMessage; + @override + final DateTime? lastMessageTime; + @override + @JsonKey() + final int unreadCount; + @override + @JsonKey() + final bool isMuted; + @override + @JsonKey() + final bool isPinned; + + @override + String toString() { + return 'Chat(id: $id, type: $type, title: $title, avatarUrl: $avatarUrl, participants: $participants, lastMessage: $lastMessage, lastMessageTime: $lastMessageTime, unreadCount: $unreadCount, isMuted: $isMuted, isPinned: $isPinned)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ChatImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.type, type) || other.type == type) && + (identical(other.title, title) || other.title == title) && + (identical(other.avatarUrl, avatarUrl) || + other.avatarUrl == avatarUrl) && + const DeepCollectionEquality() + .equals(other._participants, _participants) && + (identical(other.lastMessage, lastMessage) || + other.lastMessage == lastMessage) && + (identical(other.lastMessageTime, lastMessageTime) || + other.lastMessageTime == lastMessageTime) && + (identical(other.unreadCount, unreadCount) || + other.unreadCount == unreadCount) && + (identical(other.isMuted, isMuted) || other.isMuted == isMuted) && + (identical(other.isPinned, isPinned) || + other.isPinned == isPinned)); + } + + @override + int get hashCode => Object.hash( + runtimeType, + id, + type, + title, + avatarUrl, + const DeepCollectionEquality().hash(_participants), + lastMessage, + lastMessageTime, + unreadCount, + isMuted, + isPinned); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$ChatImplCopyWith<_$ChatImpl> get copyWith => + __$$ChatImplCopyWithImpl<_$ChatImpl>(this, _$identity); +} + +abstract class _Chat implements Chat { + const factory _Chat( + {required final String id, + required final String type, + required final String title, + final String? avatarUrl, + final List? participants, + final Message? lastMessage, + final DateTime? lastMessageTime, + final int unreadCount, + final bool isMuted, + final bool isPinned}) = _$ChatImpl; + + @override + String get id; + @override + String get type; + @override + String get title; + @override + String? get avatarUrl; + @override + List? get participants; + @override + Message? get lastMessage; + @override + DateTime? get lastMessageTime; + @override + int get unreadCount; + @override + bool get isMuted; + @override + bool get isPinned; + @override + @JsonKey(ignore: true) + _$$ChatImplCopyWith<_$ChatImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/client-mobile/lib/features/chat/domain/entities/message.dart b/client-mobile/lib/features/chat/domain/entities/message.dart new file mode 100644 index 0000000..853d41d --- /dev/null +++ b/client-mobile/lib/features/chat/domain/entities/message.dart @@ -0,0 +1,21 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'message.freezed.dart'; +// part 'message.g.dart'; + +@freezed +class Message with _$Message { + const factory Message({ + required String id, + required String chatId, + required String senderId, + required String content, + required String messageType, // 'text', 'image', 'video', 'audio', 'file' + DateTime? createdAt, + DateTime? updatedAt, + bool? isRead, + Map? media, + }) = _Message; + + // factory Message.fromJson(Map json) => _$MessageFromJson(json); +} diff --git a/client-mobile/lib/features/chat/domain/entities/message.freezed.dart b/client-mobile/lib/features/chat/domain/entities/message.freezed.dart new file mode 100644 index 0000000..2a0d83c --- /dev/null +++ b/client-mobile/lib/features/chat/domain/entities/message.freezed.dart @@ -0,0 +1,317 @@ +// 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 'message.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#adding-getters-and-methods-to-our-models'); + +/// @nodoc +mixin _$Message { + String get id => throw _privateConstructorUsedError; + String get chatId => throw _privateConstructorUsedError; + String get senderId => throw _privateConstructorUsedError; + String get content => throw _privateConstructorUsedError; + String get messageType => + throw _privateConstructorUsedError; // 'text', 'image', 'video', 'audio', 'file' + DateTime? get createdAt => throw _privateConstructorUsedError; + DateTime? get updatedAt => throw _privateConstructorUsedError; + bool? get isRead => throw _privateConstructorUsedError; + Map? get media => throw _privateConstructorUsedError; + + @JsonKey(ignore: true) + $MessageCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $MessageCopyWith<$Res> { + factory $MessageCopyWith(Message value, $Res Function(Message) then) = + _$MessageCopyWithImpl<$Res, Message>; + @useResult + $Res call( + {String id, + String chatId, + String senderId, + String content, + String messageType, + DateTime? createdAt, + DateTime? updatedAt, + bool? isRead, + Map? media}); +} + +/// @nodoc +class _$MessageCopyWithImpl<$Res, $Val extends Message> + implements $MessageCopyWith<$Res> { + _$MessageCopyWithImpl(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? chatId = null, + Object? senderId = null, + Object? content = null, + Object? messageType = null, + Object? createdAt = freezed, + Object? updatedAt = freezed, + Object? isRead = freezed, + Object? media = freezed, + }) { + return _then(_value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + chatId: null == chatId + ? _value.chatId + : chatId // ignore: cast_nullable_to_non_nullable + as String, + senderId: null == senderId + ? _value.senderId + : senderId // ignore: cast_nullable_to_non_nullable + as String, + content: null == content + ? _value.content + : content // ignore: cast_nullable_to_non_nullable + as String, + messageType: null == messageType + ? _value.messageType + : messageType // ignore: cast_nullable_to_non_nullable + as String, + createdAt: freezed == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as DateTime?, + updatedAt: freezed == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as DateTime?, + isRead: freezed == isRead + ? _value.isRead + : isRead // ignore: cast_nullable_to_non_nullable + as bool?, + media: freezed == media + ? _value.media + : media // ignore: cast_nullable_to_non_nullable + as Map?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$MessageImplCopyWith<$Res> implements $MessageCopyWith<$Res> { + factory _$$MessageImplCopyWith( + _$MessageImpl value, $Res Function(_$MessageImpl) then) = + __$$MessageImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String id, + String chatId, + String senderId, + String content, + String messageType, + DateTime? createdAt, + DateTime? updatedAt, + bool? isRead, + Map? media}); +} + +/// @nodoc +class __$$MessageImplCopyWithImpl<$Res> + extends _$MessageCopyWithImpl<$Res, _$MessageImpl> + implements _$$MessageImplCopyWith<$Res> { + __$$MessageImplCopyWithImpl( + _$MessageImpl _value, $Res Function(_$MessageImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? chatId = null, + Object? senderId = null, + Object? content = null, + Object? messageType = null, + Object? createdAt = freezed, + Object? updatedAt = freezed, + Object? isRead = freezed, + Object? media = freezed, + }) { + return _then(_$MessageImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + chatId: null == chatId + ? _value.chatId + : chatId // ignore: cast_nullable_to_non_nullable + as String, + senderId: null == senderId + ? _value.senderId + : senderId // ignore: cast_nullable_to_non_nullable + as String, + content: null == content + ? _value.content + : content // ignore: cast_nullable_to_non_nullable + as String, + messageType: null == messageType + ? _value.messageType + : messageType // ignore: cast_nullable_to_non_nullable + as String, + createdAt: freezed == createdAt + ? _value.createdAt + : createdAt // ignore: cast_nullable_to_non_nullable + as DateTime?, + updatedAt: freezed == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as DateTime?, + isRead: freezed == isRead + ? _value.isRead + : isRead // ignore: cast_nullable_to_non_nullable + as bool?, + media: freezed == media + ? _value._media + : media // ignore: cast_nullable_to_non_nullable + as Map?, + )); + } +} + +/// @nodoc + +class _$MessageImpl implements _Message { + const _$MessageImpl( + {required this.id, + required this.chatId, + required this.senderId, + required this.content, + required this.messageType, + this.createdAt, + this.updatedAt, + this.isRead, + final Map? media}) + : _media = media; + + @override + final String id; + @override + final String chatId; + @override + final String senderId; + @override + final String content; + @override + final String messageType; +// 'text', 'image', 'video', 'audio', 'file' + @override + final DateTime? createdAt; + @override + final DateTime? updatedAt; + @override + final bool? isRead; + final Map? _media; + @override + Map? get media { + final value = _media; + if (value == null) return null; + if (_media is EqualUnmodifiableMapView) return _media; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(value); + } + + @override + String toString() { + return 'Message(id: $id, chatId: $chatId, senderId: $senderId, content: $content, messageType: $messageType, createdAt: $createdAt, updatedAt: $updatedAt, isRead: $isRead, media: $media)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$MessageImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.chatId, chatId) || other.chatId == chatId) && + (identical(other.senderId, senderId) || + other.senderId == senderId) && + (identical(other.content, content) || other.content == content) && + (identical(other.messageType, messageType) || + other.messageType == messageType) && + (identical(other.createdAt, createdAt) || + other.createdAt == createdAt) && + (identical(other.updatedAt, updatedAt) || + other.updatedAt == updatedAt) && + (identical(other.isRead, isRead) || other.isRead == isRead) && + const DeepCollectionEquality().equals(other._media, _media)); + } + + @override + int get hashCode => Object.hash( + runtimeType, + id, + chatId, + senderId, + content, + messageType, + createdAt, + updatedAt, + isRead, + const DeepCollectionEquality().hash(_media)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$MessageImplCopyWith<_$MessageImpl> get copyWith => + __$$MessageImplCopyWithImpl<_$MessageImpl>(this, _$identity); +} + +abstract class _Message implements Message { + const factory _Message( + {required final String id, + required final String chatId, + required final String senderId, + required final String content, + required final String messageType, + final DateTime? createdAt, + final DateTime? updatedAt, + final bool? isRead, + final Map? media}) = _$MessageImpl; + + @override + String get id; + @override + String get chatId; + @override + String get senderId; + @override + String get content; + @override + String get messageType; + @override // 'text', 'image', 'video', 'audio', 'file' + DateTime? get createdAt; + @override + DateTime? get updatedAt; + @override + bool? get isRead; + @override + Map? get media; + @override + @JsonKey(ignore: true) + _$$MessageImplCopyWith<_$MessageImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/client-mobile/lib/features/chat/domain/entities/user.dart b/client-mobile/lib/features/chat/domain/entities/user.dart new file mode 100644 index 0000000..d6a0ddc --- /dev/null +++ b/client-mobile/lib/features/chat/domain/entities/user.dart @@ -0,0 +1,18 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'user.freezed.dart'; +// part 'user.g.dart'; + +@freezed +class User with _$User { + const factory User({ + required String id, + required String name, + String? avatarUrl, + String? role, // 'admin', 'member' + bool? isOnline, + DateTime? lastSeen, + }) = _User; + + // factory User.fromJson(Map json) => _$UserFromJson(json); +} diff --git a/client-mobile/lib/features/chat/domain/entities/user.freezed.dart b/client-mobile/lib/features/chat/domain/entities/user.freezed.dart new file mode 100644 index 0000000..80689f1 --- /dev/null +++ b/client-mobile/lib/features/chat/domain/entities/user.freezed.dart @@ -0,0 +1,237 @@ +// 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 'user.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#adding-getters-and-methods-to-our-models'); + +/// @nodoc +mixin _$User { + String get id => throw _privateConstructorUsedError; + String get name => throw _privateConstructorUsedError; + String? get avatarUrl => throw _privateConstructorUsedError; + String? get role => throw _privateConstructorUsedError; // 'admin', 'member' + bool? get isOnline => throw _privateConstructorUsedError; + DateTime? get lastSeen => throw _privateConstructorUsedError; + + @JsonKey(ignore: true) + $UserCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $UserCopyWith<$Res> { + factory $UserCopyWith(User value, $Res Function(User) then) = + _$UserCopyWithImpl<$Res, User>; + @useResult + $Res call( + {String id, + String name, + String? avatarUrl, + String? role, + bool? isOnline, + DateTime? lastSeen}); +} + +/// @nodoc +class _$UserCopyWithImpl<$Res, $Val extends User> + implements $UserCopyWith<$Res> { + _$UserCopyWithImpl(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? avatarUrl = freezed, + Object? role = freezed, + Object? isOnline = freezed, + Object? lastSeen = freezed, + }) { + return _then(_value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + avatarUrl: freezed == avatarUrl + ? _value.avatarUrl + : avatarUrl // ignore: cast_nullable_to_non_nullable + as String?, + role: freezed == role + ? _value.role + : role // ignore: cast_nullable_to_non_nullable + as String?, + isOnline: freezed == isOnline + ? _value.isOnline + : isOnline // ignore: cast_nullable_to_non_nullable + as bool?, + lastSeen: freezed == lastSeen + ? _value.lastSeen + : lastSeen // ignore: cast_nullable_to_non_nullable + as DateTime?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$UserImplCopyWith<$Res> implements $UserCopyWith<$Res> { + factory _$$UserImplCopyWith( + _$UserImpl value, $Res Function(_$UserImpl) then) = + __$$UserImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String id, + String name, + String? avatarUrl, + String? role, + bool? isOnline, + DateTime? lastSeen}); +} + +/// @nodoc +class __$$UserImplCopyWithImpl<$Res> + extends _$UserCopyWithImpl<$Res, _$UserImpl> + implements _$$UserImplCopyWith<$Res> { + __$$UserImplCopyWithImpl(_$UserImpl _value, $Res Function(_$UserImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? name = null, + Object? avatarUrl = freezed, + Object? role = freezed, + Object? isOnline = freezed, + Object? lastSeen = freezed, + }) { + return _then(_$UserImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + avatarUrl: freezed == avatarUrl + ? _value.avatarUrl + : avatarUrl // ignore: cast_nullable_to_non_nullable + as String?, + role: freezed == role + ? _value.role + : role // ignore: cast_nullable_to_non_nullable + as String?, + isOnline: freezed == isOnline + ? _value.isOnline + : isOnline // ignore: cast_nullable_to_non_nullable + as bool?, + lastSeen: freezed == lastSeen + ? _value.lastSeen + : lastSeen // ignore: cast_nullable_to_non_nullable + as DateTime?, + )); + } +} + +/// @nodoc + +class _$UserImpl implements _User { + const _$UserImpl( + {required this.id, + required this.name, + this.avatarUrl, + this.role, + this.isOnline, + this.lastSeen}); + + @override + final String id; + @override + final String name; + @override + final String? avatarUrl; + @override + final String? role; +// 'admin', 'member' + @override + final bool? isOnline; + @override + final DateTime? lastSeen; + + @override + String toString() { + return 'User(id: $id, name: $name, avatarUrl: $avatarUrl, role: $role, isOnline: $isOnline, lastSeen: $lastSeen)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$UserImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.name, name) || other.name == name) && + (identical(other.avatarUrl, avatarUrl) || + other.avatarUrl == avatarUrl) && + (identical(other.role, role) || other.role == role) && + (identical(other.isOnline, isOnline) || + other.isOnline == isOnline) && + (identical(other.lastSeen, lastSeen) || + other.lastSeen == lastSeen)); + } + + @override + int get hashCode => + Object.hash(runtimeType, id, name, avatarUrl, role, isOnline, lastSeen); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$UserImplCopyWith<_$UserImpl> get copyWith => + __$$UserImplCopyWithImpl<_$UserImpl>(this, _$identity); +} + +abstract class _User implements User { + const factory _User( + {required final String id, + required final String name, + final String? avatarUrl, + final String? role, + final bool? isOnline, + final DateTime? lastSeen}) = _$UserImpl; + + @override + String get id; + @override + String get name; + @override + String? get avatarUrl; + @override + String? get role; + @override // 'admin', 'member' + bool? get isOnline; + @override + DateTime? get lastSeen; + @override + @JsonKey(ignore: true) + _$$UserImplCopyWith<_$UserImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/client-mobile/lib/features/chat/domain/repositories/chat_repository.dart b/client-mobile/lib/features/chat/domain/repositories/chat_repository.dart new file mode 100644 index 0000000..f5b2015 --- /dev/null +++ b/client-mobile/lib/features/chat/domain/repositories/chat_repository.dart @@ -0,0 +1,13 @@ +import '../../../../core/errors/result.dart'; +import '../entities/chat.dart'; +import '../entities/message.dart'; + +abstract class ChatRepository { + Future>> getChats(); + Future> getChatById(String chatId); + Future> createChat(String title, List participantIds); + Future> sendMessage(String chatId, Message message); + Future>> getMessages(String chatId, {int? limit, String? lastMessageId}); + Future> deleteChat(String chatId); + Future> updateChat(String chatId, String title); +} diff --git a/client-mobile/lib/features/chat/domain/usecases/get_chats.dart b/client-mobile/lib/features/chat/domain/usecases/get_chats.dart new file mode 100644 index 0000000..5a06975 --- /dev/null +++ b/client-mobile/lib/features/chat/domain/usecases/get_chats.dart @@ -0,0 +1,13 @@ +import '../../../../core/errors/result.dart'; +import '../repositories/chat_repository.dart'; +import '../entities/chat.dart'; + +class GetChatsUseCase { + final ChatRepository _repository; + + GetChatsUseCase(this._repository); + + Future>> execute() { + return _repository.getChats(); + } +} diff --git a/client-mobile/lib/features/chat/presentation/bloc/chat_bloc.dart b/client-mobile/lib/features/chat/presentation/bloc/chat_bloc.dart new file mode 100644 index 0000000..60671cf --- /dev/null +++ b/client-mobile/lib/features/chat/presentation/bloc/chat_bloc.dart @@ -0,0 +1,23 @@ +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'chat_event.dart'; +import 'chat_state.dart'; + +class ChatBloc extends Bloc { + ChatBloc() : super(const ChatState.initial()) { + on(_onStarted); + on(_onChatsLoaded); + on(_onChatSelected); + on(_onMessagesRequested); + on(_onMessageSent); + } + + Future _onStarted(ChatEventStarted event, emit) async { + emit(const ChatState.loading()); + emit(const ChatState.chatsLoaded([])); + } + + Future _onChatsLoaded(ChatEventChatsLoaded event, emit) async {} + Future _onChatSelected(ChatEventChatSelected event, emit) async {} + Future _onMessagesRequested(ChatEventMessagesRequested event, emit) async {} + Future _onMessageSent(ChatEventMessageSent event, emit) async {} +} diff --git a/client-mobile/lib/features/chat/presentation/bloc/chat_event.dart b/client-mobile/lib/features/chat/presentation/bloc/chat_event.dart new file mode 100644 index 0000000..c94c783 --- /dev/null +++ b/client-mobile/lib/features/chat/presentation/bloc/chat_event.dart @@ -0,0 +1,14 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'chat_event.freezed.dart'; + +@freezed +class ChatEvent with _$ChatEvent { + const factory ChatEvent.started() = ChatEventStarted; + const factory ChatEvent.chatsLoaded() = ChatEventChatsLoaded; + const factory ChatEvent.chatSelected(String chatId) = ChatEventChatSelected; + const factory ChatEvent.messagesRequested(String chatId, {String? lastMessageId}) = ChatEventMessagesRequested; + const factory ChatEvent.messageSent(String chatId, String content) = ChatEventMessageSent; + const factory ChatEvent.messageRead(String chatId, String messageId) = ChatEventMessageRead; + const factory ChatEvent.chatCreated(String title, List participantIds) = ChatEventChatCreated; +} diff --git a/client-mobile/lib/features/chat/presentation/bloc/chat_event.freezed.dart b/client-mobile/lib/features/chat/presentation/bloc/chat_event.freezed.dart new file mode 100644 index 0000000..83e3d4c --- /dev/null +++ b/client-mobile/lib/features/chat/presentation/bloc/chat_event.freezed.dart @@ -0,0 +1,1272 @@ +// 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 'chat_event.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#adding-getters-and-methods-to-our-models'); + +/// @nodoc +mixin _$ChatEvent { + @optionalTypeArgs + TResult when({ + required TResult Function() started, + required TResult Function() chatsLoaded, + required TResult Function(String chatId) chatSelected, + required TResult Function(String chatId, String? lastMessageId) + messagesRequested, + required TResult Function(String chatId, String content) messageSent, + required TResult Function(String chatId, String messageId) messageRead, + required TResult Function(String title, List participantIds) + chatCreated, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? started, + TResult? Function()? chatsLoaded, + TResult? Function(String chatId)? chatSelected, + TResult? Function(String chatId, String? lastMessageId)? messagesRequested, + TResult? Function(String chatId, String content)? messageSent, + TResult? Function(String chatId, String messageId)? messageRead, + TResult? Function(String title, List participantIds)? chatCreated, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? started, + TResult Function()? chatsLoaded, + TResult Function(String chatId)? chatSelected, + TResult Function(String chatId, String? lastMessageId)? messagesRequested, + TResult Function(String chatId, String content)? messageSent, + TResult Function(String chatId, String messageId)? messageRead, + TResult Function(String title, List participantIds)? chatCreated, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(ChatEventStarted value) started, + required TResult Function(ChatEventChatsLoaded value) chatsLoaded, + required TResult Function(ChatEventChatSelected value) chatSelected, + required TResult Function(ChatEventMessagesRequested value) + messagesRequested, + required TResult Function(ChatEventMessageSent value) messageSent, + required TResult Function(ChatEventMessageRead value) messageRead, + required TResult Function(ChatEventChatCreated value) chatCreated, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(ChatEventStarted value)? started, + TResult? Function(ChatEventChatsLoaded value)? chatsLoaded, + TResult? Function(ChatEventChatSelected value)? chatSelected, + TResult? Function(ChatEventMessagesRequested value)? messagesRequested, + TResult? Function(ChatEventMessageSent value)? messageSent, + TResult? Function(ChatEventMessageRead value)? messageRead, + TResult? Function(ChatEventChatCreated value)? chatCreated, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(ChatEventStarted value)? started, + TResult Function(ChatEventChatsLoaded value)? chatsLoaded, + TResult Function(ChatEventChatSelected value)? chatSelected, + TResult Function(ChatEventMessagesRequested value)? messagesRequested, + TResult Function(ChatEventMessageSent value)? messageSent, + TResult Function(ChatEventMessageRead value)? messageRead, + TResult Function(ChatEventChatCreated value)? chatCreated, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ChatEventCopyWith<$Res> { + factory $ChatEventCopyWith(ChatEvent value, $Res Function(ChatEvent) then) = + _$ChatEventCopyWithImpl<$Res, ChatEvent>; +} + +/// @nodoc +class _$ChatEventCopyWithImpl<$Res, $Val extends ChatEvent> + implements $ChatEventCopyWith<$Res> { + _$ChatEventCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; +} + +/// @nodoc +abstract class _$$ChatEventStartedImplCopyWith<$Res> { + factory _$$ChatEventStartedImplCopyWith(_$ChatEventStartedImpl value, + $Res Function(_$ChatEventStartedImpl) then) = + __$$ChatEventStartedImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$ChatEventStartedImplCopyWithImpl<$Res> + extends _$ChatEventCopyWithImpl<$Res, _$ChatEventStartedImpl> + implements _$$ChatEventStartedImplCopyWith<$Res> { + __$$ChatEventStartedImplCopyWithImpl(_$ChatEventStartedImpl _value, + $Res Function(_$ChatEventStartedImpl) _then) + : super(_value, _then); +} + +/// @nodoc + +class _$ChatEventStartedImpl implements ChatEventStarted { + const _$ChatEventStartedImpl(); + + @override + String toString() { + return 'ChatEvent.started()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$ChatEventStartedImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() started, + required TResult Function() chatsLoaded, + required TResult Function(String chatId) chatSelected, + required TResult Function(String chatId, String? lastMessageId) + messagesRequested, + required TResult Function(String chatId, String content) messageSent, + required TResult Function(String chatId, String messageId) messageRead, + required TResult Function(String title, List participantIds) + chatCreated, + }) { + return started(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? started, + TResult? Function()? chatsLoaded, + TResult? Function(String chatId)? chatSelected, + TResult? Function(String chatId, String? lastMessageId)? messagesRequested, + TResult? Function(String chatId, String content)? messageSent, + TResult? Function(String chatId, String messageId)? messageRead, + TResult? Function(String title, List participantIds)? chatCreated, + }) { + return started?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? started, + TResult Function()? chatsLoaded, + TResult Function(String chatId)? chatSelected, + TResult Function(String chatId, String? lastMessageId)? messagesRequested, + TResult Function(String chatId, String content)? messageSent, + TResult Function(String chatId, String messageId)? messageRead, + TResult Function(String title, List participantIds)? chatCreated, + required TResult orElse(), + }) { + if (started != null) { + return started(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(ChatEventStarted value) started, + required TResult Function(ChatEventChatsLoaded value) chatsLoaded, + required TResult Function(ChatEventChatSelected value) chatSelected, + required TResult Function(ChatEventMessagesRequested value) + messagesRequested, + required TResult Function(ChatEventMessageSent value) messageSent, + required TResult Function(ChatEventMessageRead value) messageRead, + required TResult Function(ChatEventChatCreated value) chatCreated, + }) { + return started(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(ChatEventStarted value)? started, + TResult? Function(ChatEventChatsLoaded value)? chatsLoaded, + TResult? Function(ChatEventChatSelected value)? chatSelected, + TResult? Function(ChatEventMessagesRequested value)? messagesRequested, + TResult? Function(ChatEventMessageSent value)? messageSent, + TResult? Function(ChatEventMessageRead value)? messageRead, + TResult? Function(ChatEventChatCreated value)? chatCreated, + }) { + return started?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(ChatEventStarted value)? started, + TResult Function(ChatEventChatsLoaded value)? chatsLoaded, + TResult Function(ChatEventChatSelected value)? chatSelected, + TResult Function(ChatEventMessagesRequested value)? messagesRequested, + TResult Function(ChatEventMessageSent value)? messageSent, + TResult Function(ChatEventMessageRead value)? messageRead, + TResult Function(ChatEventChatCreated value)? chatCreated, + required TResult orElse(), + }) { + if (started != null) { + return started(this); + } + return orElse(); + } +} + +abstract class ChatEventStarted implements ChatEvent { + const factory ChatEventStarted() = _$ChatEventStartedImpl; +} + +/// @nodoc +abstract class _$$ChatEventChatsLoadedImplCopyWith<$Res> { + factory _$$ChatEventChatsLoadedImplCopyWith(_$ChatEventChatsLoadedImpl value, + $Res Function(_$ChatEventChatsLoadedImpl) then) = + __$$ChatEventChatsLoadedImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$ChatEventChatsLoadedImplCopyWithImpl<$Res> + extends _$ChatEventCopyWithImpl<$Res, _$ChatEventChatsLoadedImpl> + implements _$$ChatEventChatsLoadedImplCopyWith<$Res> { + __$$ChatEventChatsLoadedImplCopyWithImpl(_$ChatEventChatsLoadedImpl _value, + $Res Function(_$ChatEventChatsLoadedImpl) _then) + : super(_value, _then); +} + +/// @nodoc + +class _$ChatEventChatsLoadedImpl implements ChatEventChatsLoaded { + const _$ChatEventChatsLoadedImpl(); + + @override + String toString() { + return 'ChatEvent.chatsLoaded()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ChatEventChatsLoadedImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() started, + required TResult Function() chatsLoaded, + required TResult Function(String chatId) chatSelected, + required TResult Function(String chatId, String? lastMessageId) + messagesRequested, + required TResult Function(String chatId, String content) messageSent, + required TResult Function(String chatId, String messageId) messageRead, + required TResult Function(String title, List participantIds) + chatCreated, + }) { + return chatsLoaded(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? started, + TResult? Function()? chatsLoaded, + TResult? Function(String chatId)? chatSelected, + TResult? Function(String chatId, String? lastMessageId)? messagesRequested, + TResult? Function(String chatId, String content)? messageSent, + TResult? Function(String chatId, String messageId)? messageRead, + TResult? Function(String title, List participantIds)? chatCreated, + }) { + return chatsLoaded?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? started, + TResult Function()? chatsLoaded, + TResult Function(String chatId)? chatSelected, + TResult Function(String chatId, String? lastMessageId)? messagesRequested, + TResult Function(String chatId, String content)? messageSent, + TResult Function(String chatId, String messageId)? messageRead, + TResult Function(String title, List participantIds)? chatCreated, + required TResult orElse(), + }) { + if (chatsLoaded != null) { + return chatsLoaded(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(ChatEventStarted value) started, + required TResult Function(ChatEventChatsLoaded value) chatsLoaded, + required TResult Function(ChatEventChatSelected value) chatSelected, + required TResult Function(ChatEventMessagesRequested value) + messagesRequested, + required TResult Function(ChatEventMessageSent value) messageSent, + required TResult Function(ChatEventMessageRead value) messageRead, + required TResult Function(ChatEventChatCreated value) chatCreated, + }) { + return chatsLoaded(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(ChatEventStarted value)? started, + TResult? Function(ChatEventChatsLoaded value)? chatsLoaded, + TResult? Function(ChatEventChatSelected value)? chatSelected, + TResult? Function(ChatEventMessagesRequested value)? messagesRequested, + TResult? Function(ChatEventMessageSent value)? messageSent, + TResult? Function(ChatEventMessageRead value)? messageRead, + TResult? Function(ChatEventChatCreated value)? chatCreated, + }) { + return chatsLoaded?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(ChatEventStarted value)? started, + TResult Function(ChatEventChatsLoaded value)? chatsLoaded, + TResult Function(ChatEventChatSelected value)? chatSelected, + TResult Function(ChatEventMessagesRequested value)? messagesRequested, + TResult Function(ChatEventMessageSent value)? messageSent, + TResult Function(ChatEventMessageRead value)? messageRead, + TResult Function(ChatEventChatCreated value)? chatCreated, + required TResult orElse(), + }) { + if (chatsLoaded != null) { + return chatsLoaded(this); + } + return orElse(); + } +} + +abstract class ChatEventChatsLoaded implements ChatEvent { + const factory ChatEventChatsLoaded() = _$ChatEventChatsLoadedImpl; +} + +/// @nodoc +abstract class _$$ChatEventChatSelectedImplCopyWith<$Res> { + factory _$$ChatEventChatSelectedImplCopyWith( + _$ChatEventChatSelectedImpl value, + $Res Function(_$ChatEventChatSelectedImpl) then) = + __$$ChatEventChatSelectedImplCopyWithImpl<$Res>; + @useResult + $Res call({String chatId}); +} + +/// @nodoc +class __$$ChatEventChatSelectedImplCopyWithImpl<$Res> + extends _$ChatEventCopyWithImpl<$Res, _$ChatEventChatSelectedImpl> + implements _$$ChatEventChatSelectedImplCopyWith<$Res> { + __$$ChatEventChatSelectedImplCopyWithImpl(_$ChatEventChatSelectedImpl _value, + $Res Function(_$ChatEventChatSelectedImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? chatId = null, + }) { + return _then(_$ChatEventChatSelectedImpl( + null == chatId + ? _value.chatId + : chatId // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$ChatEventChatSelectedImpl implements ChatEventChatSelected { + const _$ChatEventChatSelectedImpl(this.chatId); + + @override + final String chatId; + + @override + String toString() { + return 'ChatEvent.chatSelected(chatId: $chatId)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ChatEventChatSelectedImpl && + (identical(other.chatId, chatId) || other.chatId == chatId)); + } + + @override + int get hashCode => Object.hash(runtimeType, chatId); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$ChatEventChatSelectedImplCopyWith<_$ChatEventChatSelectedImpl> + get copyWith => __$$ChatEventChatSelectedImplCopyWithImpl< + _$ChatEventChatSelectedImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() started, + required TResult Function() chatsLoaded, + required TResult Function(String chatId) chatSelected, + required TResult Function(String chatId, String? lastMessageId) + messagesRequested, + required TResult Function(String chatId, String content) messageSent, + required TResult Function(String chatId, String messageId) messageRead, + required TResult Function(String title, List participantIds) + chatCreated, + }) { + return chatSelected(chatId); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? started, + TResult? Function()? chatsLoaded, + TResult? Function(String chatId)? chatSelected, + TResult? Function(String chatId, String? lastMessageId)? messagesRequested, + TResult? Function(String chatId, String content)? messageSent, + TResult? Function(String chatId, String messageId)? messageRead, + TResult? Function(String title, List participantIds)? chatCreated, + }) { + return chatSelected?.call(chatId); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? started, + TResult Function()? chatsLoaded, + TResult Function(String chatId)? chatSelected, + TResult Function(String chatId, String? lastMessageId)? messagesRequested, + TResult Function(String chatId, String content)? messageSent, + TResult Function(String chatId, String messageId)? messageRead, + TResult Function(String title, List participantIds)? chatCreated, + required TResult orElse(), + }) { + if (chatSelected != null) { + return chatSelected(chatId); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(ChatEventStarted value) started, + required TResult Function(ChatEventChatsLoaded value) chatsLoaded, + required TResult Function(ChatEventChatSelected value) chatSelected, + required TResult Function(ChatEventMessagesRequested value) + messagesRequested, + required TResult Function(ChatEventMessageSent value) messageSent, + required TResult Function(ChatEventMessageRead value) messageRead, + required TResult Function(ChatEventChatCreated value) chatCreated, + }) { + return chatSelected(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(ChatEventStarted value)? started, + TResult? Function(ChatEventChatsLoaded value)? chatsLoaded, + TResult? Function(ChatEventChatSelected value)? chatSelected, + TResult? Function(ChatEventMessagesRequested value)? messagesRequested, + TResult? Function(ChatEventMessageSent value)? messageSent, + TResult? Function(ChatEventMessageRead value)? messageRead, + TResult? Function(ChatEventChatCreated value)? chatCreated, + }) { + return chatSelected?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(ChatEventStarted value)? started, + TResult Function(ChatEventChatsLoaded value)? chatsLoaded, + TResult Function(ChatEventChatSelected value)? chatSelected, + TResult Function(ChatEventMessagesRequested value)? messagesRequested, + TResult Function(ChatEventMessageSent value)? messageSent, + TResult Function(ChatEventMessageRead value)? messageRead, + TResult Function(ChatEventChatCreated value)? chatCreated, + required TResult orElse(), + }) { + if (chatSelected != null) { + return chatSelected(this); + } + return orElse(); + } +} + +abstract class ChatEventChatSelected implements ChatEvent { + const factory ChatEventChatSelected(final String chatId) = + _$ChatEventChatSelectedImpl; + + String get chatId; + @JsonKey(ignore: true) + _$$ChatEventChatSelectedImplCopyWith<_$ChatEventChatSelectedImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$ChatEventMessagesRequestedImplCopyWith<$Res> { + factory _$$ChatEventMessagesRequestedImplCopyWith( + _$ChatEventMessagesRequestedImpl value, + $Res Function(_$ChatEventMessagesRequestedImpl) then) = + __$$ChatEventMessagesRequestedImplCopyWithImpl<$Res>; + @useResult + $Res call({String chatId, String? lastMessageId}); +} + +/// @nodoc +class __$$ChatEventMessagesRequestedImplCopyWithImpl<$Res> + extends _$ChatEventCopyWithImpl<$Res, _$ChatEventMessagesRequestedImpl> + implements _$$ChatEventMessagesRequestedImplCopyWith<$Res> { + __$$ChatEventMessagesRequestedImplCopyWithImpl( + _$ChatEventMessagesRequestedImpl _value, + $Res Function(_$ChatEventMessagesRequestedImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? chatId = null, + Object? lastMessageId = freezed, + }) { + return _then(_$ChatEventMessagesRequestedImpl( + null == chatId + ? _value.chatId + : chatId // ignore: cast_nullable_to_non_nullable + as String, + lastMessageId: freezed == lastMessageId + ? _value.lastMessageId + : lastMessageId // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc + +class _$ChatEventMessagesRequestedImpl implements ChatEventMessagesRequested { + const _$ChatEventMessagesRequestedImpl(this.chatId, {this.lastMessageId}); + + @override + final String chatId; + @override + final String? lastMessageId; + + @override + String toString() { + return 'ChatEvent.messagesRequested(chatId: $chatId, lastMessageId: $lastMessageId)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ChatEventMessagesRequestedImpl && + (identical(other.chatId, chatId) || other.chatId == chatId) && + (identical(other.lastMessageId, lastMessageId) || + other.lastMessageId == lastMessageId)); + } + + @override + int get hashCode => Object.hash(runtimeType, chatId, lastMessageId); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$ChatEventMessagesRequestedImplCopyWith<_$ChatEventMessagesRequestedImpl> + get copyWith => __$$ChatEventMessagesRequestedImplCopyWithImpl< + _$ChatEventMessagesRequestedImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() started, + required TResult Function() chatsLoaded, + required TResult Function(String chatId) chatSelected, + required TResult Function(String chatId, String? lastMessageId) + messagesRequested, + required TResult Function(String chatId, String content) messageSent, + required TResult Function(String chatId, String messageId) messageRead, + required TResult Function(String title, List participantIds) + chatCreated, + }) { + return messagesRequested(chatId, lastMessageId); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? started, + TResult? Function()? chatsLoaded, + TResult? Function(String chatId)? chatSelected, + TResult? Function(String chatId, String? lastMessageId)? messagesRequested, + TResult? Function(String chatId, String content)? messageSent, + TResult? Function(String chatId, String messageId)? messageRead, + TResult? Function(String title, List participantIds)? chatCreated, + }) { + return messagesRequested?.call(chatId, lastMessageId); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? started, + TResult Function()? chatsLoaded, + TResult Function(String chatId)? chatSelected, + TResult Function(String chatId, String? lastMessageId)? messagesRequested, + TResult Function(String chatId, String content)? messageSent, + TResult Function(String chatId, String messageId)? messageRead, + TResult Function(String title, List participantIds)? chatCreated, + required TResult orElse(), + }) { + if (messagesRequested != null) { + return messagesRequested(chatId, lastMessageId); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(ChatEventStarted value) started, + required TResult Function(ChatEventChatsLoaded value) chatsLoaded, + required TResult Function(ChatEventChatSelected value) chatSelected, + required TResult Function(ChatEventMessagesRequested value) + messagesRequested, + required TResult Function(ChatEventMessageSent value) messageSent, + required TResult Function(ChatEventMessageRead value) messageRead, + required TResult Function(ChatEventChatCreated value) chatCreated, + }) { + return messagesRequested(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(ChatEventStarted value)? started, + TResult? Function(ChatEventChatsLoaded value)? chatsLoaded, + TResult? Function(ChatEventChatSelected value)? chatSelected, + TResult? Function(ChatEventMessagesRequested value)? messagesRequested, + TResult? Function(ChatEventMessageSent value)? messageSent, + TResult? Function(ChatEventMessageRead value)? messageRead, + TResult? Function(ChatEventChatCreated value)? chatCreated, + }) { + return messagesRequested?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(ChatEventStarted value)? started, + TResult Function(ChatEventChatsLoaded value)? chatsLoaded, + TResult Function(ChatEventChatSelected value)? chatSelected, + TResult Function(ChatEventMessagesRequested value)? messagesRequested, + TResult Function(ChatEventMessageSent value)? messageSent, + TResult Function(ChatEventMessageRead value)? messageRead, + TResult Function(ChatEventChatCreated value)? chatCreated, + required TResult orElse(), + }) { + if (messagesRequested != null) { + return messagesRequested(this); + } + return orElse(); + } +} + +abstract class ChatEventMessagesRequested implements ChatEvent { + const factory ChatEventMessagesRequested(final String chatId, + {final String? lastMessageId}) = _$ChatEventMessagesRequestedImpl; + + String get chatId; + String? get lastMessageId; + @JsonKey(ignore: true) + _$$ChatEventMessagesRequestedImplCopyWith<_$ChatEventMessagesRequestedImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$ChatEventMessageSentImplCopyWith<$Res> { + factory _$$ChatEventMessageSentImplCopyWith(_$ChatEventMessageSentImpl value, + $Res Function(_$ChatEventMessageSentImpl) then) = + __$$ChatEventMessageSentImplCopyWithImpl<$Res>; + @useResult + $Res call({String chatId, String content}); +} + +/// @nodoc +class __$$ChatEventMessageSentImplCopyWithImpl<$Res> + extends _$ChatEventCopyWithImpl<$Res, _$ChatEventMessageSentImpl> + implements _$$ChatEventMessageSentImplCopyWith<$Res> { + __$$ChatEventMessageSentImplCopyWithImpl(_$ChatEventMessageSentImpl _value, + $Res Function(_$ChatEventMessageSentImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? chatId = null, + Object? content = null, + }) { + return _then(_$ChatEventMessageSentImpl( + null == chatId + ? _value.chatId + : chatId // ignore: cast_nullable_to_non_nullable + as String, + null == content + ? _value.content + : content // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$ChatEventMessageSentImpl implements ChatEventMessageSent { + const _$ChatEventMessageSentImpl(this.chatId, this.content); + + @override + final String chatId; + @override + final String content; + + @override + String toString() { + return 'ChatEvent.messageSent(chatId: $chatId, content: $content)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ChatEventMessageSentImpl && + (identical(other.chatId, chatId) || other.chatId == chatId) && + (identical(other.content, content) || other.content == content)); + } + + @override + int get hashCode => Object.hash(runtimeType, chatId, content); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$ChatEventMessageSentImplCopyWith<_$ChatEventMessageSentImpl> + get copyWith => + __$$ChatEventMessageSentImplCopyWithImpl<_$ChatEventMessageSentImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() started, + required TResult Function() chatsLoaded, + required TResult Function(String chatId) chatSelected, + required TResult Function(String chatId, String? lastMessageId) + messagesRequested, + required TResult Function(String chatId, String content) messageSent, + required TResult Function(String chatId, String messageId) messageRead, + required TResult Function(String title, List participantIds) + chatCreated, + }) { + return messageSent(chatId, content); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? started, + TResult? Function()? chatsLoaded, + TResult? Function(String chatId)? chatSelected, + TResult? Function(String chatId, String? lastMessageId)? messagesRequested, + TResult? Function(String chatId, String content)? messageSent, + TResult? Function(String chatId, String messageId)? messageRead, + TResult? Function(String title, List participantIds)? chatCreated, + }) { + return messageSent?.call(chatId, content); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? started, + TResult Function()? chatsLoaded, + TResult Function(String chatId)? chatSelected, + TResult Function(String chatId, String? lastMessageId)? messagesRequested, + TResult Function(String chatId, String content)? messageSent, + TResult Function(String chatId, String messageId)? messageRead, + TResult Function(String title, List participantIds)? chatCreated, + required TResult orElse(), + }) { + if (messageSent != null) { + return messageSent(chatId, content); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(ChatEventStarted value) started, + required TResult Function(ChatEventChatsLoaded value) chatsLoaded, + required TResult Function(ChatEventChatSelected value) chatSelected, + required TResult Function(ChatEventMessagesRequested value) + messagesRequested, + required TResult Function(ChatEventMessageSent value) messageSent, + required TResult Function(ChatEventMessageRead value) messageRead, + required TResult Function(ChatEventChatCreated value) chatCreated, + }) { + return messageSent(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(ChatEventStarted value)? started, + TResult? Function(ChatEventChatsLoaded value)? chatsLoaded, + TResult? Function(ChatEventChatSelected value)? chatSelected, + TResult? Function(ChatEventMessagesRequested value)? messagesRequested, + TResult? Function(ChatEventMessageSent value)? messageSent, + TResult? Function(ChatEventMessageRead value)? messageRead, + TResult? Function(ChatEventChatCreated value)? chatCreated, + }) { + return messageSent?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(ChatEventStarted value)? started, + TResult Function(ChatEventChatsLoaded value)? chatsLoaded, + TResult Function(ChatEventChatSelected value)? chatSelected, + TResult Function(ChatEventMessagesRequested value)? messagesRequested, + TResult Function(ChatEventMessageSent value)? messageSent, + TResult Function(ChatEventMessageRead value)? messageRead, + TResult Function(ChatEventChatCreated value)? chatCreated, + required TResult orElse(), + }) { + if (messageSent != null) { + return messageSent(this); + } + return orElse(); + } +} + +abstract class ChatEventMessageSent implements ChatEvent { + const factory ChatEventMessageSent( + final String chatId, final String content) = _$ChatEventMessageSentImpl; + + String get chatId; + String get content; + @JsonKey(ignore: true) + _$$ChatEventMessageSentImplCopyWith<_$ChatEventMessageSentImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$ChatEventMessageReadImplCopyWith<$Res> { + factory _$$ChatEventMessageReadImplCopyWith(_$ChatEventMessageReadImpl value, + $Res Function(_$ChatEventMessageReadImpl) then) = + __$$ChatEventMessageReadImplCopyWithImpl<$Res>; + @useResult + $Res call({String chatId, String messageId}); +} + +/// @nodoc +class __$$ChatEventMessageReadImplCopyWithImpl<$Res> + extends _$ChatEventCopyWithImpl<$Res, _$ChatEventMessageReadImpl> + implements _$$ChatEventMessageReadImplCopyWith<$Res> { + __$$ChatEventMessageReadImplCopyWithImpl(_$ChatEventMessageReadImpl _value, + $Res Function(_$ChatEventMessageReadImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? chatId = null, + Object? messageId = null, + }) { + return _then(_$ChatEventMessageReadImpl( + null == chatId + ? _value.chatId + : chatId // ignore: cast_nullable_to_non_nullable + as String, + null == messageId + ? _value.messageId + : messageId // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$ChatEventMessageReadImpl implements ChatEventMessageRead { + const _$ChatEventMessageReadImpl(this.chatId, this.messageId); + + @override + final String chatId; + @override + final String messageId; + + @override + String toString() { + return 'ChatEvent.messageRead(chatId: $chatId, messageId: $messageId)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ChatEventMessageReadImpl && + (identical(other.chatId, chatId) || other.chatId == chatId) && + (identical(other.messageId, messageId) || + other.messageId == messageId)); + } + + @override + int get hashCode => Object.hash(runtimeType, chatId, messageId); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$ChatEventMessageReadImplCopyWith<_$ChatEventMessageReadImpl> + get copyWith => + __$$ChatEventMessageReadImplCopyWithImpl<_$ChatEventMessageReadImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() started, + required TResult Function() chatsLoaded, + required TResult Function(String chatId) chatSelected, + required TResult Function(String chatId, String? lastMessageId) + messagesRequested, + required TResult Function(String chatId, String content) messageSent, + required TResult Function(String chatId, String messageId) messageRead, + required TResult Function(String title, List participantIds) + chatCreated, + }) { + return messageRead(chatId, messageId); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? started, + TResult? Function()? chatsLoaded, + TResult? Function(String chatId)? chatSelected, + TResult? Function(String chatId, String? lastMessageId)? messagesRequested, + TResult? Function(String chatId, String content)? messageSent, + TResult? Function(String chatId, String messageId)? messageRead, + TResult? Function(String title, List participantIds)? chatCreated, + }) { + return messageRead?.call(chatId, messageId); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? started, + TResult Function()? chatsLoaded, + TResult Function(String chatId)? chatSelected, + TResult Function(String chatId, String? lastMessageId)? messagesRequested, + TResult Function(String chatId, String content)? messageSent, + TResult Function(String chatId, String messageId)? messageRead, + TResult Function(String title, List participantIds)? chatCreated, + required TResult orElse(), + }) { + if (messageRead != null) { + return messageRead(chatId, messageId); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(ChatEventStarted value) started, + required TResult Function(ChatEventChatsLoaded value) chatsLoaded, + required TResult Function(ChatEventChatSelected value) chatSelected, + required TResult Function(ChatEventMessagesRequested value) + messagesRequested, + required TResult Function(ChatEventMessageSent value) messageSent, + required TResult Function(ChatEventMessageRead value) messageRead, + required TResult Function(ChatEventChatCreated value) chatCreated, + }) { + return messageRead(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(ChatEventStarted value)? started, + TResult? Function(ChatEventChatsLoaded value)? chatsLoaded, + TResult? Function(ChatEventChatSelected value)? chatSelected, + TResult? Function(ChatEventMessagesRequested value)? messagesRequested, + TResult? Function(ChatEventMessageSent value)? messageSent, + TResult? Function(ChatEventMessageRead value)? messageRead, + TResult? Function(ChatEventChatCreated value)? chatCreated, + }) { + return messageRead?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(ChatEventStarted value)? started, + TResult Function(ChatEventChatsLoaded value)? chatsLoaded, + TResult Function(ChatEventChatSelected value)? chatSelected, + TResult Function(ChatEventMessagesRequested value)? messagesRequested, + TResult Function(ChatEventMessageSent value)? messageSent, + TResult Function(ChatEventMessageRead value)? messageRead, + TResult Function(ChatEventChatCreated value)? chatCreated, + required TResult orElse(), + }) { + if (messageRead != null) { + return messageRead(this); + } + return orElse(); + } +} + +abstract class ChatEventMessageRead implements ChatEvent { + const factory ChatEventMessageRead( + final String chatId, final String messageId) = _$ChatEventMessageReadImpl; + + String get chatId; + String get messageId; + @JsonKey(ignore: true) + _$$ChatEventMessageReadImplCopyWith<_$ChatEventMessageReadImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$ChatEventChatCreatedImplCopyWith<$Res> { + factory _$$ChatEventChatCreatedImplCopyWith(_$ChatEventChatCreatedImpl value, + $Res Function(_$ChatEventChatCreatedImpl) then) = + __$$ChatEventChatCreatedImplCopyWithImpl<$Res>; + @useResult + $Res call({String title, List participantIds}); +} + +/// @nodoc +class __$$ChatEventChatCreatedImplCopyWithImpl<$Res> + extends _$ChatEventCopyWithImpl<$Res, _$ChatEventChatCreatedImpl> + implements _$$ChatEventChatCreatedImplCopyWith<$Res> { + __$$ChatEventChatCreatedImplCopyWithImpl(_$ChatEventChatCreatedImpl _value, + $Res Function(_$ChatEventChatCreatedImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? title = null, + Object? participantIds = null, + }) { + return _then(_$ChatEventChatCreatedImpl( + null == title + ? _value.title + : title // ignore: cast_nullable_to_non_nullable + as String, + null == participantIds + ? _value._participantIds + : participantIds // ignore: cast_nullable_to_non_nullable + as List, + )); + } +} + +/// @nodoc + +class _$ChatEventChatCreatedImpl implements ChatEventChatCreated { + const _$ChatEventChatCreatedImpl( + this.title, final List participantIds) + : _participantIds = participantIds; + + @override + final String title; + final List _participantIds; + @override + List get participantIds { + if (_participantIds is EqualUnmodifiableListView) return _participantIds; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_participantIds); + } + + @override + String toString() { + return 'ChatEvent.chatCreated(title: $title, participantIds: $participantIds)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ChatEventChatCreatedImpl && + (identical(other.title, title) || other.title == title) && + const DeepCollectionEquality() + .equals(other._participantIds, _participantIds)); + } + + @override + int get hashCode => Object.hash( + runtimeType, title, const DeepCollectionEquality().hash(_participantIds)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$ChatEventChatCreatedImplCopyWith<_$ChatEventChatCreatedImpl> + get copyWith => + __$$ChatEventChatCreatedImplCopyWithImpl<_$ChatEventChatCreatedImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() started, + required TResult Function() chatsLoaded, + required TResult Function(String chatId) chatSelected, + required TResult Function(String chatId, String? lastMessageId) + messagesRequested, + required TResult Function(String chatId, String content) messageSent, + required TResult Function(String chatId, String messageId) messageRead, + required TResult Function(String title, List participantIds) + chatCreated, + }) { + return chatCreated(title, participantIds); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? started, + TResult? Function()? chatsLoaded, + TResult? Function(String chatId)? chatSelected, + TResult? Function(String chatId, String? lastMessageId)? messagesRequested, + TResult? Function(String chatId, String content)? messageSent, + TResult? Function(String chatId, String messageId)? messageRead, + TResult? Function(String title, List participantIds)? chatCreated, + }) { + return chatCreated?.call(title, participantIds); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? started, + TResult Function()? chatsLoaded, + TResult Function(String chatId)? chatSelected, + TResult Function(String chatId, String? lastMessageId)? messagesRequested, + TResult Function(String chatId, String content)? messageSent, + TResult Function(String chatId, String messageId)? messageRead, + TResult Function(String title, List participantIds)? chatCreated, + required TResult orElse(), + }) { + if (chatCreated != null) { + return chatCreated(title, participantIds); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(ChatEventStarted value) started, + required TResult Function(ChatEventChatsLoaded value) chatsLoaded, + required TResult Function(ChatEventChatSelected value) chatSelected, + required TResult Function(ChatEventMessagesRequested value) + messagesRequested, + required TResult Function(ChatEventMessageSent value) messageSent, + required TResult Function(ChatEventMessageRead value) messageRead, + required TResult Function(ChatEventChatCreated value) chatCreated, + }) { + return chatCreated(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(ChatEventStarted value)? started, + TResult? Function(ChatEventChatsLoaded value)? chatsLoaded, + TResult? Function(ChatEventChatSelected value)? chatSelected, + TResult? Function(ChatEventMessagesRequested value)? messagesRequested, + TResult? Function(ChatEventMessageSent value)? messageSent, + TResult? Function(ChatEventMessageRead value)? messageRead, + TResult? Function(ChatEventChatCreated value)? chatCreated, + }) { + return chatCreated?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(ChatEventStarted value)? started, + TResult Function(ChatEventChatsLoaded value)? chatsLoaded, + TResult Function(ChatEventChatSelected value)? chatSelected, + TResult Function(ChatEventMessagesRequested value)? messagesRequested, + TResult Function(ChatEventMessageSent value)? messageSent, + TResult Function(ChatEventMessageRead value)? messageRead, + TResult Function(ChatEventChatCreated value)? chatCreated, + required TResult orElse(), + }) { + if (chatCreated != null) { + return chatCreated(this); + } + return orElse(); + } +} + +abstract class ChatEventChatCreated implements ChatEvent { + const factory ChatEventChatCreated( + final String title, final List participantIds) = + _$ChatEventChatCreatedImpl; + + String get title; + List get participantIds; + @JsonKey(ignore: true) + _$$ChatEventChatCreatedImplCopyWith<_$ChatEventChatCreatedImpl> + get copyWith => throw _privateConstructorUsedError; +} diff --git a/client-mobile/lib/features/chat/presentation/bloc/chat_state.dart b/client-mobile/lib/features/chat/presentation/bloc/chat_state.dart new file mode 100644 index 0000000..223cc7e --- /dev/null +++ b/client-mobile/lib/features/chat/presentation/bloc/chat_state.dart @@ -0,0 +1,14 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'chat_state.freezed.dart'; + +@freezed +class ChatState with _$ChatState { + const factory ChatState.initial() = ChatInitial; + const factory ChatState.loading() = ChatLoading; + const factory ChatState.chatsLoaded(List chats) = _ChatsLoaded; + const factory ChatState.chatSelected(String chat, List messages) = _ChatSelected; + const factory ChatState.messagesLoaded(List messages) = _MessagesLoaded; + const factory ChatState.messageSent() = _MessageSent; + const factory ChatState.error(String message) = ChatError; +} diff --git a/client-mobile/lib/features/chat/presentation/bloc/chat_state.freezed.dart b/client-mobile/lib/features/chat/presentation/bloc/chat_state.freezed.dart new file mode 100644 index 0000000..a4b60f3 --- /dev/null +++ b/client-mobile/lib/features/chat/presentation/bloc/chat_state.freezed.dart @@ -0,0 +1,1184 @@ +// 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 'chat_state.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#adding-getters-and-methods-to-our-models'); + +/// @nodoc +mixin _$ChatState { + @optionalTypeArgs + TResult when({ + required TResult Function() initial, + required TResult Function() loading, + required TResult Function(List chats) chatsLoaded, + required TResult Function(String chat, List messages) chatSelected, + required TResult Function(List messages) messagesLoaded, + required TResult Function() messageSent, + required TResult Function(String message) error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? initial, + TResult? Function()? loading, + TResult? Function(List chats)? chatsLoaded, + TResult? Function(String chat, List messages)? chatSelected, + TResult? Function(List messages)? messagesLoaded, + TResult? Function()? messageSent, + TResult? Function(String message)? error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? initial, + TResult Function()? loading, + TResult Function(List chats)? chatsLoaded, + TResult Function(String chat, List messages)? chatSelected, + TResult Function(List messages)? messagesLoaded, + TResult Function()? messageSent, + TResult Function(String message)? error, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(ChatInitial value) initial, + required TResult Function(ChatLoading value) loading, + required TResult Function(_ChatsLoaded value) chatsLoaded, + required TResult Function(_ChatSelected value) chatSelected, + required TResult Function(_MessagesLoaded value) messagesLoaded, + required TResult Function(_MessageSent value) messageSent, + required TResult Function(ChatError value) error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(ChatInitial value)? initial, + TResult? Function(ChatLoading value)? loading, + TResult? Function(_ChatsLoaded value)? chatsLoaded, + TResult? Function(_ChatSelected value)? chatSelected, + TResult? Function(_MessagesLoaded value)? messagesLoaded, + TResult? Function(_MessageSent value)? messageSent, + TResult? Function(ChatError value)? error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(ChatInitial value)? initial, + TResult Function(ChatLoading value)? loading, + TResult Function(_ChatsLoaded value)? chatsLoaded, + TResult Function(_ChatSelected value)? chatSelected, + TResult Function(_MessagesLoaded value)? messagesLoaded, + TResult Function(_MessageSent value)? messageSent, + TResult Function(ChatError value)? error, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ChatStateCopyWith<$Res> { + factory $ChatStateCopyWith(ChatState value, $Res Function(ChatState) then) = + _$ChatStateCopyWithImpl<$Res, ChatState>; +} + +/// @nodoc +class _$ChatStateCopyWithImpl<$Res, $Val extends ChatState> + implements $ChatStateCopyWith<$Res> { + _$ChatStateCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; +} + +/// @nodoc +abstract class _$$ChatInitialImplCopyWith<$Res> { + factory _$$ChatInitialImplCopyWith( + _$ChatInitialImpl value, $Res Function(_$ChatInitialImpl) then) = + __$$ChatInitialImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$ChatInitialImplCopyWithImpl<$Res> + extends _$ChatStateCopyWithImpl<$Res, _$ChatInitialImpl> + implements _$$ChatInitialImplCopyWith<$Res> { + __$$ChatInitialImplCopyWithImpl( + _$ChatInitialImpl _value, $Res Function(_$ChatInitialImpl) _then) + : super(_value, _then); +} + +/// @nodoc + +class _$ChatInitialImpl implements ChatInitial { + const _$ChatInitialImpl(); + + @override + String toString() { + return 'ChatState.initial()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$ChatInitialImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() initial, + required TResult Function() loading, + required TResult Function(List chats) chatsLoaded, + required TResult Function(String chat, List messages) chatSelected, + required TResult Function(List messages) messagesLoaded, + required TResult Function() messageSent, + required TResult Function(String message) error, + }) { + return initial(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? initial, + TResult? Function()? loading, + TResult? Function(List chats)? chatsLoaded, + TResult? Function(String chat, List messages)? chatSelected, + TResult? Function(List messages)? messagesLoaded, + TResult? Function()? messageSent, + TResult? Function(String message)? error, + }) { + return initial?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? initial, + TResult Function()? loading, + TResult Function(List chats)? chatsLoaded, + TResult Function(String chat, List messages)? chatSelected, + TResult Function(List messages)? messagesLoaded, + TResult Function()? messageSent, + TResult Function(String message)? error, + required TResult orElse(), + }) { + if (initial != null) { + return initial(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(ChatInitial value) initial, + required TResult Function(ChatLoading value) loading, + required TResult Function(_ChatsLoaded value) chatsLoaded, + required TResult Function(_ChatSelected value) chatSelected, + required TResult Function(_MessagesLoaded value) messagesLoaded, + required TResult Function(_MessageSent value) messageSent, + required TResult Function(ChatError value) error, + }) { + return initial(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(ChatInitial value)? initial, + TResult? Function(ChatLoading value)? loading, + TResult? Function(_ChatsLoaded value)? chatsLoaded, + TResult? Function(_ChatSelected value)? chatSelected, + TResult? Function(_MessagesLoaded value)? messagesLoaded, + TResult? Function(_MessageSent value)? messageSent, + TResult? Function(ChatError value)? error, + }) { + return initial?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(ChatInitial value)? initial, + TResult Function(ChatLoading value)? loading, + TResult Function(_ChatsLoaded value)? chatsLoaded, + TResult Function(_ChatSelected value)? chatSelected, + TResult Function(_MessagesLoaded value)? messagesLoaded, + TResult Function(_MessageSent value)? messageSent, + TResult Function(ChatError value)? error, + required TResult orElse(), + }) { + if (initial != null) { + return initial(this); + } + return orElse(); + } +} + +abstract class ChatInitial implements ChatState { + const factory ChatInitial() = _$ChatInitialImpl; +} + +/// @nodoc +abstract class _$$ChatLoadingImplCopyWith<$Res> { + factory _$$ChatLoadingImplCopyWith( + _$ChatLoadingImpl value, $Res Function(_$ChatLoadingImpl) then) = + __$$ChatLoadingImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$ChatLoadingImplCopyWithImpl<$Res> + extends _$ChatStateCopyWithImpl<$Res, _$ChatLoadingImpl> + implements _$$ChatLoadingImplCopyWith<$Res> { + __$$ChatLoadingImplCopyWithImpl( + _$ChatLoadingImpl _value, $Res Function(_$ChatLoadingImpl) _then) + : super(_value, _then); +} + +/// @nodoc + +class _$ChatLoadingImpl implements ChatLoading { + const _$ChatLoadingImpl(); + + @override + String toString() { + return 'ChatState.loading()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$ChatLoadingImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() initial, + required TResult Function() loading, + required TResult Function(List chats) chatsLoaded, + required TResult Function(String chat, List messages) chatSelected, + required TResult Function(List messages) messagesLoaded, + required TResult Function() messageSent, + required TResult Function(String message) error, + }) { + return loading(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? initial, + TResult? Function()? loading, + TResult? Function(List chats)? chatsLoaded, + TResult? Function(String chat, List messages)? chatSelected, + TResult? Function(List messages)? messagesLoaded, + TResult? Function()? messageSent, + TResult? Function(String message)? error, + }) { + return loading?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? initial, + TResult Function()? loading, + TResult Function(List chats)? chatsLoaded, + TResult Function(String chat, List messages)? chatSelected, + TResult Function(List messages)? messagesLoaded, + TResult Function()? messageSent, + TResult Function(String message)? error, + required TResult orElse(), + }) { + if (loading != null) { + return loading(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(ChatInitial value) initial, + required TResult Function(ChatLoading value) loading, + required TResult Function(_ChatsLoaded value) chatsLoaded, + required TResult Function(_ChatSelected value) chatSelected, + required TResult Function(_MessagesLoaded value) messagesLoaded, + required TResult Function(_MessageSent value) messageSent, + required TResult Function(ChatError value) error, + }) { + return loading(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(ChatInitial value)? initial, + TResult? Function(ChatLoading value)? loading, + TResult? Function(_ChatsLoaded value)? chatsLoaded, + TResult? Function(_ChatSelected value)? chatSelected, + TResult? Function(_MessagesLoaded value)? messagesLoaded, + TResult? Function(_MessageSent value)? messageSent, + TResult? Function(ChatError value)? error, + }) { + return loading?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(ChatInitial value)? initial, + TResult Function(ChatLoading value)? loading, + TResult Function(_ChatsLoaded value)? chatsLoaded, + TResult Function(_ChatSelected value)? chatSelected, + TResult Function(_MessagesLoaded value)? messagesLoaded, + TResult Function(_MessageSent value)? messageSent, + TResult Function(ChatError value)? error, + required TResult orElse(), + }) { + if (loading != null) { + return loading(this); + } + return orElse(); + } +} + +abstract class ChatLoading implements ChatState { + const factory ChatLoading() = _$ChatLoadingImpl; +} + +/// @nodoc +abstract class _$$ChatsLoadedImplCopyWith<$Res> { + factory _$$ChatsLoadedImplCopyWith( + _$ChatsLoadedImpl value, $Res Function(_$ChatsLoadedImpl) then) = + __$$ChatsLoadedImplCopyWithImpl<$Res>; + @useResult + $Res call({List chats}); +} + +/// @nodoc +class __$$ChatsLoadedImplCopyWithImpl<$Res> + extends _$ChatStateCopyWithImpl<$Res, _$ChatsLoadedImpl> + implements _$$ChatsLoadedImplCopyWith<$Res> { + __$$ChatsLoadedImplCopyWithImpl( + _$ChatsLoadedImpl _value, $Res Function(_$ChatsLoadedImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? chats = null, + }) { + return _then(_$ChatsLoadedImpl( + null == chats + ? _value._chats + : chats // ignore: cast_nullable_to_non_nullable + as List, + )); + } +} + +/// @nodoc + +class _$ChatsLoadedImpl implements _ChatsLoaded { + const _$ChatsLoadedImpl(final List chats) : _chats = chats; + + final List _chats; + @override + List get chats { + if (_chats is EqualUnmodifiableListView) return _chats; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_chats); + } + + @override + String toString() { + return 'ChatState.chatsLoaded(chats: $chats)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ChatsLoadedImpl && + const DeepCollectionEquality().equals(other._chats, _chats)); + } + + @override + int get hashCode => + Object.hash(runtimeType, const DeepCollectionEquality().hash(_chats)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$ChatsLoadedImplCopyWith<_$ChatsLoadedImpl> get copyWith => + __$$ChatsLoadedImplCopyWithImpl<_$ChatsLoadedImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() initial, + required TResult Function() loading, + required TResult Function(List chats) chatsLoaded, + required TResult Function(String chat, List messages) chatSelected, + required TResult Function(List messages) messagesLoaded, + required TResult Function() messageSent, + required TResult Function(String message) error, + }) { + return chatsLoaded(chats); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? initial, + TResult? Function()? loading, + TResult? Function(List chats)? chatsLoaded, + TResult? Function(String chat, List messages)? chatSelected, + TResult? Function(List messages)? messagesLoaded, + TResult? Function()? messageSent, + TResult? Function(String message)? error, + }) { + return chatsLoaded?.call(chats); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? initial, + TResult Function()? loading, + TResult Function(List chats)? chatsLoaded, + TResult Function(String chat, List messages)? chatSelected, + TResult Function(List messages)? messagesLoaded, + TResult Function()? messageSent, + TResult Function(String message)? error, + required TResult orElse(), + }) { + if (chatsLoaded != null) { + return chatsLoaded(chats); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(ChatInitial value) initial, + required TResult Function(ChatLoading value) loading, + required TResult Function(_ChatsLoaded value) chatsLoaded, + required TResult Function(_ChatSelected value) chatSelected, + required TResult Function(_MessagesLoaded value) messagesLoaded, + required TResult Function(_MessageSent value) messageSent, + required TResult Function(ChatError value) error, + }) { + return chatsLoaded(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(ChatInitial value)? initial, + TResult? Function(ChatLoading value)? loading, + TResult? Function(_ChatsLoaded value)? chatsLoaded, + TResult? Function(_ChatSelected value)? chatSelected, + TResult? Function(_MessagesLoaded value)? messagesLoaded, + TResult? Function(_MessageSent value)? messageSent, + TResult? Function(ChatError value)? error, + }) { + return chatsLoaded?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(ChatInitial value)? initial, + TResult Function(ChatLoading value)? loading, + TResult Function(_ChatsLoaded value)? chatsLoaded, + TResult Function(_ChatSelected value)? chatSelected, + TResult Function(_MessagesLoaded value)? messagesLoaded, + TResult Function(_MessageSent value)? messageSent, + TResult Function(ChatError value)? error, + required TResult orElse(), + }) { + if (chatsLoaded != null) { + return chatsLoaded(this); + } + return orElse(); + } +} + +abstract class _ChatsLoaded implements ChatState { + const factory _ChatsLoaded(final List chats) = _$ChatsLoadedImpl; + + List get chats; + @JsonKey(ignore: true) + _$$ChatsLoadedImplCopyWith<_$ChatsLoadedImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$ChatSelectedImplCopyWith<$Res> { + factory _$$ChatSelectedImplCopyWith( + _$ChatSelectedImpl value, $Res Function(_$ChatSelectedImpl) then) = + __$$ChatSelectedImplCopyWithImpl<$Res>; + @useResult + $Res call({String chat, List messages}); +} + +/// @nodoc +class __$$ChatSelectedImplCopyWithImpl<$Res> + extends _$ChatStateCopyWithImpl<$Res, _$ChatSelectedImpl> + implements _$$ChatSelectedImplCopyWith<$Res> { + __$$ChatSelectedImplCopyWithImpl( + _$ChatSelectedImpl _value, $Res Function(_$ChatSelectedImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? chat = null, + Object? messages = null, + }) { + return _then(_$ChatSelectedImpl( + null == chat + ? _value.chat + : chat // ignore: cast_nullable_to_non_nullable + as String, + null == messages + ? _value._messages + : messages // ignore: cast_nullable_to_non_nullable + as List, + )); + } +} + +/// @nodoc + +class _$ChatSelectedImpl implements _ChatSelected { + const _$ChatSelectedImpl(this.chat, final List messages) + : _messages = messages; + + @override + final String chat; + final List _messages; + @override + List get messages { + if (_messages is EqualUnmodifiableListView) return _messages; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_messages); + } + + @override + String toString() { + return 'ChatState.chatSelected(chat: $chat, messages: $messages)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ChatSelectedImpl && + (identical(other.chat, chat) || other.chat == chat) && + const DeepCollectionEquality().equals(other._messages, _messages)); + } + + @override + int get hashCode => Object.hash( + runtimeType, chat, const DeepCollectionEquality().hash(_messages)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$ChatSelectedImplCopyWith<_$ChatSelectedImpl> get copyWith => + __$$ChatSelectedImplCopyWithImpl<_$ChatSelectedImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() initial, + required TResult Function() loading, + required TResult Function(List chats) chatsLoaded, + required TResult Function(String chat, List messages) chatSelected, + required TResult Function(List messages) messagesLoaded, + required TResult Function() messageSent, + required TResult Function(String message) error, + }) { + return chatSelected(chat, messages); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? initial, + TResult? Function()? loading, + TResult? Function(List chats)? chatsLoaded, + TResult? Function(String chat, List messages)? chatSelected, + TResult? Function(List messages)? messagesLoaded, + TResult? Function()? messageSent, + TResult? Function(String message)? error, + }) { + return chatSelected?.call(chat, messages); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? initial, + TResult Function()? loading, + TResult Function(List chats)? chatsLoaded, + TResult Function(String chat, List messages)? chatSelected, + TResult Function(List messages)? messagesLoaded, + TResult Function()? messageSent, + TResult Function(String message)? error, + required TResult orElse(), + }) { + if (chatSelected != null) { + return chatSelected(chat, messages); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(ChatInitial value) initial, + required TResult Function(ChatLoading value) loading, + required TResult Function(_ChatsLoaded value) chatsLoaded, + required TResult Function(_ChatSelected value) chatSelected, + required TResult Function(_MessagesLoaded value) messagesLoaded, + required TResult Function(_MessageSent value) messageSent, + required TResult Function(ChatError value) error, + }) { + return chatSelected(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(ChatInitial value)? initial, + TResult? Function(ChatLoading value)? loading, + TResult? Function(_ChatsLoaded value)? chatsLoaded, + TResult? Function(_ChatSelected value)? chatSelected, + TResult? Function(_MessagesLoaded value)? messagesLoaded, + TResult? Function(_MessageSent value)? messageSent, + TResult? Function(ChatError value)? error, + }) { + return chatSelected?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(ChatInitial value)? initial, + TResult Function(ChatLoading value)? loading, + TResult Function(_ChatsLoaded value)? chatsLoaded, + TResult Function(_ChatSelected value)? chatSelected, + TResult Function(_MessagesLoaded value)? messagesLoaded, + TResult Function(_MessageSent value)? messageSent, + TResult Function(ChatError value)? error, + required TResult orElse(), + }) { + if (chatSelected != null) { + return chatSelected(this); + } + return orElse(); + } +} + +abstract class _ChatSelected implements ChatState { + const factory _ChatSelected(final String chat, final List messages) = + _$ChatSelectedImpl; + + String get chat; + List get messages; + @JsonKey(ignore: true) + _$$ChatSelectedImplCopyWith<_$ChatSelectedImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$MessagesLoadedImplCopyWith<$Res> { + factory _$$MessagesLoadedImplCopyWith(_$MessagesLoadedImpl value, + $Res Function(_$MessagesLoadedImpl) then) = + __$$MessagesLoadedImplCopyWithImpl<$Res>; + @useResult + $Res call({List messages}); +} + +/// @nodoc +class __$$MessagesLoadedImplCopyWithImpl<$Res> + extends _$ChatStateCopyWithImpl<$Res, _$MessagesLoadedImpl> + implements _$$MessagesLoadedImplCopyWith<$Res> { + __$$MessagesLoadedImplCopyWithImpl( + _$MessagesLoadedImpl _value, $Res Function(_$MessagesLoadedImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? messages = null, + }) { + return _then(_$MessagesLoadedImpl( + null == messages + ? _value._messages + : messages // ignore: cast_nullable_to_non_nullable + as List, + )); + } +} + +/// @nodoc + +class _$MessagesLoadedImpl implements _MessagesLoaded { + const _$MessagesLoadedImpl(final List messages) + : _messages = messages; + + final List _messages; + @override + List get messages { + if (_messages is EqualUnmodifiableListView) return _messages; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_messages); + } + + @override + String toString() { + return 'ChatState.messagesLoaded(messages: $messages)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$MessagesLoadedImpl && + const DeepCollectionEquality().equals(other._messages, _messages)); + } + + @override + int get hashCode => + Object.hash(runtimeType, const DeepCollectionEquality().hash(_messages)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$MessagesLoadedImplCopyWith<_$MessagesLoadedImpl> get copyWith => + __$$MessagesLoadedImplCopyWithImpl<_$MessagesLoadedImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() initial, + required TResult Function() loading, + required TResult Function(List chats) chatsLoaded, + required TResult Function(String chat, List messages) chatSelected, + required TResult Function(List messages) messagesLoaded, + required TResult Function() messageSent, + required TResult Function(String message) error, + }) { + return messagesLoaded(messages); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? initial, + TResult? Function()? loading, + TResult? Function(List chats)? chatsLoaded, + TResult? Function(String chat, List messages)? chatSelected, + TResult? Function(List messages)? messagesLoaded, + TResult? Function()? messageSent, + TResult? Function(String message)? error, + }) { + return messagesLoaded?.call(messages); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? initial, + TResult Function()? loading, + TResult Function(List chats)? chatsLoaded, + TResult Function(String chat, List messages)? chatSelected, + TResult Function(List messages)? messagesLoaded, + TResult Function()? messageSent, + TResult Function(String message)? error, + required TResult orElse(), + }) { + if (messagesLoaded != null) { + return messagesLoaded(messages); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(ChatInitial value) initial, + required TResult Function(ChatLoading value) loading, + required TResult Function(_ChatsLoaded value) chatsLoaded, + required TResult Function(_ChatSelected value) chatSelected, + required TResult Function(_MessagesLoaded value) messagesLoaded, + required TResult Function(_MessageSent value) messageSent, + required TResult Function(ChatError value) error, + }) { + return messagesLoaded(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(ChatInitial value)? initial, + TResult? Function(ChatLoading value)? loading, + TResult? Function(_ChatsLoaded value)? chatsLoaded, + TResult? Function(_ChatSelected value)? chatSelected, + TResult? Function(_MessagesLoaded value)? messagesLoaded, + TResult? Function(_MessageSent value)? messageSent, + TResult? Function(ChatError value)? error, + }) { + return messagesLoaded?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(ChatInitial value)? initial, + TResult Function(ChatLoading value)? loading, + TResult Function(_ChatsLoaded value)? chatsLoaded, + TResult Function(_ChatSelected value)? chatSelected, + TResult Function(_MessagesLoaded value)? messagesLoaded, + TResult Function(_MessageSent value)? messageSent, + TResult Function(ChatError value)? error, + required TResult orElse(), + }) { + if (messagesLoaded != null) { + return messagesLoaded(this); + } + return orElse(); + } +} + +abstract class _MessagesLoaded implements ChatState { + const factory _MessagesLoaded(final List messages) = + _$MessagesLoadedImpl; + + List get messages; + @JsonKey(ignore: true) + _$$MessagesLoadedImplCopyWith<_$MessagesLoadedImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$MessageSentImplCopyWith<$Res> { + factory _$$MessageSentImplCopyWith( + _$MessageSentImpl value, $Res Function(_$MessageSentImpl) then) = + __$$MessageSentImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$MessageSentImplCopyWithImpl<$Res> + extends _$ChatStateCopyWithImpl<$Res, _$MessageSentImpl> + implements _$$MessageSentImplCopyWith<$Res> { + __$$MessageSentImplCopyWithImpl( + _$MessageSentImpl _value, $Res Function(_$MessageSentImpl) _then) + : super(_value, _then); +} + +/// @nodoc + +class _$MessageSentImpl implements _MessageSent { + const _$MessageSentImpl(); + + @override + String toString() { + return 'ChatState.messageSent()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$MessageSentImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() initial, + required TResult Function() loading, + required TResult Function(List chats) chatsLoaded, + required TResult Function(String chat, List messages) chatSelected, + required TResult Function(List messages) messagesLoaded, + required TResult Function() messageSent, + required TResult Function(String message) error, + }) { + return messageSent(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? initial, + TResult? Function()? loading, + TResult? Function(List chats)? chatsLoaded, + TResult? Function(String chat, List messages)? chatSelected, + TResult? Function(List messages)? messagesLoaded, + TResult? Function()? messageSent, + TResult? Function(String message)? error, + }) { + return messageSent?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? initial, + TResult Function()? loading, + TResult Function(List chats)? chatsLoaded, + TResult Function(String chat, List messages)? chatSelected, + TResult Function(List messages)? messagesLoaded, + TResult Function()? messageSent, + TResult Function(String message)? error, + required TResult orElse(), + }) { + if (messageSent != null) { + return messageSent(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(ChatInitial value) initial, + required TResult Function(ChatLoading value) loading, + required TResult Function(_ChatsLoaded value) chatsLoaded, + required TResult Function(_ChatSelected value) chatSelected, + required TResult Function(_MessagesLoaded value) messagesLoaded, + required TResult Function(_MessageSent value) messageSent, + required TResult Function(ChatError value) error, + }) { + return messageSent(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(ChatInitial value)? initial, + TResult? Function(ChatLoading value)? loading, + TResult? Function(_ChatsLoaded value)? chatsLoaded, + TResult? Function(_ChatSelected value)? chatSelected, + TResult? Function(_MessagesLoaded value)? messagesLoaded, + TResult? Function(_MessageSent value)? messageSent, + TResult? Function(ChatError value)? error, + }) { + return messageSent?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(ChatInitial value)? initial, + TResult Function(ChatLoading value)? loading, + TResult Function(_ChatsLoaded value)? chatsLoaded, + TResult Function(_ChatSelected value)? chatSelected, + TResult Function(_MessagesLoaded value)? messagesLoaded, + TResult Function(_MessageSent value)? messageSent, + TResult Function(ChatError value)? error, + required TResult orElse(), + }) { + if (messageSent != null) { + return messageSent(this); + } + return orElse(); + } +} + +abstract class _MessageSent implements ChatState { + const factory _MessageSent() = _$MessageSentImpl; +} + +/// @nodoc +abstract class _$$ChatErrorImplCopyWith<$Res> { + factory _$$ChatErrorImplCopyWith( + _$ChatErrorImpl value, $Res Function(_$ChatErrorImpl) then) = + __$$ChatErrorImplCopyWithImpl<$Res>; + @useResult + $Res call({String message}); +} + +/// @nodoc +class __$$ChatErrorImplCopyWithImpl<$Res> + extends _$ChatStateCopyWithImpl<$Res, _$ChatErrorImpl> + implements _$$ChatErrorImplCopyWith<$Res> { + __$$ChatErrorImplCopyWithImpl( + _$ChatErrorImpl _value, $Res Function(_$ChatErrorImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? message = null, + }) { + return _then(_$ChatErrorImpl( + null == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$ChatErrorImpl implements ChatError { + const _$ChatErrorImpl(this.message); + + @override + final String message; + + @override + String toString() { + return 'ChatState.error(message: $message)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ChatErrorImpl && + (identical(other.message, message) || other.message == message)); + } + + @override + int get hashCode => Object.hash(runtimeType, message); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$ChatErrorImplCopyWith<_$ChatErrorImpl> get copyWith => + __$$ChatErrorImplCopyWithImpl<_$ChatErrorImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() initial, + required TResult Function() loading, + required TResult Function(List chats) chatsLoaded, + required TResult Function(String chat, List messages) chatSelected, + required TResult Function(List messages) messagesLoaded, + required TResult Function() messageSent, + required TResult Function(String message) error, + }) { + return error(message); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? initial, + TResult? Function()? loading, + TResult? Function(List chats)? chatsLoaded, + TResult? Function(String chat, List messages)? chatSelected, + TResult? Function(List messages)? messagesLoaded, + TResult? Function()? messageSent, + TResult? Function(String message)? error, + }) { + return error?.call(message); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? initial, + TResult Function()? loading, + TResult Function(List chats)? chatsLoaded, + TResult Function(String chat, List messages)? chatSelected, + TResult Function(List messages)? messagesLoaded, + TResult Function()? messageSent, + TResult Function(String message)? error, + required TResult orElse(), + }) { + if (error != null) { + return error(message); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(ChatInitial value) initial, + required TResult Function(ChatLoading value) loading, + required TResult Function(_ChatsLoaded value) chatsLoaded, + required TResult Function(_ChatSelected value) chatSelected, + required TResult Function(_MessagesLoaded value) messagesLoaded, + required TResult Function(_MessageSent value) messageSent, + required TResult Function(ChatError value) error, + }) { + return error(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(ChatInitial value)? initial, + TResult? Function(ChatLoading value)? loading, + TResult? Function(_ChatsLoaded value)? chatsLoaded, + TResult? Function(_ChatSelected value)? chatSelected, + TResult? Function(_MessagesLoaded value)? messagesLoaded, + TResult? Function(_MessageSent value)? messageSent, + TResult? Function(ChatError value)? error, + }) { + return error?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(ChatInitial value)? initial, + TResult Function(ChatLoading value)? loading, + TResult Function(_ChatsLoaded value)? chatsLoaded, + TResult Function(_ChatSelected value)? chatSelected, + TResult Function(_MessagesLoaded value)? messagesLoaded, + TResult Function(_MessageSent value)? messageSent, + TResult Function(ChatError value)? error, + required TResult orElse(), + }) { + if (error != null) { + return error(this); + } + return orElse(); + } +} + +abstract class ChatError implements ChatState { + const factory ChatError(final String message) = _$ChatErrorImpl; + + String get message; + @JsonKey(ignore: true) + _$$ChatErrorImplCopyWith<_$ChatErrorImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/client-mobile/lib/features/chat/presentation/pages/chat_detail_page.dart b/client-mobile/lib/features/chat/presentation/pages/chat_detail_page.dart new file mode 100644 index 0000000..dbe81b0 --- /dev/null +++ b/client-mobile/lib/features/chat/presentation/pages/chat_detail_page.dart @@ -0,0 +1,105 @@ +import 'package:flutter/material.dart'; + +class ChatDetailPage extends StatefulWidget { + final String chatId; + final String chatTitle; + + const ChatDetailPage({ + super.key, + required this.chatId, + required this.chatTitle, + }); + + @override + State createState() => _ChatDetailPageState(); +} + +class _ChatDetailPageState extends State { + final _messageController = TextEditingController(); + + @override + void dispose() { + _messageController.dispose(); + super.dispose(); + } + + void _sendMessage() { + if (_messageController.text.trim().isEmpty) return; + _messageController.clear(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text(widget.chatTitle), + ), + body: const Center(child: Text('Chat Detail')), + bottomNavigationBar: _MessageInput( + controller: _messageController, + onSend: _sendMessage, + ), + ); + } +} + +class _MessageInput extends StatelessWidget { + final TextEditingController controller; + final VoidCallback onSend; + + const _MessageInput({ + required this.controller, + required this.onSend, + }); + + @override + Widget build(BuildContext context) { + return Container( + padding: const EdgeInsets.all(8), + decoration: BoxDecoration( + color: Colors.white, + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.1), + blurRadius: 4, + offset: const Offset(0, -2), + ), + ], + ), + child: Row( + children: [ + IconButton( + icon: const Icon(Icons.attach_file), + onPressed: () {}, + ), + Expanded( + child: TextField( + controller: controller, + decoration: InputDecoration( + hintText: 'Сообщение', + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(24), + borderSide: BorderSide.none, + ), + filled: true, + fillColor: Colors.grey[200], + contentPadding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 8, + ), + ), + maxLines: null, + onSubmitted: (_) => onSend(), + ), + ), + const SizedBox(width: 8), + IconButton( + icon: const Icon(Icons.send), + color: Theme.of(context).primaryColor, + onPressed: onSend, + ), + ], + ), + ); + } +} diff --git a/client-mobile/lib/features/chat/presentation/pages/chats_page.dart b/client-mobile/lib/features/chat/presentation/pages/chats_page.dart new file mode 100644 index 0000000..d0421b8 --- /dev/null +++ b/client-mobile/lib/features/chat/presentation/pages/chats_page.dart @@ -0,0 +1,35 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import '../bloc/chat_bloc.dart'; +import '../bloc/chat_state.dart'; + +class ChatsPage extends StatelessWidget { + const ChatsPage({super.key}); + + @override + Widget build(BuildContext context) { + return BlocBuilder( + builder: (context, state) { + return state.when( + initial: () => const Center(child: CircularProgressIndicator()), + loading: () => const Center(child: CircularProgressIndicator()), + chatsLoaded: (_) => const Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon(Icons.chat_bubble_outline, size: 64, color: Colors.grey), + SizedBox(height: 16), + Text('У вас пока нет чатов'), + ], + ), + ), + chatSelected: (_, __) => const Center(child: Text('Chat selected')), + messagesLoaded: (_) => const Center(child: Text('Messages loaded')), + messageSent: () => const Center(child: Text('Message sent')), + error: (message) => Center(child: Text('Ошибка: $message')), + ); + }, + ); + } +} + diff --git a/client-mobile/lib/features/profile/domain/entities/profile.dart b/client-mobile/lib/features/profile/domain/entities/profile.dart new file mode 100644 index 0000000..d762cd0 --- /dev/null +++ b/client-mobile/lib/features/profile/domain/entities/profile.dart @@ -0,0 +1,21 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'profile.freezed.dart'; +// part 'profile.g.dart'; + +@freezed +class Profile with _$Profile { + const factory Profile({ + required String id, + required String userId, + String? bio, + String? avatarUrl, + String? phoneNumber, + String? email, + DateTime? lastSeen, + bool? isOnline, + String? status, + }) = _Profile; + + // factory Profile.fromJson(Map json) => _$ProfileFromJson(json); +} diff --git a/client-mobile/lib/features/profile/domain/entities/profile.freezed.dart b/client-mobile/lib/features/profile/domain/entities/profile.freezed.dart new file mode 100644 index 0000000..9bdd64e --- /dev/null +++ b/client-mobile/lib/features/profile/domain/entities/profile.freezed.dart @@ -0,0 +1,298 @@ +// 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 'profile.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#adding-getters-and-methods-to-our-models'); + +/// @nodoc +mixin _$Profile { + String get id => throw _privateConstructorUsedError; + String get userId => throw _privateConstructorUsedError; + String? get bio => throw _privateConstructorUsedError; + String? get avatarUrl => throw _privateConstructorUsedError; + String? get phoneNumber => throw _privateConstructorUsedError; + String? get email => throw _privateConstructorUsedError; + DateTime? get lastSeen => throw _privateConstructorUsedError; + bool? get isOnline => throw _privateConstructorUsedError; + String? get status => throw _privateConstructorUsedError; + + @JsonKey(ignore: true) + $ProfileCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ProfileCopyWith<$Res> { + factory $ProfileCopyWith(Profile value, $Res Function(Profile) then) = + _$ProfileCopyWithImpl<$Res, Profile>; + @useResult + $Res call( + {String id, + String userId, + String? bio, + String? avatarUrl, + String? phoneNumber, + String? email, + DateTime? lastSeen, + bool? isOnline, + String? status}); +} + +/// @nodoc +class _$ProfileCopyWithImpl<$Res, $Val extends Profile> + implements $ProfileCopyWith<$Res> { + _$ProfileCopyWithImpl(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? userId = null, + Object? bio = freezed, + Object? avatarUrl = freezed, + Object? phoneNumber = freezed, + Object? email = freezed, + Object? lastSeen = freezed, + Object? isOnline = freezed, + Object? status = freezed, + }) { + return _then(_value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + userId: null == userId + ? _value.userId + : userId // ignore: cast_nullable_to_non_nullable + as String, + bio: freezed == bio + ? _value.bio + : bio // ignore: cast_nullable_to_non_nullable + as String?, + avatarUrl: freezed == avatarUrl + ? _value.avatarUrl + : avatarUrl // ignore: cast_nullable_to_non_nullable + as String?, + phoneNumber: freezed == phoneNumber + ? _value.phoneNumber + : phoneNumber // ignore: cast_nullable_to_non_nullable + as String?, + email: freezed == email + ? _value.email + : email // ignore: cast_nullable_to_non_nullable + as String?, + lastSeen: freezed == lastSeen + ? _value.lastSeen + : lastSeen // ignore: cast_nullable_to_non_nullable + as DateTime?, + isOnline: freezed == isOnline + ? _value.isOnline + : isOnline // ignore: cast_nullable_to_non_nullable + as bool?, + status: freezed == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$ProfileImplCopyWith<$Res> implements $ProfileCopyWith<$Res> { + factory _$$ProfileImplCopyWith( + _$ProfileImpl value, $Res Function(_$ProfileImpl) then) = + __$$ProfileImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String id, + String userId, + String? bio, + String? avatarUrl, + String? phoneNumber, + String? email, + DateTime? lastSeen, + bool? isOnline, + String? status}); +} + +/// @nodoc +class __$$ProfileImplCopyWithImpl<$Res> + extends _$ProfileCopyWithImpl<$Res, _$ProfileImpl> + implements _$$ProfileImplCopyWith<$Res> { + __$$ProfileImplCopyWithImpl( + _$ProfileImpl _value, $Res Function(_$ProfileImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? userId = null, + Object? bio = freezed, + Object? avatarUrl = freezed, + Object? phoneNumber = freezed, + Object? email = freezed, + Object? lastSeen = freezed, + Object? isOnline = freezed, + Object? status = freezed, + }) { + return _then(_$ProfileImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + userId: null == userId + ? _value.userId + : userId // ignore: cast_nullable_to_non_nullable + as String, + bio: freezed == bio + ? _value.bio + : bio // ignore: cast_nullable_to_non_nullable + as String?, + avatarUrl: freezed == avatarUrl + ? _value.avatarUrl + : avatarUrl // ignore: cast_nullable_to_non_nullable + as String?, + phoneNumber: freezed == phoneNumber + ? _value.phoneNumber + : phoneNumber // ignore: cast_nullable_to_non_nullable + as String?, + email: freezed == email + ? _value.email + : email // ignore: cast_nullable_to_non_nullable + as String?, + lastSeen: freezed == lastSeen + ? _value.lastSeen + : lastSeen // ignore: cast_nullable_to_non_nullable + as DateTime?, + isOnline: freezed == isOnline + ? _value.isOnline + : isOnline // ignore: cast_nullable_to_non_nullable + as bool?, + status: freezed == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc + +class _$ProfileImpl implements _Profile { + const _$ProfileImpl( + {required this.id, + required this.userId, + this.bio, + this.avatarUrl, + this.phoneNumber, + this.email, + this.lastSeen, + this.isOnline, + this.status}); + + @override + final String id; + @override + final String userId; + @override + final String? bio; + @override + final String? avatarUrl; + @override + final String? phoneNumber; + @override + final String? email; + @override + final DateTime? lastSeen; + @override + final bool? isOnline; + @override + final String? status; + + @override + String toString() { + return 'Profile(id: $id, userId: $userId, bio: $bio, avatarUrl: $avatarUrl, phoneNumber: $phoneNumber, email: $email, lastSeen: $lastSeen, isOnline: $isOnline, status: $status)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ProfileImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.userId, userId) || other.userId == userId) && + (identical(other.bio, bio) || other.bio == bio) && + (identical(other.avatarUrl, avatarUrl) || + other.avatarUrl == avatarUrl) && + (identical(other.phoneNumber, phoneNumber) || + other.phoneNumber == phoneNumber) && + (identical(other.email, email) || other.email == email) && + (identical(other.lastSeen, lastSeen) || + other.lastSeen == lastSeen) && + (identical(other.isOnline, isOnline) || + other.isOnline == isOnline) && + (identical(other.status, status) || other.status == status)); + } + + @override + int get hashCode => Object.hash(runtimeType, id, userId, bio, avatarUrl, + phoneNumber, email, lastSeen, isOnline, status); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$ProfileImplCopyWith<_$ProfileImpl> get copyWith => + __$$ProfileImplCopyWithImpl<_$ProfileImpl>(this, _$identity); +} + +abstract class _Profile implements Profile { + const factory _Profile( + {required final String id, + required final String userId, + final String? bio, + final String? avatarUrl, + final String? phoneNumber, + final String? email, + final DateTime? lastSeen, + final bool? isOnline, + final String? status}) = _$ProfileImpl; + + @override + String get id; + @override + String get userId; + @override + String? get bio; + @override + String? get avatarUrl; + @override + String? get phoneNumber; + @override + String? get email; + @override + DateTime? get lastSeen; + @override + bool? get isOnline; + @override + String? get status; + @override + @JsonKey(ignore: true) + _$$ProfileImplCopyWith<_$ProfileImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/client-mobile/lib/features/profile/domain/repositories/profile_repository.dart b/client-mobile/lib/features/profile/domain/repositories/profile_repository.dart new file mode 100644 index 0000000..cb18af7 --- /dev/null +++ b/client-mobile/lib/features/profile/domain/repositories/profile_repository.dart @@ -0,0 +1,9 @@ +import '../../../../core/errors/result.dart'; +import '../entities/profile.dart'; + +abstract class ProfileRepository { + Future> getProfile(String userId); + Future> updateProfile(Map data); + Future> uploadAvatar(String imagePath); + Future> updateStatus(String status); +} diff --git a/client-mobile/lib/features/profile/domain/usecases/get_profile.dart b/client-mobile/lib/features/profile/domain/usecases/get_profile.dart new file mode 100644 index 0000000..4afa8af --- /dev/null +++ b/client-mobile/lib/features/profile/domain/usecases/get_profile.dart @@ -0,0 +1,13 @@ +import '../../../../core/errors/result.dart'; +import '../repositories/profile_repository.dart'; +import '../entities/profile.dart'; + +class GetProfileUseCase { + final ProfileRepository _repository; + + GetProfileUseCase(this._repository); + + Future> execute(String userId) { + return _repository.getProfile(userId); + } +} diff --git a/client-mobile/lib/features/settings/data/datasources/settings_local_datasource.dart b/client-mobile/lib/features/settings/data/datasources/settings_local_datasource.dart new file mode 100644 index 0000000..3d5656a --- /dev/null +++ b/client-mobile/lib/features/settings/data/datasources/settings_local_datasource.dart @@ -0,0 +1,57 @@ +import 'dart:convert'; +import 'package:shared_preferences/shared_preferences.dart'; +import '../../../../core/constants/storage_keys.dart'; +import '../../domain/entities/server_config.dart'; + +abstract class SettingsLocalDataSource { + Future getApiUrl(); + Future saveApiUrl(String url); + Future getLanguageCode(); + Future saveLanguageCode(String code); + Future getServerConfig(); + Future saveServerConfig(ServerConfig config); +} + +class SettingsLocalDataSourceImpl implements SettingsLocalDataSource { + final SharedPreferences _prefs; + + SettingsLocalDataSourceImpl(this._prefs); + + @override + Future getApiUrl() async { + return _prefs.getString(StorageKeys.apiUrl); + } + + @override + Future saveApiUrl(String url) async { + await _prefs.setString(StorageKeys.apiUrl, url); + } + + @override + Future getLanguageCode() async { + return _prefs.getString(StorageKeys.languageCode); + } + + @override + Future saveLanguageCode(String code) async { + await _prefs.setString(StorageKeys.languageCode, code); + } + + @override + Future getServerConfig() async { + final jsonString = _prefs.getString(StorageKeys.serverConfig); + if (jsonString == null) return null; + try { + final json = jsonDecode(jsonString) as Map; + return ServerConfig.fromJson(json); + } catch (_) { + return null; + } + } + + @override + Future saveServerConfig(ServerConfig config) async { + final jsonString = jsonEncode(config.toJson()); + await _prefs.setString(StorageKeys.serverConfig, jsonString); + } +} diff --git a/client-mobile/lib/features/settings/data/datasources/settings_remote_datasource.dart b/client-mobile/lib/features/settings/data/datasources/settings_remote_datasource.dart new file mode 100644 index 0000000..06bb9ad --- /dev/null +++ b/client-mobile/lib/features/settings/data/datasources/settings_remote_datasource.dart @@ -0,0 +1,30 @@ +import 'package:dio/dio.dart'; +import '../../../../core/errors/errors.dart'; +import '../../../../core/errors/result.dart'; +import '../../domain/entities/server_config.dart'; + +abstract class SettingsRemoteDataSource { + Future> getServerConfig(); +} + +class SettingsRemoteDataSourceImpl implements SettingsRemoteDataSource { + final Dio _dio; + + SettingsRemoteDataSourceImpl(this._dio); + + @override + Future> getServerConfig() async { + try { + final response = await _dio.get('/api/config'); + if (response.statusCode == 200) { + final config = ServerConfig.fromJson(response.data as Map); + return Result.success(config); + } + return Result.failure(AppError.server(statusCode: 500, message: 'Failed to load config')); + } on DioException catch (e) { + return Result.failure(AppError.network(message: e.message)); + } catch (e) { + return Result.failure(const AppError.unknown(message: 'Unknown error')); + } + } +} diff --git a/client-mobile/lib/features/settings/data/repositories/settings_repository_impl.dart b/client-mobile/lib/features/settings/data/repositories/settings_repository_impl.dart new file mode 100644 index 0000000..f392d71 --- /dev/null +++ b/client-mobile/lib/features/settings/data/repositories/settings_repository_impl.dart @@ -0,0 +1,83 @@ +import '../../../../core/errors/errors.dart'; +import '../../../../core/errors/result.dart'; +import '../../domain/entities/server_config.dart'; +import '../../domain/repositories/settings_repository.dart'; +import '../datasources/settings_local_datasource.dart'; +import '../datasources/settings_remote_datasource.dart'; + +class SettingsRepositoryImpl implements SettingsRepository { + final SettingsLocalDataSource _local; + final SettingsRemoteDataSource _remote; + + SettingsRepositoryImpl(this._local, this._remote); + + @override + Future getApiUrl() => _local.getApiUrl(); + + @override + Future> saveApiUrl(String url) async { + try { + await _local.saveApiUrl(url); + return const Result.success(null); + } catch (e) { + return const Result.failure(AppError.unknown(message: 'Failed to save API URL')); + } + } + + @override + Future getLanguageCode() => _local.getLanguageCode(); + + @override + Future> saveLanguageCode(String code) async { + try { + await _local.saveLanguageCode(code); + return const Result.success(null); + } catch (e) { + return const Result.failure(AppError.unknown(message: 'Failed to save language')); + } + } + + @override + Future> getServerConfig() async { + final local = await _local.getServerConfig(); + if (local != null) { + return Result.success(local); + } + return refreshServerConfig(); + } + + @override + Future> refreshServerConfig() async { + final result = await _remote.getServerConfig(); + result.when( + onSuccess: (config) async => await _local.saveServerConfig(config), + onFailure: (_) {}, + ); + return result; + } + + @override + Future> getNotificationsEnabled() async { + return const Result.success(true); + } + + @override + Future> setNotificationsEnabled(bool enabled) async { + return const Result.success(null); + } + + @override + Future> getDarkModeEnabled() async { + return const Result.success(false); + } + + @override + Future> setDarkModeEnabled(bool enabled) async { + return const Result.success(null); + } + + @override + Future> clearAllData() async { + return const Result.success(null); + } +} diff --git a/client-mobile/lib/features/settings/domain/entities/server_config.dart b/client-mobile/lib/features/settings/domain/entities/server_config.dart new file mode 100644 index 0000000..1f16bcb --- /dev/null +++ b/client-mobile/lib/features/settings/domain/entities/server_config.dart @@ -0,0 +1,144 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'server_config.freezed.dart'; +part 'server_config.g.dart'; + +@freezed +class ServerConfig with _$ServerConfig { + const factory ServerConfig({ + required SystemConfig system, + required StoriesConfig stories, + required ChatsModuleConfig chats, + required MessagesConfig messages, + required WebRtcConfig webRtc, + required KlipyConfig klipy, + required ImportConfig import, + required FederationConfig federation, + }) = _ServerConfig; + + factory ServerConfig.fromJson(Map json) => + _$ServerConfigFromJson(json); +} + +@Freezed(toJson: true) +class SystemConfig with _$SystemConfig { + const factory SystemConfig({ + required String domainUrl, + required bool enableRegistration, + }) = _SystemConfig; + + factory SystemConfig.fromJson(Map json) => + _$SystemConfigFromJson(json); +} + +@Freezed(toJson: true) +class StoriesConfig with _$StoriesConfig { + const factory StoriesConfig({ + required bool enabled, + required int maxStoriesPerPeriod, + required int storyLifetimeHours, + required bool textStoriesEnabled, + required int textStoryDurationSeconds, + required int mediaStoryMaxDurationSeconds, + required int maxMediaSizeBytes, + }) = _StoriesConfig; + + factory StoriesConfig.fromJson(Map json) => + _$StoriesConfigFromJson(json); +} + +@Freezed(toJson: true) +class ChatsModuleConfig with _$ChatsModuleConfig { + const factory ChatsModuleConfig({ + required bool supportGroups, + required int maxGroupParticipants, + required bool allowChatToGroupConversion, + required bool enableFolders, + }) = _ChatsModuleConfig; + + factory ChatsModuleConfig.fromJson(Map json) => + _$ChatsModuleConfigFromJson(json); +} + +@Freezed(toJson: true) +class MessagesConfig with _$MessagesConfig { + const factory MessagesConfig({ + required int dailyMessageLimitPerUser, + required int chatMessageLimit, + required bool allowMedia, + required int maxMediaSizeBytes, + required List allowedMediaTypes, + required bool allowVoiceMessages, + required bool allowForwarding, + required bool allowReactions, + required bool allowReplies, + required bool allowQuoting, + required bool allowMessageDeletion, + required bool forbidCopying, + required bool allowLinks, + required bool allowPolls, + required bool allowPinning, + }) = _MessagesConfig; + + factory MessagesConfig.fromJson(Map json) => + _$MessagesConfigFromJson(json); +} + +@Freezed(toJson: true) +class WebRtcConfig with _$WebRtcConfig { + const factory WebRtcConfig({ + required bool enabled, + required bool enableVoiceCalls, + required bool enableVideoCalls, + required bool enableScreenSharing, + required String turnHost, + required int turnPort, + }) = _WebRtcConfig; + + factory WebRtcConfig.fromJson(Map json) => + _$WebRtcConfigFromJson(json); +} + +@Freezed(toJson: true) +class KlipyConfig with _$KlipyConfig { + const factory KlipyConfig({ + required bool enabled, + required String appName, + }) = _KlipyConfig; + + factory KlipyConfig.fromJson(Map json) => + _$KlipyConfigFromJson(json); +} + +@Freezed(toJson: true) +class ImportConfig with _$ImportConfig { + const factory ImportConfig({ + required bool enabled, + }) = _ImportConfig; + + factory ImportConfig.fromJson(Map json) => + _$ImportConfigFromJson(json); +} + +@Freezed(toJson: true) +class FederationConfig with _$FederationConfig { + const factory FederationConfig({ + required bool enabled, + required String serverDescription, + required List allowedDomains, + }) = _FederationConfig; + + factory FederationConfig.fromJson(Map json) => + _$FederationConfigFromJson(json); +} + +@Freezed(toJson: true) +class FederationDomainConfig with _$FederationDomainConfig { + const factory FederationDomainConfig({ + required String domain, + required bool enabled, + }) = _FederationDomainConfig; + + factory FederationDomainConfig.fromJson(Map json) => + _$FederationDomainConfigFromJson(json); +} diff --git a/client-mobile/lib/features/settings/domain/entities/server_config.freezed.dart b/client-mobile/lib/features/settings/domain/entities/server_config.freezed.dart new file mode 100644 index 0000000..55b3713 --- /dev/null +++ b/client-mobile/lib/features/settings/domain/entities/server_config.freezed.dart @@ -0,0 +1,2381 @@ +// 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 'server_config.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#adding-getters-and-methods-to-our-models'); + +ServerConfig _$ServerConfigFromJson(Map json) { + return _ServerConfig.fromJson(json); +} + +/// @nodoc +mixin _$ServerConfig { + SystemConfig get system => throw _privateConstructorUsedError; + StoriesConfig get stories => throw _privateConstructorUsedError; + ChatsModuleConfig get chats => throw _privateConstructorUsedError; + MessagesConfig get messages => throw _privateConstructorUsedError; + WebRtcConfig get webRtc => throw _privateConstructorUsedError; + KlipyConfig get klipy => throw _privateConstructorUsedError; + ImportConfig get import => throw _privateConstructorUsedError; + FederationConfig get federation => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $ServerConfigCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ServerConfigCopyWith<$Res> { + factory $ServerConfigCopyWith( + ServerConfig value, $Res Function(ServerConfig) then) = + _$ServerConfigCopyWithImpl<$Res, ServerConfig>; + @useResult + $Res call( + {SystemConfig system, + StoriesConfig stories, + ChatsModuleConfig chats, + MessagesConfig messages, + WebRtcConfig webRtc, + KlipyConfig klipy, + ImportConfig import, + FederationConfig federation}); + + $SystemConfigCopyWith<$Res> get system; + $StoriesConfigCopyWith<$Res> get stories; + $ChatsModuleConfigCopyWith<$Res> get chats; + $MessagesConfigCopyWith<$Res> get messages; + $WebRtcConfigCopyWith<$Res> get webRtc; + $KlipyConfigCopyWith<$Res> get klipy; + $ImportConfigCopyWith<$Res> get import; + $FederationConfigCopyWith<$Res> get federation; +} + +/// @nodoc +class _$ServerConfigCopyWithImpl<$Res, $Val extends ServerConfig> + implements $ServerConfigCopyWith<$Res> { + _$ServerConfigCopyWithImpl(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? system = null, + Object? stories = null, + Object? chats = null, + Object? messages = null, + Object? webRtc = null, + Object? klipy = null, + Object? import = null, + Object? federation = null, + }) { + return _then(_value.copyWith( + system: null == system + ? _value.system + : system // ignore: cast_nullable_to_non_nullable + as SystemConfig, + stories: null == stories + ? _value.stories + : stories // ignore: cast_nullable_to_non_nullable + as StoriesConfig, + chats: null == chats + ? _value.chats + : chats // ignore: cast_nullable_to_non_nullable + as ChatsModuleConfig, + messages: null == messages + ? _value.messages + : messages // ignore: cast_nullable_to_non_nullable + as MessagesConfig, + webRtc: null == webRtc + ? _value.webRtc + : webRtc // ignore: cast_nullable_to_non_nullable + as WebRtcConfig, + klipy: null == klipy + ? _value.klipy + : klipy // ignore: cast_nullable_to_non_nullable + as KlipyConfig, + import: null == import + ? _value.import + : import // ignore: cast_nullable_to_non_nullable + as ImportConfig, + federation: null == federation + ? _value.federation + : federation // ignore: cast_nullable_to_non_nullable + as FederationConfig, + ) as $Val); + } + + @override + @pragma('vm:prefer-inline') + $SystemConfigCopyWith<$Res> get system { + return $SystemConfigCopyWith<$Res>(_value.system, (value) { + return _then(_value.copyWith(system: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $StoriesConfigCopyWith<$Res> get stories { + return $StoriesConfigCopyWith<$Res>(_value.stories, (value) { + return _then(_value.copyWith(stories: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $ChatsModuleConfigCopyWith<$Res> get chats { + return $ChatsModuleConfigCopyWith<$Res>(_value.chats, (value) { + return _then(_value.copyWith(chats: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $MessagesConfigCopyWith<$Res> get messages { + return $MessagesConfigCopyWith<$Res>(_value.messages, (value) { + return _then(_value.copyWith(messages: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $WebRtcConfigCopyWith<$Res> get webRtc { + return $WebRtcConfigCopyWith<$Res>(_value.webRtc, (value) { + return _then(_value.copyWith(webRtc: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $KlipyConfigCopyWith<$Res> get klipy { + return $KlipyConfigCopyWith<$Res>(_value.klipy, (value) { + return _then(_value.copyWith(klipy: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $ImportConfigCopyWith<$Res> get import { + return $ImportConfigCopyWith<$Res>(_value.import, (value) { + return _then(_value.copyWith(import: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $FederationConfigCopyWith<$Res> get federation { + return $FederationConfigCopyWith<$Res>(_value.federation, (value) { + return _then(_value.copyWith(federation: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$ServerConfigImplCopyWith<$Res> + implements $ServerConfigCopyWith<$Res> { + factory _$$ServerConfigImplCopyWith( + _$ServerConfigImpl value, $Res Function(_$ServerConfigImpl) then) = + __$$ServerConfigImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {SystemConfig system, + StoriesConfig stories, + ChatsModuleConfig chats, + MessagesConfig messages, + WebRtcConfig webRtc, + KlipyConfig klipy, + ImportConfig import, + FederationConfig federation}); + + @override + $SystemConfigCopyWith<$Res> get system; + @override + $StoriesConfigCopyWith<$Res> get stories; + @override + $ChatsModuleConfigCopyWith<$Res> get chats; + @override + $MessagesConfigCopyWith<$Res> get messages; + @override + $WebRtcConfigCopyWith<$Res> get webRtc; + @override + $KlipyConfigCopyWith<$Res> get klipy; + @override + $ImportConfigCopyWith<$Res> get import; + @override + $FederationConfigCopyWith<$Res> get federation; +} + +/// @nodoc +class __$$ServerConfigImplCopyWithImpl<$Res> + extends _$ServerConfigCopyWithImpl<$Res, _$ServerConfigImpl> + implements _$$ServerConfigImplCopyWith<$Res> { + __$$ServerConfigImplCopyWithImpl( + _$ServerConfigImpl _value, $Res Function(_$ServerConfigImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? system = null, + Object? stories = null, + Object? chats = null, + Object? messages = null, + Object? webRtc = null, + Object? klipy = null, + Object? import = null, + Object? federation = null, + }) { + return _then(_$ServerConfigImpl( + system: null == system + ? _value.system + : system // ignore: cast_nullable_to_non_nullable + as SystemConfig, + stories: null == stories + ? _value.stories + : stories // ignore: cast_nullable_to_non_nullable + as StoriesConfig, + chats: null == chats + ? _value.chats + : chats // ignore: cast_nullable_to_non_nullable + as ChatsModuleConfig, + messages: null == messages + ? _value.messages + : messages // ignore: cast_nullable_to_non_nullable + as MessagesConfig, + webRtc: null == webRtc + ? _value.webRtc + : webRtc // ignore: cast_nullable_to_non_nullable + as WebRtcConfig, + klipy: null == klipy + ? _value.klipy + : klipy // ignore: cast_nullable_to_non_nullable + as KlipyConfig, + import: null == import + ? _value.import + : import // ignore: cast_nullable_to_non_nullable + as ImportConfig, + federation: null == federation + ? _value.federation + : federation // ignore: cast_nullable_to_non_nullable + as FederationConfig, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$ServerConfigImpl implements _ServerConfig { + const _$ServerConfigImpl( + {required this.system, + required this.stories, + required this.chats, + required this.messages, + required this.webRtc, + required this.klipy, + required this.import, + required this.federation}); + + factory _$ServerConfigImpl.fromJson(Map json) => + _$$ServerConfigImplFromJson(json); + + @override + final SystemConfig system; + @override + final StoriesConfig stories; + @override + final ChatsModuleConfig chats; + @override + final MessagesConfig messages; + @override + final WebRtcConfig webRtc; + @override + final KlipyConfig klipy; + @override + final ImportConfig import; + @override + final FederationConfig federation; + + @override + String toString() { + return 'ServerConfig(system: $system, stories: $stories, chats: $chats, messages: $messages, webRtc: $webRtc, klipy: $klipy, import: $import, federation: $federation)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ServerConfigImpl && + (identical(other.system, system) || other.system == system) && + (identical(other.stories, stories) || other.stories == stories) && + (identical(other.chats, chats) || other.chats == chats) && + (identical(other.messages, messages) || + other.messages == messages) && + (identical(other.webRtc, webRtc) || other.webRtc == webRtc) && + (identical(other.klipy, klipy) || other.klipy == klipy) && + (identical(other.import, import) || other.import == import) && + (identical(other.federation, federation) || + other.federation == federation)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, system, stories, chats, messages, + webRtc, klipy, import, federation); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$ServerConfigImplCopyWith<_$ServerConfigImpl> get copyWith => + __$$ServerConfigImplCopyWithImpl<_$ServerConfigImpl>(this, _$identity); + + @override + Map toJson() { + return _$$ServerConfigImplToJson( + this, + ); + } +} + +abstract class _ServerConfig implements ServerConfig { + const factory _ServerConfig( + {required final SystemConfig system, + required final StoriesConfig stories, + required final ChatsModuleConfig chats, + required final MessagesConfig messages, + required final WebRtcConfig webRtc, + required final KlipyConfig klipy, + required final ImportConfig import, + required final FederationConfig federation}) = _$ServerConfigImpl; + + factory _ServerConfig.fromJson(Map json) = + _$ServerConfigImpl.fromJson; + + @override + SystemConfig get system; + @override + StoriesConfig get stories; + @override + ChatsModuleConfig get chats; + @override + MessagesConfig get messages; + @override + WebRtcConfig get webRtc; + @override + KlipyConfig get klipy; + @override + ImportConfig get import; + @override + FederationConfig get federation; + @override + @JsonKey(ignore: true) + _$$ServerConfigImplCopyWith<_$ServerConfigImpl> get copyWith => + throw _privateConstructorUsedError; +} + +SystemConfig _$SystemConfigFromJson(Map json) { + return _SystemConfig.fromJson(json); +} + +/// @nodoc +mixin _$SystemConfig { + String get domainUrl => throw _privateConstructorUsedError; + bool get enableRegistration => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $SystemConfigCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $SystemConfigCopyWith<$Res> { + factory $SystemConfigCopyWith( + SystemConfig value, $Res Function(SystemConfig) then) = + _$SystemConfigCopyWithImpl<$Res, SystemConfig>; + @useResult + $Res call({String domainUrl, bool enableRegistration}); +} + +/// @nodoc +class _$SystemConfigCopyWithImpl<$Res, $Val extends SystemConfig> + implements $SystemConfigCopyWith<$Res> { + _$SystemConfigCopyWithImpl(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? domainUrl = null, + Object? enableRegistration = null, + }) { + return _then(_value.copyWith( + domainUrl: null == domainUrl + ? _value.domainUrl + : domainUrl // ignore: cast_nullable_to_non_nullable + as String, + enableRegistration: null == enableRegistration + ? _value.enableRegistration + : enableRegistration // ignore: cast_nullable_to_non_nullable + as bool, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$SystemConfigImplCopyWith<$Res> + implements $SystemConfigCopyWith<$Res> { + factory _$$SystemConfigImplCopyWith( + _$SystemConfigImpl value, $Res Function(_$SystemConfigImpl) then) = + __$$SystemConfigImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({String domainUrl, bool enableRegistration}); +} + +/// @nodoc +class __$$SystemConfigImplCopyWithImpl<$Res> + extends _$SystemConfigCopyWithImpl<$Res, _$SystemConfigImpl> + implements _$$SystemConfigImplCopyWith<$Res> { + __$$SystemConfigImplCopyWithImpl( + _$SystemConfigImpl _value, $Res Function(_$SystemConfigImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? domainUrl = null, + Object? enableRegistration = null, + }) { + return _then(_$SystemConfigImpl( + domainUrl: null == domainUrl + ? _value.domainUrl + : domainUrl // ignore: cast_nullable_to_non_nullable + as String, + enableRegistration: null == enableRegistration + ? _value.enableRegistration + : enableRegistration // ignore: cast_nullable_to_non_nullable + as bool, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$SystemConfigImpl implements _SystemConfig { + const _$SystemConfigImpl( + {required this.domainUrl, required this.enableRegistration}); + + factory _$SystemConfigImpl.fromJson(Map json) => + _$$SystemConfigImplFromJson(json); + + @override + final String domainUrl; + @override + final bool enableRegistration; + + @override + String toString() { + return 'SystemConfig(domainUrl: $domainUrl, enableRegistration: $enableRegistration)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$SystemConfigImpl && + (identical(other.domainUrl, domainUrl) || + other.domainUrl == domainUrl) && + (identical(other.enableRegistration, enableRegistration) || + other.enableRegistration == enableRegistration)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, domainUrl, enableRegistration); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$SystemConfigImplCopyWith<_$SystemConfigImpl> get copyWith => + __$$SystemConfigImplCopyWithImpl<_$SystemConfigImpl>(this, _$identity); + + @override + Map toJson() { + return _$$SystemConfigImplToJson( + this, + ); + } +} + +abstract class _SystemConfig implements SystemConfig { + const factory _SystemConfig( + {required final String domainUrl, + required final bool enableRegistration}) = _$SystemConfigImpl; + + factory _SystemConfig.fromJson(Map json) = + _$SystemConfigImpl.fromJson; + + @override + String get domainUrl; + @override + bool get enableRegistration; + @override + @JsonKey(ignore: true) + _$$SystemConfigImplCopyWith<_$SystemConfigImpl> get copyWith => + throw _privateConstructorUsedError; +} + +StoriesConfig _$StoriesConfigFromJson(Map json) { + return _StoriesConfig.fromJson(json); +} + +/// @nodoc +mixin _$StoriesConfig { + bool get enabled => throw _privateConstructorUsedError; + int get maxStoriesPerPeriod => throw _privateConstructorUsedError; + int get storyLifetimeHours => throw _privateConstructorUsedError; + bool get textStoriesEnabled => throw _privateConstructorUsedError; + int get textStoryDurationSeconds => throw _privateConstructorUsedError; + int get mediaStoryMaxDurationSeconds => throw _privateConstructorUsedError; + int get maxMediaSizeBytes => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $StoriesConfigCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $StoriesConfigCopyWith<$Res> { + factory $StoriesConfigCopyWith( + StoriesConfig value, $Res Function(StoriesConfig) then) = + _$StoriesConfigCopyWithImpl<$Res, StoriesConfig>; + @useResult + $Res call( + {bool enabled, + int maxStoriesPerPeriod, + int storyLifetimeHours, + bool textStoriesEnabled, + int textStoryDurationSeconds, + int mediaStoryMaxDurationSeconds, + int maxMediaSizeBytes}); +} + +/// @nodoc +class _$StoriesConfigCopyWithImpl<$Res, $Val extends StoriesConfig> + implements $StoriesConfigCopyWith<$Res> { + _$StoriesConfigCopyWithImpl(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? enabled = null, + Object? maxStoriesPerPeriod = null, + Object? storyLifetimeHours = null, + Object? textStoriesEnabled = null, + Object? textStoryDurationSeconds = null, + Object? mediaStoryMaxDurationSeconds = null, + Object? maxMediaSizeBytes = null, + }) { + return _then(_value.copyWith( + enabled: null == enabled + ? _value.enabled + : enabled // ignore: cast_nullable_to_non_nullable + as bool, + maxStoriesPerPeriod: null == maxStoriesPerPeriod + ? _value.maxStoriesPerPeriod + : maxStoriesPerPeriod // ignore: cast_nullable_to_non_nullable + as int, + storyLifetimeHours: null == storyLifetimeHours + ? _value.storyLifetimeHours + : storyLifetimeHours // ignore: cast_nullable_to_non_nullable + as int, + textStoriesEnabled: null == textStoriesEnabled + ? _value.textStoriesEnabled + : textStoriesEnabled // ignore: cast_nullable_to_non_nullable + as bool, + textStoryDurationSeconds: null == textStoryDurationSeconds + ? _value.textStoryDurationSeconds + : textStoryDurationSeconds // ignore: cast_nullable_to_non_nullable + as int, + mediaStoryMaxDurationSeconds: null == mediaStoryMaxDurationSeconds + ? _value.mediaStoryMaxDurationSeconds + : mediaStoryMaxDurationSeconds // ignore: cast_nullable_to_non_nullable + as int, + maxMediaSizeBytes: null == maxMediaSizeBytes + ? _value.maxMediaSizeBytes + : maxMediaSizeBytes // ignore: cast_nullable_to_non_nullable + as int, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$StoriesConfigImplCopyWith<$Res> + implements $StoriesConfigCopyWith<$Res> { + factory _$$StoriesConfigImplCopyWith( + _$StoriesConfigImpl value, $Res Function(_$StoriesConfigImpl) then) = + __$$StoriesConfigImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {bool enabled, + int maxStoriesPerPeriod, + int storyLifetimeHours, + bool textStoriesEnabled, + int textStoryDurationSeconds, + int mediaStoryMaxDurationSeconds, + int maxMediaSizeBytes}); +} + +/// @nodoc +class __$$StoriesConfigImplCopyWithImpl<$Res> + extends _$StoriesConfigCopyWithImpl<$Res, _$StoriesConfigImpl> + implements _$$StoriesConfigImplCopyWith<$Res> { + __$$StoriesConfigImplCopyWithImpl( + _$StoriesConfigImpl _value, $Res Function(_$StoriesConfigImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? enabled = null, + Object? maxStoriesPerPeriod = null, + Object? storyLifetimeHours = null, + Object? textStoriesEnabled = null, + Object? textStoryDurationSeconds = null, + Object? mediaStoryMaxDurationSeconds = null, + Object? maxMediaSizeBytes = null, + }) { + return _then(_$StoriesConfigImpl( + enabled: null == enabled + ? _value.enabled + : enabled // ignore: cast_nullable_to_non_nullable + as bool, + maxStoriesPerPeriod: null == maxStoriesPerPeriod + ? _value.maxStoriesPerPeriod + : maxStoriesPerPeriod // ignore: cast_nullable_to_non_nullable + as int, + storyLifetimeHours: null == storyLifetimeHours + ? _value.storyLifetimeHours + : storyLifetimeHours // ignore: cast_nullable_to_non_nullable + as int, + textStoriesEnabled: null == textStoriesEnabled + ? _value.textStoriesEnabled + : textStoriesEnabled // ignore: cast_nullable_to_non_nullable + as bool, + textStoryDurationSeconds: null == textStoryDurationSeconds + ? _value.textStoryDurationSeconds + : textStoryDurationSeconds // ignore: cast_nullable_to_non_nullable + as int, + mediaStoryMaxDurationSeconds: null == mediaStoryMaxDurationSeconds + ? _value.mediaStoryMaxDurationSeconds + : mediaStoryMaxDurationSeconds // ignore: cast_nullable_to_non_nullable + as int, + maxMediaSizeBytes: null == maxMediaSizeBytes + ? _value.maxMediaSizeBytes + : maxMediaSizeBytes // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$StoriesConfigImpl implements _StoriesConfig { + const _$StoriesConfigImpl( + {required this.enabled, + required this.maxStoriesPerPeriod, + required this.storyLifetimeHours, + required this.textStoriesEnabled, + required this.textStoryDurationSeconds, + required this.mediaStoryMaxDurationSeconds, + required this.maxMediaSizeBytes}); + + factory _$StoriesConfigImpl.fromJson(Map json) => + _$$StoriesConfigImplFromJson(json); + + @override + final bool enabled; + @override + final int maxStoriesPerPeriod; + @override + final int storyLifetimeHours; + @override + final bool textStoriesEnabled; + @override + final int textStoryDurationSeconds; + @override + final int mediaStoryMaxDurationSeconds; + @override + final int maxMediaSizeBytes; + + @override + String toString() { + return 'StoriesConfig(enabled: $enabled, maxStoriesPerPeriod: $maxStoriesPerPeriod, storyLifetimeHours: $storyLifetimeHours, textStoriesEnabled: $textStoriesEnabled, textStoryDurationSeconds: $textStoryDurationSeconds, mediaStoryMaxDurationSeconds: $mediaStoryMaxDurationSeconds, maxMediaSizeBytes: $maxMediaSizeBytes)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$StoriesConfigImpl && + (identical(other.enabled, enabled) || other.enabled == enabled) && + (identical(other.maxStoriesPerPeriod, maxStoriesPerPeriod) || + other.maxStoriesPerPeriod == maxStoriesPerPeriod) && + (identical(other.storyLifetimeHours, storyLifetimeHours) || + other.storyLifetimeHours == storyLifetimeHours) && + (identical(other.textStoriesEnabled, textStoriesEnabled) || + other.textStoriesEnabled == textStoriesEnabled) && + (identical( + other.textStoryDurationSeconds, textStoryDurationSeconds) || + other.textStoryDurationSeconds == textStoryDurationSeconds) && + (identical(other.mediaStoryMaxDurationSeconds, + mediaStoryMaxDurationSeconds) || + other.mediaStoryMaxDurationSeconds == + mediaStoryMaxDurationSeconds) && + (identical(other.maxMediaSizeBytes, maxMediaSizeBytes) || + other.maxMediaSizeBytes == maxMediaSizeBytes)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, + enabled, + maxStoriesPerPeriod, + storyLifetimeHours, + textStoriesEnabled, + textStoryDurationSeconds, + mediaStoryMaxDurationSeconds, + maxMediaSizeBytes); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$StoriesConfigImplCopyWith<_$StoriesConfigImpl> get copyWith => + __$$StoriesConfigImplCopyWithImpl<_$StoriesConfigImpl>(this, _$identity); + + @override + Map toJson() { + return _$$StoriesConfigImplToJson( + this, + ); + } +} + +abstract class _StoriesConfig implements StoriesConfig { + const factory _StoriesConfig( + {required final bool enabled, + required final int maxStoriesPerPeriod, + required final int storyLifetimeHours, + required final bool textStoriesEnabled, + required final int textStoryDurationSeconds, + required final int mediaStoryMaxDurationSeconds, + required final int maxMediaSizeBytes}) = _$StoriesConfigImpl; + + factory _StoriesConfig.fromJson(Map json) = + _$StoriesConfigImpl.fromJson; + + @override + bool get enabled; + @override + int get maxStoriesPerPeriod; + @override + int get storyLifetimeHours; + @override + bool get textStoriesEnabled; + @override + int get textStoryDurationSeconds; + @override + int get mediaStoryMaxDurationSeconds; + @override + int get maxMediaSizeBytes; + @override + @JsonKey(ignore: true) + _$$StoriesConfigImplCopyWith<_$StoriesConfigImpl> get copyWith => + throw _privateConstructorUsedError; +} + +ChatsModuleConfig _$ChatsModuleConfigFromJson(Map json) { + return _ChatsModuleConfig.fromJson(json); +} + +/// @nodoc +mixin _$ChatsModuleConfig { + bool get supportGroups => throw _privateConstructorUsedError; + int get maxGroupParticipants => throw _privateConstructorUsedError; + bool get allowChatToGroupConversion => throw _privateConstructorUsedError; + bool get enableFolders => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $ChatsModuleConfigCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ChatsModuleConfigCopyWith<$Res> { + factory $ChatsModuleConfigCopyWith( + ChatsModuleConfig value, $Res Function(ChatsModuleConfig) then) = + _$ChatsModuleConfigCopyWithImpl<$Res, ChatsModuleConfig>; + @useResult + $Res call( + {bool supportGroups, + int maxGroupParticipants, + bool allowChatToGroupConversion, + bool enableFolders}); +} + +/// @nodoc +class _$ChatsModuleConfigCopyWithImpl<$Res, $Val extends ChatsModuleConfig> + implements $ChatsModuleConfigCopyWith<$Res> { + _$ChatsModuleConfigCopyWithImpl(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? supportGroups = null, + Object? maxGroupParticipants = null, + Object? allowChatToGroupConversion = null, + Object? enableFolders = null, + }) { + return _then(_value.copyWith( + supportGroups: null == supportGroups + ? _value.supportGroups + : supportGroups // ignore: cast_nullable_to_non_nullable + as bool, + maxGroupParticipants: null == maxGroupParticipants + ? _value.maxGroupParticipants + : maxGroupParticipants // ignore: cast_nullable_to_non_nullable + as int, + allowChatToGroupConversion: null == allowChatToGroupConversion + ? _value.allowChatToGroupConversion + : allowChatToGroupConversion // ignore: cast_nullable_to_non_nullable + as bool, + enableFolders: null == enableFolders + ? _value.enableFolders + : enableFolders // ignore: cast_nullable_to_non_nullable + as bool, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$ChatsModuleConfigImplCopyWith<$Res> + implements $ChatsModuleConfigCopyWith<$Res> { + factory _$$ChatsModuleConfigImplCopyWith(_$ChatsModuleConfigImpl value, + $Res Function(_$ChatsModuleConfigImpl) then) = + __$$ChatsModuleConfigImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {bool supportGroups, + int maxGroupParticipants, + bool allowChatToGroupConversion, + bool enableFolders}); +} + +/// @nodoc +class __$$ChatsModuleConfigImplCopyWithImpl<$Res> + extends _$ChatsModuleConfigCopyWithImpl<$Res, _$ChatsModuleConfigImpl> + implements _$$ChatsModuleConfigImplCopyWith<$Res> { + __$$ChatsModuleConfigImplCopyWithImpl(_$ChatsModuleConfigImpl _value, + $Res Function(_$ChatsModuleConfigImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? supportGroups = null, + Object? maxGroupParticipants = null, + Object? allowChatToGroupConversion = null, + Object? enableFolders = null, + }) { + return _then(_$ChatsModuleConfigImpl( + supportGroups: null == supportGroups + ? _value.supportGroups + : supportGroups // ignore: cast_nullable_to_non_nullable + as bool, + maxGroupParticipants: null == maxGroupParticipants + ? _value.maxGroupParticipants + : maxGroupParticipants // ignore: cast_nullable_to_non_nullable + as int, + allowChatToGroupConversion: null == allowChatToGroupConversion + ? _value.allowChatToGroupConversion + : allowChatToGroupConversion // ignore: cast_nullable_to_non_nullable + as bool, + enableFolders: null == enableFolders + ? _value.enableFolders + : enableFolders // ignore: cast_nullable_to_non_nullable + as bool, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$ChatsModuleConfigImpl implements _ChatsModuleConfig { + const _$ChatsModuleConfigImpl( + {required this.supportGroups, + required this.maxGroupParticipants, + required this.allowChatToGroupConversion, + required this.enableFolders}); + + factory _$ChatsModuleConfigImpl.fromJson(Map json) => + _$$ChatsModuleConfigImplFromJson(json); + + @override + final bool supportGroups; + @override + final int maxGroupParticipants; + @override + final bool allowChatToGroupConversion; + @override + final bool enableFolders; + + @override + String toString() { + return 'ChatsModuleConfig(supportGroups: $supportGroups, maxGroupParticipants: $maxGroupParticipants, allowChatToGroupConversion: $allowChatToGroupConversion, enableFolders: $enableFolders)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ChatsModuleConfigImpl && + (identical(other.supportGroups, supportGroups) || + other.supportGroups == supportGroups) && + (identical(other.maxGroupParticipants, maxGroupParticipants) || + other.maxGroupParticipants == maxGroupParticipants) && + (identical(other.allowChatToGroupConversion, + allowChatToGroupConversion) || + other.allowChatToGroupConversion == + allowChatToGroupConversion) && + (identical(other.enableFolders, enableFolders) || + other.enableFolders == enableFolders)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, supportGroups, + maxGroupParticipants, allowChatToGroupConversion, enableFolders); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$ChatsModuleConfigImplCopyWith<_$ChatsModuleConfigImpl> get copyWith => + __$$ChatsModuleConfigImplCopyWithImpl<_$ChatsModuleConfigImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$ChatsModuleConfigImplToJson( + this, + ); + } +} + +abstract class _ChatsModuleConfig implements ChatsModuleConfig { + const factory _ChatsModuleConfig( + {required final bool supportGroups, + required final int maxGroupParticipants, + required final bool allowChatToGroupConversion, + required final bool enableFolders}) = _$ChatsModuleConfigImpl; + + factory _ChatsModuleConfig.fromJson(Map json) = + _$ChatsModuleConfigImpl.fromJson; + + @override + bool get supportGroups; + @override + int get maxGroupParticipants; + @override + bool get allowChatToGroupConversion; + @override + bool get enableFolders; + @override + @JsonKey(ignore: true) + _$$ChatsModuleConfigImplCopyWith<_$ChatsModuleConfigImpl> get copyWith => + throw _privateConstructorUsedError; +} + +MessagesConfig _$MessagesConfigFromJson(Map json) { + return _MessagesConfig.fromJson(json); +} + +/// @nodoc +mixin _$MessagesConfig { + int get dailyMessageLimitPerUser => throw _privateConstructorUsedError; + int get chatMessageLimit => throw _privateConstructorUsedError; + bool get allowMedia => throw _privateConstructorUsedError; + int get maxMediaSizeBytes => throw _privateConstructorUsedError; + List get allowedMediaTypes => throw _privateConstructorUsedError; + bool get allowVoiceMessages => throw _privateConstructorUsedError; + bool get allowForwarding => throw _privateConstructorUsedError; + bool get allowReactions => throw _privateConstructorUsedError; + bool get allowReplies => throw _privateConstructorUsedError; + bool get allowQuoting => throw _privateConstructorUsedError; + bool get allowMessageDeletion => throw _privateConstructorUsedError; + bool get forbidCopying => throw _privateConstructorUsedError; + bool get allowLinks => throw _privateConstructorUsedError; + bool get allowPolls => throw _privateConstructorUsedError; + bool get allowPinning => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $MessagesConfigCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $MessagesConfigCopyWith<$Res> { + factory $MessagesConfigCopyWith( + MessagesConfig value, $Res Function(MessagesConfig) then) = + _$MessagesConfigCopyWithImpl<$Res, MessagesConfig>; + @useResult + $Res call( + {int dailyMessageLimitPerUser, + int chatMessageLimit, + bool allowMedia, + int maxMediaSizeBytes, + List allowedMediaTypes, + bool allowVoiceMessages, + bool allowForwarding, + bool allowReactions, + bool allowReplies, + bool allowQuoting, + bool allowMessageDeletion, + bool forbidCopying, + bool allowLinks, + bool allowPolls, + bool allowPinning}); +} + +/// @nodoc +class _$MessagesConfigCopyWithImpl<$Res, $Val extends MessagesConfig> + implements $MessagesConfigCopyWith<$Res> { + _$MessagesConfigCopyWithImpl(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? dailyMessageLimitPerUser = null, + Object? chatMessageLimit = null, + Object? allowMedia = null, + Object? maxMediaSizeBytes = null, + Object? allowedMediaTypes = null, + Object? allowVoiceMessages = null, + Object? allowForwarding = null, + Object? allowReactions = null, + Object? allowReplies = null, + Object? allowQuoting = null, + Object? allowMessageDeletion = null, + Object? forbidCopying = null, + Object? allowLinks = null, + Object? allowPolls = null, + Object? allowPinning = null, + }) { + return _then(_value.copyWith( + dailyMessageLimitPerUser: null == dailyMessageLimitPerUser + ? _value.dailyMessageLimitPerUser + : dailyMessageLimitPerUser // ignore: cast_nullable_to_non_nullable + as int, + chatMessageLimit: null == chatMessageLimit + ? _value.chatMessageLimit + : chatMessageLimit // ignore: cast_nullable_to_non_nullable + as int, + allowMedia: null == allowMedia + ? _value.allowMedia + : allowMedia // ignore: cast_nullable_to_non_nullable + as bool, + maxMediaSizeBytes: null == maxMediaSizeBytes + ? _value.maxMediaSizeBytes + : maxMediaSizeBytes // ignore: cast_nullable_to_non_nullable + as int, + allowedMediaTypes: null == allowedMediaTypes + ? _value.allowedMediaTypes + : allowedMediaTypes // ignore: cast_nullable_to_non_nullable + as List, + allowVoiceMessages: null == allowVoiceMessages + ? _value.allowVoiceMessages + : allowVoiceMessages // ignore: cast_nullable_to_non_nullable + as bool, + allowForwarding: null == allowForwarding + ? _value.allowForwarding + : allowForwarding // ignore: cast_nullable_to_non_nullable + as bool, + allowReactions: null == allowReactions + ? _value.allowReactions + : allowReactions // ignore: cast_nullable_to_non_nullable + as bool, + allowReplies: null == allowReplies + ? _value.allowReplies + : allowReplies // ignore: cast_nullable_to_non_nullable + as bool, + allowQuoting: null == allowQuoting + ? _value.allowQuoting + : allowQuoting // ignore: cast_nullable_to_non_nullable + as bool, + allowMessageDeletion: null == allowMessageDeletion + ? _value.allowMessageDeletion + : allowMessageDeletion // ignore: cast_nullable_to_non_nullable + as bool, + forbidCopying: null == forbidCopying + ? _value.forbidCopying + : forbidCopying // ignore: cast_nullable_to_non_nullable + as bool, + allowLinks: null == allowLinks + ? _value.allowLinks + : allowLinks // ignore: cast_nullable_to_non_nullable + as bool, + allowPolls: null == allowPolls + ? _value.allowPolls + : allowPolls // ignore: cast_nullable_to_non_nullable + as bool, + allowPinning: null == allowPinning + ? _value.allowPinning + : allowPinning // ignore: cast_nullable_to_non_nullable + as bool, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$MessagesConfigImplCopyWith<$Res> + implements $MessagesConfigCopyWith<$Res> { + factory _$$MessagesConfigImplCopyWith(_$MessagesConfigImpl value, + $Res Function(_$MessagesConfigImpl) then) = + __$$MessagesConfigImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {int dailyMessageLimitPerUser, + int chatMessageLimit, + bool allowMedia, + int maxMediaSizeBytes, + List allowedMediaTypes, + bool allowVoiceMessages, + bool allowForwarding, + bool allowReactions, + bool allowReplies, + bool allowQuoting, + bool allowMessageDeletion, + bool forbidCopying, + bool allowLinks, + bool allowPolls, + bool allowPinning}); +} + +/// @nodoc +class __$$MessagesConfigImplCopyWithImpl<$Res> + extends _$MessagesConfigCopyWithImpl<$Res, _$MessagesConfigImpl> + implements _$$MessagesConfigImplCopyWith<$Res> { + __$$MessagesConfigImplCopyWithImpl( + _$MessagesConfigImpl _value, $Res Function(_$MessagesConfigImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? dailyMessageLimitPerUser = null, + Object? chatMessageLimit = null, + Object? allowMedia = null, + Object? maxMediaSizeBytes = null, + Object? allowedMediaTypes = null, + Object? allowVoiceMessages = null, + Object? allowForwarding = null, + Object? allowReactions = null, + Object? allowReplies = null, + Object? allowQuoting = null, + Object? allowMessageDeletion = null, + Object? forbidCopying = null, + Object? allowLinks = null, + Object? allowPolls = null, + Object? allowPinning = null, + }) { + return _then(_$MessagesConfigImpl( + dailyMessageLimitPerUser: null == dailyMessageLimitPerUser + ? _value.dailyMessageLimitPerUser + : dailyMessageLimitPerUser // ignore: cast_nullable_to_non_nullable + as int, + chatMessageLimit: null == chatMessageLimit + ? _value.chatMessageLimit + : chatMessageLimit // ignore: cast_nullable_to_non_nullable + as int, + allowMedia: null == allowMedia + ? _value.allowMedia + : allowMedia // ignore: cast_nullable_to_non_nullable + as bool, + maxMediaSizeBytes: null == maxMediaSizeBytes + ? _value.maxMediaSizeBytes + : maxMediaSizeBytes // ignore: cast_nullable_to_non_nullable + as int, + allowedMediaTypes: null == allowedMediaTypes + ? _value._allowedMediaTypes + : allowedMediaTypes // ignore: cast_nullable_to_non_nullable + as List, + allowVoiceMessages: null == allowVoiceMessages + ? _value.allowVoiceMessages + : allowVoiceMessages // ignore: cast_nullable_to_non_nullable + as bool, + allowForwarding: null == allowForwarding + ? _value.allowForwarding + : allowForwarding // ignore: cast_nullable_to_non_nullable + as bool, + allowReactions: null == allowReactions + ? _value.allowReactions + : allowReactions // ignore: cast_nullable_to_non_nullable + as bool, + allowReplies: null == allowReplies + ? _value.allowReplies + : allowReplies // ignore: cast_nullable_to_non_nullable + as bool, + allowQuoting: null == allowQuoting + ? _value.allowQuoting + : allowQuoting // ignore: cast_nullable_to_non_nullable + as bool, + allowMessageDeletion: null == allowMessageDeletion + ? _value.allowMessageDeletion + : allowMessageDeletion // ignore: cast_nullable_to_non_nullable + as bool, + forbidCopying: null == forbidCopying + ? _value.forbidCopying + : forbidCopying // ignore: cast_nullable_to_non_nullable + as bool, + allowLinks: null == allowLinks + ? _value.allowLinks + : allowLinks // ignore: cast_nullable_to_non_nullable + as bool, + allowPolls: null == allowPolls + ? _value.allowPolls + : allowPolls // ignore: cast_nullable_to_non_nullable + as bool, + allowPinning: null == allowPinning + ? _value.allowPinning + : allowPinning // ignore: cast_nullable_to_non_nullable + as bool, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$MessagesConfigImpl implements _MessagesConfig { + const _$MessagesConfigImpl( + {required this.dailyMessageLimitPerUser, + required this.chatMessageLimit, + required this.allowMedia, + required this.maxMediaSizeBytes, + required final List allowedMediaTypes, + required this.allowVoiceMessages, + required this.allowForwarding, + required this.allowReactions, + required this.allowReplies, + required this.allowQuoting, + required this.allowMessageDeletion, + required this.forbidCopying, + required this.allowLinks, + required this.allowPolls, + required this.allowPinning}) + : _allowedMediaTypes = allowedMediaTypes; + + factory _$MessagesConfigImpl.fromJson(Map json) => + _$$MessagesConfigImplFromJson(json); + + @override + final int dailyMessageLimitPerUser; + @override + final int chatMessageLimit; + @override + final bool allowMedia; + @override + final int maxMediaSizeBytes; + final List _allowedMediaTypes; + @override + List get allowedMediaTypes { + if (_allowedMediaTypes is EqualUnmodifiableListView) + return _allowedMediaTypes; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_allowedMediaTypes); + } + + @override + final bool allowVoiceMessages; + @override + final bool allowForwarding; + @override + final bool allowReactions; + @override + final bool allowReplies; + @override + final bool allowQuoting; + @override + final bool allowMessageDeletion; + @override + final bool forbidCopying; + @override + final bool allowLinks; + @override + final bool allowPolls; + @override + final bool allowPinning; + + @override + String toString() { + return 'MessagesConfig(dailyMessageLimitPerUser: $dailyMessageLimitPerUser, chatMessageLimit: $chatMessageLimit, allowMedia: $allowMedia, maxMediaSizeBytes: $maxMediaSizeBytes, allowedMediaTypes: $allowedMediaTypes, allowVoiceMessages: $allowVoiceMessages, allowForwarding: $allowForwarding, allowReactions: $allowReactions, allowReplies: $allowReplies, allowQuoting: $allowQuoting, allowMessageDeletion: $allowMessageDeletion, forbidCopying: $forbidCopying, allowLinks: $allowLinks, allowPolls: $allowPolls, allowPinning: $allowPinning)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$MessagesConfigImpl && + (identical( + other.dailyMessageLimitPerUser, dailyMessageLimitPerUser) || + other.dailyMessageLimitPerUser == dailyMessageLimitPerUser) && + (identical(other.chatMessageLimit, chatMessageLimit) || + other.chatMessageLimit == chatMessageLimit) && + (identical(other.allowMedia, allowMedia) || + other.allowMedia == allowMedia) && + (identical(other.maxMediaSizeBytes, maxMediaSizeBytes) || + other.maxMediaSizeBytes == maxMediaSizeBytes) && + const DeepCollectionEquality() + .equals(other._allowedMediaTypes, _allowedMediaTypes) && + (identical(other.allowVoiceMessages, allowVoiceMessages) || + other.allowVoiceMessages == allowVoiceMessages) && + (identical(other.allowForwarding, allowForwarding) || + other.allowForwarding == allowForwarding) && + (identical(other.allowReactions, allowReactions) || + other.allowReactions == allowReactions) && + (identical(other.allowReplies, allowReplies) || + other.allowReplies == allowReplies) && + (identical(other.allowQuoting, allowQuoting) || + other.allowQuoting == allowQuoting) && + (identical(other.allowMessageDeletion, allowMessageDeletion) || + other.allowMessageDeletion == allowMessageDeletion) && + (identical(other.forbidCopying, forbidCopying) || + other.forbidCopying == forbidCopying) && + (identical(other.allowLinks, allowLinks) || + other.allowLinks == allowLinks) && + (identical(other.allowPolls, allowPolls) || + other.allowPolls == allowPolls) && + (identical(other.allowPinning, allowPinning) || + other.allowPinning == allowPinning)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, + dailyMessageLimitPerUser, + chatMessageLimit, + allowMedia, + maxMediaSizeBytes, + const DeepCollectionEquality().hash(_allowedMediaTypes), + allowVoiceMessages, + allowForwarding, + allowReactions, + allowReplies, + allowQuoting, + allowMessageDeletion, + forbidCopying, + allowLinks, + allowPolls, + allowPinning); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$MessagesConfigImplCopyWith<_$MessagesConfigImpl> get copyWith => + __$$MessagesConfigImplCopyWithImpl<_$MessagesConfigImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$MessagesConfigImplToJson( + this, + ); + } +} + +abstract class _MessagesConfig implements MessagesConfig { + const factory _MessagesConfig( + {required final int dailyMessageLimitPerUser, + required final int chatMessageLimit, + required final bool allowMedia, + required final int maxMediaSizeBytes, + required final List allowedMediaTypes, + required final bool allowVoiceMessages, + required final bool allowForwarding, + required final bool allowReactions, + required final bool allowReplies, + required final bool allowQuoting, + required final bool allowMessageDeletion, + required final bool forbidCopying, + required final bool allowLinks, + required final bool allowPolls, + required final bool allowPinning}) = _$MessagesConfigImpl; + + factory _MessagesConfig.fromJson(Map json) = + _$MessagesConfigImpl.fromJson; + + @override + int get dailyMessageLimitPerUser; + @override + int get chatMessageLimit; + @override + bool get allowMedia; + @override + int get maxMediaSizeBytes; + @override + List get allowedMediaTypes; + @override + bool get allowVoiceMessages; + @override + bool get allowForwarding; + @override + bool get allowReactions; + @override + bool get allowReplies; + @override + bool get allowQuoting; + @override + bool get allowMessageDeletion; + @override + bool get forbidCopying; + @override + bool get allowLinks; + @override + bool get allowPolls; + @override + bool get allowPinning; + @override + @JsonKey(ignore: true) + _$$MessagesConfigImplCopyWith<_$MessagesConfigImpl> get copyWith => + throw _privateConstructorUsedError; +} + +WebRtcConfig _$WebRtcConfigFromJson(Map json) { + return _WebRtcConfig.fromJson(json); +} + +/// @nodoc +mixin _$WebRtcConfig { + bool get enabled => throw _privateConstructorUsedError; + bool get enableVoiceCalls => throw _privateConstructorUsedError; + bool get enableVideoCalls => throw _privateConstructorUsedError; + bool get enableScreenSharing => throw _privateConstructorUsedError; + String get turnHost => throw _privateConstructorUsedError; + int get turnPort => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $WebRtcConfigCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $WebRtcConfigCopyWith<$Res> { + factory $WebRtcConfigCopyWith( + WebRtcConfig value, $Res Function(WebRtcConfig) then) = + _$WebRtcConfigCopyWithImpl<$Res, WebRtcConfig>; + @useResult + $Res call( + {bool enabled, + bool enableVoiceCalls, + bool enableVideoCalls, + bool enableScreenSharing, + String turnHost, + int turnPort}); +} + +/// @nodoc +class _$WebRtcConfigCopyWithImpl<$Res, $Val extends WebRtcConfig> + implements $WebRtcConfigCopyWith<$Res> { + _$WebRtcConfigCopyWithImpl(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? enabled = null, + Object? enableVoiceCalls = null, + Object? enableVideoCalls = null, + Object? enableScreenSharing = null, + Object? turnHost = null, + Object? turnPort = null, + }) { + return _then(_value.copyWith( + enabled: null == enabled + ? _value.enabled + : enabled // ignore: cast_nullable_to_non_nullable + as bool, + enableVoiceCalls: null == enableVoiceCalls + ? _value.enableVoiceCalls + : enableVoiceCalls // ignore: cast_nullable_to_non_nullable + as bool, + enableVideoCalls: null == enableVideoCalls + ? _value.enableVideoCalls + : enableVideoCalls // ignore: cast_nullable_to_non_nullable + as bool, + enableScreenSharing: null == enableScreenSharing + ? _value.enableScreenSharing + : enableScreenSharing // ignore: cast_nullable_to_non_nullable + as bool, + turnHost: null == turnHost + ? _value.turnHost + : turnHost // ignore: cast_nullable_to_non_nullable + as String, + turnPort: null == turnPort + ? _value.turnPort + : turnPort // ignore: cast_nullable_to_non_nullable + as int, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$WebRtcConfigImplCopyWith<$Res> + implements $WebRtcConfigCopyWith<$Res> { + factory _$$WebRtcConfigImplCopyWith( + _$WebRtcConfigImpl value, $Res Function(_$WebRtcConfigImpl) then) = + __$$WebRtcConfigImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {bool enabled, + bool enableVoiceCalls, + bool enableVideoCalls, + bool enableScreenSharing, + String turnHost, + int turnPort}); +} + +/// @nodoc +class __$$WebRtcConfigImplCopyWithImpl<$Res> + extends _$WebRtcConfigCopyWithImpl<$Res, _$WebRtcConfigImpl> + implements _$$WebRtcConfigImplCopyWith<$Res> { + __$$WebRtcConfigImplCopyWithImpl( + _$WebRtcConfigImpl _value, $Res Function(_$WebRtcConfigImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? enabled = null, + Object? enableVoiceCalls = null, + Object? enableVideoCalls = null, + Object? enableScreenSharing = null, + Object? turnHost = null, + Object? turnPort = null, + }) { + return _then(_$WebRtcConfigImpl( + enabled: null == enabled + ? _value.enabled + : enabled // ignore: cast_nullable_to_non_nullable + as bool, + enableVoiceCalls: null == enableVoiceCalls + ? _value.enableVoiceCalls + : enableVoiceCalls // ignore: cast_nullable_to_non_nullable + as bool, + enableVideoCalls: null == enableVideoCalls + ? _value.enableVideoCalls + : enableVideoCalls // ignore: cast_nullable_to_non_nullable + as bool, + enableScreenSharing: null == enableScreenSharing + ? _value.enableScreenSharing + : enableScreenSharing // ignore: cast_nullable_to_non_nullable + as bool, + turnHost: null == turnHost + ? _value.turnHost + : turnHost // ignore: cast_nullable_to_non_nullable + as String, + turnPort: null == turnPort + ? _value.turnPort + : turnPort // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$WebRtcConfigImpl implements _WebRtcConfig { + const _$WebRtcConfigImpl( + {required this.enabled, + required this.enableVoiceCalls, + required this.enableVideoCalls, + required this.enableScreenSharing, + required this.turnHost, + required this.turnPort}); + + factory _$WebRtcConfigImpl.fromJson(Map json) => + _$$WebRtcConfigImplFromJson(json); + + @override + final bool enabled; + @override + final bool enableVoiceCalls; + @override + final bool enableVideoCalls; + @override + final bool enableScreenSharing; + @override + final String turnHost; + @override + final int turnPort; + + @override + String toString() { + return 'WebRtcConfig(enabled: $enabled, enableVoiceCalls: $enableVoiceCalls, enableVideoCalls: $enableVideoCalls, enableScreenSharing: $enableScreenSharing, turnHost: $turnHost, turnPort: $turnPort)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$WebRtcConfigImpl && + (identical(other.enabled, enabled) || other.enabled == enabled) && + (identical(other.enableVoiceCalls, enableVoiceCalls) || + other.enableVoiceCalls == enableVoiceCalls) && + (identical(other.enableVideoCalls, enableVideoCalls) || + other.enableVideoCalls == enableVideoCalls) && + (identical(other.enableScreenSharing, enableScreenSharing) || + other.enableScreenSharing == enableScreenSharing) && + (identical(other.turnHost, turnHost) || + other.turnHost == turnHost) && + (identical(other.turnPort, turnPort) || + other.turnPort == turnPort)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, enabled, enableVoiceCalls, + enableVideoCalls, enableScreenSharing, turnHost, turnPort); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$WebRtcConfigImplCopyWith<_$WebRtcConfigImpl> get copyWith => + __$$WebRtcConfigImplCopyWithImpl<_$WebRtcConfigImpl>(this, _$identity); + + @override + Map toJson() { + return _$$WebRtcConfigImplToJson( + this, + ); + } +} + +abstract class _WebRtcConfig implements WebRtcConfig { + const factory _WebRtcConfig( + {required final bool enabled, + required final bool enableVoiceCalls, + required final bool enableVideoCalls, + required final bool enableScreenSharing, + required final String turnHost, + required final int turnPort}) = _$WebRtcConfigImpl; + + factory _WebRtcConfig.fromJson(Map json) = + _$WebRtcConfigImpl.fromJson; + + @override + bool get enabled; + @override + bool get enableVoiceCalls; + @override + bool get enableVideoCalls; + @override + bool get enableScreenSharing; + @override + String get turnHost; + @override + int get turnPort; + @override + @JsonKey(ignore: true) + _$$WebRtcConfigImplCopyWith<_$WebRtcConfigImpl> get copyWith => + throw _privateConstructorUsedError; +} + +KlipyConfig _$KlipyConfigFromJson(Map json) { + return _KlipyConfig.fromJson(json); +} + +/// @nodoc +mixin _$KlipyConfig { + bool get enabled => throw _privateConstructorUsedError; + String get appName => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $KlipyConfigCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $KlipyConfigCopyWith<$Res> { + factory $KlipyConfigCopyWith( + KlipyConfig value, $Res Function(KlipyConfig) then) = + _$KlipyConfigCopyWithImpl<$Res, KlipyConfig>; + @useResult + $Res call({bool enabled, String appName}); +} + +/// @nodoc +class _$KlipyConfigCopyWithImpl<$Res, $Val extends KlipyConfig> + implements $KlipyConfigCopyWith<$Res> { + _$KlipyConfigCopyWithImpl(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? enabled = null, + Object? appName = null, + }) { + return _then(_value.copyWith( + enabled: null == enabled + ? _value.enabled + : enabled // ignore: cast_nullable_to_non_nullable + as bool, + appName: null == appName + ? _value.appName + : appName // ignore: cast_nullable_to_non_nullable + as String, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$KlipyConfigImplCopyWith<$Res> + implements $KlipyConfigCopyWith<$Res> { + factory _$$KlipyConfigImplCopyWith( + _$KlipyConfigImpl value, $Res Function(_$KlipyConfigImpl) then) = + __$$KlipyConfigImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({bool enabled, String appName}); +} + +/// @nodoc +class __$$KlipyConfigImplCopyWithImpl<$Res> + extends _$KlipyConfigCopyWithImpl<$Res, _$KlipyConfigImpl> + implements _$$KlipyConfigImplCopyWith<$Res> { + __$$KlipyConfigImplCopyWithImpl( + _$KlipyConfigImpl _value, $Res Function(_$KlipyConfigImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? enabled = null, + Object? appName = null, + }) { + return _then(_$KlipyConfigImpl( + enabled: null == enabled + ? _value.enabled + : enabled // ignore: cast_nullable_to_non_nullable + as bool, + appName: null == appName + ? _value.appName + : appName // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$KlipyConfigImpl implements _KlipyConfig { + const _$KlipyConfigImpl({required this.enabled, required this.appName}); + + factory _$KlipyConfigImpl.fromJson(Map json) => + _$$KlipyConfigImplFromJson(json); + + @override + final bool enabled; + @override + final String appName; + + @override + String toString() { + return 'KlipyConfig(enabled: $enabled, appName: $appName)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$KlipyConfigImpl && + (identical(other.enabled, enabled) || other.enabled == enabled) && + (identical(other.appName, appName) || other.appName == appName)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, enabled, appName); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$KlipyConfigImplCopyWith<_$KlipyConfigImpl> get copyWith => + __$$KlipyConfigImplCopyWithImpl<_$KlipyConfigImpl>(this, _$identity); + + @override + Map toJson() { + return _$$KlipyConfigImplToJson( + this, + ); + } +} + +abstract class _KlipyConfig implements KlipyConfig { + const factory _KlipyConfig( + {required final bool enabled, + required final String appName}) = _$KlipyConfigImpl; + + factory _KlipyConfig.fromJson(Map json) = + _$KlipyConfigImpl.fromJson; + + @override + bool get enabled; + @override + String get appName; + @override + @JsonKey(ignore: true) + _$$KlipyConfigImplCopyWith<_$KlipyConfigImpl> get copyWith => + throw _privateConstructorUsedError; +} + +ImportConfig _$ImportConfigFromJson(Map json) { + return _ImportConfig.fromJson(json); +} + +/// @nodoc +mixin _$ImportConfig { + bool get enabled => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $ImportConfigCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ImportConfigCopyWith<$Res> { + factory $ImportConfigCopyWith( + ImportConfig value, $Res Function(ImportConfig) then) = + _$ImportConfigCopyWithImpl<$Res, ImportConfig>; + @useResult + $Res call({bool enabled}); +} + +/// @nodoc +class _$ImportConfigCopyWithImpl<$Res, $Val extends ImportConfig> + implements $ImportConfigCopyWith<$Res> { + _$ImportConfigCopyWithImpl(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? enabled = null, + }) { + return _then(_value.copyWith( + enabled: null == enabled + ? _value.enabled + : enabled // ignore: cast_nullable_to_non_nullable + as bool, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$ImportConfigImplCopyWith<$Res> + implements $ImportConfigCopyWith<$Res> { + factory _$$ImportConfigImplCopyWith( + _$ImportConfigImpl value, $Res Function(_$ImportConfigImpl) then) = + __$$ImportConfigImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({bool enabled}); +} + +/// @nodoc +class __$$ImportConfigImplCopyWithImpl<$Res> + extends _$ImportConfigCopyWithImpl<$Res, _$ImportConfigImpl> + implements _$$ImportConfigImplCopyWith<$Res> { + __$$ImportConfigImplCopyWithImpl( + _$ImportConfigImpl _value, $Res Function(_$ImportConfigImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? enabled = null, + }) { + return _then(_$ImportConfigImpl( + enabled: null == enabled + ? _value.enabled + : enabled // ignore: cast_nullable_to_non_nullable + as bool, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$ImportConfigImpl implements _ImportConfig { + const _$ImportConfigImpl({required this.enabled}); + + factory _$ImportConfigImpl.fromJson(Map json) => + _$$ImportConfigImplFromJson(json); + + @override + final bool enabled; + + @override + String toString() { + return 'ImportConfig(enabled: $enabled)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ImportConfigImpl && + (identical(other.enabled, enabled) || other.enabled == enabled)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, enabled); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$ImportConfigImplCopyWith<_$ImportConfigImpl> get copyWith => + __$$ImportConfigImplCopyWithImpl<_$ImportConfigImpl>(this, _$identity); + + @override + Map toJson() { + return _$$ImportConfigImplToJson( + this, + ); + } +} + +abstract class _ImportConfig implements ImportConfig { + const factory _ImportConfig({required final bool enabled}) = + _$ImportConfigImpl; + + factory _ImportConfig.fromJson(Map json) = + _$ImportConfigImpl.fromJson; + + @override + bool get enabled; + @override + @JsonKey(ignore: true) + _$$ImportConfigImplCopyWith<_$ImportConfigImpl> get copyWith => + throw _privateConstructorUsedError; +} + +FederationConfig _$FederationConfigFromJson(Map json) { + return _FederationConfig.fromJson(json); +} + +/// @nodoc +mixin _$FederationConfig { + bool get enabled => throw _privateConstructorUsedError; + String get serverDescription => throw _privateConstructorUsedError; + List get allowedDomains => + throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $FederationConfigCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $FederationConfigCopyWith<$Res> { + factory $FederationConfigCopyWith( + FederationConfig value, $Res Function(FederationConfig) then) = + _$FederationConfigCopyWithImpl<$Res, FederationConfig>; + @useResult + $Res call( + {bool enabled, + String serverDescription, + List allowedDomains}); +} + +/// @nodoc +class _$FederationConfigCopyWithImpl<$Res, $Val extends FederationConfig> + implements $FederationConfigCopyWith<$Res> { + _$FederationConfigCopyWithImpl(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? enabled = null, + Object? serverDescription = null, + Object? allowedDomains = null, + }) { + return _then(_value.copyWith( + enabled: null == enabled + ? _value.enabled + : enabled // ignore: cast_nullable_to_non_nullable + as bool, + serverDescription: null == serverDescription + ? _value.serverDescription + : serverDescription // ignore: cast_nullable_to_non_nullable + as String, + allowedDomains: null == allowedDomains + ? _value.allowedDomains + : allowedDomains // ignore: cast_nullable_to_non_nullable + as List, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$FederationConfigImplCopyWith<$Res> + implements $FederationConfigCopyWith<$Res> { + factory _$$FederationConfigImplCopyWith(_$FederationConfigImpl value, + $Res Function(_$FederationConfigImpl) then) = + __$$FederationConfigImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {bool enabled, + String serverDescription, + List allowedDomains}); +} + +/// @nodoc +class __$$FederationConfigImplCopyWithImpl<$Res> + extends _$FederationConfigCopyWithImpl<$Res, _$FederationConfigImpl> + implements _$$FederationConfigImplCopyWith<$Res> { + __$$FederationConfigImplCopyWithImpl(_$FederationConfigImpl _value, + $Res Function(_$FederationConfigImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? enabled = null, + Object? serverDescription = null, + Object? allowedDomains = null, + }) { + return _then(_$FederationConfigImpl( + enabled: null == enabled + ? _value.enabled + : enabled // ignore: cast_nullable_to_non_nullable + as bool, + serverDescription: null == serverDescription + ? _value.serverDescription + : serverDescription // ignore: cast_nullable_to_non_nullable + as String, + allowedDomains: null == allowedDomains + ? _value._allowedDomains + : allowedDomains // ignore: cast_nullable_to_non_nullable + as List, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$FederationConfigImpl implements _FederationConfig { + const _$FederationConfigImpl( + {required this.enabled, + required this.serverDescription, + required final List allowedDomains}) + : _allowedDomains = allowedDomains; + + factory _$FederationConfigImpl.fromJson(Map json) => + _$$FederationConfigImplFromJson(json); + + @override + final bool enabled; + @override + final String serverDescription; + final List _allowedDomains; + @override + List get allowedDomains { + if (_allowedDomains is EqualUnmodifiableListView) return _allowedDomains; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_allowedDomains); + } + + @override + String toString() { + return 'FederationConfig(enabled: $enabled, serverDescription: $serverDescription, allowedDomains: $allowedDomains)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$FederationConfigImpl && + (identical(other.enabled, enabled) || other.enabled == enabled) && + (identical(other.serverDescription, serverDescription) || + other.serverDescription == serverDescription) && + const DeepCollectionEquality() + .equals(other._allowedDomains, _allowedDomains)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, enabled, serverDescription, + const DeepCollectionEquality().hash(_allowedDomains)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$FederationConfigImplCopyWith<_$FederationConfigImpl> get copyWith => + __$$FederationConfigImplCopyWithImpl<_$FederationConfigImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$FederationConfigImplToJson( + this, + ); + } +} + +abstract class _FederationConfig implements FederationConfig { + const factory _FederationConfig( + {required final bool enabled, + required final String serverDescription, + required final List allowedDomains}) = + _$FederationConfigImpl; + + factory _FederationConfig.fromJson(Map json) = + _$FederationConfigImpl.fromJson; + + @override + bool get enabled; + @override + String get serverDescription; + @override + List get allowedDomains; + @override + @JsonKey(ignore: true) + _$$FederationConfigImplCopyWith<_$FederationConfigImpl> get copyWith => + throw _privateConstructorUsedError; +} + +FederationDomainConfig _$FederationDomainConfigFromJson( + Map json) { + return _FederationDomainConfig.fromJson(json); +} + +/// @nodoc +mixin _$FederationDomainConfig { + String get domain => throw _privateConstructorUsedError; + bool get enabled => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $FederationDomainConfigCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $FederationDomainConfigCopyWith<$Res> { + factory $FederationDomainConfigCopyWith(FederationDomainConfig value, + $Res Function(FederationDomainConfig) then) = + _$FederationDomainConfigCopyWithImpl<$Res, FederationDomainConfig>; + @useResult + $Res call({String domain, bool enabled}); +} + +/// @nodoc +class _$FederationDomainConfigCopyWithImpl<$Res, + $Val extends FederationDomainConfig> + implements $FederationDomainConfigCopyWith<$Res> { + _$FederationDomainConfigCopyWithImpl(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? domain = null, + Object? enabled = null, + }) { + return _then(_value.copyWith( + domain: null == domain + ? _value.domain + : domain // ignore: cast_nullable_to_non_nullable + as String, + enabled: null == enabled + ? _value.enabled + : enabled // ignore: cast_nullable_to_non_nullable + as bool, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$FederationDomainConfigImplCopyWith<$Res> + implements $FederationDomainConfigCopyWith<$Res> { + factory _$$FederationDomainConfigImplCopyWith( + _$FederationDomainConfigImpl value, + $Res Function(_$FederationDomainConfigImpl) then) = + __$$FederationDomainConfigImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({String domain, bool enabled}); +} + +/// @nodoc +class __$$FederationDomainConfigImplCopyWithImpl<$Res> + extends _$FederationDomainConfigCopyWithImpl<$Res, + _$FederationDomainConfigImpl> + implements _$$FederationDomainConfigImplCopyWith<$Res> { + __$$FederationDomainConfigImplCopyWithImpl( + _$FederationDomainConfigImpl _value, + $Res Function(_$FederationDomainConfigImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? domain = null, + Object? enabled = null, + }) { + return _then(_$FederationDomainConfigImpl( + domain: null == domain + ? _value.domain + : domain // ignore: cast_nullable_to_non_nullable + as String, + enabled: null == enabled + ? _value.enabled + : enabled // ignore: cast_nullable_to_non_nullable + as bool, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$FederationDomainConfigImpl implements _FederationDomainConfig { + const _$FederationDomainConfigImpl( + {required this.domain, required this.enabled}); + + factory _$FederationDomainConfigImpl.fromJson(Map json) => + _$$FederationDomainConfigImplFromJson(json); + + @override + final String domain; + @override + final bool enabled; + + @override + String toString() { + return 'FederationDomainConfig(domain: $domain, enabled: $enabled)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$FederationDomainConfigImpl && + (identical(other.domain, domain) || other.domain == domain) && + (identical(other.enabled, enabled) || other.enabled == enabled)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, domain, enabled); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$FederationDomainConfigImplCopyWith<_$FederationDomainConfigImpl> + get copyWith => __$$FederationDomainConfigImplCopyWithImpl< + _$FederationDomainConfigImpl>(this, _$identity); + + @override + Map toJson() { + return _$$FederationDomainConfigImplToJson( + this, + ); + } +} + +abstract class _FederationDomainConfig implements FederationDomainConfig { + const factory _FederationDomainConfig( + {required final String domain, + required final bool enabled}) = _$FederationDomainConfigImpl; + + factory _FederationDomainConfig.fromJson(Map json) = + _$FederationDomainConfigImpl.fromJson; + + @override + String get domain; + @override + bool get enabled; + @override + @JsonKey(ignore: true) + _$$FederationDomainConfigImplCopyWith<_$FederationDomainConfigImpl> + get copyWith => throw _privateConstructorUsedError; +} diff --git a/client-mobile/lib/features/settings/domain/entities/server_config.g.dart b/client-mobile/lib/features/settings/domain/entities/server_config.g.dart new file mode 100644 index 0000000..aace8df --- /dev/null +++ b/client-mobile/lib/features/settings/domain/entities/server_config.g.dart @@ -0,0 +1,204 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'server_config.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$ServerConfigImpl _$$ServerConfigImplFromJson(Map json) => + _$ServerConfigImpl( + system: SystemConfig.fromJson(json['system'] as Map), + stories: StoriesConfig.fromJson(json['stories'] as Map), + chats: ChatsModuleConfig.fromJson(json['chats'] as Map), + messages: + MessagesConfig.fromJson(json['messages'] as Map), + webRtc: WebRtcConfig.fromJson(json['webRtc'] as Map), + klipy: KlipyConfig.fromJson(json['klipy'] as Map), + import: ImportConfig.fromJson(json['import'] as Map), + federation: + FederationConfig.fromJson(json['federation'] as Map), + ); + +Map _$$ServerConfigImplToJson(_$ServerConfigImpl instance) => + { + 'system': instance.system, + 'stories': instance.stories, + 'chats': instance.chats, + 'messages': instance.messages, + 'webRtc': instance.webRtc, + 'klipy': instance.klipy, + 'import': instance.import, + 'federation': instance.federation, + }; + +_$SystemConfigImpl _$$SystemConfigImplFromJson(Map json) => + _$SystemConfigImpl( + domainUrl: json['domainUrl'] as String, + enableRegistration: json['enableRegistration'] as bool, + ); + +Map _$$SystemConfigImplToJson(_$SystemConfigImpl instance) => + { + 'domainUrl': instance.domainUrl, + 'enableRegistration': instance.enableRegistration, + }; + +_$StoriesConfigImpl _$$StoriesConfigImplFromJson(Map json) => + _$StoriesConfigImpl( + enabled: json['enabled'] as bool, + maxStoriesPerPeriod: (json['maxStoriesPerPeriod'] as num).toInt(), + storyLifetimeHours: (json['storyLifetimeHours'] as num).toInt(), + textStoriesEnabled: json['textStoriesEnabled'] as bool, + textStoryDurationSeconds: + (json['textStoryDurationSeconds'] as num).toInt(), + mediaStoryMaxDurationSeconds: + (json['mediaStoryMaxDurationSeconds'] as num).toInt(), + maxMediaSizeBytes: (json['maxMediaSizeBytes'] as num).toInt(), + ); + +Map _$$StoriesConfigImplToJson(_$StoriesConfigImpl instance) => + { + 'enabled': instance.enabled, + 'maxStoriesPerPeriod': instance.maxStoriesPerPeriod, + 'storyLifetimeHours': instance.storyLifetimeHours, + 'textStoriesEnabled': instance.textStoriesEnabled, + 'textStoryDurationSeconds': instance.textStoryDurationSeconds, + 'mediaStoryMaxDurationSeconds': instance.mediaStoryMaxDurationSeconds, + 'maxMediaSizeBytes': instance.maxMediaSizeBytes, + }; + +_$ChatsModuleConfigImpl _$$ChatsModuleConfigImplFromJson( + Map json) => + _$ChatsModuleConfigImpl( + supportGroups: json['supportGroups'] as bool, + maxGroupParticipants: (json['maxGroupParticipants'] as num).toInt(), + allowChatToGroupConversion: json['allowChatToGroupConversion'] as bool, + enableFolders: json['enableFolders'] as bool, + ); + +Map _$$ChatsModuleConfigImplToJson( + _$ChatsModuleConfigImpl instance) => + { + 'supportGroups': instance.supportGroups, + 'maxGroupParticipants': instance.maxGroupParticipants, + 'allowChatToGroupConversion': instance.allowChatToGroupConversion, + 'enableFolders': instance.enableFolders, + }; + +_$MessagesConfigImpl _$$MessagesConfigImplFromJson(Map json) => + _$MessagesConfigImpl( + dailyMessageLimitPerUser: + (json['dailyMessageLimitPerUser'] as num).toInt(), + chatMessageLimit: (json['chatMessageLimit'] as num).toInt(), + allowMedia: json['allowMedia'] as bool, + maxMediaSizeBytes: (json['maxMediaSizeBytes'] as num).toInt(), + allowedMediaTypes: (json['allowedMediaTypes'] as List) + .map((e) => e as String) + .toList(), + allowVoiceMessages: json['allowVoiceMessages'] as bool, + allowForwarding: json['allowForwarding'] as bool, + allowReactions: json['allowReactions'] as bool, + allowReplies: json['allowReplies'] as bool, + allowQuoting: json['allowQuoting'] as bool, + allowMessageDeletion: json['allowMessageDeletion'] as bool, + forbidCopying: json['forbidCopying'] as bool, + allowLinks: json['allowLinks'] as bool, + allowPolls: json['allowPolls'] as bool, + allowPinning: json['allowPinning'] as bool, + ); + +Map _$$MessagesConfigImplToJson( + _$MessagesConfigImpl instance) => + { + 'dailyMessageLimitPerUser': instance.dailyMessageLimitPerUser, + 'chatMessageLimit': instance.chatMessageLimit, + 'allowMedia': instance.allowMedia, + 'maxMediaSizeBytes': instance.maxMediaSizeBytes, + 'allowedMediaTypes': instance.allowedMediaTypes, + 'allowVoiceMessages': instance.allowVoiceMessages, + 'allowForwarding': instance.allowForwarding, + 'allowReactions': instance.allowReactions, + 'allowReplies': instance.allowReplies, + 'allowQuoting': instance.allowQuoting, + 'allowMessageDeletion': instance.allowMessageDeletion, + 'forbidCopying': instance.forbidCopying, + 'allowLinks': instance.allowLinks, + 'allowPolls': instance.allowPolls, + 'allowPinning': instance.allowPinning, + }; + +_$WebRtcConfigImpl _$$WebRtcConfigImplFromJson(Map json) => + _$WebRtcConfigImpl( + enabled: json['enabled'] as bool, + enableVoiceCalls: json['enableVoiceCalls'] as bool, + enableVideoCalls: json['enableVideoCalls'] as bool, + enableScreenSharing: json['enableScreenSharing'] as bool, + turnHost: json['turnHost'] as String, + turnPort: (json['turnPort'] as num).toInt(), + ); + +Map _$$WebRtcConfigImplToJson(_$WebRtcConfigImpl instance) => + { + 'enabled': instance.enabled, + 'enableVoiceCalls': instance.enableVoiceCalls, + 'enableVideoCalls': instance.enableVideoCalls, + 'enableScreenSharing': instance.enableScreenSharing, + 'turnHost': instance.turnHost, + 'turnPort': instance.turnPort, + }; + +_$KlipyConfigImpl _$$KlipyConfigImplFromJson(Map json) => + _$KlipyConfigImpl( + enabled: json['enabled'] as bool, + appName: json['appName'] as String, + ); + +Map _$$KlipyConfigImplToJson(_$KlipyConfigImpl instance) => + { + 'enabled': instance.enabled, + 'appName': instance.appName, + }; + +_$ImportConfigImpl _$$ImportConfigImplFromJson(Map json) => + _$ImportConfigImpl( + enabled: json['enabled'] as bool, + ); + +Map _$$ImportConfigImplToJson(_$ImportConfigImpl instance) => + { + 'enabled': instance.enabled, + }; + +_$FederationConfigImpl _$$FederationConfigImplFromJson( + Map json) => + _$FederationConfigImpl( + enabled: json['enabled'] as bool, + serverDescription: json['serverDescription'] as String, + allowedDomains: (json['allowedDomains'] as List) + .map( + (e) => FederationDomainConfig.fromJson(e as Map)) + .toList(), + ); + +Map _$$FederationConfigImplToJson( + _$FederationConfigImpl instance) => + { + 'enabled': instance.enabled, + 'serverDescription': instance.serverDescription, + 'allowedDomains': instance.allowedDomains, + }; + +_$FederationDomainConfigImpl _$$FederationDomainConfigImplFromJson( + Map json) => + _$FederationDomainConfigImpl( + domain: json['domain'] as String, + enabled: json['enabled'] as bool, + ); + +Map _$$FederationDomainConfigImplToJson( + _$FederationDomainConfigImpl instance) => + { + 'domain': instance.domain, + 'enabled': instance.enabled, + }; diff --git a/client-mobile/lib/features/settings/domain/entities/settings.dart b/client-mobile/lib/features/settings/domain/entities/settings.dart new file mode 100644 index 0000000..cfffd8f --- /dev/null +++ b/client-mobile/lib/features/settings/domain/entities/settings.dart @@ -0,0 +1,18 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'settings.freezed.dart'; +// part 'settings.g.dart'; + +@freezed +class AppSettings with _$AppSettings { + const factory AppSettings({ + required bool notificationsEnabled, + required bool darkModeEnabled, + required String language, + bool? soundEnabled, + bool? vibrationEnabled, + String? themeColor, + }) = _AppSettings; + + // factory AppSettings.fromJson(Map json) => _$AppSettingsFromJson(json); +} diff --git a/client-mobile/lib/features/settings/domain/entities/settings.freezed.dart b/client-mobile/lib/features/settings/domain/entities/settings.freezed.dart new file mode 100644 index 0000000..5fa9944 --- /dev/null +++ b/client-mobile/lib/features/settings/domain/entities/settings.freezed.dart @@ -0,0 +1,243 @@ +// 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 'settings.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#adding-getters-and-methods-to-our-models'); + +/// @nodoc +mixin _$AppSettings { + bool get notificationsEnabled => throw _privateConstructorUsedError; + bool get darkModeEnabled => throw _privateConstructorUsedError; + String get language => throw _privateConstructorUsedError; + bool? get soundEnabled => throw _privateConstructorUsedError; + bool? get vibrationEnabled => throw _privateConstructorUsedError; + String? get themeColor => throw _privateConstructorUsedError; + + @JsonKey(ignore: true) + $AppSettingsCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $AppSettingsCopyWith<$Res> { + factory $AppSettingsCopyWith( + AppSettings value, $Res Function(AppSettings) then) = + _$AppSettingsCopyWithImpl<$Res, AppSettings>; + @useResult + $Res call( + {bool notificationsEnabled, + bool darkModeEnabled, + String language, + bool? soundEnabled, + bool? vibrationEnabled, + String? themeColor}); +} + +/// @nodoc +class _$AppSettingsCopyWithImpl<$Res, $Val extends AppSettings> + implements $AppSettingsCopyWith<$Res> { + _$AppSettingsCopyWithImpl(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? notificationsEnabled = null, + Object? darkModeEnabled = null, + Object? language = null, + Object? soundEnabled = freezed, + Object? vibrationEnabled = freezed, + Object? themeColor = freezed, + }) { + return _then(_value.copyWith( + notificationsEnabled: null == notificationsEnabled + ? _value.notificationsEnabled + : notificationsEnabled // ignore: cast_nullable_to_non_nullable + as bool, + darkModeEnabled: null == darkModeEnabled + ? _value.darkModeEnabled + : darkModeEnabled // ignore: cast_nullable_to_non_nullable + as bool, + language: null == language + ? _value.language + : language // ignore: cast_nullable_to_non_nullable + as String, + soundEnabled: freezed == soundEnabled + ? _value.soundEnabled + : soundEnabled // ignore: cast_nullable_to_non_nullable + as bool?, + vibrationEnabled: freezed == vibrationEnabled + ? _value.vibrationEnabled + : vibrationEnabled // ignore: cast_nullable_to_non_nullable + as bool?, + themeColor: freezed == themeColor + ? _value.themeColor + : themeColor // ignore: cast_nullable_to_non_nullable + as String?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$AppSettingsImplCopyWith<$Res> + implements $AppSettingsCopyWith<$Res> { + factory _$$AppSettingsImplCopyWith( + _$AppSettingsImpl value, $Res Function(_$AppSettingsImpl) then) = + __$$AppSettingsImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {bool notificationsEnabled, + bool darkModeEnabled, + String language, + bool? soundEnabled, + bool? vibrationEnabled, + String? themeColor}); +} + +/// @nodoc +class __$$AppSettingsImplCopyWithImpl<$Res> + extends _$AppSettingsCopyWithImpl<$Res, _$AppSettingsImpl> + implements _$$AppSettingsImplCopyWith<$Res> { + __$$AppSettingsImplCopyWithImpl( + _$AppSettingsImpl _value, $Res Function(_$AppSettingsImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? notificationsEnabled = null, + Object? darkModeEnabled = null, + Object? language = null, + Object? soundEnabled = freezed, + Object? vibrationEnabled = freezed, + Object? themeColor = freezed, + }) { + return _then(_$AppSettingsImpl( + notificationsEnabled: null == notificationsEnabled + ? _value.notificationsEnabled + : notificationsEnabled // ignore: cast_nullable_to_non_nullable + as bool, + darkModeEnabled: null == darkModeEnabled + ? _value.darkModeEnabled + : darkModeEnabled // ignore: cast_nullable_to_non_nullable + as bool, + language: null == language + ? _value.language + : language // ignore: cast_nullable_to_non_nullable + as String, + soundEnabled: freezed == soundEnabled + ? _value.soundEnabled + : soundEnabled // ignore: cast_nullable_to_non_nullable + as bool?, + vibrationEnabled: freezed == vibrationEnabled + ? _value.vibrationEnabled + : vibrationEnabled // ignore: cast_nullable_to_non_nullable + as bool?, + themeColor: freezed == themeColor + ? _value.themeColor + : themeColor // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc + +class _$AppSettingsImpl implements _AppSettings { + const _$AppSettingsImpl( + {required this.notificationsEnabled, + required this.darkModeEnabled, + required this.language, + this.soundEnabled, + this.vibrationEnabled, + this.themeColor}); + + @override + final bool notificationsEnabled; + @override + final bool darkModeEnabled; + @override + final String language; + @override + final bool? soundEnabled; + @override + final bool? vibrationEnabled; + @override + final String? themeColor; + + @override + String toString() { + return 'AppSettings(notificationsEnabled: $notificationsEnabled, darkModeEnabled: $darkModeEnabled, language: $language, soundEnabled: $soundEnabled, vibrationEnabled: $vibrationEnabled, themeColor: $themeColor)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$AppSettingsImpl && + (identical(other.notificationsEnabled, notificationsEnabled) || + other.notificationsEnabled == notificationsEnabled) && + (identical(other.darkModeEnabled, darkModeEnabled) || + other.darkModeEnabled == darkModeEnabled) && + (identical(other.language, language) || + other.language == language) && + (identical(other.soundEnabled, soundEnabled) || + other.soundEnabled == soundEnabled) && + (identical(other.vibrationEnabled, vibrationEnabled) || + other.vibrationEnabled == vibrationEnabled) && + (identical(other.themeColor, themeColor) || + other.themeColor == themeColor)); + } + + @override + int get hashCode => Object.hash(runtimeType, notificationsEnabled, + darkModeEnabled, language, soundEnabled, vibrationEnabled, themeColor); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$AppSettingsImplCopyWith<_$AppSettingsImpl> get copyWith => + __$$AppSettingsImplCopyWithImpl<_$AppSettingsImpl>(this, _$identity); +} + +abstract class _AppSettings implements AppSettings { + const factory _AppSettings( + {required final bool notificationsEnabled, + required final bool darkModeEnabled, + required final String language, + final bool? soundEnabled, + final bool? vibrationEnabled, + final String? themeColor}) = _$AppSettingsImpl; + + @override + bool get notificationsEnabled; + @override + bool get darkModeEnabled; + @override + String get language; + @override + bool? get soundEnabled; + @override + bool? get vibrationEnabled; + @override + String? get themeColor; + @override + @JsonKey(ignore: true) + _$$AppSettingsImplCopyWith<_$AppSettingsImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/client-mobile/lib/features/settings/domain/repositories/settings_repository.dart b/client-mobile/lib/features/settings/domain/repositories/settings_repository.dart new file mode 100644 index 0000000..9face88 --- /dev/null +++ b/client-mobile/lib/features/settings/domain/repositories/settings_repository.dart @@ -0,0 +1,16 @@ +import '../../../../core/errors/result.dart'; +import '../entities/server_config.dart'; + +abstract class SettingsRepository { + Future getApiUrl(); + Future> saveApiUrl(String url); + Future getLanguageCode(); + Future> saveLanguageCode(String code); + Future> getServerConfig(); + Future> refreshServerConfig(); + Future> getNotificationsEnabled(); + Future> setNotificationsEnabled(bool enabled); + Future> getDarkModeEnabled(); + Future> setDarkModeEnabled(bool enabled); + Future> clearAllData(); +} diff --git a/client-mobile/lib/features/settings/domain/usecases/get_settings.dart b/client-mobile/lib/features/settings/domain/usecases/get_settings.dart new file mode 100644 index 0000000..8be91c4 --- /dev/null +++ b/client-mobile/lib/features/settings/domain/usecases/get_settings.dart @@ -0,0 +1,13 @@ +import '../../../../core/errors/result.dart'; +import '../repositories/settings_repository.dart'; + +class GetSettingsUseCase { + final SettingsRepository _repository; + + GetSettingsUseCase(this._repository); + + Future> execute() async { + final language = await _repository.getLanguageCode(); + return Result.success(language); + } +} diff --git a/client-mobile/lib/features/settings/presentation/bloc/settings_bloc.dart b/client-mobile/lib/features/settings/presentation/bloc/settings_bloc.dart new file mode 100644 index 0000000..c4e2446 --- /dev/null +++ b/client-mobile/lib/features/settings/presentation/bloc/settings_bloc.dart @@ -0,0 +1,110 @@ +import 'package:flutter_bloc/flutter_bloc.dart'; +import '../../domain/repositories/settings_repository.dart'; +import 'settings_event.dart'; +import 'settings_state.dart'; + +class SettingsBloc extends Bloc { + final SettingsRepository _repository; + + SettingsBloc(this._repository) : super(const SettingsState.initial()) { + on(_onStarted); + on(_onConfigRequested); + on(_onApiUrlChanged); + on(_onApiUrlSaved); + on(_onLanguageChanged); + on(_onRefreshConfig); + } + + Future _onStarted(SettingsStarted event, emit) async { + emit(const SettingsState.loading()); + + final apiUrl = await _repository.getApiUrl() ?? ''; + final languageCode = await _repository.getLanguageCode() ?? 'ru'; + final configResult = await _repository.getServerConfig(); + + configResult.when( + onSuccess: (config) { + emit(SettingsState.loaded( + apiUrl: apiUrl, + serverConfig: config, + languageCode: languageCode, + )); + }, + onFailure: (error) { + emit(SettingsState.loaded( + apiUrl: apiUrl, + serverConfig: null, + languageCode: languageCode, + error: 'Failed to load server config', + )); + }, + ); + } + + Future _onConfigRequested(SettingsConfigRequested event, emit) async { + if (state is! SettingsLoaded) return; + final currentState = state as SettingsLoaded; + + emit(const SettingsState.loading()); + final configResult = await _repository.getServerConfig(); + + configResult.when( + onSuccess: (config) { + emit(SettingsState.loaded( + apiUrl: currentState.apiUrl, + serverConfig: config, + languageCode: currentState.languageCode, + )); + }, + onFailure: (error) { + emit(SettingsState.loaded( + apiUrl: currentState.apiUrl, + serverConfig: null, + languageCode: currentState.languageCode, + error: 'Failed to refresh config', + )); + }, + ); + } + + void _onApiUrlChanged(SettingsApiUrlChanged event, emit) { + if (state is! SettingsLoaded) return; + final currentState = state as SettingsLoaded; + emit(SettingsState.loaded( + apiUrl: event.url, + serverConfig: currentState.serverConfig, + languageCode: currentState.languageCode, + )); + } + + Future _onApiUrlSaved(SettingsApiUrlSaved event, emit) async { + if (state is! SettingsLoaded) return; + final currentState = state as SettingsLoaded; + + await _repository.saveApiUrl(event.url); + + emit(SettingsState.loaded( + apiUrl: event.url, + serverConfig: currentState.serverConfig, + languageCode: currentState.languageCode, + )); + } + + Future _onLanguageChanged(SettingsLanguageChanged event, emit) async { + if (state is! SettingsLoaded) return; + final currentState = state as SettingsLoaded; + + await _repository.saveLanguageCode(event.code); + + emit(SettingsState.loaded( + apiUrl: currentState.apiUrl, + serverConfig: currentState.serverConfig, + languageCode: event.code, + )); + } + + Future _onRefreshConfig(SettingsRefreshConfig event, emit) async { + add(const SettingsConfigRequested()); + await Future.delayed(const Duration(milliseconds: 100)); + } +} diff --git a/client-mobile/lib/features/settings/presentation/bloc/settings_event.dart b/client-mobile/lib/features/settings/presentation/bloc/settings_event.dart new file mode 100644 index 0000000..aaf79b2 --- /dev/null +++ b/client-mobile/lib/features/settings/presentation/bloc/settings_event.dart @@ -0,0 +1,13 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'settings_event.freezed.dart'; + +@freezed +class SettingsEvent with _$SettingsEvent { + const factory SettingsEvent.started() = SettingsStarted; + const factory SettingsEvent.configRequested() = SettingsConfigRequested; + const factory SettingsEvent.apiUrlChanged(String url) = SettingsApiUrlChanged; + const factory SettingsEvent.apiUrlSaved(String url) = SettingsApiUrlSaved; + const factory SettingsEvent.languageChanged(String code) = SettingsLanguageChanged; + const factory SettingsEvent.refreshConfig() = SettingsRefreshConfig; +} diff --git a/client-mobile/lib/features/settings/presentation/bloc/settings_event.freezed.dart b/client-mobile/lib/features/settings/presentation/bloc/settings_event.freezed.dart new file mode 100644 index 0000000..9f6698c --- /dev/null +++ b/client-mobile/lib/features/settings/presentation/bloc/settings_event.freezed.dart @@ -0,0 +1,962 @@ +// 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 'settings_event.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#adding-getters-and-methods-to-our-models'); + +/// @nodoc +mixin _$SettingsEvent { + @optionalTypeArgs + TResult when({ + required TResult Function() started, + required TResult Function() configRequested, + required TResult Function(String url) apiUrlChanged, + required TResult Function(String url) apiUrlSaved, + required TResult Function(String code) languageChanged, + required TResult Function() refreshConfig, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? started, + TResult? Function()? configRequested, + TResult? Function(String url)? apiUrlChanged, + TResult? Function(String url)? apiUrlSaved, + TResult? Function(String code)? languageChanged, + TResult? Function()? refreshConfig, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? started, + TResult Function()? configRequested, + TResult Function(String url)? apiUrlChanged, + TResult Function(String url)? apiUrlSaved, + TResult Function(String code)? languageChanged, + TResult Function()? refreshConfig, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(SettingsStarted value) started, + required TResult Function(SettingsConfigRequested value) configRequested, + required TResult Function(SettingsApiUrlChanged value) apiUrlChanged, + required TResult Function(SettingsApiUrlSaved value) apiUrlSaved, + required TResult Function(SettingsLanguageChanged value) languageChanged, + required TResult Function(SettingsRefreshConfig value) refreshConfig, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(SettingsStarted value)? started, + TResult? Function(SettingsConfigRequested value)? configRequested, + TResult? Function(SettingsApiUrlChanged value)? apiUrlChanged, + TResult? Function(SettingsApiUrlSaved value)? apiUrlSaved, + TResult? Function(SettingsLanguageChanged value)? languageChanged, + TResult? Function(SettingsRefreshConfig value)? refreshConfig, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(SettingsStarted value)? started, + TResult Function(SettingsConfigRequested value)? configRequested, + TResult Function(SettingsApiUrlChanged value)? apiUrlChanged, + TResult Function(SettingsApiUrlSaved value)? apiUrlSaved, + TResult Function(SettingsLanguageChanged value)? languageChanged, + TResult Function(SettingsRefreshConfig value)? refreshConfig, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $SettingsEventCopyWith<$Res> { + factory $SettingsEventCopyWith( + SettingsEvent value, $Res Function(SettingsEvent) then) = + _$SettingsEventCopyWithImpl<$Res, SettingsEvent>; +} + +/// @nodoc +class _$SettingsEventCopyWithImpl<$Res, $Val extends SettingsEvent> + implements $SettingsEventCopyWith<$Res> { + _$SettingsEventCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; +} + +/// @nodoc +abstract class _$$SettingsStartedImplCopyWith<$Res> { + factory _$$SettingsStartedImplCopyWith(_$SettingsStartedImpl value, + $Res Function(_$SettingsStartedImpl) then) = + __$$SettingsStartedImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$SettingsStartedImplCopyWithImpl<$Res> + extends _$SettingsEventCopyWithImpl<$Res, _$SettingsStartedImpl> + implements _$$SettingsStartedImplCopyWith<$Res> { + __$$SettingsStartedImplCopyWithImpl( + _$SettingsStartedImpl _value, $Res Function(_$SettingsStartedImpl) _then) + : super(_value, _then); +} + +/// @nodoc + +class _$SettingsStartedImpl implements SettingsStarted { + const _$SettingsStartedImpl(); + + @override + String toString() { + return 'SettingsEvent.started()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$SettingsStartedImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() started, + required TResult Function() configRequested, + required TResult Function(String url) apiUrlChanged, + required TResult Function(String url) apiUrlSaved, + required TResult Function(String code) languageChanged, + required TResult Function() refreshConfig, + }) { + return started(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? started, + TResult? Function()? configRequested, + TResult? Function(String url)? apiUrlChanged, + TResult? Function(String url)? apiUrlSaved, + TResult? Function(String code)? languageChanged, + TResult? Function()? refreshConfig, + }) { + return started?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? started, + TResult Function()? configRequested, + TResult Function(String url)? apiUrlChanged, + TResult Function(String url)? apiUrlSaved, + TResult Function(String code)? languageChanged, + TResult Function()? refreshConfig, + required TResult orElse(), + }) { + if (started != null) { + return started(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(SettingsStarted value) started, + required TResult Function(SettingsConfigRequested value) configRequested, + required TResult Function(SettingsApiUrlChanged value) apiUrlChanged, + required TResult Function(SettingsApiUrlSaved value) apiUrlSaved, + required TResult Function(SettingsLanguageChanged value) languageChanged, + required TResult Function(SettingsRefreshConfig value) refreshConfig, + }) { + return started(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(SettingsStarted value)? started, + TResult? Function(SettingsConfigRequested value)? configRequested, + TResult? Function(SettingsApiUrlChanged value)? apiUrlChanged, + TResult? Function(SettingsApiUrlSaved value)? apiUrlSaved, + TResult? Function(SettingsLanguageChanged value)? languageChanged, + TResult? Function(SettingsRefreshConfig value)? refreshConfig, + }) { + return started?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(SettingsStarted value)? started, + TResult Function(SettingsConfigRequested value)? configRequested, + TResult Function(SettingsApiUrlChanged value)? apiUrlChanged, + TResult Function(SettingsApiUrlSaved value)? apiUrlSaved, + TResult Function(SettingsLanguageChanged value)? languageChanged, + TResult Function(SettingsRefreshConfig value)? refreshConfig, + required TResult orElse(), + }) { + if (started != null) { + return started(this); + } + return orElse(); + } +} + +abstract class SettingsStarted implements SettingsEvent { + const factory SettingsStarted() = _$SettingsStartedImpl; +} + +/// @nodoc +abstract class _$$SettingsConfigRequestedImplCopyWith<$Res> { + factory _$$SettingsConfigRequestedImplCopyWith( + _$SettingsConfigRequestedImpl value, + $Res Function(_$SettingsConfigRequestedImpl) then) = + __$$SettingsConfigRequestedImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$SettingsConfigRequestedImplCopyWithImpl<$Res> + extends _$SettingsEventCopyWithImpl<$Res, _$SettingsConfigRequestedImpl> + implements _$$SettingsConfigRequestedImplCopyWith<$Res> { + __$$SettingsConfigRequestedImplCopyWithImpl( + _$SettingsConfigRequestedImpl _value, + $Res Function(_$SettingsConfigRequestedImpl) _then) + : super(_value, _then); +} + +/// @nodoc + +class _$SettingsConfigRequestedImpl implements SettingsConfigRequested { + const _$SettingsConfigRequestedImpl(); + + @override + String toString() { + return 'SettingsEvent.configRequested()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$SettingsConfigRequestedImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() started, + required TResult Function() configRequested, + required TResult Function(String url) apiUrlChanged, + required TResult Function(String url) apiUrlSaved, + required TResult Function(String code) languageChanged, + required TResult Function() refreshConfig, + }) { + return configRequested(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? started, + TResult? Function()? configRequested, + TResult? Function(String url)? apiUrlChanged, + TResult? Function(String url)? apiUrlSaved, + TResult? Function(String code)? languageChanged, + TResult? Function()? refreshConfig, + }) { + return configRequested?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? started, + TResult Function()? configRequested, + TResult Function(String url)? apiUrlChanged, + TResult Function(String url)? apiUrlSaved, + TResult Function(String code)? languageChanged, + TResult Function()? refreshConfig, + required TResult orElse(), + }) { + if (configRequested != null) { + return configRequested(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(SettingsStarted value) started, + required TResult Function(SettingsConfigRequested value) configRequested, + required TResult Function(SettingsApiUrlChanged value) apiUrlChanged, + required TResult Function(SettingsApiUrlSaved value) apiUrlSaved, + required TResult Function(SettingsLanguageChanged value) languageChanged, + required TResult Function(SettingsRefreshConfig value) refreshConfig, + }) { + return configRequested(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(SettingsStarted value)? started, + TResult? Function(SettingsConfigRequested value)? configRequested, + TResult? Function(SettingsApiUrlChanged value)? apiUrlChanged, + TResult? Function(SettingsApiUrlSaved value)? apiUrlSaved, + TResult? Function(SettingsLanguageChanged value)? languageChanged, + TResult? Function(SettingsRefreshConfig value)? refreshConfig, + }) { + return configRequested?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(SettingsStarted value)? started, + TResult Function(SettingsConfigRequested value)? configRequested, + TResult Function(SettingsApiUrlChanged value)? apiUrlChanged, + TResult Function(SettingsApiUrlSaved value)? apiUrlSaved, + TResult Function(SettingsLanguageChanged value)? languageChanged, + TResult Function(SettingsRefreshConfig value)? refreshConfig, + required TResult orElse(), + }) { + if (configRequested != null) { + return configRequested(this); + } + return orElse(); + } +} + +abstract class SettingsConfigRequested implements SettingsEvent { + const factory SettingsConfigRequested() = _$SettingsConfigRequestedImpl; +} + +/// @nodoc +abstract class _$$SettingsApiUrlChangedImplCopyWith<$Res> { + factory _$$SettingsApiUrlChangedImplCopyWith( + _$SettingsApiUrlChangedImpl value, + $Res Function(_$SettingsApiUrlChangedImpl) then) = + __$$SettingsApiUrlChangedImplCopyWithImpl<$Res>; + @useResult + $Res call({String url}); +} + +/// @nodoc +class __$$SettingsApiUrlChangedImplCopyWithImpl<$Res> + extends _$SettingsEventCopyWithImpl<$Res, _$SettingsApiUrlChangedImpl> + implements _$$SettingsApiUrlChangedImplCopyWith<$Res> { + __$$SettingsApiUrlChangedImplCopyWithImpl(_$SettingsApiUrlChangedImpl _value, + $Res Function(_$SettingsApiUrlChangedImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? url = null, + }) { + return _then(_$SettingsApiUrlChangedImpl( + null == url + ? _value.url + : url // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$SettingsApiUrlChangedImpl implements SettingsApiUrlChanged { + const _$SettingsApiUrlChangedImpl(this.url); + + @override + final String url; + + @override + String toString() { + return 'SettingsEvent.apiUrlChanged(url: $url)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$SettingsApiUrlChangedImpl && + (identical(other.url, url) || other.url == url)); + } + + @override + int get hashCode => Object.hash(runtimeType, url); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$SettingsApiUrlChangedImplCopyWith<_$SettingsApiUrlChangedImpl> + get copyWith => __$$SettingsApiUrlChangedImplCopyWithImpl< + _$SettingsApiUrlChangedImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() started, + required TResult Function() configRequested, + required TResult Function(String url) apiUrlChanged, + required TResult Function(String url) apiUrlSaved, + required TResult Function(String code) languageChanged, + required TResult Function() refreshConfig, + }) { + return apiUrlChanged(url); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? started, + TResult? Function()? configRequested, + TResult? Function(String url)? apiUrlChanged, + TResult? Function(String url)? apiUrlSaved, + TResult? Function(String code)? languageChanged, + TResult? Function()? refreshConfig, + }) { + return apiUrlChanged?.call(url); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? started, + TResult Function()? configRequested, + TResult Function(String url)? apiUrlChanged, + TResult Function(String url)? apiUrlSaved, + TResult Function(String code)? languageChanged, + TResult Function()? refreshConfig, + required TResult orElse(), + }) { + if (apiUrlChanged != null) { + return apiUrlChanged(url); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(SettingsStarted value) started, + required TResult Function(SettingsConfigRequested value) configRequested, + required TResult Function(SettingsApiUrlChanged value) apiUrlChanged, + required TResult Function(SettingsApiUrlSaved value) apiUrlSaved, + required TResult Function(SettingsLanguageChanged value) languageChanged, + required TResult Function(SettingsRefreshConfig value) refreshConfig, + }) { + return apiUrlChanged(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(SettingsStarted value)? started, + TResult? Function(SettingsConfigRequested value)? configRequested, + TResult? Function(SettingsApiUrlChanged value)? apiUrlChanged, + TResult? Function(SettingsApiUrlSaved value)? apiUrlSaved, + TResult? Function(SettingsLanguageChanged value)? languageChanged, + TResult? Function(SettingsRefreshConfig value)? refreshConfig, + }) { + return apiUrlChanged?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(SettingsStarted value)? started, + TResult Function(SettingsConfigRequested value)? configRequested, + TResult Function(SettingsApiUrlChanged value)? apiUrlChanged, + TResult Function(SettingsApiUrlSaved value)? apiUrlSaved, + TResult Function(SettingsLanguageChanged value)? languageChanged, + TResult Function(SettingsRefreshConfig value)? refreshConfig, + required TResult orElse(), + }) { + if (apiUrlChanged != null) { + return apiUrlChanged(this); + } + return orElse(); + } +} + +abstract class SettingsApiUrlChanged implements SettingsEvent { + const factory SettingsApiUrlChanged(final String url) = + _$SettingsApiUrlChangedImpl; + + String get url; + @JsonKey(ignore: true) + _$$SettingsApiUrlChangedImplCopyWith<_$SettingsApiUrlChangedImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$SettingsApiUrlSavedImplCopyWith<$Res> { + factory _$$SettingsApiUrlSavedImplCopyWith(_$SettingsApiUrlSavedImpl value, + $Res Function(_$SettingsApiUrlSavedImpl) then) = + __$$SettingsApiUrlSavedImplCopyWithImpl<$Res>; + @useResult + $Res call({String url}); +} + +/// @nodoc +class __$$SettingsApiUrlSavedImplCopyWithImpl<$Res> + extends _$SettingsEventCopyWithImpl<$Res, _$SettingsApiUrlSavedImpl> + implements _$$SettingsApiUrlSavedImplCopyWith<$Res> { + __$$SettingsApiUrlSavedImplCopyWithImpl(_$SettingsApiUrlSavedImpl _value, + $Res Function(_$SettingsApiUrlSavedImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? url = null, + }) { + return _then(_$SettingsApiUrlSavedImpl( + null == url + ? _value.url + : url // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$SettingsApiUrlSavedImpl implements SettingsApiUrlSaved { + const _$SettingsApiUrlSavedImpl(this.url); + + @override + final String url; + + @override + String toString() { + return 'SettingsEvent.apiUrlSaved(url: $url)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$SettingsApiUrlSavedImpl && + (identical(other.url, url) || other.url == url)); + } + + @override + int get hashCode => Object.hash(runtimeType, url); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$SettingsApiUrlSavedImplCopyWith<_$SettingsApiUrlSavedImpl> get copyWith => + __$$SettingsApiUrlSavedImplCopyWithImpl<_$SettingsApiUrlSavedImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() started, + required TResult Function() configRequested, + required TResult Function(String url) apiUrlChanged, + required TResult Function(String url) apiUrlSaved, + required TResult Function(String code) languageChanged, + required TResult Function() refreshConfig, + }) { + return apiUrlSaved(url); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? started, + TResult? Function()? configRequested, + TResult? Function(String url)? apiUrlChanged, + TResult? Function(String url)? apiUrlSaved, + TResult? Function(String code)? languageChanged, + TResult? Function()? refreshConfig, + }) { + return apiUrlSaved?.call(url); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? started, + TResult Function()? configRequested, + TResult Function(String url)? apiUrlChanged, + TResult Function(String url)? apiUrlSaved, + TResult Function(String code)? languageChanged, + TResult Function()? refreshConfig, + required TResult orElse(), + }) { + if (apiUrlSaved != null) { + return apiUrlSaved(url); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(SettingsStarted value) started, + required TResult Function(SettingsConfigRequested value) configRequested, + required TResult Function(SettingsApiUrlChanged value) apiUrlChanged, + required TResult Function(SettingsApiUrlSaved value) apiUrlSaved, + required TResult Function(SettingsLanguageChanged value) languageChanged, + required TResult Function(SettingsRefreshConfig value) refreshConfig, + }) { + return apiUrlSaved(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(SettingsStarted value)? started, + TResult? Function(SettingsConfigRequested value)? configRequested, + TResult? Function(SettingsApiUrlChanged value)? apiUrlChanged, + TResult? Function(SettingsApiUrlSaved value)? apiUrlSaved, + TResult? Function(SettingsLanguageChanged value)? languageChanged, + TResult? Function(SettingsRefreshConfig value)? refreshConfig, + }) { + return apiUrlSaved?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(SettingsStarted value)? started, + TResult Function(SettingsConfigRequested value)? configRequested, + TResult Function(SettingsApiUrlChanged value)? apiUrlChanged, + TResult Function(SettingsApiUrlSaved value)? apiUrlSaved, + TResult Function(SettingsLanguageChanged value)? languageChanged, + TResult Function(SettingsRefreshConfig value)? refreshConfig, + required TResult orElse(), + }) { + if (apiUrlSaved != null) { + return apiUrlSaved(this); + } + return orElse(); + } +} + +abstract class SettingsApiUrlSaved implements SettingsEvent { + const factory SettingsApiUrlSaved(final String url) = + _$SettingsApiUrlSavedImpl; + + String get url; + @JsonKey(ignore: true) + _$$SettingsApiUrlSavedImplCopyWith<_$SettingsApiUrlSavedImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$SettingsLanguageChangedImplCopyWith<$Res> { + factory _$$SettingsLanguageChangedImplCopyWith( + _$SettingsLanguageChangedImpl value, + $Res Function(_$SettingsLanguageChangedImpl) then) = + __$$SettingsLanguageChangedImplCopyWithImpl<$Res>; + @useResult + $Res call({String code}); +} + +/// @nodoc +class __$$SettingsLanguageChangedImplCopyWithImpl<$Res> + extends _$SettingsEventCopyWithImpl<$Res, _$SettingsLanguageChangedImpl> + implements _$$SettingsLanguageChangedImplCopyWith<$Res> { + __$$SettingsLanguageChangedImplCopyWithImpl( + _$SettingsLanguageChangedImpl _value, + $Res Function(_$SettingsLanguageChangedImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? code = null, + }) { + return _then(_$SettingsLanguageChangedImpl( + null == code + ? _value.code + : code // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$SettingsLanguageChangedImpl implements SettingsLanguageChanged { + const _$SettingsLanguageChangedImpl(this.code); + + @override + final String code; + + @override + String toString() { + return 'SettingsEvent.languageChanged(code: $code)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$SettingsLanguageChangedImpl && + (identical(other.code, code) || other.code == code)); + } + + @override + int get hashCode => Object.hash(runtimeType, code); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$SettingsLanguageChangedImplCopyWith<_$SettingsLanguageChangedImpl> + get copyWith => __$$SettingsLanguageChangedImplCopyWithImpl< + _$SettingsLanguageChangedImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() started, + required TResult Function() configRequested, + required TResult Function(String url) apiUrlChanged, + required TResult Function(String url) apiUrlSaved, + required TResult Function(String code) languageChanged, + required TResult Function() refreshConfig, + }) { + return languageChanged(code); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? started, + TResult? Function()? configRequested, + TResult? Function(String url)? apiUrlChanged, + TResult? Function(String url)? apiUrlSaved, + TResult? Function(String code)? languageChanged, + TResult? Function()? refreshConfig, + }) { + return languageChanged?.call(code); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? started, + TResult Function()? configRequested, + TResult Function(String url)? apiUrlChanged, + TResult Function(String url)? apiUrlSaved, + TResult Function(String code)? languageChanged, + TResult Function()? refreshConfig, + required TResult orElse(), + }) { + if (languageChanged != null) { + return languageChanged(code); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(SettingsStarted value) started, + required TResult Function(SettingsConfigRequested value) configRequested, + required TResult Function(SettingsApiUrlChanged value) apiUrlChanged, + required TResult Function(SettingsApiUrlSaved value) apiUrlSaved, + required TResult Function(SettingsLanguageChanged value) languageChanged, + required TResult Function(SettingsRefreshConfig value) refreshConfig, + }) { + return languageChanged(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(SettingsStarted value)? started, + TResult? Function(SettingsConfigRequested value)? configRequested, + TResult? Function(SettingsApiUrlChanged value)? apiUrlChanged, + TResult? Function(SettingsApiUrlSaved value)? apiUrlSaved, + TResult? Function(SettingsLanguageChanged value)? languageChanged, + TResult? Function(SettingsRefreshConfig value)? refreshConfig, + }) { + return languageChanged?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(SettingsStarted value)? started, + TResult Function(SettingsConfigRequested value)? configRequested, + TResult Function(SettingsApiUrlChanged value)? apiUrlChanged, + TResult Function(SettingsApiUrlSaved value)? apiUrlSaved, + TResult Function(SettingsLanguageChanged value)? languageChanged, + TResult Function(SettingsRefreshConfig value)? refreshConfig, + required TResult orElse(), + }) { + if (languageChanged != null) { + return languageChanged(this); + } + return orElse(); + } +} + +abstract class SettingsLanguageChanged implements SettingsEvent { + const factory SettingsLanguageChanged(final String code) = + _$SettingsLanguageChangedImpl; + + String get code; + @JsonKey(ignore: true) + _$$SettingsLanguageChangedImplCopyWith<_$SettingsLanguageChangedImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$SettingsRefreshConfigImplCopyWith<$Res> { + factory _$$SettingsRefreshConfigImplCopyWith( + _$SettingsRefreshConfigImpl value, + $Res Function(_$SettingsRefreshConfigImpl) then) = + __$$SettingsRefreshConfigImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$SettingsRefreshConfigImplCopyWithImpl<$Res> + extends _$SettingsEventCopyWithImpl<$Res, _$SettingsRefreshConfigImpl> + implements _$$SettingsRefreshConfigImplCopyWith<$Res> { + __$$SettingsRefreshConfigImplCopyWithImpl(_$SettingsRefreshConfigImpl _value, + $Res Function(_$SettingsRefreshConfigImpl) _then) + : super(_value, _then); +} + +/// @nodoc + +class _$SettingsRefreshConfigImpl implements SettingsRefreshConfig { + const _$SettingsRefreshConfigImpl(); + + @override + String toString() { + return 'SettingsEvent.refreshConfig()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$SettingsRefreshConfigImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() started, + required TResult Function() configRequested, + required TResult Function(String url) apiUrlChanged, + required TResult Function(String url) apiUrlSaved, + required TResult Function(String code) languageChanged, + required TResult Function() refreshConfig, + }) { + return refreshConfig(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? started, + TResult? Function()? configRequested, + TResult? Function(String url)? apiUrlChanged, + TResult? Function(String url)? apiUrlSaved, + TResult? Function(String code)? languageChanged, + TResult? Function()? refreshConfig, + }) { + return refreshConfig?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? started, + TResult Function()? configRequested, + TResult Function(String url)? apiUrlChanged, + TResult Function(String url)? apiUrlSaved, + TResult Function(String code)? languageChanged, + TResult Function()? refreshConfig, + required TResult orElse(), + }) { + if (refreshConfig != null) { + return refreshConfig(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(SettingsStarted value) started, + required TResult Function(SettingsConfigRequested value) configRequested, + required TResult Function(SettingsApiUrlChanged value) apiUrlChanged, + required TResult Function(SettingsApiUrlSaved value) apiUrlSaved, + required TResult Function(SettingsLanguageChanged value) languageChanged, + required TResult Function(SettingsRefreshConfig value) refreshConfig, + }) { + return refreshConfig(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(SettingsStarted value)? started, + TResult? Function(SettingsConfigRequested value)? configRequested, + TResult? Function(SettingsApiUrlChanged value)? apiUrlChanged, + TResult? Function(SettingsApiUrlSaved value)? apiUrlSaved, + TResult? Function(SettingsLanguageChanged value)? languageChanged, + TResult? Function(SettingsRefreshConfig value)? refreshConfig, + }) { + return refreshConfig?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(SettingsStarted value)? started, + TResult Function(SettingsConfigRequested value)? configRequested, + TResult Function(SettingsApiUrlChanged value)? apiUrlChanged, + TResult Function(SettingsApiUrlSaved value)? apiUrlSaved, + TResult Function(SettingsLanguageChanged value)? languageChanged, + TResult Function(SettingsRefreshConfig value)? refreshConfig, + required TResult orElse(), + }) { + if (refreshConfig != null) { + return refreshConfig(this); + } + return orElse(); + } +} + +abstract class SettingsRefreshConfig implements SettingsEvent { + const factory SettingsRefreshConfig() = _$SettingsRefreshConfigImpl; +} diff --git a/client-mobile/lib/features/settings/presentation/bloc/settings_state.dart b/client-mobile/lib/features/settings/presentation/bloc/settings_state.dart new file mode 100644 index 0000000..e213f00 --- /dev/null +++ b/client-mobile/lib/features/settings/presentation/bloc/settings_state.dart @@ -0,0 +1,17 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; +import '../../domain/entities/server_config.dart'; + +part 'settings_state.freezed.dart'; + +@freezed +class SettingsState with _$SettingsState { + const factory SettingsState.initial() = SettingsInitial; + const factory SettingsState.loading() = SettingsLoading; + const factory SettingsState.loaded({ + required String apiUrl, + required ServerConfig? serverConfig, + required String languageCode, + String? error, + }) = SettingsLoaded; + const factory SettingsState.error(String message) = SettingsError; +} diff --git a/client-mobile/lib/features/settings/presentation/bloc/settings_state.freezed.dart b/client-mobile/lib/features/settings/presentation/bloc/settings_state.freezed.dart new file mode 100644 index 0000000..dd19689 --- /dev/null +++ b/client-mobile/lib/features/settings/presentation/bloc/settings_state.freezed.dart @@ -0,0 +1,692 @@ +// 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 'settings_state.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#adding-getters-and-methods-to-our-models'); + +/// @nodoc +mixin _$SettingsState { + @optionalTypeArgs + TResult when({ + required TResult Function() initial, + required TResult Function() loading, + required TResult Function(String apiUrl, ServerConfig? serverConfig, + String languageCode, String? error) + loaded, + required TResult Function(String message) error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? initial, + TResult? Function()? loading, + TResult? Function(String apiUrl, ServerConfig? serverConfig, + String languageCode, String? error)? + loaded, + TResult? Function(String message)? error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? initial, + TResult Function()? loading, + TResult Function(String apiUrl, ServerConfig? serverConfig, + String languageCode, String? error)? + loaded, + TResult Function(String message)? error, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(SettingsInitial value) initial, + required TResult Function(SettingsLoading value) loading, + required TResult Function(SettingsLoaded value) loaded, + required TResult Function(SettingsError value) error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(SettingsInitial value)? initial, + TResult? Function(SettingsLoading value)? loading, + TResult? Function(SettingsLoaded value)? loaded, + TResult? Function(SettingsError value)? error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(SettingsInitial value)? initial, + TResult Function(SettingsLoading value)? loading, + TResult Function(SettingsLoaded value)? loaded, + TResult Function(SettingsError value)? error, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $SettingsStateCopyWith<$Res> { + factory $SettingsStateCopyWith( + SettingsState value, $Res Function(SettingsState) then) = + _$SettingsStateCopyWithImpl<$Res, SettingsState>; +} + +/// @nodoc +class _$SettingsStateCopyWithImpl<$Res, $Val extends SettingsState> + implements $SettingsStateCopyWith<$Res> { + _$SettingsStateCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; +} + +/// @nodoc +abstract class _$$SettingsInitialImplCopyWith<$Res> { + factory _$$SettingsInitialImplCopyWith(_$SettingsInitialImpl value, + $Res Function(_$SettingsInitialImpl) then) = + __$$SettingsInitialImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$SettingsInitialImplCopyWithImpl<$Res> + extends _$SettingsStateCopyWithImpl<$Res, _$SettingsInitialImpl> + implements _$$SettingsInitialImplCopyWith<$Res> { + __$$SettingsInitialImplCopyWithImpl( + _$SettingsInitialImpl _value, $Res Function(_$SettingsInitialImpl) _then) + : super(_value, _then); +} + +/// @nodoc + +class _$SettingsInitialImpl implements SettingsInitial { + const _$SettingsInitialImpl(); + + @override + String toString() { + return 'SettingsState.initial()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$SettingsInitialImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() initial, + required TResult Function() loading, + required TResult Function(String apiUrl, ServerConfig? serverConfig, + String languageCode, String? error) + loaded, + required TResult Function(String message) error, + }) { + return initial(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? initial, + TResult? Function()? loading, + TResult? Function(String apiUrl, ServerConfig? serverConfig, + String languageCode, String? error)? + loaded, + TResult? Function(String message)? error, + }) { + return initial?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? initial, + TResult Function()? loading, + TResult Function(String apiUrl, ServerConfig? serverConfig, + String languageCode, String? error)? + loaded, + TResult Function(String message)? error, + required TResult orElse(), + }) { + if (initial != null) { + return initial(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(SettingsInitial value) initial, + required TResult Function(SettingsLoading value) loading, + required TResult Function(SettingsLoaded value) loaded, + required TResult Function(SettingsError value) error, + }) { + return initial(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(SettingsInitial value)? initial, + TResult? Function(SettingsLoading value)? loading, + TResult? Function(SettingsLoaded value)? loaded, + TResult? Function(SettingsError value)? error, + }) { + return initial?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(SettingsInitial value)? initial, + TResult Function(SettingsLoading value)? loading, + TResult Function(SettingsLoaded value)? loaded, + TResult Function(SettingsError value)? error, + required TResult orElse(), + }) { + if (initial != null) { + return initial(this); + } + return orElse(); + } +} + +abstract class SettingsInitial implements SettingsState { + const factory SettingsInitial() = _$SettingsInitialImpl; +} + +/// @nodoc +abstract class _$$SettingsLoadingImplCopyWith<$Res> { + factory _$$SettingsLoadingImplCopyWith(_$SettingsLoadingImpl value, + $Res Function(_$SettingsLoadingImpl) then) = + __$$SettingsLoadingImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$SettingsLoadingImplCopyWithImpl<$Res> + extends _$SettingsStateCopyWithImpl<$Res, _$SettingsLoadingImpl> + implements _$$SettingsLoadingImplCopyWith<$Res> { + __$$SettingsLoadingImplCopyWithImpl( + _$SettingsLoadingImpl _value, $Res Function(_$SettingsLoadingImpl) _then) + : super(_value, _then); +} + +/// @nodoc + +class _$SettingsLoadingImpl implements SettingsLoading { + const _$SettingsLoadingImpl(); + + @override + String toString() { + return 'SettingsState.loading()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$SettingsLoadingImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() initial, + required TResult Function() loading, + required TResult Function(String apiUrl, ServerConfig? serverConfig, + String languageCode, String? error) + loaded, + required TResult Function(String message) error, + }) { + return loading(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? initial, + TResult? Function()? loading, + TResult? Function(String apiUrl, ServerConfig? serverConfig, + String languageCode, String? error)? + loaded, + TResult? Function(String message)? error, + }) { + return loading?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? initial, + TResult Function()? loading, + TResult Function(String apiUrl, ServerConfig? serverConfig, + String languageCode, String? error)? + loaded, + TResult Function(String message)? error, + required TResult orElse(), + }) { + if (loading != null) { + return loading(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(SettingsInitial value) initial, + required TResult Function(SettingsLoading value) loading, + required TResult Function(SettingsLoaded value) loaded, + required TResult Function(SettingsError value) error, + }) { + return loading(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(SettingsInitial value)? initial, + TResult? Function(SettingsLoading value)? loading, + TResult? Function(SettingsLoaded value)? loaded, + TResult? Function(SettingsError value)? error, + }) { + return loading?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(SettingsInitial value)? initial, + TResult Function(SettingsLoading value)? loading, + TResult Function(SettingsLoaded value)? loaded, + TResult Function(SettingsError value)? error, + required TResult orElse(), + }) { + if (loading != null) { + return loading(this); + } + return orElse(); + } +} + +abstract class SettingsLoading implements SettingsState { + const factory SettingsLoading() = _$SettingsLoadingImpl; +} + +/// @nodoc +abstract class _$$SettingsLoadedImplCopyWith<$Res> { + factory _$$SettingsLoadedImplCopyWith(_$SettingsLoadedImpl value, + $Res Function(_$SettingsLoadedImpl) then) = + __$$SettingsLoadedImplCopyWithImpl<$Res>; + @useResult + $Res call( + {String apiUrl, + ServerConfig? serverConfig, + String languageCode, + String? error}); + + $ServerConfigCopyWith<$Res>? get serverConfig; +} + +/// @nodoc +class __$$SettingsLoadedImplCopyWithImpl<$Res> + extends _$SettingsStateCopyWithImpl<$Res, _$SettingsLoadedImpl> + implements _$$SettingsLoadedImplCopyWith<$Res> { + __$$SettingsLoadedImplCopyWithImpl( + _$SettingsLoadedImpl _value, $Res Function(_$SettingsLoadedImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? apiUrl = null, + Object? serverConfig = freezed, + Object? languageCode = null, + Object? error = freezed, + }) { + return _then(_$SettingsLoadedImpl( + apiUrl: null == apiUrl + ? _value.apiUrl + : apiUrl // ignore: cast_nullable_to_non_nullable + as String, + serverConfig: freezed == serverConfig + ? _value.serverConfig + : serverConfig // ignore: cast_nullable_to_non_nullable + as ServerConfig?, + languageCode: null == languageCode + ? _value.languageCode + : languageCode // ignore: cast_nullable_to_non_nullable + as String, + error: freezed == error + ? _value.error + : error // ignore: cast_nullable_to_non_nullable + as String?, + )); + } + + @override + @pragma('vm:prefer-inline') + $ServerConfigCopyWith<$Res>? get serverConfig { + if (_value.serverConfig == null) { + return null; + } + + return $ServerConfigCopyWith<$Res>(_value.serverConfig!, (value) { + return _then(_value.copyWith(serverConfig: value)); + }); + } +} + +/// @nodoc + +class _$SettingsLoadedImpl implements SettingsLoaded { + const _$SettingsLoadedImpl( + {required this.apiUrl, + required this.serverConfig, + required this.languageCode, + this.error}); + + @override + final String apiUrl; + @override + final ServerConfig? serverConfig; + @override + final String languageCode; + @override + final String? error; + + @override + String toString() { + return 'SettingsState.loaded(apiUrl: $apiUrl, serverConfig: $serverConfig, languageCode: $languageCode, error: $error)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$SettingsLoadedImpl && + (identical(other.apiUrl, apiUrl) || other.apiUrl == apiUrl) && + (identical(other.serverConfig, serverConfig) || + other.serverConfig == serverConfig) && + (identical(other.languageCode, languageCode) || + other.languageCode == languageCode) && + (identical(other.error, error) || other.error == error)); + } + + @override + int get hashCode => + Object.hash(runtimeType, apiUrl, serverConfig, languageCode, error); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$SettingsLoadedImplCopyWith<_$SettingsLoadedImpl> get copyWith => + __$$SettingsLoadedImplCopyWithImpl<_$SettingsLoadedImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() initial, + required TResult Function() loading, + required TResult Function(String apiUrl, ServerConfig? serverConfig, + String languageCode, String? error) + loaded, + required TResult Function(String message) error, + }) { + return loaded(apiUrl, serverConfig, languageCode, this.error); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? initial, + TResult? Function()? loading, + TResult? Function(String apiUrl, ServerConfig? serverConfig, + String languageCode, String? error)? + loaded, + TResult? Function(String message)? error, + }) { + return loaded?.call(apiUrl, serverConfig, languageCode, this.error); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? initial, + TResult Function()? loading, + TResult Function(String apiUrl, ServerConfig? serverConfig, + String languageCode, String? error)? + loaded, + TResult Function(String message)? error, + required TResult orElse(), + }) { + if (loaded != null) { + return loaded(apiUrl, serverConfig, languageCode, this.error); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(SettingsInitial value) initial, + required TResult Function(SettingsLoading value) loading, + required TResult Function(SettingsLoaded value) loaded, + required TResult Function(SettingsError value) error, + }) { + return loaded(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(SettingsInitial value)? initial, + TResult? Function(SettingsLoading value)? loading, + TResult? Function(SettingsLoaded value)? loaded, + TResult? Function(SettingsError value)? error, + }) { + return loaded?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(SettingsInitial value)? initial, + TResult Function(SettingsLoading value)? loading, + TResult Function(SettingsLoaded value)? loaded, + TResult Function(SettingsError value)? error, + required TResult orElse(), + }) { + if (loaded != null) { + return loaded(this); + } + return orElse(); + } +} + +abstract class SettingsLoaded implements SettingsState { + const factory SettingsLoaded( + {required final String apiUrl, + required final ServerConfig? serverConfig, + required final String languageCode, + final String? error}) = _$SettingsLoadedImpl; + + String get apiUrl; + ServerConfig? get serverConfig; + String get languageCode; + String? get error; + @JsonKey(ignore: true) + _$$SettingsLoadedImplCopyWith<_$SettingsLoadedImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$SettingsErrorImplCopyWith<$Res> { + factory _$$SettingsErrorImplCopyWith( + _$SettingsErrorImpl value, $Res Function(_$SettingsErrorImpl) then) = + __$$SettingsErrorImplCopyWithImpl<$Res>; + @useResult + $Res call({String message}); +} + +/// @nodoc +class __$$SettingsErrorImplCopyWithImpl<$Res> + extends _$SettingsStateCopyWithImpl<$Res, _$SettingsErrorImpl> + implements _$$SettingsErrorImplCopyWith<$Res> { + __$$SettingsErrorImplCopyWithImpl( + _$SettingsErrorImpl _value, $Res Function(_$SettingsErrorImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? message = null, + }) { + return _then(_$SettingsErrorImpl( + null == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$SettingsErrorImpl implements SettingsError { + const _$SettingsErrorImpl(this.message); + + @override + final String message; + + @override + String toString() { + return 'SettingsState.error(message: $message)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$SettingsErrorImpl && + (identical(other.message, message) || other.message == message)); + } + + @override + int get hashCode => Object.hash(runtimeType, message); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$SettingsErrorImplCopyWith<_$SettingsErrorImpl> get copyWith => + __$$SettingsErrorImplCopyWithImpl<_$SettingsErrorImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() initial, + required TResult Function() loading, + required TResult Function(String apiUrl, ServerConfig? serverConfig, + String languageCode, String? error) + loaded, + required TResult Function(String message) error, + }) { + return error(message); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? initial, + TResult? Function()? loading, + TResult? Function(String apiUrl, ServerConfig? serverConfig, + String languageCode, String? error)? + loaded, + TResult? Function(String message)? error, + }) { + return error?.call(message); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? initial, + TResult Function()? loading, + TResult Function(String apiUrl, ServerConfig? serverConfig, + String languageCode, String? error)? + loaded, + TResult Function(String message)? error, + required TResult orElse(), + }) { + if (error != null) { + return error(message); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(SettingsInitial value) initial, + required TResult Function(SettingsLoading value) loading, + required TResult Function(SettingsLoaded value) loaded, + required TResult Function(SettingsError value) error, + }) { + return error(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(SettingsInitial value)? initial, + TResult? Function(SettingsLoading value)? loading, + TResult? Function(SettingsLoaded value)? loaded, + TResult? Function(SettingsError value)? error, + }) { + return error?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(SettingsInitial value)? initial, + TResult Function(SettingsLoading value)? loading, + TResult Function(SettingsLoaded value)? loaded, + TResult Function(SettingsError value)? error, + required TResult orElse(), + }) { + if (error != null) { + return error(this); + } + return orElse(); + } +} + +abstract class SettingsError implements SettingsState { + const factory SettingsError(final String message) = _$SettingsErrorImpl; + + String get message; + @JsonKey(ignore: true) + _$$SettingsErrorImplCopyWith<_$SettingsErrorImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/client-mobile/lib/features/settings/presentation/l10n/app_localizations.dart b/client-mobile/lib/features/settings/presentation/l10n/app_localizations.dart new file mode 100644 index 0000000..6c5d639 --- /dev/null +++ b/client-mobile/lib/features/settings/presentation/l10n/app_localizations.dart @@ -0,0 +1,417 @@ +import 'dart:async'; + +import 'package:flutter/foundation.dart'; +import 'package:flutter/widgets.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; +import 'package:intl/intl.dart' as intl; + +import 'app_localizations_en.dart'; +import 'app_localizations_ru.dart'; + +// ignore_for_file: type=lint + +/// Callers can lookup localized strings with an instance of AppLocalizations +/// returned by `AppLocalizations.of(context)`. +/// +/// Applications need to include `AppLocalizations.delegate()` in their app's +/// `localizationDelegates` list, and the locales they support in the app's +/// `supportedLocales` list. For example: +/// +/// ```dart +/// import 'l10n/app_localizations.dart'; +/// +/// return MaterialApp( +/// localizationsDelegates: AppLocalizations.localizationsDelegates, +/// supportedLocales: AppLocalizations.supportedLocales, +/// home: MyApplicationHome(), +/// ); +/// ``` +/// +/// ## Update pubspec.yaml +/// +/// Please make sure to update your pubspec.yaml to include the following +/// packages: +/// +/// ```yaml +/// dependencies: +/// # Internationalization support. +/// flutter_localizations: +/// sdk: flutter +/// intl: any # Use the pinned version from flutter_localizations +/// +/// # Rest of dependencies +/// ``` +/// +/// ## iOS Applications +/// +/// iOS applications define key application metadata, including supported +/// locales, in an Info.plist file that is built into the application bundle. +/// To configure the locales supported by your app, you’ll need to edit this +/// file. +/// +/// First, open your project’s ios/Runner.xcworkspace Xcode workspace file. +/// Then, in the Project Navigator, open the Info.plist file under the Runner +/// project’s Runner folder. +/// +/// Next, select the Information Property List item, select Add Item from the +/// Editor menu, then select Localizations from the pop-up menu. +/// +/// Select and expand the newly-created Localizations item then, for each +/// locale your application supports, add a new item and select the locale +/// you wish to add from the pop-up menu in the Value field. This list should +/// be consistent with the languages listed in the AppLocalizations.supportedLocales +/// property. +abstract class AppLocalizations { + AppLocalizations(String locale) : localeName = intl.Intl.canonicalizedLocale(locale.toString()); + + final String localeName; + + static AppLocalizations? of(BuildContext context) { + return Localizations.of(context, AppLocalizations); + } + + static const LocalizationsDelegate delegate = _AppLocalizationsDelegate(); + + /// A list of this localizations delegate along with the default localizations + /// delegates. + /// + /// Returns a list of localizations delegates containing this delegate along with + /// GlobalMaterialLocalizations.delegate, GlobalCupertinoLocalizations.delegate, + /// and GlobalWidgetsLocalizations.delegate. + /// + /// Additional delegates can be added by appending to this list in + /// MaterialApp. This list does not have to be used at all if a custom list + /// of delegates is preferred or required. + static const List> localizationsDelegates = >[ + delegate, + GlobalMaterialLocalizations.delegate, + GlobalCupertinoLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + ]; + + /// A list of this localizations delegate's supported locales. + static const List supportedLocales = [ + Locale('en'), + Locale('ru') + ]; + + /// No description provided for @appTitle. + /// + /// In en, this message translates to: + /// **'Messenger'** + String get appTitle; + + /// No description provided for @chats. + /// + /// In en, this message translates to: + /// **'Chats'** + String get chats; + + /// No description provided for @contacts. + /// + /// In en, this message translates to: + /// **'Contacts'** + String get contacts; + + /// No description provided for @settings. + /// + /// In en, this message translates to: + /// **'Settings'** + String get settings; + + /// No description provided for @login. + /// + /// In en, this message translates to: + /// **'Login'** + String get login; + + /// No description provided for @email. + /// + /// In en, this message translates to: + /// **'Email'** + String get email; + + /// No description provided for @password. + /// + /// In en, this message translates to: + /// **'Password'** + String get password; + + /// No description provided for @name. + /// + /// In en, this message translates to: + /// **'Name'** + String get name; + + /// No description provided for @loginButton. + /// + /// In en, this message translates to: + /// **'Sign In'** + String get loginButton; + + /// No description provided for @register. + /// + /// In en, this message translates to: + /// **'Register'** + String get register; + + /// No description provided for @noAccount. + /// + /// In en, this message translates to: + /// **'No account? Sign up'** + String get noAccount; + + /// No description provided for @logout. + /// + /// In en, this message translates to: + /// **'Sign Out'** + String get logout; + + /// No description provided for @serverSettings. + /// + /// In en, this message translates to: + /// **'Server Settings'** + String get serverSettings; + + /// No description provided for @apiUrl. + /// + /// In en, this message translates to: + /// **'API URL'** + String get apiUrl; + + /// No description provided for @apiUrlHint. + /// + /// In en, this message translates to: + /// **'https://api.example.com'** + String get apiUrlHint; + + /// No description provided for @save. + /// + /// In en, this message translates to: + /// **'Save'** + String get save; + + /// No description provided for @serverConfig. + /// + /// In en, this message translates to: + /// **'Server Configuration'** + String get serverConfig; + + /// No description provided for @system. + /// + /// In en, this message translates to: + /// **'System'** + String get system; + + /// No description provided for @stories. + /// + /// In en, this message translates to: + /// **'Stories'** + String get stories; + + /// No description provided for @chatsModule. + /// + /// In en, this message translates to: + /// **'Chats'** + String get chatsModule; + + /// No description provided for @messages. + /// + /// In en, this message translates to: + /// **'Messages'** + String get messages; + + /// No description provided for @calls. + /// + /// In en, this message translates to: + /// **'Calls'** + String get calls; + + /// No description provided for @klipy. + /// + /// In en, this message translates to: + /// **'Klipy'** + String get klipy; + + /// No description provided for @import. + /// + /// In en, this message translates to: + /// **'Import'** + String get import; + + /// No description provided for @federation. + /// + /// In en, this message translates to: + /// **'Federation'** + String get federation; + + /// No description provided for @domainUrl. + /// + /// In en, this message translates to: + /// **'Domain'** + String get domainUrl; + + /// No description provided for @enableRegistration. + /// + /// In en, this message translates to: + /// **'Registration Enabled'** + String get enableRegistration; + + /// No description provided for @enabled. + /// + /// In en, this message translates to: + /// **'Enabled'** + String get enabled; + + /// No description provided for @disabled. + /// + /// In en, this message translates to: + /// **'Disabled'** + String get disabled; + + /// No description provided for @language. + /// + /// In en, this message translates to: + /// **'Language'** + String get language; + + /// No description provided for @russian. + /// + /// In en, this message translates to: + /// **'Русский'** + String get russian; + + /// No description provided for @english. + /// + /// In en, this message translates to: + /// **'English'** + String get english; + + /// No description provided for @notifications. + /// + /// In en, this message translates to: + /// **'Notifications'** + String get notifications; + + /// No description provided for @privacy. + /// + /// In en, this message translates to: + /// **'Privacy'** + String get privacy; + + /// No description provided for @soundsAndVibration. + /// + /// In en, this message translates to: + /// **'Sounds & Vibration'** + String get soundsAndVibration; + + /// No description provided for @dataAndStorage. + /// + /// In en, this message translates to: + /// **'Data & Storage'** + String get dataAndStorage; + + /// No description provided for @aboutApp. + /// + /// In en, this message translates to: + /// **'About App'** + String get aboutApp; + + /// No description provided for @help. + /// + /// In en, this message translates to: + /// **'Help'** + String get help; + + /// No description provided for @version. + /// + /// In en, this message translates to: + /// **'Version'** + String get version; + + /// No description provided for @loading. + /// + /// In en, this message translates to: + /// **'Loading...'** + String get loading; + + /// No description provided for @error. + /// + /// In en, this message translates to: + /// **'Error'** + String get error; + + /// No description provided for @retry. + /// + /// In en, this message translates to: + /// **'Retry'** + String get retry; + + /// No description provided for @noChats. + /// + /// In en, this message translates to: + /// **'No chats yet'** + String get noChats; + + /// No description provided for @inDevelopment. + /// + /// In en, this message translates to: + /// **'In development'** + String get inDevelopment; + + /// No description provided for @user. + /// + /// In en, this message translates to: + /// **'User'** + String get user; + + /// No description provided for @edit. + /// + /// In en, this message translates to: + /// **'Edit'** + String get edit; + + /// No description provided for @serverConnectionError. + /// + /// In en, this message translates to: + /// **'Server connection error'** + String get serverConnectionError; + + /// No description provided for @settingsSaved. + /// + /// In en, this message translates to: + /// **'Settings saved'** + String get settingsSaved; +} + +class _AppLocalizationsDelegate extends LocalizationsDelegate { + const _AppLocalizationsDelegate(); + + @override + Future load(Locale locale) { + return SynchronousFuture(lookupAppLocalizations(locale)); + } + + @override + bool isSupported(Locale locale) => ['en', 'ru'].contains(locale.languageCode); + + @override + bool shouldReload(_AppLocalizationsDelegate old) => false; +} + +AppLocalizations lookupAppLocalizations(Locale locale) { + + + // Lookup logic when only language code is specified. + switch (locale.languageCode) { + case 'en': return AppLocalizationsEn(); + case 'ru': return AppLocalizationsRu(); + } + + throw FlutterError( + 'AppLocalizations.delegate failed to load unsupported locale "$locale". This is likely ' + 'an issue with the localizations generation tool. Please file an issue ' + 'on GitHub with a reproducible sample app and the gen-l10n configuration ' + 'that was used.' + ); +} diff --git a/client-mobile/lib/features/settings/presentation/l10n/app_localizations_en.dart b/client-mobile/lib/features/settings/presentation/l10n/app_localizations_en.dart new file mode 100644 index 0000000..25720e4 --- /dev/null +++ b/client-mobile/lib/features/settings/presentation/l10n/app_localizations_en.dart @@ -0,0 +1,154 @@ +// ignore: unused_import +import 'package:intl/intl.dart' as intl; +import 'app_localizations.dart'; + +// ignore_for_file: type=lint + +/// The translations for English (`en`). +class AppLocalizationsEn extends AppLocalizations { + AppLocalizationsEn([String locale = 'en']) : super(locale); + + @override + String get appTitle => 'Messenger'; + + @override + String get chats => 'Chats'; + + @override + String get contacts => 'Contacts'; + + @override + String get settings => 'Settings'; + + @override + String get login => 'Login'; + + @override + String get email => 'Email'; + + @override + String get password => 'Password'; + + @override + String get name => 'Name'; + + @override + String get loginButton => 'Sign In'; + + @override + String get register => 'Register'; + + @override + String get noAccount => 'No account? Sign up'; + + @override + String get logout => 'Sign Out'; + + @override + String get serverSettings => 'Server Settings'; + + @override + String get apiUrl => 'API URL'; + + @override + String get apiUrlHint => 'https://api.example.com'; + + @override + String get save => 'Save'; + + @override + String get serverConfig => 'Server Configuration'; + + @override + String get system => 'System'; + + @override + String get stories => 'Stories'; + + @override + String get chatsModule => 'Chats'; + + @override + String get messages => 'Messages'; + + @override + String get calls => 'Calls'; + + @override + String get klipy => 'Klipy'; + + @override + String get import => 'Import'; + + @override + String get federation => 'Federation'; + + @override + String get domainUrl => 'Domain'; + + @override + String get enableRegistration => 'Registration Enabled'; + + @override + String get enabled => 'Enabled'; + + @override + String get disabled => 'Disabled'; + + @override + String get language => 'Language'; + + @override + String get russian => 'Русский'; + + @override + String get english => 'English'; + + @override + String get notifications => 'Notifications'; + + @override + String get privacy => 'Privacy'; + + @override + String get soundsAndVibration => 'Sounds & Vibration'; + + @override + String get dataAndStorage => 'Data & Storage'; + + @override + String get aboutApp => 'About App'; + + @override + String get help => 'Help'; + + @override + String get version => 'Version'; + + @override + String get loading => 'Loading...'; + + @override + String get error => 'Error'; + + @override + String get retry => 'Retry'; + + @override + String get noChats => 'No chats yet'; + + @override + String get inDevelopment => 'In development'; + + @override + String get user => 'User'; + + @override + String get edit => 'Edit'; + + @override + String get serverConnectionError => 'Server connection error'; + + @override + String get settingsSaved => 'Settings saved'; +} diff --git a/client-mobile/lib/features/settings/presentation/l10n/app_localizations_ru.dart b/client-mobile/lib/features/settings/presentation/l10n/app_localizations_ru.dart new file mode 100644 index 0000000..d3fab57 --- /dev/null +++ b/client-mobile/lib/features/settings/presentation/l10n/app_localizations_ru.dart @@ -0,0 +1,154 @@ +// ignore: unused_import +import 'package:intl/intl.dart' as intl; +import 'app_localizations.dart'; + +// ignore_for_file: type=lint + +/// The translations for Russian (`ru`). +class AppLocalizationsRu extends AppLocalizations { + AppLocalizationsRu([String locale = 'ru']) : super(locale); + + @override + String get appTitle => 'Мессенджер'; + + @override + String get chats => 'Чаты'; + + @override + String get contacts => 'Контакты'; + + @override + String get settings => 'Настройки'; + + @override + String get login => 'Вход'; + + @override + String get email => 'Email'; + + @override + String get password => 'Пароль'; + + @override + String get name => 'Имя'; + + @override + String get loginButton => 'Войти'; + + @override + String get register => 'Зарегистрироваться'; + + @override + String get noAccount => 'Нет аккаунта? Зарегистрироваться'; + + @override + String get logout => 'Выйти из аккаунта'; + + @override + String get serverSettings => 'Настройки сервера'; + + @override + String get apiUrl => 'Адрес API'; + + @override + String get apiUrlHint => 'https://api.example.com'; + + @override + String get save => 'Сохранить'; + + @override + String get serverConfig => 'Конфигурация сервера'; + + @override + String get system => 'Система'; + + @override + String get stories => 'Истории'; + + @override + String get chatsModule => 'Чаты'; + + @override + String get messages => 'Сообщения'; + + @override + String get calls => 'Звонки'; + + @override + String get klipy => 'Клипы'; + + @override + String get import => 'Импорт'; + + @override + String get federation => 'Федерация'; + + @override + String get domainUrl => 'Домен'; + + @override + String get enableRegistration => 'Регистрация включена'; + + @override + String get enabled => 'Включено'; + + @override + String get disabled => 'Отключено'; + + @override + String get language => 'Язык'; + + @override + String get russian => 'Русский'; + + @override + String get english => 'English'; + + @override + String get notifications => 'Уведомления'; + + @override + String get privacy => 'Конфиденциальность'; + + @override + String get soundsAndVibration => 'Звуки и вибрация'; + + @override + String get dataAndStorage => 'Данные и память'; + + @override + String get aboutApp => 'О приложении'; + + @override + String get help => 'Помощь'; + + @override + String get version => 'Версия'; + + @override + String get loading => 'Загрузка...'; + + @override + String get error => 'Ошибка'; + + @override + String get retry => 'Повторить'; + + @override + String get noChats => 'У вас пока нет чатов'; + + @override + String get inDevelopment => 'Функция в разработке'; + + @override + String get user => 'Пользователь'; + + @override + String get edit => 'Редактировать'; + + @override + String get serverConnectionError => 'Ошибка подключения к серверу'; + + @override + String get settingsSaved => 'Настройки сохранены'; +} diff --git a/client-mobile/lib/features/settings/presentation/pages/settings_page.dart b/client-mobile/lib/features/settings/presentation/pages/settings_page.dart new file mode 100644 index 0000000..0ce2aa5 --- /dev/null +++ b/client-mobile/lib/features/settings/presentation/pages/settings_page.dart @@ -0,0 +1,424 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import '../l10n/app_localizations.dart'; +import '../../domain/entities/server_config.dart'; +import '../bloc/settings_bloc.dart'; +import '../bloc/settings_event.dart'; +import '../bloc/settings_state.dart'; + +class SettingsPage extends StatelessWidget { + const SettingsPage({super.key}); + + @override + Widget build(BuildContext context) { + return BlocBuilder( + builder: (context, state) { + return state.when( + initial: () => const Center(child: CircularProgressIndicator()), + loading: () => const Center(child: CircularProgressIndicator()), + loaded: (apiUrl, serverConfig, languageCode, error) => _SettingsContent( + apiUrl: apiUrl, + serverConfig: serverConfig, + languageCode: languageCode, + error: error, + ), + error: (message) => Center(child: Text(message)), + ); + }, + ); + } +} + +class _SettingsContent extends StatelessWidget { + final String apiUrl; + final ServerConfig? serverConfig; + final String languageCode; + final String? error; + + const _SettingsContent({ + required this.apiUrl, + required this.serverConfig, + required this.languageCode, + this.error, + }); + + @override + Widget build(BuildContext context) { + final l10n = AppLocalizations.of(context)!; + + return ListView( + children: [ + _SectionHeader(title: l10n.serverSettings), + _ApiUrlTile( + apiUrl: apiUrl, + onSave: (url) { + context.read().add(SettingsApiUrlSaved(url)); + }, + ), + const Divider(), + + _SectionHeader(title: l10n.language), + _LanguageTile( + currentCode: languageCode, + onChanged: (code) { + context.read().add(SettingsLanguageChanged(code)); + }, + ), + const Divider(), + + if (serverConfig != null) ...[ + _SectionHeader(title: l10n.serverConfig), + _ConfigModuleCard( + title: l10n.system, + icon: Icons.computer, + children: [ + _ConfigItem(label: l10n.domainUrl, value: serverConfig!.system.domainUrl), + _ConfigItem(label: l10n.enableRegistration, value: serverConfig!.system.enableRegistration ? l10n.enabled : l10n.disabled), + ], + ), + _ConfigModuleCard( + title: l10n.messages, + icon: Icons.message, + children: [ + _ConfigItem(label: l10n.enabled, value: serverConfig!.messages.allowMedia ? l10n.enabled : l10n.disabled), + _ConfigItem(label: 'Max media size', value: '${(serverConfig!.messages.maxMediaSizeBytes / 1024 / 1024).toStringAsFixed(1)} MB'), + ], + ), + _ConfigModuleCard( + title: l10n.calls, + icon: Icons.call, + children: [ + _ConfigItem(label: l10n.enabled, value: serverConfig!.webRtc.enabled ? l10n.enabled : l10n.disabled), + _ConfigItem(label: 'Voice calls', value: serverConfig!.webRtc.enableVoiceCalls ? l10n.enabled : l10n.disabled), + _ConfigItem(label: 'Video calls', value: serverConfig!.webRtc.enableVideoCalls ? l10n.enabled : l10n.disabled), + ], + ), + _ConfigModuleCard( + title: l10n.stories, + icon: Icons.auto_stories, + children: [ + _ConfigItem(label: l10n.enabled, value: serverConfig!.stories.enabled ? l10n.enabled : l10n.disabled), + _ConfigItem(label: 'Lifetime', value: '${serverConfig!.stories.storyLifetimeHours}h'), + ], + ), + _ConfigModuleCard( + title: l10n.chatsModule, + icon: Icons.chat_bubble, + children: [ + _ConfigItem(label: 'Groups', value: serverConfig!.chats.supportGroups ? l10n.enabled : l10n.disabled), + _ConfigItem(label: 'Max participants', value: '${serverConfig!.chats.maxGroupParticipants}'), + ], + ), + if (serverConfig!.federation.enabled) + _ConfigModuleCard( + title: l10n.federation, + icon: Icons.public, + children: [ + _ConfigItem(label: 'Description', value: serverConfig!.federation.serverDescription), + ], + ), + const Divider(), + ], + + if (serverConfig == null) + ListTile( + leading: const Icon(Icons.refresh), + title: Text(l10n.retry), + onTap: () { + context.read().add(const SettingsRefreshConfig()); + }, + ), + + _SectionHeader(title: l10n.settings), + _SettingsTile( + icon: Icons.notifications_outlined, + title: l10n.notifications, + onTap: () {}, + ), + _SettingsTile( + icon: Icons.security, + title: l10n.privacy, + onTap: () {}, + ), + _SettingsTile( + icon: Icons.volume_up, + title: l10n.soundsAndVibration, + onTap: () {}, + ), + _SettingsTile( + icon: Icons.storage, + title: l10n.dataAndStorage, + onTap: () {}, + ), + const Divider(), + + _SettingsTile( + icon: Icons.info_outline, + title: l10n.aboutApp, + subtitle: '${l10n.version} 1.0.0', + onTap: () {}, + ), + _SettingsTile( + icon: Icons.help_outline, + title: l10n.help, + onTap: () {}, + ), + const Divider(), + + Padding( + padding: const EdgeInsets.all(16), + child: OutlinedButton( + onPressed: () {}, + style: OutlinedButton.styleFrom( + foregroundColor: Colors.red, + side: const BorderSide(color: Colors.red), + ), + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 12), + child: Text(l10n.logout), + ), + ), + ), + ], + ); + } +} + +class _SectionHeader extends StatelessWidget { + final String title; + + const _SectionHeader({required this.title}); + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.fromLTRB(16, 16, 16, 8), + child: Text( + title.toUpperCase(), + style: TextStyle( + fontSize: 13, + fontWeight: FontWeight.w600, + color: Theme.of(context).colorScheme.primary, + letterSpacing: 0.5, + ), + ), + ); + } +} + +class _ApiUrlTile extends StatefulWidget { + final String apiUrl; + final ValueChanged onSave; + + const _ApiUrlTile({ + required this.apiUrl, + required this.onSave, + }); + + @override + State<_ApiUrlTile> createState() => _ApiUrlTileState(); +} + +class _ApiUrlTileState extends State<_ApiUrlTile> { + late final TextEditingController _controller; + bool _isEditing = false; + + @override + void initState() { + super.initState(); + _controller = TextEditingController(text: widget.apiUrl); + } + + @override + void didUpdateWidget(covariant _ApiUrlTile oldWidget) { + super.didUpdateWidget(oldWidget); + if (oldWidget.apiUrl != widget.apiUrl) { + _controller.text = widget.apiUrl; + } + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + final l10n = AppLocalizations.of(context)!; + + if (_isEditing) { + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), + child: Row( + children: [ + Expanded( + child: TextField( + controller: _controller, + decoration: InputDecoration( + labelText: l10n.apiUrl, + hintText: l10n.apiUrlHint, + border: const OutlineInputBorder(), + contentPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), + ), + keyboardType: TextInputType.url, + ), + ), + const SizedBox(width: 8), + IconButton( + icon: const Icon(Icons.check, color: Colors.green), + onPressed: () { + widget.onSave(_controller.text.trim()); + setState(() => _isEditing = false); + }, + ), + IconButton( + icon: const Icon(Icons.close, color: Colors.red), + onPressed: () { + _controller.text = widget.apiUrl; + setState(() => _isEditing = false); + }, + ), + ], + ), + ); + } + + return ListTile( + leading: const Icon(Icons.link), + title: Text(l10n.apiUrl), + subtitle: Text( + widget.apiUrl.isEmpty ? l10n.apiUrlHint : widget.apiUrl, + style: TextStyle( + color: widget.apiUrl.isEmpty ? Colors.grey : null, + ), + ), + trailing: const Icon(Icons.edit), + onTap: () => setState(() => _isEditing = true), + ); + } +} + +class _LanguageTile extends StatelessWidget { + final String currentCode; + final ValueChanged onChanged; + + const _LanguageTile({ + required this.currentCode, + required this.onChanged, + }); + + @override + Widget build(BuildContext context) { + final l10n = AppLocalizations.of(context)!; + + return ListTile( + leading: const Icon(Icons.language), + title: Text(l10n.language), + subtitle: Text(currentCode == 'ru' ? l10n.russian : l10n.english), + trailing: DropdownButton( + value: currentCode, + underline: const SizedBox(), + items: [ + DropdownMenuItem(value: 'ru', child: Text(l10n.russian)), + DropdownMenuItem(value: 'en', child: Text(l10n.english)), + ], + onChanged: (value) { + if (value != null) onChanged(value); + }, + ), + ); + } +} + +class _ConfigModuleCard extends StatelessWidget { + final String title; + final IconData icon; + final List children; + + const _ConfigModuleCard({ + required this.title, + required this.icon, + required this.children, + }); + + @override + Widget build(BuildContext context) { + return Card( + margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 4), + child: ExpansionTile( + leading: Icon(icon, color: Theme.of(context).colorScheme.primary), + title: Text(title), + children: [ + Padding( + padding: const EdgeInsets.fromLTRB(16, 0, 16, 12), + child: Column( + children: children, + ), + ), + ], + ), + ); + } +} + +class _ConfigItem extends StatelessWidget { + final String label; + final String value; + + const _ConfigItem({ + required this.label, + required this.value, + }); + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 4), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + label, + style: TextStyle( + color: Colors.grey[600], + fontSize: 13, + ), + ), + Text( + value, + style: const TextStyle( + fontWeight: FontWeight.w500, + fontSize: 13, + ), + ), + ], + ), + ); + } +} + +class _SettingsTile extends StatelessWidget { + final IconData icon; + final String title; + final String? subtitle; + final VoidCallback onTap; + + const _SettingsTile({ + required this.icon, + required this.title, + this.subtitle, + required this.onTap, + }); + + @override + Widget build(BuildContext context) { + return ListTile( + leading: Icon(icon), + title: Text(title), + subtitle: subtitle != null ? Text(subtitle!) : null, + trailing: const Icon(Icons.chevron_right), + onTap: onTap, + ); + } +} diff --git a/client-mobile/lib/internal/di/injection_container.dart b/client-mobile/lib/internal/di/injection_container.dart new file mode 100644 index 0000000..58d0e05 --- /dev/null +++ b/client-mobile/lib/internal/di/injection_container.dart @@ -0,0 +1,53 @@ +import 'package:get_it/get_it.dart'; +import 'package:dio/dio.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +import '../../core/network/api_client.dart'; +import '../../features/auth/presentation/bloc/auth_bloc.dart'; +import '../../features/chat/presentation/bloc/chat_bloc.dart'; +import '../../features/settings/data/datasources/settings_local_datasource.dart'; +import '../../features/settings/data/datasources/settings_remote_datasource.dart'; +import '../../features/settings/data/repositories/settings_repository_impl.dart'; +import '../../features/settings/domain/repositories/settings_repository.dart'; +import '../../features/settings/presentation/bloc/settings_bloc.dart'; + +final sl = GetIt.instance; + +Future initDependencies() async { + // Core - SharedPreferences + final prefs = await SharedPreferences.getInstance(); + sl.registerLazySingleton(() => prefs); + + // Core - Settings Local DataSource + sl.registerLazySingleton( + () => SettingsLocalDataSourceImpl(sl()), + ); + + // Core - Dio (with dynamic base URL from settings) + sl.registerLazySingleton(() { + final apiUrl = prefs.getString('api_url') ?? 'https://api.messenger.app'; + return Dio(BaseOptions( + baseUrl: apiUrl, + connectTimeout: const Duration(seconds: 30), + receiveTimeout: const Duration(seconds: 30), + )); + }); + + // Core - API Client + sl.registerLazySingleton(() => ApiClient(sl())); + + // Settings + sl.registerLazySingleton( + () => SettingsRemoteDataSourceImpl(sl()), + ); + sl.registerLazySingleton( + () => SettingsRepositoryImpl(sl(), sl()), + ); + sl.registerFactory(() => SettingsBloc(sl())); + + // Auth + sl.registerFactory(() => AuthBloc()); + + // Chat + sl.registerFactory(() => ChatBloc()); +} diff --git a/client-mobile/lib/internal/router/chats_placeholder.dart b/client-mobile/lib/internal/router/chats_placeholder.dart new file mode 100644 index 0000000..c47b4ce --- /dev/null +++ b/client-mobile/lib/internal/router/chats_placeholder.dart @@ -0,0 +1,21 @@ +import 'package:flutter/material.dart'; + +class ChatsPage extends StatelessWidget { + const ChatsPage({super.key}); + + @override + Widget build(BuildContext context) { + return const Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon(Icons.chat_bubble_outline, size: 64, color: Colors.grey), + SizedBox(height: 16), + Text('Чаты', style: TextStyle(fontSize: 18)), + SizedBox(height: 8), + Text('Функция в разработке', style: TextStyle(color: Colors.grey)), + ], + ), + ); + } +} diff --git a/client-mobile/lib/internal/router/main_screen.dart b/client-mobile/lib/internal/router/main_screen.dart new file mode 100644 index 0000000..b62130a --- /dev/null +++ b/client-mobile/lib/internal/router/main_screen.dart @@ -0,0 +1,104 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import '../../features/auth/presentation/bloc/auth_bloc.dart'; +import '../../features/auth/presentation/bloc/auth_state.dart'; +import '../../features/auth/presentation/pages/login_page.dart'; +import '../../features/settings/presentation/pages/settings_page.dart'; +import '../router/chats_placeholder.dart'; + +class MainScreen extends StatefulWidget { + static const String routeName = '/main'; + + const MainScreen({super.key}); + + @override + State createState() => _MainScreenState(); +} + +class _MainScreenState extends State { + int _currentIndex = 0; + + @override + Widget build(BuildContext context) { + return Scaffold( + body: IndexedStack( + index: _currentIndex, + children: const [ + ChatsTab(), + ContactsTab(), + SettingsTab(), + ], + ), + bottomNavigationBar: BottomNavigationBar( + currentIndex: _currentIndex, + onTap: (index) => setState(() => _currentIndex = index), + type: BottomNavigationBarType.fixed, + items: const [ + BottomNavigationBarItem( + icon: Icon(Icons.chat_bubble_outline), + activeIcon: Icon(Icons.chat_bubble), + label: 'Чаты', + ), + BottomNavigationBarItem( + icon: Icon(Icons.contacts_outlined), + activeIcon: Icon(Icons.contacts), + label: 'Контакты', + ), + BottomNavigationBarItem( + icon: Icon(Icons.settings_outlined), + activeIcon: Icon(Icons.settings), + label: 'Настройки', + ), + ], + ), + ); + } +} + +class ChatsTab extends StatelessWidget { + const ChatsTab({super.key}); + + @override + Widget build(BuildContext context) { + return const ChatsPage(); + } +} + +class ContactsTab extends StatelessWidget { + const ContactsTab({super.key}); + + @override + Widget build(BuildContext context) { + return const Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon(Icons.contacts_outlined, size: 64, color: Colors.grey), + SizedBox(height: 16), + Text('Контакты', style: TextStyle(fontSize: 18)), + SizedBox(height: 8), + Text('Функция в разработке', style: TextStyle(color: Colors.grey)), + ], + ), + ); + } +} + +class SettingsTab extends StatelessWidget { + const SettingsTab({super.key}); + + @override + Widget build(BuildContext context) { + return BlocBuilder( + builder: (context, authState) { + return authState.when( + initial: () => const Center(child: CircularProgressIndicator()), + loading: () => const Center(child: CircularProgressIndicator()), + authenticated: (_) => const SettingsPage(), + unauthenticated: () => const LoginPage(), + error: (_) => const LoginPage(), + ); + }, + ); + } +} diff --git a/client-mobile/lib/l10n/app_localizations.dart b/client-mobile/lib/l10n/app_localizations.dart new file mode 100644 index 0000000..6c5d639 --- /dev/null +++ b/client-mobile/lib/l10n/app_localizations.dart @@ -0,0 +1,417 @@ +import 'dart:async'; + +import 'package:flutter/foundation.dart'; +import 'package:flutter/widgets.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; +import 'package:intl/intl.dart' as intl; + +import 'app_localizations_en.dart'; +import 'app_localizations_ru.dart'; + +// ignore_for_file: type=lint + +/// Callers can lookup localized strings with an instance of AppLocalizations +/// returned by `AppLocalizations.of(context)`. +/// +/// Applications need to include `AppLocalizations.delegate()` in their app's +/// `localizationDelegates` list, and the locales they support in the app's +/// `supportedLocales` list. For example: +/// +/// ```dart +/// import 'l10n/app_localizations.dart'; +/// +/// return MaterialApp( +/// localizationsDelegates: AppLocalizations.localizationsDelegates, +/// supportedLocales: AppLocalizations.supportedLocales, +/// home: MyApplicationHome(), +/// ); +/// ``` +/// +/// ## Update pubspec.yaml +/// +/// Please make sure to update your pubspec.yaml to include the following +/// packages: +/// +/// ```yaml +/// dependencies: +/// # Internationalization support. +/// flutter_localizations: +/// sdk: flutter +/// intl: any # Use the pinned version from flutter_localizations +/// +/// # Rest of dependencies +/// ``` +/// +/// ## iOS Applications +/// +/// iOS applications define key application metadata, including supported +/// locales, in an Info.plist file that is built into the application bundle. +/// To configure the locales supported by your app, you’ll need to edit this +/// file. +/// +/// First, open your project’s ios/Runner.xcworkspace Xcode workspace file. +/// Then, in the Project Navigator, open the Info.plist file under the Runner +/// project’s Runner folder. +/// +/// Next, select the Information Property List item, select Add Item from the +/// Editor menu, then select Localizations from the pop-up menu. +/// +/// Select and expand the newly-created Localizations item then, for each +/// locale your application supports, add a new item and select the locale +/// you wish to add from the pop-up menu in the Value field. This list should +/// be consistent with the languages listed in the AppLocalizations.supportedLocales +/// property. +abstract class AppLocalizations { + AppLocalizations(String locale) : localeName = intl.Intl.canonicalizedLocale(locale.toString()); + + final String localeName; + + static AppLocalizations? of(BuildContext context) { + return Localizations.of(context, AppLocalizations); + } + + static const LocalizationsDelegate delegate = _AppLocalizationsDelegate(); + + /// A list of this localizations delegate along with the default localizations + /// delegates. + /// + /// Returns a list of localizations delegates containing this delegate along with + /// GlobalMaterialLocalizations.delegate, GlobalCupertinoLocalizations.delegate, + /// and GlobalWidgetsLocalizations.delegate. + /// + /// Additional delegates can be added by appending to this list in + /// MaterialApp. This list does not have to be used at all if a custom list + /// of delegates is preferred or required. + static const List> localizationsDelegates = >[ + delegate, + GlobalMaterialLocalizations.delegate, + GlobalCupertinoLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + ]; + + /// A list of this localizations delegate's supported locales. + static const List supportedLocales = [ + Locale('en'), + Locale('ru') + ]; + + /// No description provided for @appTitle. + /// + /// In en, this message translates to: + /// **'Messenger'** + String get appTitle; + + /// No description provided for @chats. + /// + /// In en, this message translates to: + /// **'Chats'** + String get chats; + + /// No description provided for @contacts. + /// + /// In en, this message translates to: + /// **'Contacts'** + String get contacts; + + /// No description provided for @settings. + /// + /// In en, this message translates to: + /// **'Settings'** + String get settings; + + /// No description provided for @login. + /// + /// In en, this message translates to: + /// **'Login'** + String get login; + + /// No description provided for @email. + /// + /// In en, this message translates to: + /// **'Email'** + String get email; + + /// No description provided for @password. + /// + /// In en, this message translates to: + /// **'Password'** + String get password; + + /// No description provided for @name. + /// + /// In en, this message translates to: + /// **'Name'** + String get name; + + /// No description provided for @loginButton. + /// + /// In en, this message translates to: + /// **'Sign In'** + String get loginButton; + + /// No description provided for @register. + /// + /// In en, this message translates to: + /// **'Register'** + String get register; + + /// No description provided for @noAccount. + /// + /// In en, this message translates to: + /// **'No account? Sign up'** + String get noAccount; + + /// No description provided for @logout. + /// + /// In en, this message translates to: + /// **'Sign Out'** + String get logout; + + /// No description provided for @serverSettings. + /// + /// In en, this message translates to: + /// **'Server Settings'** + String get serverSettings; + + /// No description provided for @apiUrl. + /// + /// In en, this message translates to: + /// **'API URL'** + String get apiUrl; + + /// No description provided for @apiUrlHint. + /// + /// In en, this message translates to: + /// **'https://api.example.com'** + String get apiUrlHint; + + /// No description provided for @save. + /// + /// In en, this message translates to: + /// **'Save'** + String get save; + + /// No description provided for @serverConfig. + /// + /// In en, this message translates to: + /// **'Server Configuration'** + String get serverConfig; + + /// No description provided for @system. + /// + /// In en, this message translates to: + /// **'System'** + String get system; + + /// No description provided for @stories. + /// + /// In en, this message translates to: + /// **'Stories'** + String get stories; + + /// No description provided for @chatsModule. + /// + /// In en, this message translates to: + /// **'Chats'** + String get chatsModule; + + /// No description provided for @messages. + /// + /// In en, this message translates to: + /// **'Messages'** + String get messages; + + /// No description provided for @calls. + /// + /// In en, this message translates to: + /// **'Calls'** + String get calls; + + /// No description provided for @klipy. + /// + /// In en, this message translates to: + /// **'Klipy'** + String get klipy; + + /// No description provided for @import. + /// + /// In en, this message translates to: + /// **'Import'** + String get import; + + /// No description provided for @federation. + /// + /// In en, this message translates to: + /// **'Federation'** + String get federation; + + /// No description provided for @domainUrl. + /// + /// In en, this message translates to: + /// **'Domain'** + String get domainUrl; + + /// No description provided for @enableRegistration. + /// + /// In en, this message translates to: + /// **'Registration Enabled'** + String get enableRegistration; + + /// No description provided for @enabled. + /// + /// In en, this message translates to: + /// **'Enabled'** + String get enabled; + + /// No description provided for @disabled. + /// + /// In en, this message translates to: + /// **'Disabled'** + String get disabled; + + /// No description provided for @language. + /// + /// In en, this message translates to: + /// **'Language'** + String get language; + + /// No description provided for @russian. + /// + /// In en, this message translates to: + /// **'Русский'** + String get russian; + + /// No description provided for @english. + /// + /// In en, this message translates to: + /// **'English'** + String get english; + + /// No description provided for @notifications. + /// + /// In en, this message translates to: + /// **'Notifications'** + String get notifications; + + /// No description provided for @privacy. + /// + /// In en, this message translates to: + /// **'Privacy'** + String get privacy; + + /// No description provided for @soundsAndVibration. + /// + /// In en, this message translates to: + /// **'Sounds & Vibration'** + String get soundsAndVibration; + + /// No description provided for @dataAndStorage. + /// + /// In en, this message translates to: + /// **'Data & Storage'** + String get dataAndStorage; + + /// No description provided for @aboutApp. + /// + /// In en, this message translates to: + /// **'About App'** + String get aboutApp; + + /// No description provided for @help. + /// + /// In en, this message translates to: + /// **'Help'** + String get help; + + /// No description provided for @version. + /// + /// In en, this message translates to: + /// **'Version'** + String get version; + + /// No description provided for @loading. + /// + /// In en, this message translates to: + /// **'Loading...'** + String get loading; + + /// No description provided for @error. + /// + /// In en, this message translates to: + /// **'Error'** + String get error; + + /// No description provided for @retry. + /// + /// In en, this message translates to: + /// **'Retry'** + String get retry; + + /// No description provided for @noChats. + /// + /// In en, this message translates to: + /// **'No chats yet'** + String get noChats; + + /// No description provided for @inDevelopment. + /// + /// In en, this message translates to: + /// **'In development'** + String get inDevelopment; + + /// No description provided for @user. + /// + /// In en, this message translates to: + /// **'User'** + String get user; + + /// No description provided for @edit. + /// + /// In en, this message translates to: + /// **'Edit'** + String get edit; + + /// No description provided for @serverConnectionError. + /// + /// In en, this message translates to: + /// **'Server connection error'** + String get serverConnectionError; + + /// No description provided for @settingsSaved. + /// + /// In en, this message translates to: + /// **'Settings saved'** + String get settingsSaved; +} + +class _AppLocalizationsDelegate extends LocalizationsDelegate { + const _AppLocalizationsDelegate(); + + @override + Future load(Locale locale) { + return SynchronousFuture(lookupAppLocalizations(locale)); + } + + @override + bool isSupported(Locale locale) => ['en', 'ru'].contains(locale.languageCode); + + @override + bool shouldReload(_AppLocalizationsDelegate old) => false; +} + +AppLocalizations lookupAppLocalizations(Locale locale) { + + + // Lookup logic when only language code is specified. + switch (locale.languageCode) { + case 'en': return AppLocalizationsEn(); + case 'ru': return AppLocalizationsRu(); + } + + throw FlutterError( + 'AppLocalizations.delegate failed to load unsupported locale "$locale". This is likely ' + 'an issue with the localizations generation tool. Please file an issue ' + 'on GitHub with a reproducible sample app and the gen-l10n configuration ' + 'that was used.' + ); +} diff --git a/client-mobile/lib/l10n/app_localizations_en.dart b/client-mobile/lib/l10n/app_localizations_en.dart new file mode 100644 index 0000000..25720e4 --- /dev/null +++ b/client-mobile/lib/l10n/app_localizations_en.dart @@ -0,0 +1,154 @@ +// ignore: unused_import +import 'package:intl/intl.dart' as intl; +import 'app_localizations.dart'; + +// ignore_for_file: type=lint + +/// The translations for English (`en`). +class AppLocalizationsEn extends AppLocalizations { + AppLocalizationsEn([String locale = 'en']) : super(locale); + + @override + String get appTitle => 'Messenger'; + + @override + String get chats => 'Chats'; + + @override + String get contacts => 'Contacts'; + + @override + String get settings => 'Settings'; + + @override + String get login => 'Login'; + + @override + String get email => 'Email'; + + @override + String get password => 'Password'; + + @override + String get name => 'Name'; + + @override + String get loginButton => 'Sign In'; + + @override + String get register => 'Register'; + + @override + String get noAccount => 'No account? Sign up'; + + @override + String get logout => 'Sign Out'; + + @override + String get serverSettings => 'Server Settings'; + + @override + String get apiUrl => 'API URL'; + + @override + String get apiUrlHint => 'https://api.example.com'; + + @override + String get save => 'Save'; + + @override + String get serverConfig => 'Server Configuration'; + + @override + String get system => 'System'; + + @override + String get stories => 'Stories'; + + @override + String get chatsModule => 'Chats'; + + @override + String get messages => 'Messages'; + + @override + String get calls => 'Calls'; + + @override + String get klipy => 'Klipy'; + + @override + String get import => 'Import'; + + @override + String get federation => 'Federation'; + + @override + String get domainUrl => 'Domain'; + + @override + String get enableRegistration => 'Registration Enabled'; + + @override + String get enabled => 'Enabled'; + + @override + String get disabled => 'Disabled'; + + @override + String get language => 'Language'; + + @override + String get russian => 'Русский'; + + @override + String get english => 'English'; + + @override + String get notifications => 'Notifications'; + + @override + String get privacy => 'Privacy'; + + @override + String get soundsAndVibration => 'Sounds & Vibration'; + + @override + String get dataAndStorage => 'Data & Storage'; + + @override + String get aboutApp => 'About App'; + + @override + String get help => 'Help'; + + @override + String get version => 'Version'; + + @override + String get loading => 'Loading...'; + + @override + String get error => 'Error'; + + @override + String get retry => 'Retry'; + + @override + String get noChats => 'No chats yet'; + + @override + String get inDevelopment => 'In development'; + + @override + String get user => 'User'; + + @override + String get edit => 'Edit'; + + @override + String get serverConnectionError => 'Server connection error'; + + @override + String get settingsSaved => 'Settings saved'; +} diff --git a/client-mobile/lib/l10n/app_localizations_ru.dart b/client-mobile/lib/l10n/app_localizations_ru.dart new file mode 100644 index 0000000..d3fab57 --- /dev/null +++ b/client-mobile/lib/l10n/app_localizations_ru.dart @@ -0,0 +1,154 @@ +// ignore: unused_import +import 'package:intl/intl.dart' as intl; +import 'app_localizations.dart'; + +// ignore_for_file: type=lint + +/// The translations for Russian (`ru`). +class AppLocalizationsRu extends AppLocalizations { + AppLocalizationsRu([String locale = 'ru']) : super(locale); + + @override + String get appTitle => 'Мессенджер'; + + @override + String get chats => 'Чаты'; + + @override + String get contacts => 'Контакты'; + + @override + String get settings => 'Настройки'; + + @override + String get login => 'Вход'; + + @override + String get email => 'Email'; + + @override + String get password => 'Пароль'; + + @override + String get name => 'Имя'; + + @override + String get loginButton => 'Войти'; + + @override + String get register => 'Зарегистрироваться'; + + @override + String get noAccount => 'Нет аккаунта? Зарегистрироваться'; + + @override + String get logout => 'Выйти из аккаунта'; + + @override + String get serverSettings => 'Настройки сервера'; + + @override + String get apiUrl => 'Адрес API'; + + @override + String get apiUrlHint => 'https://api.example.com'; + + @override + String get save => 'Сохранить'; + + @override + String get serverConfig => 'Конфигурация сервера'; + + @override + String get system => 'Система'; + + @override + String get stories => 'Истории'; + + @override + String get chatsModule => 'Чаты'; + + @override + String get messages => 'Сообщения'; + + @override + String get calls => 'Звонки'; + + @override + String get klipy => 'Клипы'; + + @override + String get import => 'Импорт'; + + @override + String get federation => 'Федерация'; + + @override + String get domainUrl => 'Домен'; + + @override + String get enableRegistration => 'Регистрация включена'; + + @override + String get enabled => 'Включено'; + + @override + String get disabled => 'Отключено'; + + @override + String get language => 'Язык'; + + @override + String get russian => 'Русский'; + + @override + String get english => 'English'; + + @override + String get notifications => 'Уведомления'; + + @override + String get privacy => 'Конфиденциальность'; + + @override + String get soundsAndVibration => 'Звуки и вибрация'; + + @override + String get dataAndStorage => 'Данные и память'; + + @override + String get aboutApp => 'О приложении'; + + @override + String get help => 'Помощь'; + + @override + String get version => 'Версия'; + + @override + String get loading => 'Загрузка...'; + + @override + String get error => 'Ошибка'; + + @override + String get retry => 'Повторить'; + + @override + String get noChats => 'У вас пока нет чатов'; + + @override + String get inDevelopment => 'Функция в разработке'; + + @override + String get user => 'Пользователь'; + + @override + String get edit => 'Редактировать'; + + @override + String get serverConnectionError => 'Ошибка подключения к серверу'; + + @override + String get settingsSaved => 'Настройки сохранены'; +} diff --git a/client-mobile/lib/main.dart b/client-mobile/lib/main.dart new file mode 100644 index 0000000..cdac889 --- /dev/null +++ b/client-mobile/lib/main.dart @@ -0,0 +1,19 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'internal/di/injection_container.dart' as di; +import 'app.dart'; + +void main() async { + WidgetsFlutterBinding.ensureInitialized(); + + // Set preferred orientations + await SystemChrome.setPreferredOrientations([ + DeviceOrientation.portraitUp, + DeviceOrientation.portraitDown, + ]); + + // Initialize dependencies + await di.initDependencies(); + + runApp(const MessengerApp()); +} diff --git a/client-mobile/linux/flutter/ephemeral/.plugin_symlinks/isar_flutter_libs b/client-mobile/linux/flutter/ephemeral/.plugin_symlinks/isar_flutter_libs new file mode 120000 index 0000000..f3c469f --- /dev/null +++ b/client-mobile/linux/flutter/ephemeral/.plugin_symlinks/isar_flutter_libs @@ -0,0 +1 @@ +C:/Users/HomePC/AppData/Local/Pub/Cache/hosted/pub.dev/isar_flutter_libs-3.1.0+1/ \ No newline at end of file diff --git a/client-mobile/linux/flutter/ephemeral/.plugin_symlinks/jni b/client-mobile/linux/flutter/ephemeral/.plugin_symlinks/jni new file mode 120000 index 0000000..1a6f27a --- /dev/null +++ b/client-mobile/linux/flutter/ephemeral/.plugin_symlinks/jni @@ -0,0 +1 @@ +C:/Users/HomePC/AppData/Local/Pub/Cache/hosted/pub.dev/jni-1.0.0/ \ No newline at end of file diff --git a/client-mobile/linux/flutter/ephemeral/.plugin_symlinks/path_provider_linux b/client-mobile/linux/flutter/ephemeral/.plugin_symlinks/path_provider_linux new file mode 120000 index 0000000..492a086 --- /dev/null +++ b/client-mobile/linux/flutter/ephemeral/.plugin_symlinks/path_provider_linux @@ -0,0 +1 @@ +C:/Users/HomePC/AppData/Local/Pub/Cache/hosted/pub.dev/path_provider_linux-2.2.1/ \ No newline at end of file diff --git a/client-mobile/linux/flutter/ephemeral/.plugin_symlinks/shared_preferences_linux b/client-mobile/linux/flutter/ephemeral/.plugin_symlinks/shared_preferences_linux new file mode 120000 index 0000000..1e625d9 --- /dev/null +++ b/client-mobile/linux/flutter/ephemeral/.plugin_symlinks/shared_preferences_linux @@ -0,0 +1 @@ +C:/Users/HomePC/AppData/Local/Pub/Cache/hosted/pub.dev/shared_preferences_linux-2.4.1/ \ No newline at end of file diff --git a/client-mobile/linux/flutter/generated_plugin_registrant.cc b/client-mobile/linux/flutter/generated_plugin_registrant.cc new file mode 100644 index 0000000..b898c8c --- /dev/null +++ b/client-mobile/linux/flutter/generated_plugin_registrant.cc @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + +#include + +void fl_register_plugins(FlPluginRegistry* registry) { + g_autoptr(FlPluginRegistrar) isar_flutter_libs_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "IsarFlutterLibsPlugin"); + isar_flutter_libs_plugin_register_with_registrar(isar_flutter_libs_registrar); +} diff --git a/client-mobile/linux/flutter/generated_plugin_registrant.h b/client-mobile/linux/flutter/generated_plugin_registrant.h new file mode 100644 index 0000000..e0f0a47 --- /dev/null +++ b/client-mobile/linux/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void fl_register_plugins(FlPluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/client-mobile/linux/flutter/generated_plugins.cmake b/client-mobile/linux/flutter/generated_plugins.cmake new file mode 100644 index 0000000..7b2a448 --- /dev/null +++ b/client-mobile/linux/flutter/generated_plugins.cmake @@ -0,0 +1,25 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST + isar_flutter_libs +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST + jni +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/client-mobile/linux/main.cc b/client-mobile/linux/main.cc new file mode 100644 index 0000000..e7c5c54 --- /dev/null +++ b/client-mobile/linux/main.cc @@ -0,0 +1,6 @@ +#include "my_application.h" + +int main(int argc, char** argv) { + g_autoptr(MyApplication) app = my_application_new(); + return g_application_run(G_APPLICATION(app), argc, argv); +} diff --git a/client-mobile/macos/Flutter/GeneratedPluginRegistrant.swift b/client-mobile/macos/Flutter/GeneratedPluginRegistrant.swift new file mode 100644 index 0000000..bde4b2c --- /dev/null +++ b/client-mobile/macos/Flutter/GeneratedPluginRegistrant.swift @@ -0,0 +1,14 @@ +// +// Generated file. Do not edit. +// + +import FlutterMacOS +import Foundation + +import isar_flutter_libs +import shared_preferences_foundation + +func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + IsarFlutterLibsPlugin.register(with: registry.registrar(forPlugin: "IsarFlutterLibsPlugin")) + SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) +} diff --git a/client-mobile/macos/Flutter/ephemeral/Flutter-Generated.xcconfig b/client-mobile/macos/Flutter/ephemeral/Flutter-Generated.xcconfig new file mode 100644 index 0000000..eec589a --- /dev/null +++ b/client-mobile/macos/Flutter/ephemeral/Flutter-Generated.xcconfig @@ -0,0 +1,11 @@ +// This is a generated file; do not edit or check into version control. +FLUTTER_ROOT=C:\src\flutter +FLUTTER_APPLICATION_PATH=E:\GIT\forkmessager\client-mobile +COCOAPODS_PARALLEL_CODE_SIGN=true +FLUTTER_BUILD_DIR=build +FLUTTER_BUILD_NAME=1.0.0 +FLUTTER_BUILD_NUMBER=1 +DART_OBFUSCATION=false +TRACK_WIDGET_CREATION=true +TREE_SHAKE_ICONS=false +PACKAGE_CONFIG=.dart_tool/package_config.json diff --git a/client-mobile/macos/Flutter/ephemeral/flutter_export_environment.sh b/client-mobile/macos/Flutter/ephemeral/flutter_export_environment.sh new file mode 100644 index 0000000..d2ae143 --- /dev/null +++ b/client-mobile/macos/Flutter/ephemeral/flutter_export_environment.sh @@ -0,0 +1,12 @@ +#!/bin/sh +# This is a generated file; do not edit or check into version control. +export "FLUTTER_ROOT=C:\src\flutter" +export "FLUTTER_APPLICATION_PATH=E:\GIT\forkmessager\client-mobile" +export "COCOAPODS_PARALLEL_CODE_SIGN=true" +export "FLUTTER_BUILD_DIR=build" +export "FLUTTER_BUILD_NAME=1.0.0" +export "FLUTTER_BUILD_NUMBER=1" +export "DART_OBFUSCATION=false" +export "TRACK_WIDGET_CREATION=true" +export "TREE_SHAKE_ICONS=false" +export "PACKAGE_CONFIG=.dart_tool/package_config.json" diff --git a/client-mobile/macos/Runner/AppDelegate.swift b/client-mobile/macos/Runner/AppDelegate.swift new file mode 100644 index 0000000..d53ef64 --- /dev/null +++ b/client-mobile/macos/Runner/AppDelegate.swift @@ -0,0 +1,9 @@ +import Cocoa +import FlutterMacOS + +@NSApplicationMain +class AppDelegate: FlutterAppDelegate { + override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { + return true + } +} diff --git a/client-mobile/pubspec.lock b/client-mobile/pubspec.lock new file mode 100644 index 0000000..d2767d8 --- /dev/null +++ b/client-mobile/pubspec.lock @@ -0,0 +1,1023 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + sha256: ae92f5d747aee634b87f89d9946000c2de774be1d6ac3e58268224348cd0101a + url: "https://pub.dev" + source: hosted + version: "61.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + sha256: ea3d8652bda62982addfd92fdc2d0214e5f82e43325104990d4f4c4a2a313562 + url: "https://pub.dev" + source: hosted + version: "5.13.0" + args: + dependency: transitive + description: + name: args + sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04 + url: "https://pub.dev" + source: hosted + version: "2.7.0" + async: + dependency: transitive + description: + name: async + sha256: e2eb0491ba5ddb6177742d2da23904574082139b07c1e33b8503b9f46f3e1a37 + url: "https://pub.dev" + source: hosted + version: "2.13.1" + auto_route: + dependency: "direct main" + description: + name: auto_route + sha256: eb33554581a0a4aa7e6da0f13a44291a55bf71359012f1d9feb41634ff908ff8 + url: "https://pub.dev" + source: hosted + version: "7.9.2" + auto_route_generator: + dependency: "direct dev" + description: + name: auto_route_generator + sha256: "11067a3bcd643812518fe26c0c9ec073990286cabfd9d74b6da9ef9b913c4d22" + url: "https://pub.dev" + source: hosted + version: "7.3.2" + bloc: + dependency: "direct main" + description: + name: bloc + sha256: "106842ad6569f0b60297619e9e0b1885c2fb9bf84812935490e6c5275777804e" + url: "https://pub.dev" + source: hosted + version: "8.1.4" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + build: + dependency: transitive + description: + name: build + sha256: "80184af8b6cb3e5c1c4ec6d8544d27711700bc3e6d2efad04238c7b5290889f0" + url: "https://pub.dev" + source: hosted + version: "2.4.1" + build_config: + dependency: transitive + description: + name: build_config + sha256: "4ae2de3e1e67ea270081eaee972e1bd8f027d459f249e0f1186730784c2e7e33" + url: "https://pub.dev" + source: hosted + version: "1.1.2" + build_daemon: + dependency: transitive + description: + name: build_daemon + sha256: bf05f6e12cfea92d3c09308d7bcdab1906cd8a179b023269eed00c071004b957 + url: "https://pub.dev" + source: hosted + version: "4.1.1" + build_resolvers: + dependency: transitive + description: + name: build_resolvers + sha256: "339086358431fa15d7eca8b6a36e5d783728cf025e559b834f4609a1fcfb7b0a" + url: "https://pub.dev" + source: hosted + version: "2.4.2" + build_runner: + dependency: "direct dev" + description: + name: build_runner + sha256: "028819cfb90051c6b5440c7e574d1896f8037e3c96cf17aaeb054c9311cfbf4d" + url: "https://pub.dev" + source: hosted + version: "2.4.13" + build_runner_core: + dependency: transitive + description: + name: build_runner_core + sha256: f8126682b87a7282a339b871298cc12009cb67109cfa1614d6436fb0289193e0 + url: "https://pub.dev" + source: hosted + version: "7.3.2" + built_collection: + dependency: transitive + description: + name: built_collection + sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" + url: "https://pub.dev" + source: hosted + version: "5.1.1" + built_value: + dependency: transitive + description: + name: built_value + sha256: "34e4067d30ce212937df995f03b69992eea683539ceeac7f679a1f1eba055b56" + url: "https://pub.dev" + source: hosted + version: "8.12.6" + characters: + dependency: transitive + description: + name: characters + sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b + url: "https://pub.dev" + source: hosted + version: "1.4.1" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + sha256: "959525d3162f249993882720d52b7e0c833978df229be20702b33d48d91de70f" + url: "https://pub.dev" + source: hosted + version: "2.0.4" + clock: + dependency: transitive + description: + name: clock + sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b + url: "https://pub.dev" + source: hosted + version: "1.1.2" + code_assets: + dependency: transitive + description: + name: code_assets + sha256: "83ccdaa064c980b5596c35dd64a8d3ecc68620174ab9b90b6343b753aa721687" + url: "https://pub.dev" + source: hosted + version: "1.0.0" + code_builder: + dependency: transitive + description: + name: code_builder + sha256: "6a6cab2ba4680d6423f34a9b972a4c9a94ebe1b62ecec4e1a1f2cba91fd1319d" + url: "https://pub.dev" + source: hosted + version: "4.11.1" + collection: + dependency: transitive + description: + name: collection + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" + url: "https://pub.dev" + source: hosted + version: "1.19.1" + convert: + dependency: transitive + description: + name: convert + sha256: b30acd5944035672bc15c6b7a8b47d773e41e2f17de064350988c5d02adb1c68 + url: "https://pub.dev" + source: hosted + version: "3.1.2" + crypto: + dependency: transitive + description: + name: crypto + sha256: c8ea0233063ba03258fbcf2ca4d6dadfefe14f02fab57702265467a19f27fadf + url: "https://pub.dev" + source: hosted + version: "3.0.7" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + sha256: "41e005c33bd814be4d3096aff55b1908d419fde52ca656c8c47719ec745873cd" + url: "https://pub.dev" + source: hosted + version: "1.0.9" + dart_style: + dependency: transitive + description: + name: dart_style + sha256: "1efa911ca7086affd35f463ca2fc1799584fb6aa89883cf0af8e3664d6a02d55" + url: "https://pub.dev" + source: hosted + version: "2.3.2" + dartx: + dependency: transitive + description: + name: dartx + sha256: "8b25435617027257d43e6508b5fe061012880ddfdaa75a71d607c3de2a13d244" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + dio: + dependency: "direct main" + description: + name: dio + sha256: aff32c08f92787a557dd5c0145ac91536481831a01b4648136373cddb0e64f8c + url: "https://pub.dev" + source: hosted + version: "5.9.2" + dio_web_adapter: + dependency: transitive + description: + name: dio_web_adapter + sha256: "2f9e64323a7c3c7ef69567d5c800424a11f8337b8b228bad02524c9fb3c1f340" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + equatable: + dependency: "direct main" + description: + name: equatable + sha256: "3e0141505477fd8ad55d6eb4e7776d3fe8430be8e497ccb1521370c3f21a3e2b" + url: "https://pub.dev" + source: hosted + version: "2.0.8" + fake_async: + dependency: transitive + description: + name: fake_async + sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44" + url: "https://pub.dev" + source: hosted + version: "1.3.3" + ffi: + dependency: transitive + description: + name: ffi + sha256: "6d7fd89431262d8f3125e81b50d3847a091d846eafcd4fdb88dd06f36d705a45" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + file: + dependency: transitive + description: + name: file + sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4 + url: "https://pub.dev" + source: hosted + version: "7.0.1" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be + url: "https://pub.dev" + source: hosted + version: "1.1.1" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_bloc: + dependency: "direct main" + description: + name: flutter_bloc + sha256: b594505eac31a0518bdcb4b5b79573b8d9117b193cc80cc12e17d639b10aa27a + url: "https://pub.dev" + source: hosted + version: "8.1.6" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: "9e8c3858111da373efc5aa341de011d9bd23e2c5c5e0c62bccf32438e192d7b1" + url: "https://pub.dev" + source: hosted + version: "3.0.2" + flutter_localizations: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + freezed: + dependency: "direct dev" + description: + name: freezed + sha256: a434911f643466d78462625df76fd9eb13e57348ff43fe1f77bbe909522c67a1 + url: "https://pub.dev" + source: hosted + version: "2.5.2" + freezed_annotation: + dependency: "direct main" + description: + name: freezed_annotation + sha256: c2e2d632dd9b8a2b7751117abcfc2b4888ecfe181bd9fca7170d9ef02e595fe2 + url: "https://pub.dev" + source: hosted + version: "2.4.4" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + sha256: f64a0333a82f30b0cca061bc3d143813a486dc086b574bfb233b7c1372427694 + url: "https://pub.dev" + source: hosted + version: "4.0.0" + get_it: + dependency: "direct main" + description: + name: get_it + sha256: d85128a5dae4ea777324730dc65edd9c9f43155c109d5cc0a69cab74139fbac1 + url: "https://pub.dev" + source: hosted + version: "7.7.0" + glob: + dependency: transitive + description: + name: glob + sha256: c3f1ee72c96f8f78935e18aa8cecced9ab132419e8625dc187e1c2408efc20de + url: "https://pub.dev" + source: hosted + version: "2.1.3" + graphs: + dependency: transitive + description: + name: graphs + sha256: "741bbf84165310a68ff28fe9e727332eef1407342fca52759cb21ad8177bb8d0" + url: "https://pub.dev" + source: hosted + version: "2.3.2" + hooks: + dependency: transitive + description: + name: hooks + sha256: "025f060e86d2d4c3c47b56e33caf7f93bf9283340f26d23424ebcfccf34f621e" + url: "https://pub.dev" + source: hosted + version: "1.0.3" + http: + dependency: transitive + description: + name: http + sha256: "87721a4a50b19c7f1d49001e51409bddc46303966ce89a65af4f4e6004896412" + url: "https://pub.dev" + source: hosted + version: "1.6.0" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + sha256: aa6199f908078bb1c5efb8d8638d4ae191aac11b311132c3ef48ce352fb52ef8 + url: "https://pub.dev" + source: hosted + version: "3.2.2" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571" + url: "https://pub.dev" + source: hosted + version: "4.1.2" + injectable: + dependency: "direct main" + description: + name: injectable + sha256: "29559f7e3daebf0084597de86a825ae7f149d9e30264b7fbc71d1069ae82697d" + url: "https://pub.dev" + source: hosted + version: "2.6.0" + injectable_generator: + dependency: "direct dev" + description: + name: injectable_generator + sha256: "7fb573114f8bbdd169f7ae9b0bcd13f464e8170454c27be816d5a1bb39ac8086" + url: "https://pub.dev" + source: hosted + version: "2.4.2" + intl: + dependency: "direct main" + description: + name: intl + sha256: "3df61194eb431efc39c4ceba583b95633a403f46c9fd341e550ce0bfa50e9aa5" + url: "https://pub.dev" + source: hosted + version: "0.20.2" + io: + dependency: transitive + description: + name: io + sha256: dfd5a80599cf0165756e3181807ed3e77daf6dd4137caaad72d0b7931597650b + url: "https://pub.dev" + source: hosted + version: "1.0.5" + isar: + dependency: "direct main" + description: + name: isar + sha256: "99165dadb2cf2329d3140198363a7e7bff9bbd441871898a87e26914d25cf1ea" + url: "https://pub.dev" + source: hosted + version: "3.1.0+1" + isar_flutter_libs: + dependency: "direct main" + description: + name: isar_flutter_libs + sha256: bc6768cc4b9c61aabff77152e7f33b4b17d2fc93134f7af1c3dd51500fe8d5e8 + url: "https://pub.dev" + source: hosted + version: "3.1.0+1" + isar_generator: + dependency: "direct dev" + description: + name: isar_generator + sha256: "76c121e1295a30423604f2f819bc255bc79f852f3bc8743a24017df6068ad133" + url: "https://pub.dev" + source: hosted + version: "3.1.0+1" + jni: + dependency: transitive + description: + name: jni + sha256: c2230682d5bc2362c1c9e8d3c7f406d9cbba23ab3f2e203a025dd47e0fb2e68f + url: "https://pub.dev" + source: hosted + version: "1.0.0" + jni_flutter: + dependency: transitive + description: + name: jni_flutter + sha256: "8b59e590786050b1cd866677dddaf76b1ade5e7bc751abe04b86e84d379d3ba6" + url: "https://pub.dev" + source: hosted + version: "1.0.1" + js: + dependency: transitive + description: + name: js + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + url: "https://pub.dev" + source: hosted + version: "0.6.7" + json_annotation: + dependency: "direct main" + description: + name: json_annotation + sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1" + url: "https://pub.dev" + source: hosted + version: "4.9.0" + json_serializable: + dependency: "direct dev" + description: + name: json_serializable + sha256: ea1432d167339ea9b5bb153f0571d0039607a873d6e04e0117af043f14a1fd4b + url: "https://pub.dev" + source: hosted + version: "6.8.0" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de" + url: "https://pub.dev" + source: hosted + version: "11.0.2" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1" + url: "https://pub.dev" + source: hosted + version: "3.0.10" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1" + url: "https://pub.dev" + source: hosted + version: "3.0.2" + lints: + dependency: transitive + description: + name: lints + sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290 + url: "https://pub.dev" + source: hosted + version: "3.0.0" + logging: + dependency: transitive + description: + name: logging + sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 + url: "https://pub.dev" + source: hosted + version: "1.3.0" + matcher: + dependency: transitive + description: + name: matcher + sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861 + url: "https://pub.dev" + source: hosted + version: "0.12.19" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b" + url: "https://pub.dev" + source: hosted + version: "0.13.0" + message_pack_dart: + dependency: transitive + description: + name: message_pack_dart + sha256: "71b9f0ff60e5896e60b337960bb535380d7dba3297b457ac763ccae807385b59" + url: "https://pub.dev" + source: hosted + version: "2.0.1" + meta: + dependency: transitive + description: + name: meta + sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394" + url: "https://pub.dev" + source: hosted + version: "1.17.0" + mime: + dependency: transitive + description: + name: mime + sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6" + url: "https://pub.dev" + source: hosted + version: "2.0.0" + native_toolchain_c: + dependency: transitive + description: + name: native_toolchain_c + sha256: "6ba77bb18063eebe9de401f5e6437e95e1438af0a87a3a39084fbd37c90df572" + url: "https://pub.dev" + source: hosted + version: "0.17.6" + nested: + dependency: transitive + description: + name: nested + sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20" + url: "https://pub.dev" + source: hosted + version: "1.0.0" + objective_c: + dependency: transitive + description: + name: objective_c + sha256: "100a1c87616ab6ed41ec263b083c0ef3261ee6cd1dc3b0f35f8ddfa4f996fe52" + url: "https://pub.dev" + source: hosted + version: "9.3.0" + package_config: + dependency: transitive + description: + name: package_config + sha256: f096c55ebb7deb7e384101542bfba8c52696c1b56fca2eb62827989ef2353bbc + url: "https://pub.dev" + source: hosted + version: "2.2.0" + path: + dependency: transitive + description: + name: path + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" + url: "https://pub.dev" + source: hosted + version: "1.9.1" + path_provider: + dependency: "direct main" + description: + name: path_provider + sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd" + url: "https://pub.dev" + source: hosted + version: "2.1.5" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + sha256: "69cbd515a62b94d32a7944f086b2f82b4ac40a1d45bebfc00813a430ab2dabcd" + url: "https://pub.dev" + source: hosted + version: "2.3.1" + path_provider_foundation: + dependency: transitive + description: + name: path_provider_foundation + sha256: "2a376b7d6392d80cd3705782d2caa734ca4727776db0b6ec36ef3f1855197699" + url: "https://pub.dev" + source: hosted + version: "2.6.0" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279 + url: "https://pub.dev" + source: hosted + version: "2.2.1" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7 + url: "https://pub.dev" + source: hosted + version: "2.3.0" + petitparser: + dependency: transitive + description: + name: petitparser + sha256: "91bd59303e9f769f108f8df05e371341b15d59e995e6806aefab827b58336675" + url: "https://pub.dev" + source: hosted + version: "7.0.2" + platform: + dependency: transitive + description: + name: platform + sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984" + url: "https://pub.dev" + source: hosted + version: "3.1.6" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" + source: hosted + version: "2.1.8" + pool: + dependency: transitive + description: + name: pool + sha256: "978783255c543aa3586a1b3c21f6e9d720eb315376a915872c61ef8b5c20177d" + url: "https://pub.dev" + source: hosted + version: "1.5.2" + provider: + dependency: transitive + description: + name: provider + sha256: "4e82183fa20e5ca25703ead7e05de9e4cceed1fbd1eadc1ac3cb6f565a09f272" + url: "https://pub.dev" + source: hosted + version: "6.1.5+1" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "5bfcf68ca79ef689f8990d1160781b4bad40a3bd5e5218ad4076ddb7f4081585" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + pubspec_parse: + dependency: transitive + description: + name: pubspec_parse + sha256: "0560ba233314abbed0a48a2956f7f022cce7c3e1e73df540277da7544cad4082" + url: "https://pub.dev" + source: hosted + version: "1.5.0" + recase: + dependency: transitive + description: + name: recase + sha256: e4eb4ec2dcdee52dcf99cb4ceabaffc631d7424ee55e56f280bc039737f89213 + url: "https://pub.dev" + source: hosted + version: "4.1.0" + record_use: + dependency: transitive + description: + name: record_use + sha256: "2551bd8eecfe95d14ae75f6021ad0248be5c27f138c2ec12fcb52b500b3ba1ed" + url: "https://pub.dev" + source: hosted + version: "0.6.0" + shared_preferences: + dependency: "direct main" + description: + name: shared_preferences + sha256: c3025c5534b01739267eb7d76959bbc25a6d10f6988e1c2a3036940133dd10bf + url: "https://pub.dev" + source: hosted + version: "2.5.5" + shared_preferences_android: + dependency: transitive + description: + name: shared_preferences_android + sha256: e8d4762b1e2e8578fc4d0fd548cebf24afd24f49719c08974df92834565e2c53 + url: "https://pub.dev" + source: hosted + version: "2.4.23" + shared_preferences_foundation: + dependency: transitive + description: + name: shared_preferences_foundation + sha256: "4e7eaffc2b17ba398759f1151415869a34771ba11ebbccd1b0145472a619a64f" + url: "https://pub.dev" + source: hosted + version: "2.5.6" + shared_preferences_linux: + dependency: transitive + description: + name: shared_preferences_linux + sha256: "580abfd40f415611503cae30adf626e6656dfb2f0cee8f465ece7b6defb40f2f" + url: "https://pub.dev" + source: hosted + version: "2.4.1" + shared_preferences_platform_interface: + dependency: transitive + description: + name: shared_preferences_platform_interface + sha256: "649dc798a33931919ea356c4305c2d1f81619ea6e92244070b520187b5140ef9" + url: "https://pub.dev" + source: hosted + version: "2.4.2" + shared_preferences_web: + dependency: transitive + description: + name: shared_preferences_web + sha256: c49bd060261c9a3f0ff445892695d6212ff603ef3115edbb448509d407600019 + url: "https://pub.dev" + source: hosted + version: "2.4.3" + shared_preferences_windows: + dependency: transitive + description: + name: shared_preferences_windows + sha256: "94ef0f72b2d71bc3e700e025db3710911bd51a71cefb65cc609dd0d9a982e3c1" + url: "https://pub.dev" + source: hosted + version: "2.4.1" + shelf: + dependency: transitive + description: + name: shelf + sha256: e7dd780a7ffb623c57850b33f43309312fc863fb6aa3d276a754bb299839ef12 + url: "https://pub.dev" + source: hosted + version: "1.4.2" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + sha256: cc36c297b52866d203dbf9332263c94becc2fe0ceaa9681d07b6ef9807023b67 + url: "https://pub.dev" + source: hosted + version: "2.0.1" + signalr_netcore: + dependency: "direct main" + description: + name: signalr_netcore + sha256: "8d59dc61284c5ff8aa27c4e3e802fcf782367f06cf42b39d5ded81680b72f8b8" + url: "https://pub.dev" + source: hosted + version: "1.4.4" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + source_gen: + dependency: transitive + description: + name: source_gen + sha256: "14658ba5f669685cd3d63701d01b31ea748310f7ab854e471962670abcf57832" + url: "https://pub.dev" + source: hosted + version: "1.5.0" + source_helper: + dependency: transitive + description: + name: source_helper + sha256: "86d247119aedce8e63f4751bd9626fc9613255935558447569ad42f9f5b48b3c" + url: "https://pub.dev" + source: hosted + version: "1.3.5" + source_span: + dependency: transitive + description: + name: source_span + sha256: "56a02f1f4cd1a2d96303c0144c93bd6d909eea6bee6bf5a0e0b685edbd4c47ab" + url: "https://pub.dev" + source: hosted + version: "1.10.2" + sse: + dependency: transitive + description: + name: sse + sha256: a9a804dbde8bfd369da3b4aa241d44d63a6486a97388c54ec166073d88c52302 + url: "https://pub.dev" + source: hosted + version: "4.2.0" + sse_channel: + dependency: transitive + description: + name: sse_channel + sha256: "9aad5d4eef63faf6ecdefb636c0f857bd6f74146d2196087dcf4b17ab5b49b1b" + url: "https://pub.dev" + source: hosted + version: "0.1.1" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" + url: "https://pub.dev" + source: hosted + version: "1.12.1" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + stream_transform: + dependency: transitive + description: + name: stream_transform + sha256: ad47125e588cfd37a9a7f86c7d6356dde8dfe89d071d293f80ca9e9273a33871 + url: "https://pub.dev" + source: hosted + version: "2.1.1" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" + url: "https://pub.dev" + source: hosted + version: "1.4.1" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" + url: "https://pub.dev" + source: hosted + version: "1.2.2" + test_api: + dependency: transitive + description: + name: test_api + sha256: "8161c84903fd860b26bfdefb7963b3f0b68fee7adea0f59ef805ecca346f0c7a" + url: "https://pub.dev" + source: hosted + version: "0.7.10" + time: + dependency: transitive + description: + name: time + sha256: "46187cf30bffdab28c56be9a63861b36e4ab7347bf403297595d6a97e10c789f" + url: "https://pub.dev" + source: hosted + version: "2.1.6" + timing: + dependency: transitive + description: + name: timing + sha256: "62ee18aca144e4a9f29d212f5a4c6a053be252b895ab14b5821996cff4ed90fe" + url: "https://pub.dev" + source: hosted + version: "1.0.2" + tuple: + dependency: transitive + description: + name: tuple + sha256: a97ce2013f240b2f3807bcbaf218765b6f301c3eff91092bcfa23a039e7dd151 + url: "https://pub.dev" + source: hosted + version: "2.0.2" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006 + url: "https://pub.dev" + source: hosted + version: "1.4.0" + uuid: + dependency: transitive + description: + name: uuid + sha256: "1fef9e8e11e2991bb773070d4656b7bd5d850967a2456cfc83cf47925ba79489" + url: "https://pub.dev" + source: hosted + version: "4.5.3" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b + url: "https://pub.dev" + source: hosted + version: "2.2.0" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: "0016aef94fc66495ac78af5859181e3f3bf2026bd8eecc72b9565601e19ab360" + url: "https://pub.dev" + source: hosted + version: "15.2.0" + watcher: + dependency: transitive + description: + name: watcher + sha256: "1398c9f081a753f9226febe8900fce8f7d0a67163334e1c94a2438339d79d635" + url: "https://pub.dev" + source: hosted + version: "1.2.1" + web: + dependency: transitive + description: + name: web + sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a" + url: "https://pub.dev" + source: hosted + version: "1.1.1" + web_socket: + dependency: transitive + description: + name: web_socket + sha256: "34d64019aa8e36bf9842ac014bb5d2f5586ca73df5e4d9bf5c936975cae6982c" + url: "https://pub.dev" + source: hosted + version: "1.0.1" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + sha256: d645757fb0f4773d602444000a8131ff5d48c9e47adfe9772652dd1a4f2d45c8 + url: "https://pub.dev" + source: hosted + version: "3.0.3" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + xml: + dependency: transitive + description: + name: xml + sha256: "971043b3a0d3da28727e40ed3e0b5d18b742fa5a68665cca88e74b7876d5e025" + url: "https://pub.dev" + source: hosted + version: "6.6.1" + xxh3: + dependency: transitive + description: + name: xxh3 + sha256: "399a0438f5d426785723c99da6b16e136f4953fb1e9db0bf270bd41dd4619916" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + yaml: + dependency: transitive + description: + name: yaml + sha256: b9da305ac7c39faa3f030eccd175340f968459dae4af175130b3fc47e40d76ce + url: "https://pub.dev" + source: hosted + version: "3.1.3" +sdks: + dart: ">=3.11.0 <4.0.0" + flutter: ">=3.38.4" diff --git a/client-mobile/pubspec.yaml b/client-mobile/pubspec.yaml new file mode 100644 index 0000000..2340848 --- /dev/null +++ b/client-mobile/pubspec.yaml @@ -0,0 +1,62 @@ +name: messenger_app +description: A Telegram-like mobile messenger application built with Flutter. +publish_to: 'none' +version: 1.0.0+1 + +environment: + sdk: '>=3.0.0 <4.0.0' + +dependencies: + flutter: + sdk: flutter + + # State Management + flutter_bloc: ^8.1.3 + bloc: ^8.1.2 + + # Architecture & DI + get_it: ^7.6.4 + injectable: ^2.3.2 + freezed_annotation: ^2.4.1 + json_annotation: ^4.9.0 + + # Network & Real-time + dio: ^5.4.0 + signalr_netcore: ^1.3.0 + + # Navigation + auto_route: ^7.8.4 + + # Database + isar: ^3.1.0+1 + isar_flutter_libs: ^3.1.0+1 + path_provider: ^2.1.1 + + # UI + cupertino_icons: ^1.0.6 + equatable: ^2.0.5 + + # Localization + flutter_localizations: + sdk: flutter + intl: ^0.20.2 + + # Local Storage + shared_preferences: ^2.2.2 + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^3.0.1 + + # Code Generation + build_runner: ^2.4.7 + injectable_generator: ^2.4.1 + freezed: ^2.4.6 + json_serializable: ^6.7.0 + auto_route_generator: ^7.3.2 + isar_generator: ^3.1.0+1 + +flutter: + uses-material-design: true + generate: true diff --git a/client-mobile/test/widget_test.dart b/client-mobile/test/widget_test.dart new file mode 100644 index 0000000..4de63ca --- /dev/null +++ b/client-mobile/test/widget_test.dart @@ -0,0 +1,10 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:messenger_app/app.dart'; + +void main() { + testWidgets('App launches with MainScreen', (WidgetTester tester) async { + await tester.pumpWidget(const MessengerApp()); + expect(find.byType(MaterialApp), findsOneWidget); + }); +} diff --git a/client-mobile/web/index.html b/client-mobile/web/index.html new file mode 100644 index 0000000..267c125 --- /dev/null +++ b/client-mobile/web/index.html @@ -0,0 +1,25 @@ + + + + + + + + + + + + messenger_app + + + + + + + diff --git a/client-mobile/windows/runner/main.cpp b/client-mobile/windows/runner/main.cpp new file mode 100644 index 0000000..7220076 --- /dev/null +++ b/client-mobile/windows/runner/main.cpp @@ -0,0 +1,43 @@ +#include +#include +#include + +#include "flutter_window.h" +#include "utils.h" + +int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, + _In_ wchar_t *command_line, _In_ int show_command) { + // Attach to console when present (e.g., 'flutter run') or create a + // new console when running with a debugger. + if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { + CreateAndAttachConsole(); + } + + // Initialize COM, so that it is available for use in the library and/or + // plugins. + ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); + + flutter::DartProject project(L"data"); + + std::vector command_line_arguments = + GetCommandLineArguments(); + + project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); + + FlutterWindow window(project); + Win32Window::Point origin(10, 10); + Win32Window::Size size(1280, 720); + if (!window.Create(L"messenger_app", origin, size)) { + return EXIT_FAILURE; + } + window.SetQuitOnClose(true); + + ::MSG msg; + while (::GetMessage(&msg, nullptr, 0, 0)) { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + + ::CoUninitialize(); + return EXIT_SUCCESS; +}