diff --git a/flutter_app/assets/svg/flag-ru-svgrepo-com.svg b/flutter_app/assets/svg/ru.svg similarity index 100% rename from flutter_app/assets/svg/flag-ru-svgrepo-com.svg rename to flutter_app/assets/svg/ru.svg diff --git a/flutter_app/assets/svg/flag-gb-svgrepo-com.svg b/flutter_app/assets/svg/uk.svg similarity index 100% rename from flutter_app/assets/svg/flag-gb-svgrepo-com.svg rename to flutter_app/assets/svg/uk.svg diff --git a/flutter_app/lib/components/extensions/context_x.dart b/flutter_app/lib/components/extensions/context_x.dart index 8b813c2..0a3a93b 100644 --- a/flutter_app/lib/components/extensions/context_x.dart +++ b/flutter_app/lib/components/extensions/context_x.dart @@ -1,5 +1,5 @@ import 'package:flutter_app/components/locale/l10n/app_locale.dart'; -import 'package:flutter/cupertino.dart'; +import 'package:flutter/widgets.dart'; extension LocalContextX on BuildContext { AppLocale get locale => AppLocale.of(this)!; diff --git a/flutter_app/lib/components/locale/l10n/app_locale.dart b/flutter_app/lib/components/locale/l10n/app_locale.dart index dc004b6..bb28342 100644 --- a/flutter_app/lib/components/locale/l10n/app_locale.dart +++ b/flutter_app/lib/components/locale/l10n/app_locale.dart @@ -113,18 +113,6 @@ abstract class AppLocale { /// **'Удалено из понравившегося :('** String get disliked; - /// No description provided for @location. - /// - /// In ru, this message translates to: - /// **'Местоположение'** - String get location; - - /// No description provided for @species. - /// - /// In ru, this message translates to: - /// **'Вид'** - String get species; - /// No description provided for @arbEnding. /// /// In ru, this message translates to: diff --git a/flutter_app/lib/components/locale/l10n/app_locale_en.dart b/flutter_app/lib/components/locale/l10n/app_locale_en.dart index 8c0b4d3..599548c 100644 --- a/flutter_app/lib/components/locale/l10n/app_locale_en.dart +++ b/flutter_app/lib/components/locale/l10n/app_locale_en.dart @@ -2,24 +2,18 @@ import 'app_locale.dart'; // ignore_for_file: type=lint -/// The translations for Russian (`ru`). -class AppLocaleRu extends AppLocale { - AppLocaleRu([String locale = 'ru']) : super(locale); +/// The translations for English (`en`). +class AppLocaleEn extends AppLocale { + AppLocaleEn([String locale = 'en']) : super(locale); @override - String get search => 'Поиск'; + String get search => 'Search'; @override - String get liked => 'Добавлено в понравившиеся :)'; + String get liked => 'liked!'; @override - String get disliked => 'Удалено из понравившегося :('; - - @override - String get location => 'Местоположение'; - - @override - String get species => 'Вид'; + String get disliked => 'disliked :('; @override String get arbEnding => 'Чтобы не забыть про отсутствие запятой :)'; diff --git a/flutter_app/lib/components/locale/l10n/app_locale_ru.dart b/flutter_app/lib/components/locale/l10n/app_locale_ru.dart index 309e9df..fbd2661 100644 --- a/flutter_app/lib/components/locale/l10n/app_locale_ru.dart +++ b/flutter_app/lib/components/locale/l10n/app_locale_ru.dart @@ -2,24 +2,18 @@ import 'app_locale.dart'; // ignore_for_file: type=lint -/// The translations for English (`en`). -class AppLocaleEn extends AppLocale { - AppLocaleEn([String locale = 'en']) : super(locale); +/// The translations for Russian (`ru`). +class AppLocaleRu extends AppLocale { + AppLocaleRu([String locale = 'ru']) : super(locale); @override - String get search => 'Search'; + String get search => 'Поиск'; @override - String get liked => 'liked!'; + String get liked => 'Добавлено в понравившиеся :)'; @override - String get disliked => 'disliked :('; - - @override - String get location => 'Location'; - - @override - String get species => 'Species'; + String get disliked => 'Удалено из понравившегося :('; @override String get arbEnding => 'Чтобы не забыть про отсутствие запятой :)'; diff --git a/flutter_app/lib/components/resources.g.dart b/flutter_app/lib/components/resources.g.dart new file mode 100644 index 0000000..9645894 --- /dev/null +++ b/flutter_app/lib/components/resources.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_UK_SVG = 'assets/svg/uk.svg'; +} diff --git a/flutter_app/lib/data/mappers/characters_mapper.dart b/flutter_app/lib/data/mappers/characters_mapper.dart index 9debd36..323e95f 100644 --- a/flutter_app/lib/data/mappers/characters_mapper.dart +++ b/flutter_app/lib/data/mappers/characters_mapper.dart @@ -15,8 +15,6 @@ extension ThronesCharacterDtoToModel on ThronesCharacterDto { fullName: fullName, imageUrl: imageUrl, text: '', - speciesText: species ?? 'unknown', - locationText: location?.name ?? 'unknown', ); String _makeDescriptionText(String? title, String? family) { diff --git a/flutter_app/lib/domain/models/card.dart b/flutter_app/lib/domain/models/card.dart index 91e612b..7edf65c 100644 --- a/flutter_app/lib/domain/models/card.dart +++ b/flutter_app/lib/domain/models/card.dart @@ -11,8 +11,6 @@ class CardData { final String? title; final String? family; final int? id; - final String locationText; - final String speciesText; CardData({ required this.text, @@ -25,7 +23,5 @@ class CardData { required this.title, required this.family, this.id, - required this.locationText, - required this.speciesText, }); } diff --git a/flutter_app/lib/main.dart b/flutter_app/lib/main.dart index a61e127..e73fd98 100644 --- a/flutter_app/lib/main.dart +++ b/flutter_app/lib/main.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:flutter/material.dart'; import 'package:flutter_app/data/repositories/got_repository.dart'; import 'package:flutter_app/presentation/home_page/bloc/bloc.dart'; @@ -18,22 +20,6 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - // return MaterialApp( - // title: '7 Kingdoms', - // theme: ThemeData( - // colorScheme: ColorScheme.fromSeed(seedColor: const Color.fromARGB(255, 20, 40, 150)), - // useMaterial3: true, - // ), - // home: RepositoryProvider( - // lazy: true, - // create: (_) => ThronesRepository(), - // child: BlocProvider( - // lazy: false, - // create: (context) => HomeBloc(context.read()), - // child: const MyHomePage(title: '7 Kingdoms'), - // ), - // )); - return BlocProvider( lazy: false, create: (context) => LocaleBloc((Locale(Platform.localeName))), diff --git a/flutter_app/lib/presentation/common/svg_object.dart b/flutter_app/lib/presentation/common/svg_object.dart index 6e12729..bdcad59 100644 --- a/flutter_app/lib/presentation/common/svg_object.dart +++ b/flutter_app/lib/presentation/common/svg_object.dart @@ -1,12 +1,12 @@ -import 'package:flutter/cupertino.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_app/components/resources.g.dart'; abstract class SvgObjects { static void init() { final pics = [ - R.ASSETS_SVG_FLAG_GB_SVGREPO_COM_SVG, - R.ASSETS_SVG_FLAG_RU_SVGREPO_COM_SVG, + R.ASSETS_SVG_RU_SVG, + R.ASSETS_SVG_UK_SVG, ]; for (final String p in pics) { final loader = SvgAssetLoader(p); @@ -20,7 +20,7 @@ class SvgRu extends StatelessWidget { @override Widget build(BuildContext context) { - return SvgPicture.asset(R.ASSETS_SVG_FLAG_RU_SVGREPO_COM_SVG); + return SvgPicture.asset(R.ASSETS_SVG_RU_SVG); } } @@ -29,6 +29,6 @@ class SvgUk extends StatelessWidget { @override Widget build(BuildContext context) { - return SvgPicture.asset(R.ASSETS_SVG_FLAG_GB_SVGREPO_COM_SVG); + return SvgPicture.asset(R.ASSETS_SVG_UK_SVG); } } diff --git a/flutter_app/lib/presentation/home_page/card.dart b/flutter_app/lib/presentation/home_page/card.dart index 31483fb..94c6f5e 100644 --- a/flutter_app/lib/presentation/home_page/card.dart +++ b/flutter_app/lib/presentation/home_page/card.dart @@ -1,6 +1,6 @@ part of 'home_page.dart'; -typedef OnLikeCallback = void Function(int? id, String title, bool isLiked)?; +typedef OnLikeCallback = void Function(String? id, String title, bool isLiked)?; class _Card extends StatelessWidget { final String text; @@ -10,7 +10,7 @@ class _Card extends StatelessWidget { final String? imageUrl; final OnLikeCallback onLike; final VoidCallback? onTap; - final int? id; + final String? id; final bool isLiked; const _Card( @@ -40,7 +40,7 @@ class _Card extends StatelessWidget { onLike: onLike, onTap: onTap, isLiked: isLiked, - id: data.id, + id: data.id.toString() ); @override diff --git a/flutter_app/lib/presentation/home_page/home_page.dart b/flutter_app/lib/presentation/home_page/home_page.dart index 8f647f2..4d55c38 100644 --- a/flutter_app/lib/presentation/home_page/home_page.dart +++ b/flutter_app/lib/presentation/home_page/home_page.dart @@ -144,7 +144,7 @@ class _BodyState extends State { ? _Card.fromData( data, onLike: _onLike, - isLiked: likeState.likedIds?.contains(data.id) == true, + isLiked: likeState.likedIds?.contains(data.id.toString()) == true, onTap: () => _navToDetails(context, data), ) : const SizedBox.shrink(); @@ -181,16 +181,16 @@ class _BodyState extends State { WidgetsBinding.instance.addPostFrameCallback((_) { ScaffoldMessenger.of(context).showSnackBar(SnackBar( content: Text( - '$title ${isLiked ? context.locale.liked : context.locale.disliked}', - style: Theme.of(context).textTheme.bodyLarge, + '$title ${isLiked ? context.locale.disliked : context.locale.liked}', + style: const TextStyle(color: Colors.white), ), - backgroundColor: Colors.brown.shade300, + backgroundColor: const Color.fromARGB(255, 20, 40, 150), duration: const Duration(seconds: 1), )); }); } - void _onLike(int? id, String title, bool isLiked) { + void _onLike(String? id, String title, bool isLiked) { if (id != null){ context.read().add(ChangeLikeEvent(id)); _showSnackBar(context, title, isLiked); diff --git a/flutter_app/lib/presentation/like_bloc/like_bloc.dart b/flutter_app/lib/presentation/like_bloc/like_bloc.dart index 23a80ca..ca69b7a 100644 --- a/flutter_app/lib/presentation/like_bloc/like_bloc.dart +++ b/flutter_app/lib/presentation/like_bloc/like_bloc.dart @@ -22,10 +22,7 @@ class LikeBloc extends Bloc { } FutureOr _onChangeLike(ChangeLikeEvent event, Emitter emit) async{ - final updatedListInt = List.from(state.likedIds ?? []); - print(updatedListInt); - final updatedList = updatedListInt.map((int number) => number.toString()).toList(); - print(updatedList); + final updatedList = List.from(state.likedIds ?? []); if (updatedList.contains(event.id.toString())) { updatedList.remove(event.id.toString()); diff --git a/flutter_app/lib/presentation/like_bloc/like_events.dart b/flutter_app/lib/presentation/like_bloc/like_events.dart index 32db4da..43032db 100644 --- a/flutter_app/lib/presentation/like_bloc/like_events.dart +++ b/flutter_app/lib/presentation/like_bloc/like_events.dart @@ -7,7 +7,7 @@ class LoadLikesEvent extends LikeEvent { } class ChangeLikeEvent extends LikeEvent { - final int id; + final String id; const ChangeLikeEvent(this.id); } \ No newline at end of file diff --git a/flutter_app/pubspec.yaml b/flutter_app/pubspec.yaml index 83e4e8e..d2c4004 100644 --- a/flutter_app/pubspec.yaml +++ b/flutter_app/pubspec.yaml @@ -30,23 +30,39 @@ environment: dependencies: flutter: sdk: flutter + + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^1.0.8 + flutter_svg: 2.0.7 + json_annotation: ^4.8.1 dio: ^5.4.2+1 pretty_dio_logger: ^1.3.1 - cupertino_icons: ^1.0.8 - flutter_bloc: ^8.1.6 + + # BLoC + equatable: ^2.0.5 + flutter_bloc: ^8.1.5 copy_with_extension_gen: ^5.0.4 - flutter_svg: 2.0.7 + flutter_localizations: sdk: flutter intl: ^0.19.0 + shared_preferences: 2.2.3 dev_dependencies: flutter_test: sdk: flutter - + + # 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. + build_runner: ^2.4.9 json_serializable: ^6.7.1 @@ -57,15 +73,8 @@ dev_dependencies: flutter_icons: android: "ic_launcher" ios: true - image_path: "assets/icon.jpg" - min_sdk_android: 11 - - # 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: ^4.0.0 + image_path: "assets/launcher.jpg" + min_sdk_android: 21 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec @@ -76,8 +85,12 @@ 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. + generate: true uses-material-design: true + assets: + - assets/svg/ + # To add assets to your application, add an assets section, like this: # assets: # - images/a_dot_burr.jpeg @@ -107,7 +120,4 @@ flutter: # weight: 700 # # For details regarding fonts from package dependencies, - # see https://flutter.dev/to/font-from-package - generate: true - assets: - - assets/svg/ + # see https://flutter.dev/to/font-from-package \ No newline at end of file