diff --git a/flutter_course/.gitignore b/flutter_course/.gitignore
new file mode 100644
index 0000000..0fa6b67
--- /dev/null
+++ b/flutter_course/.gitignore
@@ -0,0 +1,46 @@
+# Miscellaneous
+*.class
+*.log
+*.pyc
+*.swp
+.DS_Store
+.atom/
+.buildlog/
+.history
+.svn/
+
+# 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/
+
+# Web related
+lib/generated_plugin_registrant.dart
+
+# 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/flutter_course/.metadata b/flutter_course/.metadata
new file mode 100644
index 0000000..6d6bd83
--- /dev/null
+++ b/flutter_course/.metadata
@@ -0,0 +1,30 @@
+# 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.
+
+version:
+ revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
+ channel: stable
+
+project_type: app
+
+# Tracks metadata for the flutter migrate command
+migration:
+ platforms:
+ - platform: root
+ create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
+ base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
+ - platform: android
+ create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
+ base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
+
+ # User provided section
+
+ # List of Local paths (relative to this file) that should be
+ # ignored by the migrate tool.
+ #
+ # Files that are not part of the templates will be ignored by default.
+ unmanaged_files:
+ - 'lib/main.dart'
+ - 'ios/Runner.xcodeproj/project.pbxproj'
diff --git a/flutter_course/README.md b/flutter_course/README.md
new file mode 100644
index 0000000..adc5de3
--- /dev/null
+++ b/flutter_course/README.md
@@ -0,0 +1,16 @@
+# flutter_first
+
+Course project of Epic school
+
+## Getting Started
+
+This project is a starting point for a Flutter application.
+
+A few resources to get you started if this is your first Flutter project:
+
+- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
+- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
+
+For help getting started with Flutter development, view the
+[online documentation](https://docs.flutter.dev/), which offers tutorials,
+samples, guidance on mobile development, and a full API reference.
diff --git a/flutter_course/analysis_options.yaml b/flutter_course/analysis_options.yaml
new file mode 100644
index 0000000..61b6c4d
--- /dev/null
+++ b/flutter_course/analysis_options.yaml
@@ -0,0 +1,29 @@
+# This file configures the analyzer, which statically analyzes Dart code to
+# check for errors, warnings, and lints.
+#
+# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
+# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
+# invoked from the command line by running `flutter analyze`.
+
+# The following line activates a set of recommended lints for Flutter apps,
+# packages, and plugins designed to encourage good coding practices.
+include: package:flutter_lints/flutter.yaml
+
+linter:
+ # The lint rules applied to this project can be customized in the
+ # section below to disable rules from the `package:flutter_lints/flutter.yaml`
+ # included above or to enable additional rules. A list of all available lints
+ # and their documentation is published at
+ # https://dart-lang.github.io/linter/lints/index.html.
+ #
+ # Instead of disabling a lint rule for the entire project in the
+ # section below, it can also be suppressed for a single line of code
+ # or a specific dart file by using the `// ignore: name_of_lint` and
+ # `// ignore_for_file: name_of_lint` syntax on the line or in the file
+ # producing the lint.
+ rules:
+ # avoid_print: false # Uncomment to disable the `avoid_print` rule
+ # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
+
+# Additional information about this file can be found at
+# https://dart.dev/guides/language/analysis-options
diff --git a/flutter_course/android/.gitignore b/flutter_course/android/.gitignore
new file mode 100644
index 0000000..6f56801
--- /dev/null
+++ b/flutter_course/android/.gitignore
@@ -0,0 +1,13 @@
+gradle-wrapper.jar
+/.gradle
+/captures/
+/gradlew
+/gradlew.bat
+/local.properties
+GeneratedPluginRegistrant.java
+
+# Remember to never publicly share your keystore.
+# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
+key.properties
+**/*.keystore
+**/*.jks
diff --git a/flutter_course/android/app/build.gradle b/flutter_course/android/app/build.gradle
new file mode 100644
index 0000000..2405c65
--- /dev/null
+++ b/flutter_course/android/app/build.gradle
@@ -0,0 +1,71 @@
+def localProperties = new Properties()
+def localPropertiesFile = rootProject.file('local.properties')
+if (localPropertiesFile.exists()) {
+ localPropertiesFile.withReader('UTF-8') { reader ->
+ localProperties.load(reader)
+ }
+}
+
+def flutterRoot = localProperties.getProperty('flutter.sdk')
+if (flutterRoot == null) {
+ throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
+}
+
+def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
+if (flutterVersionCode == null) {
+ flutterVersionCode = '1'
+}
+
+def flutterVersionName = localProperties.getProperty('flutter.versionName')
+if (flutterVersionName == null) {
+ flutterVersionName = '1.0'
+}
+
+apply plugin: 'com.android.application'
+apply plugin: 'kotlin-android'
+apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
+
+android {
+ compileSdkVersion flutter.compileSdkVersion
+ ndkVersion flutter.ndkVersion
+
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+
+ kotlinOptions {
+ jvmTarget = '1.8'
+ }
+
+ sourceSets {
+ main.java.srcDirs += 'src/main/kotlin'
+ }
+
+ defaultConfig {
+ // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
+ applicationId "ru.rtkit.flutter_first"
+ // You can update the following values to match your application needs.
+ // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
+ minSdkVersion flutter.minSdkVersion
+ targetSdkVersion flutter.targetSdkVersion
+ versionCode flutterVersionCode.toInteger()
+ versionName flutterVersionName
+ }
+
+ buildTypes {
+ release {
+ // TODO: Add your own signing config for the release build.
+ // Signing with the debug keys for now, so `flutter run --release` works.
+ signingConfig signingConfigs.debug
+ }
+ }
+}
+
+flutter {
+ source '../..'
+}
+
+dependencies {
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
+}
diff --git a/flutter_course/android/app/src/debug/AndroidManifest.xml b/flutter_course/android/app/src/debug/AndroidManifest.xml
new file mode 100644
index 0000000..d5f50c9
--- /dev/null
+++ b/flutter_course/android/app/src/debug/AndroidManifest.xml
@@ -0,0 +1,8 @@
+
+
+
+
diff --git a/flutter_course/android/app/src/main/AndroidManifest.xml b/flutter_course/android/app/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..ac9c217
--- /dev/null
+++ b/flutter_course/android/app/src/main/AndroidManifest.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/flutter_course/android/app/src/main/kotlin/ru/rtkit/flutter_first/MainActivity.kt b/flutter_course/android/app/src/main/kotlin/ru/rtkit/flutter_first/MainActivity.kt
new file mode 100644
index 0000000..f48de95
--- /dev/null
+++ b/flutter_course/android/app/src/main/kotlin/ru/rtkit/flutter_first/MainActivity.kt
@@ -0,0 +1,6 @@
+package ru.rtkit.flutter_first
+
+import io.flutter.embedding.android.FlutterActivity
+
+class MainActivity: FlutterActivity() {
+}
diff --git a/flutter_course/android/app/src/main/res/drawable-v21/launch_background.xml b/flutter_course/android/app/src/main/res/drawable-v21/launch_background.xml
new file mode 100644
index 0000000..f74085f
--- /dev/null
+++ b/flutter_course/android/app/src/main/res/drawable-v21/launch_background.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
diff --git a/flutter_course/android/app/src/main/res/drawable/launch_background.xml b/flutter_course/android/app/src/main/res/drawable/launch_background.xml
new file mode 100644
index 0000000..304732f
--- /dev/null
+++ b/flutter_course/android/app/src/main/res/drawable/launch_background.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
diff --git a/flutter_course/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/flutter_course/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 0000000..db77bb4
Binary files /dev/null and b/flutter_course/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/flutter_course/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/flutter_course/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000..17987b7
Binary files /dev/null and b/flutter_course/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/flutter_course/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/flutter_course/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..09d4391
Binary files /dev/null and b/flutter_course/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/flutter_course/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/flutter_course/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..d5f1c8d
Binary files /dev/null and b/flutter_course/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/flutter_course/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/flutter_course/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 0000000..4d6372e
Binary files /dev/null and b/flutter_course/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/flutter_course/android/app/src/main/res/values-night/styles.xml b/flutter_course/android/app/src/main/res/values-night/styles.xml
new file mode 100644
index 0000000..06952be
--- /dev/null
+++ b/flutter_course/android/app/src/main/res/values-night/styles.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
diff --git a/flutter_course/android/app/src/main/res/values/styles.xml b/flutter_course/android/app/src/main/res/values/styles.xml
new file mode 100644
index 0000000..cb1ef88
--- /dev/null
+++ b/flutter_course/android/app/src/main/res/values/styles.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
diff --git a/flutter_course/android/app/src/profile/AndroidManifest.xml b/flutter_course/android/app/src/profile/AndroidManifest.xml
new file mode 100644
index 0000000..d5f50c9
--- /dev/null
+++ b/flutter_course/android/app/src/profile/AndroidManifest.xml
@@ -0,0 +1,8 @@
+
+
+
+
diff --git a/flutter_course/android/build.gradle b/flutter_course/android/build.gradle
new file mode 100644
index 0000000..83ae220
--- /dev/null
+++ b/flutter_course/android/build.gradle
@@ -0,0 +1,31 @@
+buildscript {
+ ext.kotlin_version = '1.6.10'
+ repositories {
+ google()
+ mavenCentral()
+ }
+
+ dependencies {
+ classpath 'com.android.tools.build:gradle:7.1.2'
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
+ }
+}
+
+allprojects {
+ repositories {
+ google()
+ mavenCentral()
+ }
+}
+
+rootProject.buildDir = '../build'
+subprojects {
+ project.buildDir = "${rootProject.buildDir}/${project.name}"
+}
+subprojects {
+ project.evaluationDependsOn(':app')
+}
+
+task clean(type: Delete) {
+ delete rootProject.buildDir
+}
diff --git a/flutter_course/android/gradle.properties b/flutter_course/android/gradle.properties
new file mode 100644
index 0000000..94adc3a
--- /dev/null
+++ b/flutter_course/android/gradle.properties
@@ -0,0 +1,3 @@
+org.gradle.jvmargs=-Xmx1536M
+android.useAndroidX=true
+android.enableJetifier=true
diff --git a/flutter_course/android/gradle/wrapper/gradle-wrapper.properties b/flutter_course/android/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..cc5527d
--- /dev/null
+++ b/flutter_course/android/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Fri Jun 23 08:50:38 CEST 2017
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
diff --git a/flutter_course/android/settings.gradle b/flutter_course/android/settings.gradle
new file mode 100644
index 0000000..44e62bc
--- /dev/null
+++ b/flutter_course/android/settings.gradle
@@ -0,0 +1,11 @@
+include ':app'
+
+def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
+def properties = new Properties()
+
+assert localPropertiesFile.exists()
+localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
+
+def flutterSdkPath = properties.getProperty("flutter.sdk")
+assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
+apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
diff --git a/flutter_course/lib/api_service.dart b/flutter_course/lib/api_service.dart
new file mode 100644
index 0000000..b5ffbc7
--- /dev/null
+++ b/flutter_course/lib/api_service.dart
@@ -0,0 +1,57 @@
+
+import 'package:dio/dio.dart';
+import 'models/movie_model.dart';
+import 'models/review_model.dart';
+import 'models/api_model.dart';
+
+
+const _baseUrl = 'https://api.kinopoisk.dev';
+const _apiKey = 'ZQQ8GMN-TN54SGK-NB3MKEC-ZKB8V06';
+
+abstract class ApiService {
+ Future?, Failure>> getMovies();
+ Future?, Failure>> getReviews(int movieId);
+}
+
+
+
+class ApiServiceDio implements ApiService {
+ static final ApiServiceDio _instance = ApiServiceDio._();
+
+ ApiServiceDio._();
+
+ static ApiServiceDio get instance => _instance;
+
+ final Dio dio = Dio()..options.baseUrl = _baseUrl;
+
+ @override
+ Future?, Failure>> getMovies() async {
+ try {
+ final response = await dio.get('/movie?field=rating.kp&search=5-10&field=year&search=2021-2022&field=typeNumber&search=1&sortField=year&sortType=1&sortField=votes.imdb&sortType=-1&token=$_apiKey');
+
+ final list = response.data['docs'] as List;
+
+ final models = list.map((e) => Docs.fromJson(e));
+
+ return ApiModel.success(models.toList());
+ } catch (e) {
+ return ApiModel.error(Failure());
+ }
+ }
+
+ @override
+ Future?, Failure>> getReviews(int movieId) async {
+ try {
+ final response = await dio.get('/review?field=movieId&search=$movieId&&token=$_apiKey');
+
+ final list = response.data['docs'] as List;
+
+ final models = list.map((e) => ReviewDocs.fromJson(e));
+
+ return ApiModel.success(models.toList());
+ } catch (e) {
+ return ApiModel.error(Failure());
+ }
+ }
+
+}
diff --git a/flutter_course/lib/bloc/movie_bloc.dart b/flutter_course/lib/bloc/movie_bloc.dart
new file mode 100644
index 0000000..b9651b9
--- /dev/null
+++ b/flutter_course/lib/bloc/movie_bloc.dart
@@ -0,0 +1,116 @@
+import 'package:bloc/bloc.dart';
+import 'package:shared_preferences/shared_preferences.dart';
+
+import '../api_service.dart';
+
+abstract class MovieEvent {}
+
+class LoadMovieEvent extends MovieEvent {}
+
+class AddToBookmarkEvent extends MovieEvent {
+ final int movieId;
+
+ AddToBookmarkEvent(this.movieId);
+}
+
+class DeleteFromBookmarkEvent extends MovieEvent {
+ final int movieId;
+
+ DeleteFromBookmarkEvent(this.movieId);
+}
+
+
+abstract class MovieState {}
+
+class MovieInitialState extends MovieState {}
+
+class MovieLoadingState extends MovieState {}
+
+class MovieErrorState extends MovieState {
+ final String message;
+
+ MovieErrorState(this.message);
+}
+
+class MovieLoadedState extends MovieState {
+ MovieLoadedState({
+ this.movies = const [],
+ this.favoritesId = const {},
+ });
+
+ final List? movies;
+ Set favoritesId = {};
+
+ MovieLoadedState copyWith({
+ List? movies,
+ Set? favoritesId,
+
+ }) {
+ return MovieLoadedState(
+ movies: movies ?? this.movies,
+ favoritesId: favoritesId ?? this.favoritesId,
+ );
+ }
+}
+
+Set toSet(Set strings) {
+ return strings.fold>({}, (previousValue, value) {
+ final parsed = int.tryParse(value);
+ if (parsed != null) {
+ previousValue.add(parsed);
+ }
+ return previousValue;
+ });
+}
+
+class MovieBloc extends Bloc {
+ MovieBloc({
+ required ApiService service,
+ required SharedPreferences storage,
+ }) : super(MovieInitialState()) {
+ on((
+ LoadMovieEvent event,
+ Emitter emit,
+ ) async {
+ emit(MovieLoadingState());
+ try {
+ final movies = await service.getMovies();
+
+ final Set favorites = toSet(Set.of((storage.getString('favorites') ?? '').split(';')));
+
+
+ emit(MovieLoadedState(
+ movies: movies.result!,
+ favoritesId: favorites,
+ ));
+ } catch (e) {
+ emit(MovieErrorState(e.toString()));
+ }
+ });
+
+ on((
+ AddToBookmarkEvent event,
+ Emitter emit,
+ ) async {
+ if (state is MovieLoadedState) {
+ Set next = Set.from((state as MovieLoadedState).favoritesId);
+ next.add(event.movieId);
+ await storage.setString('favorites', next.join(';'));
+ emit((state as MovieLoadedState).copyWith(favoritesId: next));
+ }
+ });
+
+ on((
+ DeleteFromBookmarkEvent event,
+ Emitter emit,
+ ) async {
+ if (state is MovieLoadedState) {
+ Set next = Set.from((state as MovieLoadedState).favoritesId);
+ next.remove(event.movieId);
+
+ await storage.setString('favorites', next.join(';'));
+ emit((state as MovieLoadedState).copyWith(favoritesId: next));
+ }
+ });
+ }
+}
diff --git a/flutter_course/lib/enums.dart b/flutter_course/lib/enums.dart
new file mode 100644
index 0000000..5e9e35d
--- /dev/null
+++ b/flutter_course/lib/enums.dart
@@ -0,0 +1,15 @@
+enum ContentState {
+ initial,
+ loading,
+ success,
+ empty,
+ failure,
+}
+
+enum ReviewState {
+ initial,
+ loading,
+ success,
+ empty,
+ failure,
+}
diff --git a/flutter_course/lib/main.dart b/flutter_course/lib/main.dart
new file mode 100644
index 0000000..06ba34c
--- /dev/null
+++ b/flutter_course/lib/main.dart
@@ -0,0 +1,123 @@
+import 'package:flutter/material.dart';
+import 'package:get_it/get_it.dart';
+import 'package:provider/provider.dart';
+import 'package:shared_preferences/shared_preferences.dart';
+import 'api_service.dart';
+import 'bloc/movie_bloc.dart';
+import 'screens/movie_screen.dart';
+import 'theme/theme.dart';
+
+
+
+void main() async {
+ WidgetsFlutterBinding.ensureInitialized();
+ final storage = await SharedPreferences.getInstance();
+
+ final service = ApiServiceDio.instance;
+
+ GetIt.I.registerSingleton(
+ MovieBloc(
+ storage: storage,
+ service: service,
+ )..add(LoadMovieEvent()),
+ );
+
+
+ runApp(
+ MultiProvider(
+ providers: [
+ ChangeNotifierProvider(
+ create: (context) => ThemeState(storage),
+ )
+ ],
+ child: const App(),
+ ),
+ );
+}
+
+
+class App extends StatelessWidget {
+ const App({Key? key}) : super(key: key);
+
+
+ @override
+ Widget build(BuildContext context) {
+ return Consumer(builder: ((context, state, child) {
+
+ return MaterialApp(
+ navigatorKey: navKey,
+ themeMode: state.theme,
+ debugShowCheckedModeBanner: false,
+ theme: ThemeData(
+
+ appBarTheme: AppBarTheme(
+ backgroundColor: Colors.white,
+ elevation: 0,
+ titleTextStyle: TextStyle(
+ color: Colors.black.withOpacity(0.95),
+ fontSize: 18.0,
+ ),
+ ),
+ iconTheme: const IconThemeData(
+ color: Colors.red
+ ),
+ primaryIconTheme: const IconThemeData(
+ color: Colors.black
+ ),
+
+ dividerTheme: const DividerThemeData(
+ color: Colors.black
+ ),
+ textTheme: TextTheme(
+ headline3: TextStyle(
+ color: Colors.black.withOpacity(0.95),
+ ),
+ ),
+ scaffoldBackgroundColor: const Color.fromRGBO(244, 244, 244, 1.0),
+ ),
+ darkTheme: ThemeData(
+ appBarTheme: AppBarTheme(
+ backgroundColor: Colors.black,
+ elevation: 0,
+ titleTextStyle: TextStyle(
+ color: Colors.white.withOpacity(0.95),
+ fontSize: 18.0,
+ ),
+ ),
+ iconTheme: const IconThemeData(
+ color: Colors.white
+ ),
+ primaryIconTheme: const IconThemeData(
+ color: Colors.white
+ ),
+ dividerTheme: const DividerThemeData(
+ color: Colors.white
+ ),
+ textTheme: TextTheme(
+ headline3: TextStyle(
+ color: Colors.white.withOpacity(0.95),
+ ),
+ headline6: TextStyle(
+ color: Colors.white.withOpacity(0.95),
+ ),
+ subtitle1: TextStyle(
+ color: Colors.white.withOpacity(0.95),
+ ),
+ ),
+ scaffoldBackgroundColor: const Color.fromRGBO(11, 11, 15, 1.0),
+ switchTheme: SwitchThemeData(
+ thumbColor: MaterialStateProperty.all(Colors.white12),
+ trackColor: MaterialStateProperty.all(Colors.white),
+ ),
+ ),
+ home: const MovieScreen(),
+ );
+ }));
+ }
+}
+
+
+
+
+
+
diff --git a/flutter_course/lib/models/api_model.dart b/flutter_course/lib/models/api_model.dart
new file mode 100644
index 0000000..9d905ae
--- /dev/null
+++ b/flutter_course/lib/models/api_model.dart
@@ -0,0 +1,21 @@
+class Failure implements Exception {}
+
+class ApiModel {
+ final T? result;
+ final E? failure;
+
+ ApiModel({
+ this.result,
+ this.failure,
+ });
+
+ bool get hasError => failure != null;
+
+ factory ApiModel.success(T result) {
+ return ApiModel(result: result);
+ }
+
+ factory ApiModel.error(E failure) {
+ return ApiModel(failure: failure);
+ }
+}
diff --git a/flutter_course/lib/models/comment_model.dart b/flutter_course/lib/models/comment_model.dart
new file mode 100644
index 0000000..872094f
--- /dev/null
+++ b/flutter_course/lib/models/comment_model.dart
@@ -0,0 +1,22 @@
+class CommentModel {
+ final int postId;
+ final int id;
+ final String name;
+ final String email;
+ final String body;
+
+ CommentModel({
+ required this.postId,
+ required this.id,
+ required this.name,
+ required this.email,
+ required this.body,
+ });
+
+ CommentModel.fromJson(Map json)
+ : postId = json['postId'],
+ id = json['id'],
+ name = json['name'],
+ email = json['email'],
+ body = json['body'];
+}
diff --git a/flutter_course/lib/models/movie_model.dart b/flutter_course/lib/models/movie_model.dart
new file mode 100644
index 0000000..88ea4cd
--- /dev/null
+++ b/flutter_course/lib/models/movie_model.dart
@@ -0,0 +1,176 @@
+class MovieModel {
+ List? docs;
+ int? total;
+ int? limit;
+ int? page;
+ int? pages;
+
+ MovieModel({this.docs, this.total, this.limit, this.page, this.pages});
+
+ MovieModel.fromJson(Map json) {
+ if (json['docs'] != null) {
+ docs = [];
+ json['docs'].forEach((v) {
+ docs!.add(Docs.fromJson(v));
+ });
+ }
+ total = json['total'];
+ limit = json['limit'];
+ page = json['page'];
+ pages = json['pages'];
+ }
+
+
+}
+
+class Docs {
+ Logo? logo;
+ Poster? poster;
+ int? movieLength;
+ int? id;
+ String? type;
+ String? name;
+ String? description;
+ int? year;
+ String? alternativeName;
+ String? enName;
+ List? names;
+ String? shortDescription;
+ String? color;
+ bool? isFavorite;
+
+ Docs(
+ { this.logo,
+ this.poster,
+ this.movieLength,
+ this.id,
+ this.type,
+ this.name,
+ this.description,
+ this.year,
+ this.alternativeName,
+ this.enName,
+ this.names,
+ this.shortDescription,
+ this.color});
+
+ Docs.fromJson(Map json) {
+ logo = json['logo'] != null ? Logo.fromJson(json['logo']) : null;
+ poster =
+ json['poster'] != null ? Poster.fromJson(json['poster']) : null;
+ movieLength = json['movieLength'];
+ id = json['id'];
+ type = json['type'];
+ name = json['name'];
+ description = json['description'];
+ year = json['year'];
+ alternativeName = json['alternativeName'];
+ enName = json['enName'];
+ if (json['names'] != null) {
+ names = [];
+ json['names'].forEach((v) {
+ names!.add(Names.fromJson(v));
+ });
+ }
+ shortDescription = json['shortDescription'];
+ color = json['color'];
+ }
+
+}
+
+class Logo {
+ String? sId;
+ String? url;
+
+ Logo({this.sId, this.url});
+
+ Logo.fromJson(Map json) {
+ sId = json['_id'];
+ url = json['url'];
+ }
+
+}
+
+class Poster {
+ String? sId;
+ String? url;
+ String? previewUrl;
+
+ Poster({this.sId, this.url, this.previewUrl});
+
+ Poster.fromJson(Map json) {
+ sId = json['_id'];
+ url = json['url'];
+ previewUrl = json['previewUrl'];
+ }
+
+
+}
+
+class Rating {
+ String? sId;
+ double? kp;
+ double? imdb;
+ double? filmCritics;
+ double? russianFilmCritics;
+ double? await;
+
+ Rating(
+ {this.sId,
+ this.kp,
+ this.imdb,
+ this.filmCritics,
+ this.russianFilmCritics,
+ this.await});
+
+ Rating.fromJson(Map json) {
+ sId = json['_id'];
+ kp = json['kp'];
+ imdb = json['imdb'];
+ filmCritics = json['filmCritics'];
+ russianFilmCritics = json['russianFilmCritics'];
+ await = json['await'];
+ }
+
+
+}
+
+class Votes {
+ String? sId;
+ int? kp;
+ int? imdb;
+ int? filmCritics;
+ int? russianFilmCritics;
+ int? await;
+
+ Votes(
+ {this.sId,
+ this.kp,
+ this.imdb,
+ this.filmCritics,
+ this.russianFilmCritics,
+ this.await});
+
+ Votes.fromJson(Map json) {
+ sId = json['_id'];
+ kp = json['kp'];
+ imdb = json['imdb'];
+ filmCritics = json['filmCritics'];
+ russianFilmCritics = json['russianFilmCritics'];
+ await = json['await'];
+ }
+
+}
+
+class Names {
+ String? sId;
+ String? name;
+
+ Names({this.sId, this.name});
+
+ Names.fromJson(Map json) {
+ sId = json['_id'];
+ name = json['name'];
+ }
+
+}
\ No newline at end of file
diff --git a/flutter_course/lib/models/post_model.dart b/flutter_course/lib/models/post_model.dart
new file mode 100644
index 0000000..7eea525
--- /dev/null
+++ b/flutter_course/lib/models/post_model.dart
@@ -0,0 +1,19 @@
+class PostModel {
+ final int userId;
+ final int id;
+ final String title;
+ final String body;
+
+ PostModel({
+ required this.userId,
+ required this.id,
+ required this.title,
+ required this.body,
+ });
+
+ PostModel.fromJson(Map json)
+ : userId = json['userId'],
+ id = json['id'],
+ title = json['title'],
+ body = json['body'];
+}
diff --git a/flutter_course/lib/models/review_model.dart b/flutter_course/lib/models/review_model.dart
new file mode 100644
index 0000000..43ad65a
--- /dev/null
+++ b/flutter_course/lib/models/review_model.dart
@@ -0,0 +1,55 @@
+class ReviewModel {
+ List? docs;
+ int? total;
+ int? limit;
+ int? page;
+ int? pages;
+
+ ReviewModel({this.docs, this.total, this.limit, this.page, this.pages});
+
+ ReviewModel.fromJson(Map json) {
+ if (json['docs'] != null) {
+ docs = [];
+ json['docs'].forEach((v) {
+ docs!.add(ReviewDocs.fromJson(v));
+ });
+ }
+ total = json['total'];
+ limit = json['limit'];
+ page = json['page'];
+ pages = json['pages'];
+ }
+
+
+}
+
+class ReviewDocs {
+ int? id;
+ int? movieId;
+ String? title;
+ String? type;
+ String? review;
+ String? date;
+ String? author;
+
+ ReviewDocs(
+ {this.id,
+ this.movieId,
+ this.title,
+ this.type,
+ this.review,
+ this.date,
+ this.author});
+
+ ReviewDocs.fromJson(Map json) {
+ id = json['id'];
+ movieId = json['movieId'];
+ title = json['title'];
+ type = json['type'];
+ review = json['review'];
+ date = json['date'];
+ author = json['author'];
+ }
+
+
+}
\ No newline at end of file
diff --git a/flutter_course/lib/screens/favorite_screen.dart b/flutter_course/lib/screens/favorite_screen.dart
new file mode 100644
index 0000000..1253f9d
--- /dev/null
+++ b/flutter_course/lib/screens/favorite_screen.dart
@@ -0,0 +1,206 @@
+import 'package:flutter/material.dart';
+import 'package:get_it/get_it.dart';
+import '../bloc/movie_bloc.dart';
+import '../models/movie_model.dart';
+
+import '../api_service.dart';
+import '../enums.dart';
+import '../theme/navigator_bar.dart';
+import '../theme/theme.dart';
+import 'review_screen.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+
+
+
+
+class FavoriteScreen extends StatefulWidget {
+ const FavoriteScreen({Key? key}) : super(key: key);
+
+ @override
+ State createState() => _FavoriteScreenState();
+
+}
+
+
+class _FavoriteScreenState extends State {
+
+ final ApiService service = ApiServiceDio.instance;
+ var state = ContentState.initial;
+ final movies = [];
+
+ Future load() async {
+ setState(() {
+ state = ContentState.loading;
+ });
+ final response = await service.getMovies();
+ if (response.hasError) {
+ setState(() {
+ state = ContentState.failure;
+ movies.clear();
+ });
+ } else {
+ setState(() {
+ state = response.result!.isNotEmpty
+ ? ContentState.success
+ : ContentState.empty;
+ movies
+ ..clear()
+ ..addAll(response.result!);
+ });
+ }
+ }
+
+ @override
+ void initState() {
+ load();
+ super.initState();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final themeState = context.watch();
+ return BlocBuilder(
+ bloc: GetIt.I.get(),
+ builder: (context, state) {
+ return Scaffold(
+
+ appBar: AppBar(
+ iconTheme: Theme.of(context).primaryIconTheme,
+ title: Text(
+ "Избранное",
+ style: Theme.of(context).appBarTheme.titleTextStyle,
+ ),
+ actions: [
+ Switch(
+ value: themeState.isDark,
+ onChanged: (value) {
+ if (value) {
+ themeState.setDarkTheme();
+ } else {
+ themeState.setLightTheme();
+ }
+ },
+ ),
+ ],
+ ),
+ drawer: NavBar(),
+ body: const _FavoriteView(),
+ );
+ }
+ );
+ }
+}
+
+class _FavoriteView extends StatelessWidget {
+
+ const _FavoriteView({
+ Key? key
+ }) : super(key: key);
+
+ @override
+ Widget build(BuildContext context) {
+ return BlocBuilder(
+ bloc: GetIt.I.get(),
+ builder: (context, state) {
+ if (state is MovieInitialState ||
+ state is MovieLoadingState) {
+ return const Center(
+ child: CircularProgressIndicator(),
+ );
+ }
+
+ if (state is MovieErrorState) {
+ return Text( state.message,
+ );
+ }
+
+ if (state is MovieLoadedState) {
+ final favorites = state.favoritesId
+ .toList();
+ final items = state.movies
+ ?.where((bk) => state.favoritesId.contains(bk.id))
+ .toList();
+ if (items?.isEmpty??false) {
+ return Center(
+ child: Text(
+ 'Список Избранные пуст',
+ style: Theme.of(context).textTheme.subtitle1,
+ ),
+ );
+ } else {
+ return ListView.builder(
+ scrollDirection: Axis.vertical,
+ itemCount: items?.length,
+ itemBuilder: (context, i) => ListTile(
+ title: Row( children: [
+ ClipRRect(
+ borderRadius: BorderRadius.circular(26),
+ child: Align(
+ alignment: Alignment.topCenter,
+ child: Image.network(
+ items?[i].poster?.previewUrl,
+ width: 70,
+ height: 250,
+ ),
+ ),
+ ),
+ const SizedBox(width: 20),
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(items?[i].name??'Без названия',
+ style: Theme.of(context).textTheme.headline6,
+ ),
+ Text(items?[i].description??'Без описания',
+ style: Theme.of(context).textTheme.subtitle1,
+ maxLines: 7,
+ overflow: TextOverflow.ellipsis,
+ ),
+ ],
+ ),
+ ),
+ IconButton(
+ icon: Icon(
+ Icons.favorite ,
+ size: 30,
+ color: Theme.of(context).iconTheme.color,
+
+ ),
+ onPressed: () {
+ final bloc = GetIt.I.get();
+ if (items?[i].id != null) {
+ if (favorites.contains(items?[i].id)) {
+ bloc.add(DeleteFromBookmarkEvent(items?[i].id as int));
+ items?[i].isFavorite=false;
+ } else {
+ bloc.add(AddToBookmarkEvent(items?[i].id as int));
+ items?[i].isFavorite=true;
+ }
+ }
+ },
+ ),
+
+
+
+ ],
+ ),
+
+
+ onTap: () {
+ navKey.currentState!.push(
+ MaterialPageRoute(
+ builder: (context) => ReviewScreen(movieId: items?[i].id??1),
+ ),
+ );
+ },
+ ),
+ );
+ }
+ }
+
+ return Container();
+ },
+ );
+ }
+}
diff --git a/flutter_course/lib/screens/movie_screen.dart b/flutter_course/lib/screens/movie_screen.dart
new file mode 100644
index 0000000..86a92b9
--- /dev/null
+++ b/flutter_course/lib/screens/movie_screen.dart
@@ -0,0 +1,207 @@
+import 'package:flutter/material.dart';
+import 'package:get_it/get_it.dart';
+import '../bloc/movie_bloc.dart';
+import '../models/movie_model.dart';
+
+import '../api_service.dart';
+import '../enums.dart';
+import '../theme/navigator_bar.dart';
+import '../theme/theme.dart';
+import 'review_screen.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+
+
+
+
+class MovieScreen extends StatefulWidget {
+ const MovieScreen({Key? key}) : super(key: key);
+
+ @override
+ State createState() => _MoviesScreenState();
+
+}
+
+
+class _MoviesScreenState extends State {
+
+
+
+ final ApiService service = ApiServiceDio.instance;
+ var state = ContentState.initial;
+ final movies = [];
+
+ Future load() async {
+ setState(() {
+ state = ContentState.loading;
+ });
+ final response = await service.getMovies();
+ if (response.hasError) {
+ setState(() {
+ state = ContentState.failure;
+ movies.clear();
+ });
+ } else {
+ setState(() {
+ state = response.result!.isNotEmpty
+ ? ContentState.success
+ : ContentState.empty;
+ movies
+ ..clear()
+ ..addAll(response.result!);
+ });
+ }
+ }
+
+ @override
+ void initState() {
+ load();
+ super.initState();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final themeState = context.watch();
+ return BlocBuilder(
+ bloc: GetIt.I.get(),
+ builder: (context, state) {
+ return Scaffold(
+ appBar: AppBar(
+ iconTheme: Theme.of(context).primaryIconTheme,
+ title: Text(
+ "Кинопремьеры",
+ style: Theme.of(context).appBarTheme.titleTextStyle,
+ ),
+ actions: [
+ Switch(
+ value: themeState.isDark,
+ onChanged: (value) {
+ if (value) {
+ themeState.setDarkTheme();
+ } else {
+ themeState.setLightTheme();
+ }
+ },
+ ),
+ ],
+ ),
+ drawer: NavBar(),
+
+
+ body: const _MoviesView(),
+ );
+ }
+ );
+ }
+}
+
+class _MoviesView extends StatelessWidget {
+
+ const _MoviesView({
+ Key? key
+ }) : super(key: key);
+
+
+
+ @override
+ Widget build(BuildContext context) {
+ return BlocBuilder(
+ bloc: GetIt.I.get(),
+ builder: (context, state) {
+ if (state is MovieInitialState ||
+ state is MovieLoadingState) {
+ return const Center(
+ child: CircularProgressIndicator(),
+ );
+ }
+
+ if (state is MovieErrorState) {
+ return Text( state.message,
+ );
+ }
+
+ if (state is MovieLoadedState) {
+ final favorites = state.favoritesId
+ .toList();
+ final items = state.movies;
+
+ if (items?.isEmpty??false) {
+ return const Center(
+ child: Text(
+ 'Список пуст',
+ style: TextStyle(fontSize: 20),
+ ),
+ );
+ } else {
+ return ListView.builder(
+ scrollDirection: Axis.vertical,
+ itemCount: items?.length,
+ itemBuilder: (context, i) => ListTile(
+ title: Row( children: [
+ ClipRRect(
+ borderRadius: BorderRadius.circular(26),
+ child: Align(
+ alignment: Alignment.topCenter,
+ child: Image.network(
+ items?[i].poster?.previewUrl,
+ width: 70,
+ height: 250,
+ ),
+ ),
+ ),
+ const SizedBox(width: 20),
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(items?[i].name??'',
+ style: Theme.of(context).textTheme.headline6,
+ ),
+ Text(items?[i].description??'',
+ style: Theme.of(context).textTheme.subtitle1,
+ maxLines: 7,
+ overflow: TextOverflow.ellipsis,
+ ),
+ ],
+ ),
+ ),
+ IconButton(
+ icon: Icon(
+ favorites.contains(items?[i].id) ? Icons.favorite : Icons.favorite_border,
+ size: 30,
+ color: Theme.of(context).iconTheme.color,
+ ),
+ onPressed: () {
+ final bloc = GetIt.I.get();
+ if (items?[i].id != null) {
+ if (favorites.contains(items?[i].id) ) {
+ bloc.add(DeleteFromBookmarkEvent(items?[i].id as int));
+ } else {
+ bloc.add(AddToBookmarkEvent(items?[i].id as int));
+ }
+ }
+ },
+ ),
+
+
+
+ ],
+ ),
+
+
+ onTap: () {
+ navKey.currentState!.push(
+ MaterialPageRoute(
+ builder: (context) => ReviewScreen(movieId: items?[i].id??1),
+ ),
+ );
+ },
+ ),
+ );
+ }
+ }
+
+ return Container();
+ },
+ );
+ }
+}
diff --git a/flutter_course/lib/screens/review_detail_screen.dart b/flutter_course/lib/screens/review_detail_screen.dart
new file mode 100644
index 0000000..ea4a862
--- /dev/null
+++ b/flutter_course/lib/screens/review_detail_screen.dart
@@ -0,0 +1,126 @@
+import 'package:flutter/material.dart';
+import '../models/review_model.dart';
+import '../enums.dart';
+
+class ReviewDetailScreen extends StatefulWidget {
+ final ReviewDocs review;
+ const ReviewDetailScreen({Key? key, required this.review}) : super(key: key);
+
+ @override
+ State createState() => _ReviewDetailScreenState();
+}
+
+class _ReviewDetailScreenState extends State {
+
+
+
+ var state = ReviewState.initial;
+ late ReviewDocs reviews;
+ Future load() async {
+ setState(() {
+ state = ReviewState.loading;
+ });
+ reviews=widget.review;
+ // изменить
+
+ setState(() {
+ state = ReviewState.success;
+ }
+ );
+ }
+
+ @override
+ void initState() {
+ load();
+ super.initState();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+
+ return Scaffold(
+ appBar: AppBar(
+ iconTheme: Theme.of(context).primaryIconTheme,
+ title: const Text('Подробная информация по отзыву'),
+ ),
+ body: _ReviewDetailView(
+ state: state,
+ review: reviews,
+ ),
+ );
+ }
+}
+
+class _ReviewDetailView extends StatelessWidget {
+ final ReviewState state;
+ final ReviewDocs review;
+
+ const _ReviewDetailView({
+ Key? key,
+ required this.state,
+ required this.review,
+ }) : super(key: key);
+
+ @override
+ Widget build(BuildContext context) {
+ switch (state) {
+ case ReviewState.success:
+ return ListView.builder(
+ scrollDirection: Axis.vertical,
+ itemCount: 1,
+ itemBuilder: (context, i) => ListTile(
+
+ title: Row( children: [
+
+ const SizedBox(width: 40,),
+
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(review.author??'',
+ style: Theme.of(context).textTheme.headline6,
+ ),
+ Text(review.date??'',
+ style: Theme.of(context).textTheme.headline6,
+ ),
+ const SizedBox(height: 30,),
+ Text(review.title??'',
+ style: Theme.of(context).textTheme.headline6,
+ ),
+ Text(review.review??'',
+ style: Theme.of(context).textTheme.subtitle1,
+ ),
+
+ ],
+ ),
+ ),
+ ],
+ ),
+
+ ),
+ );
+ case ReviewState.loading:
+ return const Center(
+ child: CircularProgressIndicator(),
+ );
+ case ReviewState.empty:
+ return Center(
+ child: Text('Пустой список отзывов',
+ style: Theme.of(context).textTheme.subtitle1,
+ ),
+ );
+ case ReviewState.failure:
+ return Center(
+ child: Text(
+ 'Ууупс, что-то пошло не так',
+ style: Theme.of(context).textTheme.subtitle1,
+ ),
+ );
+ default:
+ return Center(
+ child: Text('Отзыв не загружен',style: Theme.of(context).textTheme.subtitle1,),
+ );
+ }
+ }
+}
diff --git a/flutter_course/lib/screens/review_screen.dart b/flutter_course/lib/screens/review_screen.dart
new file mode 100644
index 0000000..687dc8a
--- /dev/null
+++ b/flutter_course/lib/screens/review_screen.dart
@@ -0,0 +1,152 @@
+import 'package:MovieReview/screens/review_detail_screen.dart';
+import 'package:flutter/material.dart';
+import '../models/review_model.dart';
+import '../api_service.dart';
+import '../enums.dart';
+import '../theme/theme.dart';
+
+class ReviewScreen extends StatefulWidget {
+ final int movieId;
+ const ReviewScreen({Key? key, required this.movieId}) : super(key: key);
+
+ @override
+ State createState() => _ReviewScreenState();
+}
+
+class _ReviewScreenState extends State {
+
+
+ final ApiService service = ApiServiceDio.instance;
+ var state = ReviewState.initial;
+ final reviews = [];
+
+
+ Future load() async {
+ setState(() {
+ state = ReviewState.loading;
+ });
+ // изменить
+ final response = await service.getReviews(widget.movieId);
+ if (response.hasError) {
+ setState(() {
+ state = ReviewState.failure;
+ reviews.clear();
+ });
+ } else {
+ setState(() {
+ state = response.result!.isNotEmpty
+ ? ReviewState.success
+ : ReviewState.empty;
+ reviews
+ ..clear()
+ ..addAll(response.result!);
+ });
+ }
+ }
+
+ @override
+ void initState() {
+ load();
+ super.initState();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+
+ return Scaffold(
+ appBar: AppBar(
+ iconTheme: Theme.of(context).primaryIconTheme,
+ title: const Text('Отзывы на фильм'),
+ ),
+ body: _ReviewView(
+ state: state,
+ reviews: reviews,
+ ),
+ );
+ }
+}
+
+class _ReviewView extends StatelessWidget {
+ final ReviewState state;
+ final List? reviews;
+
+ const _ReviewView({
+ Key? key,
+ required this.state,
+ this.reviews = const [],
+ }) : super(key: key);
+
+ @override
+ Widget build(BuildContext context) {
+ switch (state) {
+ case ReviewState.success:
+ return ListView.builder(
+ scrollDirection: Axis.vertical,
+ itemCount: reviews?.length,
+ itemBuilder: (context, i) => ListTile(
+
+ title: Row( children: [
+ ((reviews?[i].type??"Нейтральный".compareTo("Позитивный"))==0 ) ?
+ const Icon(Icons.arrow_upward, color: Colors.green):
+ ((reviews?[i].type??"Нейтральный".compareTo("Негативный"))==0 ) ?
+ const Icon(Icons.arrow_downward, color: Colors.red):
+ const SizedBox(width: 40,),
+
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(reviews?[i].author??'',
+ style: Theme.of(context).textTheme.headline6,
+ ),
+ Text(reviews?[i].date??'',
+ style: Theme.of(context).textTheme.headline6,
+ ),
+ const SizedBox(height: 30,),
+ Text(reviews?[i].title??'',
+ style: Theme.of(context).textTheme.headline6,
+ ),
+ Text(reviews?[i].review??'',
+ style: Theme.of(context).textTheme.subtitle1,
+ maxLines: 7,
+ overflow: TextOverflow.ellipsis,
+ ),
+ Divider(color: Theme.of(context).dividerTheme.color,),
+ ],
+ ),
+ ),
+ ],
+ ),
+ onTap: () {
+ navKey.currentState!.push(
+ MaterialPageRoute(
+ builder: (context) => ReviewDetailScreen(review: reviews![i]),
+ ),
+ );
+ },
+ ),
+ );
+ case ReviewState.loading:
+ return const Center(
+ child: CircularProgressIndicator(),
+ );
+ case ReviewState.empty:
+ return Center(
+ child: Text('Пустой список отзывов',
+ style: Theme.of(context).textTheme.subtitle1,
+ ),
+ );
+ case ReviewState.failure:
+ return Center(
+ child: Text(
+ 'Ууупс, что-то пошло не так',
+ style: Theme.of(context).textTheme.subtitle1,
+ ),
+ );
+ default:
+ return Center(
+ child: Text('Отзывы не загружены',style: Theme.of(context).textTheme.subtitle1,),
+ );
+ }
+ }
+}
diff --git a/flutter_course/lib/theme/navigator_bar.dart b/flutter_course/lib/theme/navigator_bar.dart
new file mode 100644
index 0000000..8ac902b
--- /dev/null
+++ b/flutter_course/lib/theme/navigator_bar.dart
@@ -0,0 +1,39 @@
+import 'package:flutter/material.dart';
+
+import '../screens/favorite_screen.dart';
+import '../screens/movie_screen.dart';
+
+class NavBar extends StatelessWidget {
+ @override
+ Widget build(BuildContext context) {
+ return Drawer(
+
+ child: ListView(
+ // Remove padding
+ padding: EdgeInsets.zero,
+ children: [
+ const UserAccountsDrawerHeader(
+ accountName: Text('kotelnikov-aa'),
+ accountEmail: Text('aleksey@kotelnikov.org'),
+ decoration: BoxDecoration(
+ color: Colors.black,
+ ),
+ ),
+ ListTile(
+ leading: const Icon(Icons.person),
+ title: const Text('Кинопремьеры'),
+ onTap: () => Navigator.push(context,
+ MaterialPageRoute(builder: (context) => const MovieScreen()))
+ ),
+ ListTile(
+ leading: const Icon(Icons.favorite),
+ title: const Text("Закладки"),
+ onTap: () => Navigator.push(context,
+ MaterialPageRoute(builder: (context) => const FavoriteScreen()))
+ ),
+
+ ],
+ ),
+ );
+ }
+}
\ No newline at end of file
diff --git a/flutter_course/lib/theme/theme.dart b/flutter_course/lib/theme/theme.dart
new file mode 100644
index 0000000..0d05058
--- /dev/null
+++ b/flutter_course/lib/theme/theme.dart
@@ -0,0 +1,42 @@
+import 'package:flutter/material.dart';
+import 'package:shared_preferences/shared_preferences.dart';
+
+final navKey = GlobalKey();
+
+class ThemeState with ChangeNotifier {
+ final SharedPreferences storage;
+
+ var _theme = ThemeMode.light;
+
+ ThemeState(this.storage) {
+ _theme = _getTheme();
+ }
+
+ ThemeMode get theme => _theme;
+
+ bool get isDark => _theme == ThemeMode.dark;
+
+ ThemeMode _getTheme() {
+ final cache = storage.getString('theme') ?? '';
+
+ if (cache.isEmpty || cache == 'light') {
+ return ThemeMode.light;
+ } else {
+ return ThemeMode.dark;
+ }
+ }
+
+ void setLightTheme() {
+ _change(ThemeMode.light);
+ }
+
+ void setDarkTheme() {
+ _change(ThemeMode.dark);
+ }
+
+ void _change(ThemeMode value) {
+ _theme = value;
+ storage.setString('theme', _theme.name);
+ notifyListeners();
+ }
+}
diff --git a/flutter_course/pubspec.yaml b/flutter_course/pubspec.yaml
new file mode 100644
index 0000000..1aa7899
--- /dev/null
+++ b/flutter_course/pubspec.yaml
@@ -0,0 +1,108 @@
+name: MovieReview
+description: Course project of Epic school
+
+# The following line prevents the package from being accidentally published to
+# pub.dev using `flutter pub publish`. This is preferred for private packages.
+publish_to: 'none' # Remove this line if you wish to publish to pub.dev
+
+# The following defines the version and build number for your application.
+# A version number is three numbers separated by dots, like 1.2.43
+# followed by an optional build number separated by a +.
+# Both the version and the builder number may be overridden in flutter
+# build by specifying --build-name and --build-number, respectively.
+# In Android, build-name is used as versionName while build-number used as versionCode.
+# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
+# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
+# Read more about iOS versioning at
+# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
+version: 1.0.0+1
+
+environment:
+ sdk: ">=2.17.1 <3.0.0"
+
+# Dependencies specify other packages that your package needs in order to work.
+# To automatically upgrade your package dependencies to the latest versions
+# consider running `flutter pub upgrade --major-versions`. Alternatively,
+# dependencies can be manually updated by changing the version numbers below to
+# the latest version available on pub.dev. To see which dependencies have newer
+# versions available, run `flutter pub outdated`.
+dependencies:
+ flutter:
+ sdk: flutter
+ intl: ^0.17.0
+ http: ^0.13.4
+ dio: ^4.0.0
+ cached_network_image: ^3.2.0
+ provider: ^6.0.2
+ shared_preferences: ^2.0.13
+ flutter_form_builder: ^7.1.1
+ form_builder_extra_fields: ^7.1.0
+ form_builder_validators: ^8.1.1
+ form_builder_image_picker: ^2.0.0
+ form_builder_file_picker: ^2.1.0
+ flutter_localizations:
+ sdk: flutter
+ intl_utils: ^2.6.1
+ bloc: ^8.0.3
+ flutter_bloc: ^8.0.1
+ mobx: ^2.0.7+2
+ flutter_mobx: ^2.0.6+1
+ validators2: ^3.0.0
+ cupertino_icons: ^1.0.2
+ favorite_button: ^0.0.4
+ get_it: ^7.2.0
+
+dev_dependencies:
+ flutter_test:
+ sdk: flutter
+ build_runner: ^2.1.11
+ mobx_codegen: ^2.0.7
+
+ # The "flutter_lints" package below contains a set of recommended lints to
+ # encourage good coding practices. The lint set provided by the package is
+ # activated in the `analysis_options.yaml` file located at the root of your
+ # package. See that file for information about deactivating specific lint
+ # rules and activating additional ones.
+ flutter_lints: ^1.0.0
+
+# For information on the generic Dart part of this file, see the
+# following page: https://dart.dev/tools/pub/pubspec
+
+# The following section is specific to Flutter packages.
+flutter:
+
+ # The following line ensures that the Material Icons font is
+ # included with your application, so that you can use the icons in
+ # the material Icons class.
+ uses-material-design: true
+
+ # To add assets to your application, add an assets section, like this:
+ # assets:
+ # - images/a_dot_burr.jpeg
+ # - images/a_dot_ham.jpeg
+
+ # An image asset can refer to one or more resolution-specific "variants", see
+ # https://flutter.dev/assets-and-images/#resolution-aware
+
+ # For details regarding adding assets from package dependencies, see
+ # https://flutter.dev/assets-and-images/#from-packages
+
+ # To add custom fonts to your application, add a fonts section here,
+ # in this "flutter" section. Each entry in this list should have a
+ # "family" key with the font family name, and a "fonts" key with a
+ # list giving the asset and other descriptors for the font. For
+ # example:
+ # fonts:
+ # - family: Schyler
+ # fonts:
+ # - asset: fonts/Schyler-Regular.ttf
+ # - asset: fonts/Schyler-Italic.ttf
+ # style: italic
+ # - family: Trajan Pro
+ # fonts:
+ # - asset: fonts/TrajanPro.ttf
+ # - asset: fonts/TrajanPro_Bold.ttf
+ # weight: 700
+ #
+ # For details regarding fonts from package dependencies,
+ # see https://flutter.dev/custom-fonts/#from-packages