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..318aec9 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-mdpi/ic_launcher.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
index 17987b7..610643e 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-xhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
index 09d4391..312181c 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-xxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
index d5f1c8d..e127bb4 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-xxxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
index 4d6372e..afb2aad 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/assets/logo.jpg b/assets/logo.jpg
new file mode 100644
index 0000000..52222ab
Binary files /dev/null and b/assets/logo.jpg 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/uk.svg b/assets/svg/uk.svg
new file mode 100644
index 0000000..88e2211
--- /dev/null
+++ b/assets/svg/uk.svg
@@ -0,0 +1,23 @@
+
+
+
\ No newline at end of file
diff --git a/devtools_options.yaml b/devtools_options.yaml
new file mode 100644
index 0000000..7e9e947
--- /dev/null
+++ b/devtools_options.yaml
@@ -0,0 +1,3 @@
+description: This file stores settings for Dart & Flutter DevTools.
+documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
+extensions:
\ No newline at end of file
diff --git a/l10n.yaml b/l10n.yaml
new file mode 100644
index 0000000..d26d702
--- /dev/null
+++ b/l10n.yaml
@@ -0,0 +1,6 @@
+arb-dir: l10n
+template-arb-file: app_ru.arb
+output-localization-file: 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..6460b3a
--- /dev/null
+++ b/l10n/app_en.arb
@@ -0,0 +1,11 @@
+{
+ "@@locale": "en",
+
+ "search": "Search",
+ "liked": "liked",
+ "disliked": "disliked",
+ "previous": "previous",
+ "next": "next",
+
+ "arbEnding": "Чтобы не забыть про отсутствие запятой :)"
+}
\ No newline at end of file
diff --git a/l10n/app_ru.arb b/l10n/app_ru.arb
new file mode 100644
index 0000000..d784413
--- /dev/null
+++ b/l10n/app_ru.arb
@@ -0,0 +1,11 @@
+{
+ "@@locale": "ru",
+
+ "search": "Поиск",
+ "liked": "поставлен лайк",
+ "disliked": "убран лайк",
+ "previous": "назад",
+ "next": "вперёд",
+
+ "arbEnding": "Чтобы не забыть про отсутствие запятой :)"
+}
\ 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..8e4a7af
--- /dev/null
+++ b/lib/components/extensions/context_x.dart
@@ -0,0 +1,6 @@
+import 'package:flutter/widgets.dart';
+import '../locale/l10n/app_locale.dart';
+
+extension LocalContextX on BuildContext {
+ AppLocale get locale => AppLocale.of(this)!;
+}
diff --git a/lib/components/locale/l10n/app_locale.dart b/lib/components/locale/l10n/app_locale.dart
new file mode 100644
index 0000000..b9cad0b
--- /dev/null
+++ b/lib/components/locale/l10n/app_locale.dart
@@ -0,0 +1,165 @@
+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_locale_en.dart';
+import 'app_locale_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_locale.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 @disliked.
+ ///
+ /// In ru, this message translates to:
+ /// **'убран лайк'**
+ String get disliked;
+
+ /// No description provided for @previous.
+ ///
+ /// In ru, this message translates to:
+ /// **'назад'**
+ String get previous;
+
+ /// No description provided for @next.
+ ///
+ /// In ru, this message translates to:
+ /// **'вперёд'**
+ String get next;
+
+ /// No description provided for @arbEnding.
+ ///
+ /// In ru, this message translates to:
+ /// **'Чтобы не забыть про отсутствие запятой :)'**
+ 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_locale_en.dart b/lib/components/locale/l10n/app_locale_en.dart
new file mode 100644
index 0000000..1da8092
--- /dev/null
+++ b/lib/components/locale/l10n/app_locale_en.dart
@@ -0,0 +1,26 @@
+import 'app_locale.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 => 'liked';
+
+ @override
+ String get disliked => 'disliked';
+
+ @override
+ String get previous => 'previous';
+
+ @override
+ String get next => 'next';
+
+ @override
+ String get arbEnding => 'Чтобы не забыть про отсутствие запятой :)';
+}
diff --git a/lib/components/locale/l10n/app_locale_ru.dart b/lib/components/locale/l10n/app_locale_ru.dart
new file mode 100644
index 0000000..300b102
--- /dev/null
+++ b/lib/components/locale/l10n/app_locale_ru.dart
@@ -0,0 +1,26 @@
+import 'app_locale.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 disliked => 'убран лайк';
+
+ @override
+ String get previous => 'назад';
+
+ @override
+ String get next => 'вперёд';
+
+ @override
+ String get arbEnding => 'Чтобы не забыть про отсутствие запятой :)';
+}
diff --git a/lib/components/resources.g.dart b/lib/components/resources.g.dart
new file mode 100644
index 0000000..9645894
--- /dev/null
+++ b/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/lib/components/utils/debounce.dart b/lib/components/utils/debounce.dart
index 6b10be1..197c25f 100644
--- a/lib/components/utils/debounce.dart
+++ b/lib/components/utils/debounce.dart
@@ -10,11 +10,11 @@ class Debounce {
static Timer? _timer;
- static void run (
- VoidCallback action, {
- Duration delay = const Duration(milliseconds: 2000),
- }) {
+ static void run(
+ VoidCallback action, {
+ Duration delay = const Duration(milliseconds: 2000),
+ }) {
_timer?.cancel();
_timer = Timer(delay, action);
}
-}
\ No newline at end of file
+}
diff --git a/lib/const/resource.dart b/lib/const/resource.dart
new file mode 100644
index 0000000..51c9249
--- /dev/null
+++ b/lib/const/resource.dart
@@ -0,0 +1,6 @@
+/// 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._();
+}
diff --git a/lib/data/dtos/cats_dto.dart b/lib/data/dtos/cats_dto.dart
index 2c8fff2..a086a7e 100644
--- a/lib/data/dtos/cats_dto.dart
+++ b/lib/data/dtos/cats_dto.dart
@@ -22,4 +22,4 @@ class CatDataDto {
const CatDataDto({this.imageLink, this.name, this.origin, this.length});
factory CatDataDto.fromJson(Map json) => _$CatDataDtoFromJson(json);
-}
\ No newline at end of file
+}
diff --git a/lib/data/dtos/cats_dto.g.dart b/lib/data/dtos/cats_dto.g.dart
index a9c1a94..1a18577 100644
--- a/lib/data/dtos/cats_dto.g.dart
+++ b/lib/data/dtos/cats_dto.g.dart
@@ -7,14 +7,14 @@ part of 'cats_dto.dart';
// **************************************************************************
CatsDto _$CatsDtoFromJson(List json) => CatsDto(
- data: (json as List?)
- ?.map((e) => CatDataDto.fromJson(e as Map))
- .toList(),
-);
+ data: (json as List?)
+ ?.map((e) => CatDataDto.fromJson(e as Map))
+ .toList(),
+ );
CatDataDto _$CatDataDtoFromJson(Map json) => CatDataDto(
- imageLink: json['image_link'] as String?,
- name: json['name'] as String?,
- origin: json['origin'] as String?,
- length: json['length'] as String?,
-);
\ No newline at end of file
+ imageLink: json['image_link'] as String?,
+ name: json['name'] as String?,
+ origin: json['origin'] as String?,
+ length: json['length'] as String?,
+ );
diff --git a/lib/data/mappers/cats_mapper.dart b/lib/data/mappers/cats_mapper.dart
index 2dccbd2..f340bd1 100644
--- a/lib/data/mappers/cats_mapper.dart
+++ b/lib/data/mappers/cats_mapper.dart
@@ -7,25 +7,25 @@ const _imagePlaceholder =
extension CatsDtoToModel on CatsDto {
HomeData toDomain() => HomeData(
- data: data?.map((e) => e.toDomain()).toList(),
- );
+ data: data?.map((e) => e.toDomain()).toList(),
+ nextPage: data != null && data!.isNotEmpty ? 20 : null,
+ );
}
extension CatDataDtoToModel on CatDataDto {
CardData toDomain() => CardData(
- name ?? 'UNKNOWN',
- imageUrl: imageLink ?? _imagePlaceholder,
- descriptionText:
- _makeDescriptionText(origin, length),
- );
+ name ?? 'UNKNOWN',
+ imageUrl: imageLink ?? _imagePlaceholder,
+ descriptionText: _makeDescriptionText(origin, length),
+ );
String _makeDescriptionText(String? origin, String? length) {
return origin != null || length != null
? 'Origin: $origin \nLength: $length'
: origin != null
- ? 'Origin: $origin'
- : length != null
- ? 'Length: $length'
- : '';
+ ? 'Origin: $origin'
+ : length != null
+ ? 'Length: $length'
+ : '';
}
-}
\ No newline at end of file
+}
diff --git a/lib/data/repositories/api_interface.dart b/lib/data/repositories/api_interface.dart
index 3e0e205..9b212ec 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/cats_repository.dart b/lib/data/repositories/cats_repository.dart
index c50ba3f..b64ea6b 100644
--- a/lib/data/repositories/cats_repository.dart
+++ b/lib/data/repositories/cats_repository.dart
@@ -2,10 +2,8 @@ import 'package:dio/dio.dart';
import 'package:pmu/data/dtos/cats_dto.dart';
import 'package:pmu/data/mappers/cats_mapper.dart';
import 'package:pmu/data/repositories/api_interface.dart';
-import 'package:pmu/domain/models/card.dart';
import 'package:pretty_dio_logger/pretty_dio_logger.dart';
import 'package:pmu/domain/models/home.dart';
-import 'package:pmu/presentation/home_page/bloc/events.dart';
class CatsRepository extends ApiInterface {
static final Dio _dio = Dio(BaseOptions(
@@ -22,7 +20,7 @@ class CatsRepository extends ApiInterface {
OnErrorCallback? onError,
String? q,
int offset = 0,
- int pageSize = 20,
+ //int minWeight=1,
}) async {
try {
const String url = '/v1/cats?min_weight=1';
@@ -30,9 +28,9 @@ class CatsRepository extends ApiInterface {
final Response response = await _dio.get(
url,
queryParameters: {
+ //'min_weight': minWeight,
'name': q,
'offset': offset,
- 'limit': pageSize,
},
);
@@ -45,4 +43,4 @@ class CatsRepository extends ApiInterface {
return null;
}
}
-}
\ No newline at end of file
+}
diff --git a/lib/data/repositories/mock_repository.dart b/lib/data/repositories/mock_repository.dart
index 37434dc..eb3a25f 100644
--- a/lib/data/repositories/mock_repository.dart
+++ b/lib/data/repositories/mock_repository.dart
@@ -11,23 +11,22 @@ class MockRepository extends ApiInterface {
CardData(
'Абиссинская',
descriptionText: 'Эфиопия',
- imageUrl:
- 'https://ajo-pet.ru/u/ckupload/files/abissinskaya-koshka-sorrel.jpg',
+ imageUrl: 'https://ajo-pet.ru/u/ckupload/files/abissinskaya-koshka-sorrel.jpg',
),
CardData(
'Британская',
descriptionText: 'Великобритания',
icon: Icons.hail,
- imageUrl:
- 'https://zoopt.ru/upload/iblock/ce2/britan.png',
+ imageUrl: 'https://zoopt.ru/upload/iblock/ce2/britan.png',
),
CardData(
'Невская Маскарадная',
descriptionText: 'СССР',
icon: Icons.warning_amber,
- imageUrl: 'https://wikipet.ru/wp-content/uploads/2018-10/1539243031_1491312430_nev_mask_info.jpg',
+ imageUrl:
+ 'https://wikipet.ru/wp-content/uploads/2018-10/1539243031_1491312430_nev_mask_info.jpg',
),
],
);
}
-}
\ No newline at end of file
+}
diff --git a/lib/domain/models/card.dart b/lib/domain/models/card.dart
index 39e24b7..4cd7e71 100644
--- a/lib/domain/models/card.dart
+++ b/lib/domain/models/card.dart
@@ -5,11 +5,13 @@ class CardData {
final String descriptionText;
final IconData icon;
final String? imageUrl;
+ final String? id;
CardData(
- this.text, {
- required this.descriptionText,
- this.icon = Icons.ac_unit_outlined,
- this.imageUrl,
- });
-}
\ No newline at end of file
+ this.text, {
+ required this.descriptionText,
+ this.icon = Icons.ac_unit_outlined,
+ this.imageUrl,
+ this.id,
+ });
+}
diff --git a/lib/domain/models/home.dart b/lib/domain/models/home.dart
index 12a9508..2f0ba57 100644
--- a/lib/domain/models/home.dart
+++ b/lib/domain/models/home.dart
@@ -2,7 +2,7 @@ import 'card.dart';
class HomeData {
final List? data;
- final int? offset;
+ final int? nextPage;
- HomeData({this.data, this.offset});
-}
\ No newline at end of file
+ HomeData({this.data, this.nextPage});
+}
diff --git a/lib/main.dart b/lib/main.dart
index ddb4135..d3ec840 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -1,4 +1,4 @@
-import 'package:flutter/material.dart';
+/*import 'package:flutter/material.dart';
import 'package:pmu/data/repositories/cats_repository.dart';
import 'package:pmu/presentation/home_page/home_page.dart';
import 'package:pmu/presentation/home_page/bloc/bloc.dart';
@@ -31,4 +31,59 @@ class MyApp extends StatelessWidget {
),
);
}
-}
\ No newline at end of file
+}*/
+import 'dart:io';
+
+import 'package:flutter/material.dart';
+import 'package:pmu/components/locale/l10n/app_locale.dart';
+import 'package:pmu/data/repositories/cats_repository.dart';
+import 'package:pmu/presentation/home_page/bloc/bloc.dart';
+import 'package:pmu/presentation/home_page/home_page.dart';
+import 'package:pmu/presentation/like_bloc/like_bloc.dart';
+import 'package:pmu/presentation/locale_bloc/locale_bloc.dart';
+import 'package:pmu/presentation/locale_bloc/locale_state.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+
+void main() {
+ runApp(const MyApp());
+}
+
+class MyApp extends StatelessWidget {
+ const MyApp({super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ return BlocProvider(
+ lazy: false,
+ create: (context) => LocaleBloc(Locale(Platform.localeName)),
+ child: BlocBuilder(
+ builder: (context, state) {
+ return MaterialApp(
+ title: 'Flutter Demo',
+ locale: state.currentLocale,
+ localizationsDelegates: AppLocale.localizationsDelegates,
+ supportedLocales: AppLocale.supportedLocales,
+ debugShowCheckedModeBanner: false,
+ theme: ThemeData(
+ colorScheme: ColorScheme.fromSeed(seedColor: Colors.orangeAccent),
+ useMaterial3: true,
+ ),
+ home: RepositoryProvider(
+ lazy: true,
+ create: (_) => CatsRepository(),
+ child: BlocProvider(
+ lazy: false,
+ create: (context) => LikeBloc(),
+ child: BlocProvider(
+ lazy: false,
+ create: (context) => HomeBloc(context.read()),
+ child: const MyHomePage(),
+ ),
+ ),
+ ),
+ );
+ },
+ ),
+ );
+ }
+}
diff --git a/lib/presentation/common/svg_objects.dart b/lib/presentation/common/svg_objects.dart
new file mode 100644
index 0000000..9a41074
--- /dev/null
+++ b/lib/presentation/common/svg_objects.dart
@@ -0,0 +1,34 @@
+import 'package:flutter/widgets.dart';
+import 'package:flutter_svg/flutter_svg.dart';
+import '../../components/resources.g.dart';
+
+abstract class SvgObjects {
+ static void init() {
+ final pics = [
+ R.ASSETS_SVG_RU_SVG,
+ R.ASSETS_SVG_UK_SVG,
+ ];
+ for (final String p in pics) {
+ final loader = SvgAssetLoader(p);
+ svg.cache.putIfAbsent(loader.cacheKey(null), () => loader.loadBytes(null));
+ }
+ }
+}
+
+class SvgRu extends StatelessWidget {
+ const SvgRu({super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ return SvgPicture.asset(R.ASSETS_SVG_RU_SVG);
+ }
+}
+
+class SvgUk extends StatelessWidget {
+ const SvgUk({super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ return SvgPicture.asset(R.ASSETS_SVG_UK_SVG);
+ }
+}
diff --git a/lib/presentation/details_page/details_page.dart b/lib/presentation/details_page/details_page.dart
index c24f52f..d0d6285 100644
--- a/lib/presentation/details_page/details_page.dart
+++ b/lib/presentation/details_page/details_page.dart
@@ -10,28 +10,24 @@ class DetailsPage extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
- body: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Padding(
- padding: const EdgeInsets.only(bottom: 16.0),
- child: Image.network(
- data.imageUrl ?? '',
+ body: Padding(
+ padding: const EdgeInsets.all(20),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ children: [
+ Center(
+ child: Image.network(
+ data.imageUrl ?? '',
+ ),
),
- ),
- Padding(
- padding: const EdgeInsets.only(bottom: 4.0),
- child: Text(
- data.text,
- style: TextStyle(fontSize: 23),
- ),
- ),
- Text(
- data.descriptionText,
- style: TextStyle(fontSize: 19),
- )
- ],
+ const SizedBox(height: 20),
+ Text(data.text, style: const TextStyle(fontSize: 24, fontWeight: FontWeight.bold)),
+ const SizedBox(height: 10),
+ Text(data.descriptionText, 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 d7c5051..1c7f1a4 100644
--- a/lib/presentation/home_page/bloc/bloc.dart
+++ b/lib/presentation/home_page/bloc/bloc.dart
@@ -2,6 +2,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:pmu/data/repositories/cats_repository.dart';
import 'package:pmu/presentation/home_page/bloc/events.dart';
import 'package:pmu/presentation/home_page/bloc/state.dart';
+import '../../../domain/models/home.dart';
class HomeBloc extends Bloc {
final CatsRepository repo;
@@ -11,7 +12,7 @@ class HomeBloc extends Bloc {
}
Future _onLoadData(HomeLoadDataEvent event, Emitter emit) async {
- if (event.offset == 0) {
+ if (event.nextPage == 0) {
emit(state.copyWith(isLoading: true));
} else {
emit(state.copyWith(isPaginationLoading: true));
@@ -21,27 +22,22 @@ class HomeBloc extends Bloc {
final data = await repo.loadData(
q: event.search,
+ offset: event.nextPage ?? 0,
onError: (e) => error = e,
- offset: event.offset,
);
- if (data != null) {
- final updatedData = (event.offset == 0
- ? data.data
- : [...state.data?.data ?? [], ...data.data ?? []]);
+ final updatedData = event.nextPage != null && data != null
+ ? HomeData(
+ data: [...state.data?.data ?? [], ...data.data!],
+ nextPage: (event.nextPage! + 1),
+ )
+ : data;
- emit(state.copyWith(
- isLoading: false,
- isPaginationLoading: false,
- data: HomeData(data: updatedData),
- error: error,
- ));
- } else {
- emit(state.copyWith(
- isLoading: false,
- isPaginationLoading: false,
- error: error,
- ));
- }
+ emit(state.copyWith(
+ isLoading: false,
+ isPaginationLoading: false,
+ data: updatedData,
+ 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 49e56e6..cefba70 100644
--- a/lib/presentation/home_page/bloc/events.dart
+++ b/lib/presentation/home_page/bloc/events.dart
@@ -4,7 +4,7 @@ abstract class HomeEvent {
class HomeLoadDataEvent extends HomeEvent {
final String? search;
- final int offset;
+ final int? nextPage;
- const HomeLoadDataEvent({this.search, this.offset = 0});
-}
\ No newline at end of file
+ const HomeLoadDataEvent({this.search, this.nextPage});
+}
diff --git a/lib/presentation/home_page/bloc/state.dart b/lib/presentation/home_page/bloc/state.dart
index 8446dd9..a9ede65 100644
--- a/lib/presentation/home_page/bloc/state.dart
+++ b/lib/presentation/home_page/bloc/state.dart
@@ -22,10 +22,10 @@ class HomeState extends Equatable {
@override
List