diff --git a/Makefile.mk b/Makefile.mk
new file mode 100644
index 0000000..85df52d
--- /dev/null
+++ b/Makefile.mk
@@ -0,0 +1,15 @@
+gen:
+ flutter pub run build_runner build --delete-conflicting-outputs
+icon:
+ flutter pub run flutter_launcher_icons:main
+init_res:
+ dart pub global activate flutter_asset_generator
+ flutter pub global activate fgen
+format:
+ dart format . --line-length 100
+res:
+ fgen --output lib/components/resources.g.dart --no-watch --no-preview; \
+ make format
+loc:
+ flutter gen-l10n; \
+ make format
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..8cf393b 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..73676ed 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..cfe7d86 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..2b2f0d2 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..883ce22 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/icon.png b/assets/icon.png
new file mode 100644
index 0000000..bb96b65
Binary files /dev/null and b/assets/icon.png differ
diff --git a/assets/svg/ru.svg b/assets/svg/ru.svg
new file mode 100644
index 0000000..855b805
--- /dev/null
+++ b/assets/svg/ru.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/assets/svg/us.svg b/assets/svg/us.svg
new file mode 100644
index 0000000..9cfd0c9
--- /dev/null
+++ b/assets/svg/us.svg
@@ -0,0 +1,9 @@
+
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..a01051c
--- /dev/null
+++ b/l10n/app_en.arb
@@ -0,0 +1,9 @@
+{
+ "@@locale": "en",
+
+ "search": "Search",
+ "liked": "liked!",
+ "disliked": "disliked :(",
+
+ "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..7b30d41
--- /dev/null
+++ b/l10n/app_ru.arb
@@ -0,0 +1,9 @@
+{
+ "@@locale": "ru",
+
+ "search": "Поиск",
+ "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
new file mode 100644
index 0000000..a715b51
--- /dev/null
+++ b/lib/components/extensions/context_x.dart
@@ -0,0 +1,6 @@
+import 'package:flutter/widgets.dart';
+import 'package:pmu_new/components/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
new file mode 100644
index 0000000..0922eb1
--- /dev/null
+++ b/lib/components/locale/l10n/app_locale.dart
@@ -0,0 +1,153 @@
+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 @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..599548c
--- /dev/null
+++ b/lib/components/locale/l10n/app_locale_en.dart
@@ -0,0 +1,20 @@
+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 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..b8d5444
--- /dev/null
+++ b/lib/components/locale/l10n/app_locale_ru.dart
@@ -0,0 +1,20 @@
+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 arbEnding => 'Чтобы не забыть про отсутствие запятой :)';
+}
diff --git a/lib/components/resources.g.dart b/lib/components/resources.g.dart
new file mode 100644
index 0000000..915a8d9
--- /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_US_SVG = 'assets/svg/us.svg';
+}
diff --git a/lib/components/utils/debounce.dart b/lib/components/utils/debounce.dart
new file mode 100644
index 0000000..32d0457
--- /dev/null
+++ b/lib/components/utils/debounce.dart
@@ -0,0 +1,20 @@
+import 'dart:async';
+import 'dart:ui';
+
+class Debounce {
+ factory Debounce() => _instance;
+
+ Debounce._();
+
+ static final Debounce _instance = Debounce._();
+
+ static Timer? _timer;
+
+ static void run(
+ VoidCallback action, {
+ Duration delay = const Duration(milliseconds: 700),
+ }) {
+ _timer?.cancel();
+ _timer = Timer(delay, action);
+ }
+}
diff --git a/lib/data/dtos/PlaceDTO.dart b/lib/data/dtos/PlaceDTO.dart
index 35b9f8c..bc07748 100644
--- a/lib/data/dtos/PlaceDTO.dart
+++ b/lib/data/dtos/PlaceDTO.dart
@@ -19,7 +19,7 @@ class PlaceDataDto {
final String? description;
final String? imageData;
- const PlaceDataDto({this.id, this.name, this.yearBuilt, this.description, this.imageData});
+ const PlaceDataDto({this.id, this.name, this.yearBuilt, this.description, this.imageData});
factory PlaceDataDto.fromJson(Map json) => _$PlaceDataDtoFromJson(json);
-}
\ No newline at end of file
+}
diff --git a/lib/data/mappers/PlaceDataDtoToModel.dart b/lib/data/mappers/PlaceDataDtoToModel.dart
index 8e8da8e..95f2930 100644
--- a/lib/data/mappers/PlaceDataDtoToModel.dart
+++ b/lib/data/mappers/PlaceDataDtoToModel.dart
@@ -5,15 +5,16 @@ import '../dtos/PlaceDTO.dart';
extension PlaceDataDtoToModel on PlaceDataDto {
CardData toDomain() => CardData(
- name ?? 'Неизвестное имя',
- //imageUrl: attributes?.image,
- descriptionText: getText(),
- //bytes: (imagedata != null) ? base64.decode(imagedata!) : null,
- bytes: imageData?? null,
- );
- String getText(){
+ name ?? 'Неизвестное имя',
+ //imageUrl: attributes?.image,
+ descriptionText: getText(),
+ //bytes: (imagedata != null) ? base64.decode(imagedata!) : null,
+ bytes: imageData ?? null,
+ id: id.toString()
+ );
+ String getText() {
final String str1 = description ?? "Описания нет";
final String str2 = yearBuilt?.toString() ?? "Даты построики нет";
- return "$str1\n$str2 год";
+ return "$str1\n--------------\n$str2 год";
}
-}
\ No newline at end of file
+}
diff --git a/lib/data/repositories/MockRepository.dart b/lib/data/repositories/MockRepository.dart
index 0f61e14..355bd19 100644
--- a/lib/data/repositories/MockRepository.dart
+++ b/lib/data/repositories/MockRepository.dart
@@ -4,33 +4,29 @@ import 'package:pmu_new/data/repositories/api_Interface.dart';
import '../../models/CardData.dart';
-class MockRepository extends ApiInterface{
+class MockRepository extends ApiInterface {
@override
- Future?> loadData({OnErrorCallback? onError}) async{
+ Future?> loadData({OnErrorCallback? onError}) async {
final data = [
CardData(
'Фрукты',
descriptionText:
- 'Какие же они полезные и сладкие!!!! Generate Lorem Ipsum placeholder text for use in your graphic, print and web layouts, and discover plugins for your favorite writing, design and blogging tools',
+ 'Какие же они полезные и сладкие!!!! Generate Lorem Ipsum placeholder text for use in your graphic, print and web layouts, and discover plugins for your favorite writing, design and blogging tools',
imageUrl:
- 'https://media.gettyimages.com/id/182810893/photo/fruit-mix.jpg?s=612x612&w=0&k=20&c=v9jopDXbS5LCXY1d8uSwEldLJVVkOpYtYtyHD8azWDU=',
+ 'https://media.gettyimages.com/id/182810893/photo/fruit-mix.jpg?s=612x612&w=0&k=20&c=v9jopDXbS5LCXY1d8uSwEldLJVVkOpYtYtyHD8azWDU=',
),
CardData(
'Киви',
descriptionText:
- 'сладкий и спелый, можно купить по акции прямо сейчас звоните не пожалеете',
- Backgroundcolor: Color.fromARGB(10, 210, 30, 40),
- imageUrl:
- 'https://www.diyphotography.net/files/images/3/pictures-of-sliced-fruits-09b.jpg',
+ 'сладкий и спелый, можно купить по акции прямо сейчас звоните не пожалеете',
+ imageUrl: 'https://www.diyphotography.net/files/images/3/pictures-of-sliced-fruits-09b.jpg',
),
CardData(
'Банан',
descriptionText: 'Ого, че с ним произошло',
- Backgroundcolor: Color.fromARGB(30, 30, 210, 15),
- imageUrl:
- 'https://www.diyphotography.net/files/images/3/pictures-of-sliced-fruits-01.jpg',
+ imageUrl: 'https://www.diyphotography.net/files/images/3/pictures-of-sliced-fruits-01.jpg',
),
];
return data;
}
-}
\ No newline at end of file
+}
diff --git a/lib/data/repositories/PlacesRepository.dart b/lib/data/repositories/PlacesRepository.dart
index 8c12e78..47ffbf0 100644
--- a/lib/data/repositories/PlacesRepository.dart
+++ b/lib/data/repositories/PlacesRepository.dart
@@ -15,24 +15,29 @@ class PlacesRepository extends ApiInterface {
requestHeader: true,
requestBody: true,
));
- static const String _baseUrl = 'https://localhost:5001';
+ static const String _baseUrl = 'http://192.168.184.215:5001';
+ //static const String _baseUrl = 'https://localhost:5001';
@override
- Future?> loadData({int? q, OnErrorCallback? onError}) async {
- try {
- const String url = '$_baseUrl/api/Main/GetManufactureList';
+ Future?> loadData({int? q, OnErrorCallback? onError}) async {
+ try {
+ const String url = '$_baseUrl/api/Main/GetManufactureList';
- final Response response = await _dio.get