diff --git a/Makefile b/Makefile
index b7e451a..440356a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,2 +1,17 @@
gen:
- flutter pub run build_runner build --delete-conflicting-outputs
\ No newline at end of file
+ dart pub run build_runner build --delete-conflicting-outputs
+
+icon:
+ dart pub run flutter_launcher_icons:main
+
+init_res:
+ dart pub global activate flutter_asset_generator
+
+format:
+ dart format . --line-length 100
+
+res:
+ fgen --output lib/components/resourses.g.dart --no-watch --no-preview
+
+loc:
+ flutter gen-l10n
\ No newline at end of file
diff --git a/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
new file mode 100644
index 0000000..345888d
--- /dev/null
+++ b/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
index db77bb4..10dd1e1 100644
Binary files a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher_background.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher_background.png
new file mode 100644
index 0000000..42abb71
Binary files /dev/null and b/android/app/src/main/res/mipmap-hdpi/ic_launcher_background.png differ
diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
new file mode 100644
index 0000000..2bfdb0b
Binary files /dev/null and b/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png differ
diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher_monochrome.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher_monochrome.png
new file mode 100644
index 0000000..26d8e0c
Binary files /dev/null and b/android/app/src/main/res/mipmap-hdpi/ic_launcher_monochrome.png differ
diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
index 17987b7..2e12b31 100644
Binary files a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher_background.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher_background.png
new file mode 100644
index 0000000..a493a5c
Binary files /dev/null and b/android/app/src/main/res/mipmap-mdpi/ic_launcher_background.png differ
diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
new file mode 100644
index 0000000..8ca9cc5
Binary files /dev/null and b/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png differ
diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher_monochrome.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher_monochrome.png
new file mode 100644
index 0000000..28a1d46
Binary files /dev/null and b/android/app/src/main/res/mipmap-mdpi/ic_launcher_monochrome.png differ
diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
index 09d4391..fed48f9 100644
Binary files a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher_background.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher_background.png
new file mode 100644
index 0000000..83059ea
Binary files /dev/null and b/android/app/src/main/res/mipmap-xhdpi/ic_launcher_background.png differ
diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
new file mode 100644
index 0000000..2f14565
Binary files /dev/null and b/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png differ
diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher_monochrome.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher_monochrome.png
new file mode 100644
index 0000000..4adf323
Binary files /dev/null and b/android/app/src/main/res/mipmap-xhdpi/ic_launcher_monochrome.png differ
diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
index d5f1c8d..e5362fe 100644
Binary files a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_background.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_background.png
new file mode 100644
index 0000000..bd79dd6
Binary files /dev/null and b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_background.png differ
diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
new file mode 100644
index 0000000..13f571d
Binary files /dev/null and b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png differ
diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_monochrome.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_monochrome.png
new file mode 100644
index 0000000..9645828
Binary files /dev/null and b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_monochrome.png differ
diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
index 4d6372e..32047fe 100644
Binary files a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_background.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_background.png
new file mode 100644
index 0000000..fa7a66b
Binary files /dev/null and b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_background.png differ
diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
new file mode 100644
index 0000000..2fcccf9
Binary files /dev/null and b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png differ
diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_monochrome.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_monochrome.png
new file mode 100644
index 0000000..5d1f477
Binary files /dev/null and b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_monochrome.png differ
diff --git a/assets/svg/ru.svg b/assets/svg/ru.svg
new file mode 100644
index 0000000..ae12982
--- /dev/null
+++ b/assets/svg/ru.svg
@@ -0,0 +1,19 @@
+
+
+
\ No newline at end of file
diff --git a/assets/svg/us.svg b/assets/svg/us.svg
new file mode 100644
index 0000000..f5a7a01
--- /dev/null
+++ b/assets/svg/us.svg
@@ -0,0 +1,34 @@
+
+
+
\ No newline at end of file
diff --git a/l10n.yaml b/l10n.yaml
new file mode 100644
index 0000000..8bda731
--- /dev/null
+++ b/l10n.yaml
@@ -0,0 +1,6 @@
+arb-dir: l10n
+template-arb-file: app_ru.arb
+output-localization: app_locale.dart
+output-dir: lib/components/locale/l10n
+output-class: AppLocale
+synthetic-package: false
\ No newline at end of file
diff --git a/l10n/app_en.arb b/l10n/app_en.arb
new file mode 100644
index 0000000..f768f1b
--- /dev/null
+++ b/l10n/app_en.arb
@@ -0,0 +1,12 @@
+{
+ "@@locale": "en",
+
+ "search": "Search",
+ "liked": "You liked",
+ "unliked": "Like removed from",
+ "errorOccured": "Error occured",
+ "noErrorMsg": "No message provided",
+ "retry": "Retry",
+
+ "arbEnding": "t"
+}
\ No newline at end of file
diff --git a/l10n/app_ru.arb b/l10n/app_ru.arb
new file mode 100644
index 0000000..c06aac4
--- /dev/null
+++ b/l10n/app_ru.arb
@@ -0,0 +1,12 @@
+{
+ "@@locale": "ru",
+
+ "search": "Поиск",
+ "liked": "Вы лайкнули",
+ "unliked": "Лайк снят с",
+ "errorOccured": "Произошла ошибка",
+ "noErrorMsg": "Нет сообщения",
+ "retry": "Повторить",
+
+ "arbEnding": "t"
+}
\ No newline at end of file
diff --git a/lib/components/extensions/context_x.dart b/lib/components/extensions/context_x.dart
new file mode 100644
index 0000000..79738ef
--- /dev/null
+++ b/lib/components/extensions/context_x.dart
@@ -0,0 +1,6 @@
+import 'package:flutter/cupertino.dart';
+import 'package:flutter_project/components/locale/l10n/app_localizations.dart';
+
+extension LocalContextX on BuildContext {
+ AppLocale get locale => AppLocale.of(this)!;
+}
diff --git a/lib/components/locale/l10n/app_localizations.dart b/lib/components/locale/l10n/app_localizations.dart
new file mode 100644
index 0000000..a3dc4af
--- /dev/null
+++ b/lib/components/locale/l10n/app_localizations.dart
@@ -0,0 +1,171 @@
+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 AppLocale
+/// returned by `AppLocale.of(context)`.
+///
+/// Applications need to include `AppLocale.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: AppLocale.localizationsDelegates,
+/// supportedLocales: AppLocale.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 AppLocale.supportedLocales
+/// property.
+abstract class AppLocale {
+ AppLocale(String locale) : localeName = intl.Intl.canonicalizedLocale(locale.toString());
+
+ final String localeName;
+
+ static AppLocale? of(BuildContext context) {
+ return Localizations.of(context, AppLocale);
+ }
+
+ static const LocalizationsDelegate delegate = _AppLocaleDelegate();
+
+ /// 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 @search.
+ ///
+ /// In ru, this message translates to:
+ /// **'Поиск'**
+ String get search;
+
+ /// No description provided for @liked.
+ ///
+ /// In ru, this message translates to:
+ /// **'Вы лайкнули'**
+ String get liked;
+
+ /// No description provided for @unliked.
+ ///
+ /// In ru, this message translates to:
+ /// **'Лайк снят с'**
+ String get unliked;
+
+ /// No description provided for @errorOccured.
+ ///
+ /// In ru, this message translates to:
+ /// **'Произошла ошибка'**
+ String get errorOccured;
+
+ /// No description provided for @noErrorMsg.
+ ///
+ /// In ru, this message translates to:
+ /// **'Нет сообщения'**
+ String get noErrorMsg;
+
+ /// No description provided for @retry.
+ ///
+ /// In ru, this message translates to:
+ /// **'Повторить'**
+ String get retry;
+
+ /// No description provided for @arbEnding.
+ ///
+ /// In ru, this message translates to:
+ /// **'t'**
+ String get arbEnding;
+}
+
+class _AppLocaleDelegate extends LocalizationsDelegate {
+ const _AppLocaleDelegate();
+
+ @override
+ Future load(Locale locale) {
+ return SynchronousFuture(lookupAppLocale(locale));
+ }
+
+ @override
+ bool isSupported(Locale locale) => ['en', 'ru'].contains(locale.languageCode);
+
+ @override
+ bool shouldReload(_AppLocaleDelegate old) => false;
+}
+
+AppLocale lookupAppLocale(Locale locale) {
+
+
+ // Lookup logic when only language code is specified.
+ switch (locale.languageCode) {
+ case 'en': return AppLocaleEn();
+ case 'ru': return AppLocaleRu();
+ }
+
+ throw FlutterError(
+ 'AppLocale.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/lib/components/locale/l10n/app_localizations_en.dart b/lib/components/locale/l10n/app_localizations_en.dart
new file mode 100644
index 0000000..6f2d449
--- /dev/null
+++ b/lib/components/locale/l10n/app_localizations_en.dart
@@ -0,0 +1,29 @@
+import 'app_localizations.dart';
+
+// ignore_for_file: type=lint
+
+/// The translations for English (`en`).
+class AppLocaleEn extends AppLocale {
+ AppLocaleEn([String locale = 'en']) : super(locale);
+
+ @override
+ String get search => 'Search';
+
+ @override
+ String get liked => 'You liked';
+
+ @override
+ String get unliked => 'Like removed from';
+
+ @override
+ String get errorOccured => 'Error occured';
+
+ @override
+ String get noErrorMsg => 'No message provided';
+
+ @override
+ String get retry => 'Retry';
+
+ @override
+ String get arbEnding => 't';
+}
diff --git a/lib/components/locale/l10n/app_localizations_ru.dart b/lib/components/locale/l10n/app_localizations_ru.dart
new file mode 100644
index 0000000..e148138
--- /dev/null
+++ b/lib/components/locale/l10n/app_localizations_ru.dart
@@ -0,0 +1,29 @@
+import 'app_localizations.dart';
+
+// ignore_for_file: type=lint
+
+/// The translations for Russian (`ru`).
+class AppLocaleRu extends AppLocale {
+ AppLocaleRu([String locale = 'ru']) : super(locale);
+
+ @override
+ String get search => 'Поиск';
+
+ @override
+ String get liked => 'Вы лайкнули';
+
+ @override
+ String get unliked => 'Лайк снят с';
+
+ @override
+ String get errorOccured => 'Произошла ошибка';
+
+ @override
+ String get noErrorMsg => 'Нет сообщения';
+
+ @override
+ String get retry => 'Повторить';
+
+ @override
+ String get arbEnding => 't';
+}
diff --git a/lib/components/resourses.g.dart b/lib/components/resourses.g.dart
new file mode 100644
index 0000000..915a8d9
--- /dev/null
+++ b/lib/components/resourses.g.dart
@@ -0,0 +1,10 @@
+/// Generate by [asset_generator](https://github.com/fluttercandies/flutter_asset_generator) library.
+/// PLEASE DO NOT EDIT MANUALLY.
+// ignore_for_file: constant_identifier_names
+class R {
+ const R._();
+
+ static const String ASSETS_SVG_RU_SVG = 'assets/svg/ru.svg';
+
+ static const String ASSETS_SVG_US_SVG = 'assets/svg/us.svg';
+}
diff --git a/lib/components/utils/debounce.dart b/lib/components/utils/debounce.dart
index dda6999..9642c10 100644
--- a/lib/components/utils/debounce.dart
+++ b/lib/components/utils/debounce.dart
@@ -10,8 +10,7 @@ class Debounce {
static Timer? _timer;
- static void run(VoidCallback action,
- {Duration delay = const Duration(milliseconds: 500)}) {
+ static void run(VoidCallback action, {Duration delay = const Duration(milliseconds: 500)}) {
_timer?.cancel();
_timer = Timer(delay, action);
}
diff --git a/lib/data/dtos/animes_dto.dart b/lib/data/dtos/animes_dto.dart
index f2a6736..64fd5c9 100644
--- a/lib/data/dtos/animes_dto.dart
+++ b/lib/data/dtos/animes_dto.dart
@@ -8,8 +8,7 @@ class AnimesDto {
final PaginationDto? pagination;
const AnimesDto({this.data, this.pagination});
- factory AnimesDto.fromJson(Map json) =>
- _$AnimesDtoFromJson(json);
+ factory AnimesDto.fromJson(Map json) => _$AnimesDtoFromJson(json);
}
@JsonSerializable(createToJson: false)
@@ -23,8 +22,7 @@ class PaginationDto {
const PaginationDto({this.currentPage, this.hasNextPage, this.lastPage});
- factory PaginationDto.fromJson(Map json) =>
- _$PaginationDtoFromJson(json);
+ factory PaginationDto.fromJson(Map json) => _$PaginationDtoFromJson(json);
}
@JsonSerializable(createToJson: false)
@@ -36,16 +34,9 @@ class AnimeDto {
final String? rating;
final ImagesDto? images;
- const AnimeDto(
- {this.title,
- this.rating,
- this.synopsis,
- this.type,
- this.year,
- this.images});
+ const AnimeDto({this.title, this.rating, this.synopsis, this.type, this.year, this.images});
- factory AnimeDto.fromJson(Map json) =>
- _$AnimeDtoFromJson(json);
+ factory AnimeDto.fromJson(Map json) => _$AnimeDtoFromJson(json);
}
@JsonSerializable(createToJson: false)
@@ -54,8 +45,7 @@ class ImagesDto {
const ImagesDto({this.jpg});
- factory ImagesDto.fromJson(Map json) =>
- _$ImagesDtoFromJson(json);
+ factory ImagesDto.fromJson(Map json) => _$ImagesDtoFromJson(json);
}
@JsonSerializable(createToJson: false)
@@ -65,6 +55,5 @@ class ImageDto {
const ImageDto({this.imageUrl});
- factory ImageDto.fromJson(Map json) =>
- _$ImageDtoFromJson(json);
+ factory ImageDto.fromJson(Map json) => _$ImageDtoFromJson(json);
}
diff --git a/lib/data/mappers/animes_mapper.dart b/lib/data/mappers/animes_mapper.dart
index ef14b8f..d33824c 100644
--- a/lib/data/mappers/animes_mapper.dart
+++ b/lib/data/mappers/animes_mapper.dart
@@ -6,9 +6,7 @@ import '../dtos/animes_dto.dart';
extension AnimesMapper on AnimesDto {
HomeData toDomain() => HomeData(
data: data?.map((dto) => dto.toDomain()).toList(),
- nextPage: (pagination?.hasNextPage ?? false)
- ? ((pagination?.currentPage ?? 0) + 1)
- : null);
+ nextPage: (pagination?.hasNextPage ?? false) ? ((pagination?.currentPage ?? 0) + 1) : null);
}
extension AnimeMapper on AnimeDto {
diff --git a/lib/data/repositories/anime_repository.dart b/lib/data/repositories/anime_repository.dart
index 9feb652..6171805 100644
--- a/lib/data/repositories/anime_repository.dart
+++ b/lib/data/repositories/anime_repository.dart
@@ -15,22 +15,14 @@ class AnimeRepository extends ApiInterface {
@override
Future loadData(
- {OnErrorCallback onError,
- String? q,
- int page = 1,
- int pageSize = 25}) async {
+ {OnErrorCallback onError, String? q, int page = 1, int pageSize = 25}) async {
try {
const String url = "$_baseUrl/v4/anime?sfw";
- final Response response = await _dio
- .get