From decf3d296d73c45689ddc4625512754d13768e0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D1=8F=D1=87=D0=B5=D1=81=D0=BB=D0=B0=D0=B2=20=D0=98?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Wed, 25 Sep 2024 12:55:28 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B8=D1=87=D0=B5=D1=81=D0=B0?= =?UTF-8?q?=D0=BB=20=D0=BA=D0=BE=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- l10n/app_en.arb | 4 +- l10n/app_ru.arb | 4 +- lib/components/extensions/context_x.dart | 2 +- lib/components/locale/l10n/app_locale.dart | 4 +- lib/components/locale/l10n/app_locale_en.dart | 4 +- lib/components/locale/l10n/app_locale_ru.dart | 4 +- lib/components/resources.g.dart | 2 +- lib/components/utils/debounce.dart | 8 +- lib/data/dtos/characters_dto.dart | 17 ++-- lib/data/mappers/characters_mapper.dart | 29 +++---- lib/data/repositories/api_interface.dart | 2 +- lib/data/repositories/mock_repository.dart | 9 ++- lib/data/repositories/potter_repository.dart | 5 +- lib/domain/models/card.dart | 14 ++-- lib/domain/models/home.dart | 2 +- lib/main.dart | 5 +- lib/presentation/common/svg_objects.dart | 5 +- .../details_page/details_page.dart | 6 +- lib/presentation/home_page/bloc/bloc.dart | 5 +- lib/presentation/home_page/bloc/events.dart | 2 +- lib/presentation/home_page/bloc/state.dart | 12 +-- lib/presentation/home_page/card.dart | 80 ++++++++++--------- lib/presentation/home_page/home_page.dart | 80 +++++++++++-------- lib/presentation/like_bloc/like_bloc.dart | 8 +- lib/presentation/like_bloc/like_event.dart | 2 +- lib/presentation/like_bloc/like_state.dart | 2 +- lib/presentation/locale_bloc/locale_bloc.dart | 8 +- .../locale_bloc/locale_events.dart | 2 +- .../locale_bloc/locale_state.dart | 2 +- 29 files changed, 178 insertions(+), 151 deletions(-) diff --git a/l10n/app_en.arb b/l10n/app_en.arb index a01051c..62060fc 100644 --- a/l10n/app_en.arb +++ b/l10n/app_en.arb @@ -2,8 +2,8 @@ "@@locale": "en", "search": "Search", - "liked": "liked!", - "disliked": "disliked :(", + "liked": "liked", + "disliked": "disliked", "arbEnding": "Чтобы не забыть про отсутствие запятой :)" } \ No newline at end of file diff --git a/l10n/app_ru.arb b/l10n/app_ru.arb index 7b30d41..d686f4a 100644 --- a/l10n/app_ru.arb +++ b/l10n/app_ru.arb @@ -2,8 +2,8 @@ "@@locale": "ru", "search": "Поиск", - "liked": "понравился!", - "disliked": "разонравился :(", + "liked": "поставлен лайк", + "disliked": "убран лайк", "arbEnding": "Чтобы не забыть про отсутствие запятой :)" } \ No newline at end of file diff --git a/lib/components/extensions/context_x.dart b/lib/components/extensions/context_x.dart index a611371..8e4a7af 100644 --- a/lib/components/extensions/context_x.dart +++ b/lib/components/extensions/context_x.dart @@ -3,4 +3,4 @@ import '../locale/l10n/app_locale.dart'; extension LocalContextX on BuildContext { AppLocale get locale => AppLocale.of(this)!; -} \ No newline at end of file +} diff --git a/lib/components/locale/l10n/app_locale.dart b/lib/components/locale/l10n/app_locale.dart index 0922eb1..80c2c43 100644 --- a/lib/components/locale/l10n/app_locale.dart +++ b/lib/components/locale/l10n/app_locale.dart @@ -104,13 +104,13 @@ abstract class AppLocale { /// No description provided for @liked. /// /// In ru, this message translates to: - /// **'понравился!'** + /// **'поставлен лайк'** String get liked; /// No description provided for @disliked. /// /// In ru, this message translates to: - /// **'разонравился :('** + /// **'убран лайк'** String get disliked; /// No description provided for @arbEnding. diff --git a/lib/components/locale/l10n/app_locale_en.dart b/lib/components/locale/l10n/app_locale_en.dart index 599548c..50c3917 100644 --- a/lib/components/locale/l10n/app_locale_en.dart +++ b/lib/components/locale/l10n/app_locale_en.dart @@ -10,10 +10,10 @@ class AppLocaleEn extends AppLocale { String get search => 'Search'; @override - String get liked => 'liked!'; + String get liked => 'liked'; @override - String get disliked => 'disliked :('; + String get disliked => 'disliked'; @override String get arbEnding => 'Чтобы не забыть про отсутствие запятой :)'; diff --git a/lib/components/locale/l10n/app_locale_ru.dart b/lib/components/locale/l10n/app_locale_ru.dart index b8d5444..d7bd696 100644 --- a/lib/components/locale/l10n/app_locale_ru.dart +++ b/lib/components/locale/l10n/app_locale_ru.dart @@ -10,10 +10,10 @@ class AppLocaleRu extends AppLocale { String get search => 'Поиск'; @override - String get liked => 'понравился!'; + String get liked => 'поставлен лайк'; @override - String get disliked => 'разонравился :('; + String get disliked => 'убран лайк'; @override String get arbEnding => 'Чтобы не забыть про отсутствие запятой :)'; diff --git a/lib/components/resources.g.dart b/lib/components/resources.g.dart index bb620ab..9645894 100644 --- a/lib/components/resources.g.dart +++ b/lib/components/resources.g.dart @@ -7,4 +7,4 @@ class R { static const String ASSETS_SVG_RU_SVG = 'assets/svg/ru.svg'; static const String ASSETS_SVG_UK_SVG = 'assets/svg/uk.svg'; -} \ No newline at end of file +} diff --git a/lib/components/utils/debounce.dart b/lib/components/utils/debounce.dart index 44231fe..6100bef 100644 --- a/lib/components/utils/debounce.dart +++ b/lib/components/utils/debounce.dart @@ -11,10 +11,10 @@ class Debounce { static Timer? _timer; static void run( - VoidCallback action, { - Duration delay = const Duration(milliseconds: 500), - }) { + VoidCallback action, { + Duration delay = const Duration(milliseconds: 500), + }) { _timer?.cancel(); _timer = Timer(delay, action); } -} \ No newline at end of file +} diff --git a/lib/data/dtos/characters_dto.dart b/lib/data/dtos/characters_dto.dart index 6a6b1bf..ad5d14b 100644 --- a/lib/data/dtos/characters_dto.dart +++ b/lib/data/dtos/characters_dto.dart @@ -12,7 +12,8 @@ class CharactersDto { this.meta, }); - factory CharactersDto.fromJson(Map json) => _$CharactersDtoFromJson(json); + factory CharactersDto.fromJson(Map json) => + _$CharactersDtoFromJson(json); } @JsonSerializable(createToJson: false) @@ -23,7 +24,8 @@ class CharacterDataDto { const CharacterDataDto({this.id, this.type, this.attributes}); - factory CharacterDataDto.fromJson(Map json) => _$CharacterDataDtoFromJson(json); + factory CharacterDataDto.fromJson(Map json) => + _$CharacterDataDtoFromJson(json); } @JsonSerializable(createToJson: false) @@ -33,7 +35,8 @@ class CharacterAttributesDataDto { final String? species; final String? image; - const CharacterAttributesDataDto({this.name, this.nationality, this.species, this.image}); + const CharacterAttributesDataDto( + {this.name, this.nationality, this.species, this.image}); factory CharacterAttributesDataDto.fromJson(Map json) => _$CharacterAttributesDataDtoFromJson(json); @@ -45,7 +48,8 @@ class MetaDto { const MetaDto({this.pagination}); - factory MetaDto.fromJson(Map json) => _$MetaDtoFromJson(json); + factory MetaDto.fromJson(Map json) => + _$MetaDtoFromJson(json); } @JsonSerializable(createToJson: false) @@ -56,5 +60,6 @@ class PaginationDto { const PaginationDto({this.current, this.next, this.last}); - factory PaginationDto.fromJson(Map json) => _$PaginationDtoFromJson(json); -} \ No newline at end of file + factory PaginationDto.fromJson(Map json) => + _$PaginationDtoFromJson(json); +} diff --git a/lib/data/mappers/characters_mapper.dart b/lib/data/mappers/characters_mapper.dart index 2d4a79b..4074ebe 100644 --- a/lib/data/mappers/characters_mapper.dart +++ b/lib/data/mappers/characters_mapper.dart @@ -4,27 +4,28 @@ import '../dtos/characters_dto.dart'; extension CharactersDtoToModel on CharactersDto { HomeData toDomain() => HomeData( - data: data?.map((e) => e.toDomain()).toList(), - nextPage: meta?.pagination?.next, - ); + data: data?.map((e) => e.toDomain()).toList(), + nextPage: meta?.pagination?.next, + ); } extension CharacterDataDtoToModel on CharacterDataDto { CardData toDomain() => CardData( - attributes?.name ?? 'UNKNOWN', - image: attributes?.image ?? - 'https://upload.wikimedia.org/wikipedia/en/archive/b/b1/20210811082420%21Portrait_placeholder.png', - descriptionText: _makeDescriptionText(attributes?.nationality, attributes?.species), - id: id, - ); + attributes?.name ?? 'UNKNOWN', + image: attributes?.image ?? + 'https://upload.wikimedia.org/wikipedia/en/archive/b/b1/20210811082420%21Portrait_placeholder.png', + descriptionText: + _makeDescriptionText(attributes?.nationality, attributes?.species), + id: id, + ); String _makeDescriptionText(String? nationality, String? species) { return nationality != null && species != null ? 'Nationality - $nationality \nSpecies - $species' : nationality != null - ? 'Nationality - $nationality' - : species != null - ? 'Species - $species' - : ''; + ? 'Nationality - $nationality' + : species != null + ? 'Species - $species' + : ''; } -} \ No newline at end of file +} diff --git a/lib/data/repositories/api_interface.dart b/lib/data/repositories/api_interface.dart index 5ebe407..f988a2b 100644 --- a/lib/data/repositories/api_interface.dart +++ b/lib/data/repositories/api_interface.dart @@ -4,4 +4,4 @@ typedef OnErrorCallback = void Function(String? error); abstract class ApiInterface { Future loadData({OnErrorCallback? onError}); -} \ No newline at end of file +} diff --git a/lib/data/repositories/mock_repository.dart b/lib/data/repositories/mock_repository.dart index 59a07ca..c86a5f7 100644 --- a/lib/data/repositories/mock_repository.dart +++ b/lib/data/repositories/mock_repository.dart @@ -12,22 +12,23 @@ class MockRepository extends ApiInterface { 'Freeze', descriptionText: 'so cold..', image: - 'https://www.skedaddlewildlife.com/wp-content/uploads/2018/09/depositphotos_22425309-stock-photo-a-lonely-raccoon-in-winter.jpg', + 'https://www.skedaddlewildlife.com/wp-content/uploads/2018/09/depositphotos_22425309-stock-photo-a-lonely-raccoon-in-winter.jpg', ), CardData( 'Hi', descriptionText: 'pretty face', icon: Icons.hail, image: - 'https://www.thesprucepets.com/thmb/nKNaS4I586B_H7sEUw9QAXvWM_0=/2121x0/filters:no_upscale():strip_icc()/GettyImages-135630198-5ba7d225c9e77c0050cff91b.jpg', + 'https://www.thesprucepets.com/thmb/nKNaS4I586B_H7sEUw9QAXvWM_0=/2121x0/filters:no_upscale():strip_icc()/GettyImages-135630198-5ba7d225c9e77c0050cff91b.jpg', ), CardData( 'Orange', descriptionText: 'I like autumn', icon: Icons.warning_amber, - image: 'https://furmanagers.com/wp-content/uploads/2019/11/dreamstime_l_22075357.jpg', + image: + 'https://furmanagers.com/wp-content/uploads/2019/11/dreamstime_l_22075357.jpg', ), ], ); } -} \ No newline at end of file +} diff --git a/lib/data/repositories/potter_repository.dart b/lib/data/repositories/potter_repository.dart index e9f299a..eb49cc2 100644 --- a/lib/data/repositories/potter_repository.dart +++ b/lib/data/repositories/potter_repository.dart @@ -33,7 +33,8 @@ class PotterRepository extends ApiInterface { }, ); - final CharactersDto dto = CharactersDto.fromJson(response.data as Map); + final CharactersDto dto = + CharactersDto.fromJson(response.data as Map); final HomeData data = dto.toDomain(); return data; } on DioException catch (e) { @@ -41,4 +42,4 @@ class PotterRepository extends ApiInterface { return null; } } -} \ No newline at end of file +} diff --git a/lib/domain/models/card.dart b/lib/domain/models/card.dart index 125b8ef..ac67908 100644 --- a/lib/domain/models/card.dart +++ b/lib/domain/models/card.dart @@ -8,10 +8,10 @@ class CardData { final String? id; CardData( - this.text, { - required this.descriptionText, - this.icon = Icons.ac_unit_outlined, - this.image, - this.id, - }); -} \ No newline at end of file + this.text, { + required this.descriptionText, + this.icon = Icons.ac_unit_outlined, + this.image, + this.id, + }); +} diff --git a/lib/domain/models/home.dart b/lib/domain/models/home.dart index 4f1fbf6..2f0ba57 100644 --- a/lib/domain/models/home.dart +++ b/lib/domain/models/home.dart @@ -5,4 +5,4 @@ class HomeData { final int? nextPage; HomeData({this.data, this.nextPage}); -} \ No newline at end of file +} diff --git a/lib/main.dart b/lib/main.dart index 498ad5f..15ecd2e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -215,7 +215,8 @@ class MyApp extends StatelessWidget { create: (context) => LikeBloc(), child: BlocProvider( lazy: false, - create: (context) => HomeBloc(context.read()), + create: (context) => + HomeBloc(context.read()), child: const HomePage(), ), ), @@ -225,4 +226,4 @@ class MyApp extends StatelessWidget { ), ); } -} \ No newline at end of file +} diff --git a/lib/presentation/common/svg_objects.dart b/lib/presentation/common/svg_objects.dart index 7770ff2..7cb3d1d 100644 --- a/lib/presentation/common/svg_objects.dart +++ b/lib/presentation/common/svg_objects.dart @@ -10,7 +10,8 @@ abstract class SvgObjects { ]; for (final String p in pics) { final loader = SvgAssetLoader(p); - svg.cache.putIfAbsent(loader.cacheKey(null), () => loader.loadBytes(null)); + svg.cache + .putIfAbsent(loader.cacheKey(null), () => loader.loadBytes(null)); } } } @@ -31,4 +32,4 @@ class SvgUk extends StatelessWidget { Widget build(BuildContext context) { return SvgPicture.asset(R.ASSETS_SVG_UK_SVG); } -} \ No newline at end of file +} diff --git a/lib/presentation/details_page/details_page.dart b/lib/presentation/details_page/details_page.dart index 423df5c..519bf4f 100644 --- a/lib/presentation/details_page/details_page.dart +++ b/lib/presentation/details_page/details_page.dart @@ -23,14 +23,14 @@ class DetailsPage extends StatelessWidget { const SizedBox(height: 20), Text(data.text, style: - const TextStyle(fontSize: 24, fontWeight: FontWeight.bold)), + const TextStyle(fontSize: 24, fontWeight: FontWeight.bold)), const SizedBox(height: 10), Text(data.descriptionText, - style: const TextStyle(fontSize: 22, color: Colors.black87)), + style: const TextStyle(fontSize: 22, color: Colors.black87)), // Add more details here as needed ], ), ), ); } -} \ No newline at end of file +} diff --git a/lib/presentation/home_page/bloc/bloc.dart b/lib/presentation/home_page/bloc/bloc.dart index 31cb06c..d5d4241 100644 --- a/lib/presentation/home_page/bloc/bloc.dart +++ b/lib/presentation/home_page/bloc/bloc.dart @@ -10,7 +10,8 @@ class HomeBloc extends Bloc { on(_onLoadData); } - Future _onLoadData(HomeLoadDataEvent event, Emitter emit) async { + Future _onLoadData( + HomeLoadDataEvent event, Emitter emit) async { if (event.nextPage == null) { emit(state.copyWith(isLoading: true)); } else { @@ -36,4 +37,4 @@ class HomeBloc extends Bloc { error: error, )); } -} \ No newline at end of file +} diff --git a/lib/presentation/home_page/bloc/events.dart b/lib/presentation/home_page/bloc/events.dart index 025c2b0..cefba70 100644 --- a/lib/presentation/home_page/bloc/events.dart +++ b/lib/presentation/home_page/bloc/events.dart @@ -7,4 +7,4 @@ class HomeLoadDataEvent extends HomeEvent { final int? nextPage; const HomeLoadDataEvent({this.search, this.nextPage}); -} \ No newline at end of file +} diff --git a/lib/presentation/home_page/bloc/state.dart b/lib/presentation/home_page/bloc/state.dart index b021be0..0e9f22f 100644 --- a/lib/presentation/home_page/bloc/state.dart +++ b/lib/presentation/home_page/bloc/state.dart @@ -20,9 +20,9 @@ class HomeState extends Equatable { @override List get props => [ - data, - isLoading, - isPaginationLoading, - error, - ]; -} \ No newline at end of file + data, + isLoading, + isPaginationLoading, + error, + ]; +} diff --git a/lib/presentation/home_page/card.dart b/lib/presentation/home_page/card.dart index 4f79598..11c58e4 100644 --- a/lib/presentation/home_page/card.dart +++ b/lib/presentation/home_page/card.dart @@ -13,22 +13,22 @@ class _Card extends StatelessWidget { final bool isLiked; const _Card( - this.text, { - this.icon = Icons.ac_unit_outlined, - required this.descriptionText, - this.image, - this.onLike, - this.onTap, - this.id, - this.isLiked = false, - }); + this.text, { + this.icon = Icons.ac_unit_outlined, + required this.descriptionText, + this.image, + this.onLike, + this.onTap, + this.id, + this.isLiked = false, + }); factory _Card.fromData( - CardData data, { - OnLikeCallback onLike, - VoidCallback? onTap, - bool isLiked = false, - }) => + CardData data, { + OnLikeCallback onLike, + VoidCallback? onTap, + bool isLiked = false, + }) => _Card( data.text, descriptionText: data.descriptionText, @@ -48,7 +48,7 @@ class _Card extends StatelessWidget { margin: const EdgeInsets.all(16), constraints: const BoxConstraints(minHeight: 240), decoration: BoxDecoration( - color: Colors.white30, + color: Colors.grey, borderRadius: BorderRadius.circular(20), boxShadow: [ BoxShadow( @@ -61,6 +61,29 @@ class _Card extends StatelessWidget { ), child: Column( children: [ + Align( + alignment: Alignment.bottomRight, + child: Padding( + padding: const EdgeInsets.only( + left: 8, right: 16, bottom: 16, top: 10), + child: GestureDetector( + onTap: () => onLike?.call(id, text, isLiked), + child: AnimatedSwitcher( + duration: const Duration(milliseconds: 200), + child: isLiked + ? const Icon( + Icons.favorite, + color: Colors.redAccent, + key: ValueKey(0), + ) + : const Icon( + Icons.favorite_border, + key: ValueKey(1), + ), + ), + ), + ), + ), ClipRRect( borderRadius: const BorderRadius.only( topLeft: Radius.circular(20), @@ -83,7 +106,8 @@ class _Card extends StatelessWidget { ), ), Padding( - padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0), + padding: + const EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0), child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ @@ -100,31 +124,9 @@ class _Card extends StatelessWidget { ], ), ), - Align( - alignment: Alignment.bottomRight, - child: Padding( - padding: const EdgeInsets.only(left: 8, right: 16, bottom: 16), - child: GestureDetector( - onTap: () => onLike?.call(id, text, isLiked), - child: AnimatedSwitcher( - duration: const Duration(milliseconds: 200), - child: isLiked - ? const Icon( - Icons.favorite, - color: Colors.redAccent, - key: ValueKey(0), - ) - : const Icon( - Icons.favorite_border, - key: ValueKey(1), - ), - ), - ), - ), - ), ], ), ), ); } -} \ No newline at end of file +} diff --git a/lib/presentation/home_page/home_page.dart b/lib/presentation/home_page/home_page.dart index 77d9e25..fee46c3 100644 --- a/lib/presentation/home_page/home_page.dart +++ b/lib/presentation/home_page/home_page.dart @@ -59,7 +59,7 @@ class _BodyState extends State<_Body> { void _onNextPageListener() { if (scrollController.offset > scrollController.position.maxScrollExtent) { - // preventing multiple pagination request on multiple swipes +// preventing multiple pagination request on multiple swipes final bloc = context.read(); if (!bloc.state.isPaginationLoading) { bloc.add(HomeLoadDataEvent( @@ -93,14 +93,16 @@ class _BodyState extends State<_Body> { controller: searchController, placeholder: context.locale.search, onChanged: (search) { - Debounce.run( - () => context.read().add(HomeLoadDataEvent(search: search))); + Debounce.run(() => context + .read() + .add(HomeLoadDataEvent(search: search))); }, ), ), ), GestureDetector( - onTap: () => context.read().add(const ChangeLocaleEvent()), + onTap: () => + context.read().add(const ChangeLocaleEvent()), child: SizedBox.square( dimension: 50, child: Padding( @@ -120,36 +122,42 @@ class _BodyState extends State<_Body> { BlocBuilder( builder: (context, state) => state.error != null ? Text( - state.error ?? '', - style: Theme.of(context).textTheme.headlineSmall?.copyWith(color: Colors.red), - ) + state.error ?? '', + style: Theme.of(context) + .textTheme + .headlineSmall + ?.copyWith(color: Colors.red), + ) : state.isLoading - ? const CircularProgressIndicator() - : BlocBuilder( - builder: (context, likeState) { - return Expanded( - child: RefreshIndicator( - onRefresh: _onRefresh, - child: ListView.builder( - controller: scrollController, - padding: EdgeInsets.zero, - itemCount: state.data?.data?.length ?? 0, - itemBuilder: (context, index) { - final data = state.data?.data?[index]; - return data != null - ? _Card.fromData( - data, - onLike: _onLike, - isLiked: likeState.likedIds?.contains(data.id) == true, - onTap: () => _navToDetails(context, data), - ) - : const SizedBox.shrink(); - }, - ), - ), - ); - }, - ), + ? const CircularProgressIndicator() + : BlocBuilder( + builder: (context, likeState) { + return Expanded( + child: RefreshIndicator( + onRefresh: _onRefresh, + child: ListView.builder( + controller: scrollController, + padding: EdgeInsets.zero, + itemCount: state.data?.data?.length ?? 0, + itemBuilder: (context, index) { + final data = state.data?.data?[index]; + return data != null + ? _Card.fromData( + data, + onLike: _onLike, + isLiked: likeState.likedIds + ?.contains(data.id) == + true, + onTap: () => + _navToDetails(context, data), + ) + : const SizedBox.shrink(); + }, + ), + ), + ); + }, + ), ), BlocBuilder( builder: (context, state) => state.isPaginationLoading @@ -162,7 +170,9 @@ class _BodyState extends State<_Body> { } Future _onRefresh() { - context.read().add(HomeLoadDataEvent(search: searchController.text)); + context + .read() + .add(HomeLoadDataEvent(search: searchController.text)); return Future.value(null); } @@ -192,4 +202,4 @@ class _BodyState extends State<_Body> { )); }); } -} \ No newline at end of file +} diff --git a/lib/presentation/like_bloc/like_bloc.dart b/lib/presentation/like_bloc/like_bloc.dart index 17a9415..f48eb75 100644 --- a/lib/presentation/like_bloc/like_bloc.dart +++ b/lib/presentation/like_bloc/like_bloc.dart @@ -11,14 +11,16 @@ class LikeBloc extends Bloc { on(_onLoadLikes); } - Future _onLoadLikes(LoadLikesEvent event, Emitter emit) async { + Future _onLoadLikes( + LoadLikesEvent event, Emitter emit) async { final prefs = await SharedPreferences.getInstance(); final data = prefs.getStringList(_likedPrefsKey); emit(state.copyWith(likedIds: data)); } - Future _onChangeLike(ChangeLikeEvent event, Emitter emit) async { + Future _onChangeLike( + ChangeLikeEvent event, Emitter emit) async { final updatedList = List.from(state.likedIds ?? []); if (updatedList.contains(event.id)) { @@ -32,4 +34,4 @@ class LikeBloc extends Bloc { emit(state.copyWith(likedIds: updatedList)); } -} \ No newline at end of file +} diff --git a/lib/presentation/like_bloc/like_event.dart b/lib/presentation/like_bloc/like_event.dart index 43032db..d0326d8 100644 --- a/lib/presentation/like_bloc/like_event.dart +++ b/lib/presentation/like_bloc/like_event.dart @@ -10,4 +10,4 @@ class ChangeLikeEvent extends LikeEvent { final String id; const ChangeLikeEvent(this.id); -} \ No newline at end of file +} diff --git a/lib/presentation/like_bloc/like_state.dart b/lib/presentation/like_bloc/like_state.dart index 0099c7c..5f0959f 100644 --- a/lib/presentation/like_bloc/like_state.dart +++ b/lib/presentation/like_bloc/like_state.dart @@ -11,4 +11,4 @@ class LikeState extends Equatable { @override List get props => [likedIds]; -} \ No newline at end of file +} diff --git a/lib/presentation/locale_bloc/locale_bloc.dart b/lib/presentation/locale_bloc/locale_bloc.dart index 0b3baba..d97e13a 100644 --- a/lib/presentation/locale_bloc/locale_bloc.dart +++ b/lib/presentation/locale_bloc/locale_bloc.dart @@ -5,13 +5,15 @@ import 'package:flutter_app/presentation/locale_bloc/locale_state.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; class LocaleBloc extends Bloc { - LocaleBloc(Locale defaultLocale) : super(LocaleState(currentLocale: defaultLocale)) { + LocaleBloc(Locale defaultLocale) + : super(LocaleState(currentLocale: defaultLocale)) { on(_onChangeLocale); } - Future _onChangeLocale(ChangeLocaleEvent event, Emitter emit) async { + Future _onChangeLocale( + ChangeLocaleEvent event, Emitter emit) async { final toChange = AppLocale.supportedLocales .firstWhere((e) => e.languageCode != state.currentLocale.languageCode); emit(state.copyWith(currentLocale: toChange)); } -} \ No newline at end of file +} diff --git a/lib/presentation/locale_bloc/locale_events.dart b/lib/presentation/locale_bloc/locale_events.dart index f345ef9..c08cd1b 100644 --- a/lib/presentation/locale_bloc/locale_events.dart +++ b/lib/presentation/locale_bloc/locale_events.dart @@ -4,4 +4,4 @@ abstract class LocaleEvent { class ChangeLocaleEvent extends LocaleEvent { const ChangeLocaleEvent(); -} \ No newline at end of file +} diff --git a/lib/presentation/locale_bloc/locale_state.dart b/lib/presentation/locale_bloc/locale_state.dart index 8539fbf..b9221ca 100644 --- a/lib/presentation/locale_bloc/locale_state.dart +++ b/lib/presentation/locale_bloc/locale_state.dart @@ -12,4 +12,4 @@ class LocaleState extends Equatable { @override List get props => [currentLocale]; -} \ No newline at end of file +}