в целома работает
This commit is contained in:
parent
dba446ccd9
commit
c1d6ed3a26
Before Width: | Height: | Size: 968 B After Width: | Height: | Size: 968 B |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
@ -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)!;
|
||||
|
@ -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:
|
||||
|
@ -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 => 'Чтобы не забыть про отсутствие запятой :)';
|
||||
|
@ -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 => 'Чтобы не забыть про отсутствие запятой :)';
|
||||
|
10
flutter_app/lib/components/resources.g.dart
Normal file
10
flutter_app/lib/components/resources.g.dart
Normal file
@ -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';
|
||||
}
|
@ -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) {
|
||||
|
@ -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,
|
||||
});
|
||||
}
|
||||
|
@ -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<ThronesRepository>(
|
||||
// lazy: true,
|
||||
// create: (_) => ThronesRepository(),
|
||||
// child: BlocProvider<HomeBloc>(
|
||||
// lazy: false,
|
||||
// create: (context) => HomeBloc(context.read<ThronesRepository>()),
|
||||
// child: const MyHomePage(title: '7 Kingdoms'),
|
||||
// ),
|
||||
// ));
|
||||
|
||||
return BlocProvider<LocaleBloc>(
|
||||
lazy: false,
|
||||
create: (context) => LocaleBloc((Locale(Platform.localeName))),
|
||||
|
@ -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 = <String>[
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -144,7 +144,7 @@ class _BodyState extends State<Body> {
|
||||
? _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<Body> {
|
||||
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<LikeBloc>().add(ChangeLikeEvent(id));
|
||||
_showSnackBar(context, title, isLiked);
|
||||
|
@ -22,10 +22,7 @@ class LikeBloc extends Bloc<LikeEvent, LikeState> {
|
||||
}
|
||||
|
||||
FutureOr<void> _onChangeLike(ChangeLikeEvent event, Emitter<LikeState> emit) async{
|
||||
final updatedListInt = List<int>.from(state.likedIds ?? []);
|
||||
print(updatedListInt);
|
||||
final updatedList = updatedListInt.map((int number) => number.toString()).toList();
|
||||
print(updatedList);
|
||||
final updatedList = List<String>.from(state.likedIds ?? []);
|
||||
|
||||
if (updatedList.contains(event.id.toString())) {
|
||||
updatedList.remove(event.id.toString());
|
||||
|
@ -7,7 +7,7 @@ class LoadLikesEvent extends LikeEvent {
|
||||
}
|
||||
|
||||
class ChangeLikeEvent extends LikeEvent {
|
||||
final int id;
|
||||
final String id;
|
||||
|
||||
const ChangeLikeEvent(this.id);
|
||||
}
|
@ -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
|
||||
@ -108,6 +121,3 @@ flutter:
|
||||
#
|
||||
# For details regarding fonts from package dependencies,
|
||||
# see https://flutter.dev/to/font-from-package
|
||||
generate: true
|
||||
assets:
|
||||
- assets/svg/
|
||||
|
Loading…
Reference in New Issue
Block a user