рабочая 7 лаба
Before Width: | Height: | Size: 544 B After Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 442 B After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 721 B After Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 7.7 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 10 KiB |
BIN
assets/icon.jpg
Normal file
After Width: | Height: | Size: 1.6 MiB |
BIN
assets/icon2.png
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
assets/launcher.jpg
Normal file
After Width: | Height: | Size: 670 KiB |
19
assets/svg/ru.svg
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||||
|
<svg width="800px" height="800px" viewBox="0 -4 28 28" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<g clip-path="url(#clip0_503_2726)">
|
||||||
|
<rect x="0.25" y="0.25" width="27.5" height="19.5" rx="1.75" fill="white" stroke="#F5F5F5" stroke-width="0.5"/>
|
||||||
|
<mask id="mask0_503_2726" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="28" height="20">
|
||||||
|
<rect x="0.25" y="0.25" width="27.5" height="19.5" rx="1.75" fill="white" stroke="white" stroke-width="0.5"/>
|
||||||
|
</mask>
|
||||||
|
<g mask="url(#mask0_503_2726)">
|
||||||
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 13.3333H28V6.66667H0V13.3333Z" fill="#0C47B7"/>
|
||||||
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 20H28V13.3333H0V20Z" fill="#E53B35"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<defs>
|
||||||
|
<clipPath id="clip0_503_2726">
|
||||||
|
<rect width="28" height="20" rx="2" fill="white"/>
|
||||||
|
</clipPath>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 968 B |
35
assets/svg/uk.svg
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||||
|
<svg width="800px" height="800px" viewBox="0 -4 28 28" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<g clip-path="url(#clip0_503_4369)">
|
||||||
|
<rect width="28" height="20" rx="2" fill="white"/>
|
||||||
|
<mask id="mask0_503_4369" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="28" height="20">
|
||||||
|
<rect width="28" height="20" rx="2" fill="white"/>
|
||||||
|
</mask>
|
||||||
|
<g mask="url(#mask0_503_4369)">
|
||||||
|
<rect width="28" height="20" fill="#0A17A7"/>
|
||||||
|
<path d="M0 -0.333333H-0.901086L-0.21693 0.253086L4.33333 4.15331V5.16179L-0.193746 8.39542L-0.333333 8.49513V8.66667V9.33333V9.93475L0.176666 9.616L5.42893 6.33333H6.55984L11.0821 9.56351C11.176 9.6306 11.2886 9.66667 11.404 9.66667C11.9182 9.66667 12.1548 9.02698 11.7644 8.69237L7.66667 5.18002V4.17154L12.0542 1.03762C12.2294 0.912475 12.3333 0.710428 12.3333 0.495127V0V-0.601416L11.8233 -0.282666L6.57107 3H5.44016L0.860413 -0.271244L0.773488 -0.333333H0.666667H0Z" fill="#FF2E3B" stroke="white" stroke-width="0.666667"/>
|
||||||
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 3.33333V6H4.66667V9.33333C4.66667 9.70152 4.96514 10 5.33333 10H6.66667C7.03486 10 7.33333 9.70152 7.33333 9.33333V6H12C12.3682 6 12.6667 5.70152 12.6667 5.33333V4C12.6667 3.63181 12.3682 3.33333 12 3.33333H7.33333V0H4.66667V3.33333H0Z" fill="url(#paint0_linear_503_4369)"/>
|
||||||
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 4H5.33333V3.33333V0H6.66667V3.33333V4H12V5.33333H6.66667V6V9.33333H5.33333V6V5.33333H0V4Z" fill="url(#paint1_linear_503_4369)"/>
|
||||||
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M6 16.3333L4.82443 16.9514L5.04894 15.6424L4.09789 14.7153L5.41221 14.5243L6 13.3333L6.58779 14.5243L7.90211 14.7153L6.95106 15.6424L7.17557 16.9514L6 16.3333Z" fill="white"/>
|
||||||
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M19.9998 17.3333L19.057 17.6095L19.3332 16.6666L19.057 15.7238L19.9998 16L20.9426 15.7238L20.6665 16.6666L20.9426 17.6095L19.9998 17.3333Z" fill="white"/>
|
||||||
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M19.9998 4.66669L19.057 4.94283L19.3332 4.00002L19.057 3.05721L19.9998 3.33335L20.9426 3.05721L20.6665 4.00002L20.9426 4.94283L19.9998 4.66669Z" fill="white"/>
|
||||||
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M23.9998 8.66669L23.057 8.94283L23.3332 8.00002L23.057 7.05721L23.9998 7.33335L24.9426 7.05721L24.6665 8.00002L24.9426 8.94283L23.9998 8.66669Z" fill="white"/>
|
||||||
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M15.9998 10L15.057 10.2761L15.3332 9.33333L15.057 8.39052L15.9998 8.66667L16.9426 8.39052L16.6665 9.33333L16.9426 10.2761L15.9998 10Z" fill="white"/>
|
||||||
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M22.0002 11.6667L21.5288 11.8048L21.6668 11.3334L21.5288 10.8619L22.0002 11L22.4716 10.8619L22.3335 11.3334L22.4716 11.8048L22.0002 11.6667Z" fill="white"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="paint0_linear_503_4369" x1="0" y1="0" x2="0" y2="10" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="white"/>
|
||||||
|
<stop offset="1" stop-color="#F0F0F0"/>
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient id="paint1_linear_503_4369" x1="0" y1="0" x2="0" y2="9.33333" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop stop-color="#FF2E3B"/>
|
||||||
|
<stop offset="1" stop-color="#FC0D1B"/>
|
||||||
|
</linearGradient>
|
||||||
|
<clipPath id="clip0_503_4369">
|
||||||
|
<rect width="28" height="20" rx="2" fill="white"/>
|
||||||
|
</clipPath>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 3.3 KiB |
@ -427,7 +427,7 @@
|
|||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon;
|
||||||
CLANG_ANALYZER_NONNULL = YES;
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
CLANG_CXX_LIBRARY = "libc++";
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
@ -484,7 +484,7 @@
|
|||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon;
|
||||||
CLANG_ANALYZER_NONNULL = YES;
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
CLANG_CXX_LIBRARY = "libc++";
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 78 KiB |
Before Width: | Height: | Size: 295 B After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 406 B After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 450 B After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 282 B After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 462 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 704 B After Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 406 B After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 586 B After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 862 B After Width: | Height: | Size: 6.3 KiB |
After Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 5.2 KiB |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 6.0 KiB |
Before Width: | Height: | Size: 862 B After Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 9.4 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 7.7 KiB |
Before Width: | Height: | Size: 762 B After Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 8.0 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 8.8 KiB |
6
l10n.yaml
Normal file
@ -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
|
9
l10n/app_en.arb
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"@@locale": "en",
|
||||||
|
|
||||||
|
"search": "Search",
|
||||||
|
"liked": "liked!",
|
||||||
|
"disliked": "unliked",
|
||||||
|
"inscription": "New"
|
||||||
|
|
||||||
|
}
|
8
l10n/app_ru.arb
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"@@locale": "ru",
|
||||||
|
|
||||||
|
"search": "Поиск",
|
||||||
|
"liked": "понравился!",
|
||||||
|
"disliked": "разонравился",
|
||||||
|
"inscription": "Новинка"
|
||||||
|
}
|
6
lib/components/extension/context_x.dart
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
import 'package:pmu/components/locale/l10n/app_locale.dart';
|
||||||
|
|
||||||
|
extension LocalContextX on BuildContext {
|
||||||
|
AppLocale get locale => AppLocale.of(this)!;
|
||||||
|
}
|
153
lib/components/locale/l10n/app_locale.dart
Normal file
@ -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<AppLocale>(context, AppLocale);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const LocalizationsDelegate<AppLocale> 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<LocalizationsDelegate<dynamic>> localizationsDelegates = <LocalizationsDelegate<dynamic>>[
|
||||||
|
delegate,
|
||||||
|
GlobalMaterialLocalizations.delegate,
|
||||||
|
GlobalCupertinoLocalizations.delegate,
|
||||||
|
GlobalWidgetsLocalizations.delegate,
|
||||||
|
];
|
||||||
|
|
||||||
|
/// A list of this localizations delegate's supported locales.
|
||||||
|
static const List<Locale> supportedLocales = <Locale>[
|
||||||
|
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 @inscription.
|
||||||
|
///
|
||||||
|
/// In ru, this message translates to:
|
||||||
|
/// **'Новинка'**
|
||||||
|
String get inscription;
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AppLocaleDelegate extends LocalizationsDelegate<AppLocale> {
|
||||||
|
const _AppLocaleDelegate();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<AppLocale> load(Locale locale) {
|
||||||
|
return SynchronousFuture<AppLocale>(lookupAppLocale(locale));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool isSupported(Locale locale) => <String>['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.'
|
||||||
|
);
|
||||||
|
}
|
20
lib/components/locale/l10n/app_locale_en.dart
Normal file
@ -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 => 'unliked';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get inscription => 'New';
|
||||||
|
}
|
20
lib/components/locale/l10n/app_locale_ru.dart
Normal file
@ -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 inscription => 'Новинка';
|
||||||
|
}
|
10
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';
|
||||||
|
}
|
@ -6,5 +6,6 @@ extension FoodDataDtoToModel on FoodDataDto {
|
|||||||
beanId: idMeal ?? "Неизвестно",
|
beanId: idMeal ?? "Неизвестно",
|
||||||
colorGroup: strMeal ?? "Неизвестная категория",
|
colorGroup: strMeal ?? "Неизвестная категория",
|
||||||
imageUrl: strMealThumb,
|
imageUrl: strMealThumb,
|
||||||
|
id: idMeal,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ class FoodRepository extends ApiInterface{
|
|||||||
@override
|
@override
|
||||||
Future<List<MarketData>?> loadData({OnErrorCallback? onError, String? q}) async {
|
Future<List<MarketData>?> loadData({OnErrorCallback? onError, String? q}) async {
|
||||||
try {
|
try {
|
||||||
final String url = q != null ? '$_baseUrl/search.php' : '$_baseUrl/filter.php?i=chicken_breast';
|
final String url = q != null ? '$_baseUrl/search.php' : '$_baseUrl/search.php?f=s';
|
||||||
|
|
||||||
final Response<dynamic> response = await _dio.get(
|
final Response<dynamic> response = await _dio.get(
|
||||||
url,
|
url,
|
||||||
|
@ -2,10 +2,12 @@ class MarketData {
|
|||||||
final String beanId;
|
final String beanId;
|
||||||
final String colorGroup;
|
final String colorGroup;
|
||||||
final String? imageUrl;
|
final String? imageUrl;
|
||||||
|
final String? id;
|
||||||
|
|
||||||
MarketData({
|
MarketData({
|
||||||
required this.beanId,
|
required this.beanId,
|
||||||
required this.colorGroup,
|
required this.colorGroup,
|
||||||
required this.imageUrl,
|
required this.imageUrl,
|
||||||
|
this.id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,15 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:pmu/components/locale/l10n/app_locale.dart';
|
||||||
|
import 'package:pmu/components/locale/l10n/app_locale_ru.dart';
|
||||||
import 'package:pmu/data/repository/food_repository.dart';
|
import 'package:pmu/data/repository/food_repository.dart';
|
||||||
import 'package:pmu/presentation/home_page/bloc/bloc.dart';
|
import 'package:pmu/presentation/home_page/bloc/bloc.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:pmu/presentation/home_page/home_page.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';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
@ -13,8 +20,17 @@ class MyApp extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
return BlocProvider<LocaleBloc>(
|
||||||
|
lazy: false,
|
||||||
|
create: (context) => LocaleBloc(Locale(Platform.localeName)),
|
||||||
|
child: BlocBuilder<LocaleBloc, LocaleState>(
|
||||||
|
builder: (context, state) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
title: 'Flutter Demo',
|
title: 'Flutter Demo',
|
||||||
|
locale: state.currentLocale,
|
||||||
|
localizationsDelegates: AppLocale.localizationsDelegates,
|
||||||
|
supportedLocales: AppLocale.supportedLocales,
|
||||||
|
debugShowCheckedModeBanner: false,
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
colorScheme: ColorScheme.fromSeed(seedColor: Color(0xFFFFA400)),
|
colorScheme: ColorScheme.fromSeed(seedColor: Color(0xFFFFA400)),
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
@ -22,12 +38,17 @@ class MyApp extends StatelessWidget {
|
|||||||
home: RepositoryProvider<FoodRepository>(
|
home: RepositoryProvider<FoodRepository>(
|
||||||
lazy: true,
|
lazy: true,
|
||||||
create: (_) => FoodRepository(),
|
create: (_) => FoodRepository(),
|
||||||
|
child: BlocProvider<LikeBloc>(
|
||||||
|
lazy: false,
|
||||||
|
create: (context) => LikeBloc(),
|
||||||
child: BlocProvider<HomeBloc>(
|
child: BlocProvider<HomeBloc>(
|
||||||
lazy: false,
|
lazy: false,
|
||||||
create: (context) => HomeBloc(context.read<FoodRepository>()),
|
create: (context) =>
|
||||||
|
HomeBloc(context.read<FoodRepository>()),
|
||||||
child: const MyHomePage(title: "Food cort"),
|
child: const MyHomePage(title: "Food cort"),
|
||||||
),
|
),
|
||||||
)
|
)));
|
||||||
);
|
},
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
34
lib/presentation/common/svg_objects.dart
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
import 'package:pmu/components/resources.g.dart';
|
||||||
|
|
||||||
|
abstract class SvgObjects {
|
||||||
|
static void init() {
|
||||||
|
final pics = <String>[
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
@ -1,13 +1,15 @@
|
|||||||
part of "home_page.dart";
|
part of "home_page.dart";
|
||||||
|
|
||||||
typedef OnLikeCallback = void Function(String title, bool isLiked)?;
|
typedef OnLikeCallback = void Function(String? id, String title, bool isLiked)?;
|
||||||
|
|
||||||
class _MarketCard extends StatefulWidget {
|
class _MarketCard extends StatelessWidget {
|
||||||
final String beanId;
|
final String beanId;
|
||||||
final String colorGroup;
|
final String colorGroup;
|
||||||
final String? imageUrl;
|
final String? imageUrl;
|
||||||
final OnLikeCallback onLike;
|
final OnLikeCallback onLike;
|
||||||
final VoidCallback? onTap;
|
final VoidCallback? onTap;
|
||||||
|
final String? id;
|
||||||
|
final bool isLiked;
|
||||||
|
|
||||||
const _MarketCard({
|
const _MarketCard({
|
||||||
required this.beanId,
|
required this.beanId,
|
||||||
@ -15,29 +17,26 @@ class _MarketCard extends StatefulWidget {
|
|||||||
required this.imageUrl,
|
required this.imageUrl,
|
||||||
this.onLike,
|
this.onLike,
|
||||||
this.onTap,
|
this.onTap,
|
||||||
|
this.id,
|
||||||
|
this.isLiked = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory _MarketCard.fromData(MarketData items,
|
factory _MarketCard.fromData(MarketData items,
|
||||||
{OnLikeCallback? onLike, VoidCallback? onTap}) =>
|
{OnLikeCallback? onLike, VoidCallback? onTap, bool isLiked = false}) =>
|
||||||
_MarketCard(
|
_MarketCard(
|
||||||
beanId: items.beanId,
|
beanId: items.beanId,
|
||||||
colorGroup: items.colorGroup,
|
colorGroup: items.colorGroup,
|
||||||
imageUrl: items.imageUrl,
|
imageUrl: items.imageUrl,
|
||||||
onLike: onLike,
|
onLike: onLike,
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
|
isLiked: isLiked,
|
||||||
|
id: items.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
|
||||||
State<_MarketCard> createState() => _MarketCardState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _MarketCardState extends State<_MarketCard> {
|
|
||||||
bool isLiked = false;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: widget.onTap,
|
onTap: onTap,
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.all(10),
|
padding: const EdgeInsets.all(10),
|
||||||
margin: const EdgeInsets.all(4),
|
margin: const EdgeInsets.all(4),
|
||||||
@ -59,7 +58,7 @@ class _MarketCardState extends State<_MarketCard> {
|
|||||||
children: [
|
children: [
|
||||||
Positioned.fill(
|
Positioned.fill(
|
||||||
child: Image.network(
|
child: Image.network(
|
||||||
widget.imageUrl ?? '',
|
imageUrl ?? '',
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
errorBuilder: (_, __, ___) => const Placeholder(),
|
errorBuilder: (_, __, ___) => const Placeholder(),
|
||||||
),
|
),
|
||||||
@ -75,7 +74,7 @@ class _MarketCardState extends State<_MarketCard> {
|
|||||||
),
|
),
|
||||||
padding: const EdgeInsets.fromLTRB(8, 2, 8, 2),
|
padding: const EdgeInsets.fromLTRB(8, 2, 8, 2),
|
||||||
child: Text(
|
child: Text(
|
||||||
"новинка",
|
context.locale.inscription,
|
||||||
style: Theme.of(context)
|
style: Theme.of(context)
|
||||||
.textTheme
|
.textTheme
|
||||||
.bodyMedium
|
.bodyMedium
|
||||||
@ -90,7 +89,7 @@ class _MarketCardState extends State<_MarketCard> {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(top: 8.0),
|
padding: const EdgeInsets.only(top: 8.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
widget.colorGroup,
|
colorGroup,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
@ -106,14 +105,9 @@ class _MarketCardState extends State<_MarketCard> {
|
|||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () {
|
onTap: () => onLike?.call(id, colorGroup, isLiked),
|
||||||
setState(() {
|
|
||||||
isLiked = !isLiked;
|
|
||||||
});
|
|
||||||
widget.onLike?.call(widget.colorGroup, isLiked);
|
|
||||||
},
|
|
||||||
child: AnimatedSwitcher(
|
child: AnimatedSwitcher(
|
||||||
duration: const Duration(milliseconds: 100),
|
duration: const Duration(milliseconds: 200),
|
||||||
child: isLiked
|
child: isLiked
|
||||||
? const Icon(
|
? const Icon(
|
||||||
Icons.favorite,
|
Icons.favorite,
|
||||||
@ -121,8 +115,7 @@ class _MarketCardState extends State<_MarketCard> {
|
|||||||
key: ValueKey<int>(0),
|
key: ValueKey<int>(0),
|
||||||
)
|
)
|
||||||
: const Icon(
|
: const Icon(
|
||||||
Icons.favorite,
|
Icons.favorite_border,
|
||||||
color: Colors.grey,
|
|
||||||
key: ValueKey<int>(1),
|
key: ValueKey<int>(1),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -1,15 +1,23 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:pmu/components/extension/context_x.dart';
|
||||||
import 'package:pmu/components/utils/debounce.dart';
|
import 'package:pmu/components/utils/debounce.dart';
|
||||||
import 'package:pmu/data/repository/food_repository.dart';
|
import 'package:pmu/data/repository/food_repository.dart';
|
||||||
import 'package:pmu/data/repository/mock_repository.dart';
|
import 'package:pmu/data/repository/mock_repository.dart';
|
||||||
import 'package:pmu/domain/models/card.dart';
|
import 'package:pmu/domain/models/card.dart';
|
||||||
import 'package:pmu/main.dart';
|
import 'package:pmu/main.dart';
|
||||||
|
import 'package:pmu/presentation/common/svg_objects.dart';
|
||||||
import 'package:pmu/presentation/details_page/details_page.dart';
|
import 'package:pmu/presentation/details_page/details_page.dart';
|
||||||
import 'package:pmu/presentation/home_page/bloc/bloc.dart';
|
import 'package:pmu/presentation/home_page/bloc/bloc.dart';
|
||||||
import 'package:pmu/presentation/home_page/bloc/events.dart';
|
import 'package:pmu/presentation/home_page/bloc/events.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:pmu/presentation/home_page/bloc/state.dart';
|
import 'package:pmu/presentation/home_page/bloc/state.dart';
|
||||||
|
import 'package:pmu/presentation/like_bloc/like_bloc.dart';
|
||||||
|
import 'package:pmu/presentation/like_bloc/like_event.dart';
|
||||||
|
import 'package:pmu/presentation/like_bloc/like_state.dart';
|
||||||
|
import 'package:pmu/presentation/locale_bloc/locale_bloc.dart';
|
||||||
|
import 'package:pmu/presentation/locale_bloc/locale_events.dart';
|
||||||
|
import 'package:pmu/presentation/locale_bloc/locale_state.dart';
|
||||||
|
|
||||||
part 'card.dart';
|
part 'card.dart';
|
||||||
|
|
||||||
@ -24,14 +32,17 @@ class MyHomePage extends StatefulWidget {
|
|||||||
|
|
||||||
class _MyHomePageState extends State<MyHomePage> {
|
class _MyHomePageState extends State<MyHomePage> {
|
||||||
final Color _color = const Color(0xFFFFA400);
|
final Color _color = const Color(0xFFFFA400);
|
||||||
|
final scrollController = ScrollController();
|
||||||
final searchController = TextEditingController();
|
final searchController = TextEditingController();
|
||||||
late Future<List<MarketData>?> data;
|
late Future<List<MarketData>?> data;
|
||||||
final repo = FoodRepository();
|
final repo = FoodRepository();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
SvgObjects.init();
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
context.read<HomeBloc>().add(const HomeLoadDataEvent());
|
context.read<HomeBloc>().add(const HomeLoadDataEvent());
|
||||||
|
context.read<LikeBloc>().add(const LoadLikesEvent());
|
||||||
});
|
});
|
||||||
|
|
||||||
super.initState();
|
super.initState();
|
||||||
@ -43,6 +54,14 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _onLike(String? id, String title, bool isLiked) {
|
||||||
|
print("$id $title, $isLiked");
|
||||||
|
if (id != null) {
|
||||||
|
context.read<LikeBloc>().add(ChangeLikeEvent(id));
|
||||||
|
_showSnackBar(context, title, !isLiked);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _onRefresh() {
|
Future<void> _onRefresh() {
|
||||||
context
|
context
|
||||||
.read<HomeBloc>()
|
.read<HomeBloc>()
|
||||||
@ -61,6 +80,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
padding: const EdgeInsets.all(12),
|
padding: const EdgeInsets.all(12),
|
||||||
child: CupertinoSearchTextField(
|
child: CupertinoSearchTextField(
|
||||||
controller: searchController,
|
controller: searchController,
|
||||||
|
placeholder: context.locale.search,
|
||||||
onChanged: (search) {
|
onChanged: (search) {
|
||||||
Debounce.run(() => context
|
Debounce.run(() => context
|
||||||
.read<HomeBloc>()
|
.read<HomeBloc>()
|
||||||
@ -68,21 +88,32 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () =>
|
||||||
|
context.read<LocaleBloc>().add(const ChangeLocaleEvent()),
|
||||||
|
child: SizedBox.square(
|
||||||
|
dimension: 50,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 12),
|
||||||
|
child: BlocBuilder<LocaleBloc, LocaleState>(
|
||||||
|
builder: (context, state) {
|
||||||
|
return state.currentLocale.languageCode == 'ru'
|
||||||
|
? const SvgRu()
|
||||||
|
: const SvgUk();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
BlocBuilder<HomeBloc, HomeState>(
|
BlocBuilder<HomeBloc, HomeState>(
|
||||||
builder: (context, state) => state.error != null
|
builder: (context, state) => state.isLoading
|
||||||
? Text(
|
? CircularProgressIndicator()
|
||||||
state.error ?? '',
|
: BlocBuilder<LikeBloc, LikeState>(
|
||||||
style: Theme.of(context)
|
builder: (context, likeState) => Expanded(
|
||||||
.textTheme
|
|
||||||
.headlineSmall
|
|
||||||
?.copyWith(color: Colors.red),
|
|
||||||
)
|
|
||||||
: state.isLoading
|
|
||||||
? const CircularProgressIndicator()
|
|
||||||
: Expanded(
|
|
||||||
child: RefreshIndicator(
|
child: RefreshIndicator(
|
||||||
onRefresh: _onRefresh,
|
onRefresh: _onRefresh,
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
|
controller: scrollController,
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
itemCount: state.data?.length ?? 0,
|
itemCount: state.data?.length ?? 0,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
@ -90,14 +121,15 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
return data != null
|
return data != null
|
||||||
? _MarketCard.fromData(
|
? _MarketCard.fromData(
|
||||||
data,
|
data,
|
||||||
onLike: (title, isLiked) =>
|
isLiked: likeState.likedIds
|
||||||
_showSnackBar(
|
?.contains(data.id) ==
|
||||||
context, title, isLiked),
|
true,
|
||||||
|
onLike: _onLike,
|
||||||
onTap: () =>
|
onTap: () =>
|
||||||
_navToDetails(context, data),
|
_navToDetails(context, data),
|
||||||
)
|
)
|
||||||
: const SizedBox.shrink();
|
: const SizedBox.shrink();
|
||||||
},
|
}),
|
||||||
),
|
),
|
||||||
))),
|
))),
|
||||||
],
|
],
|
||||||
@ -110,7 +142,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||||
content: Text(
|
content: Text(
|
||||||
'Товар $title ${isLiked ? 'добавлен в избранное' : 'удален из избранного'}',
|
'$title ${isLiked ? context.locale.liked : context.locale.disliked}',
|
||||||
style: Theme.of(context).textTheme.bodyLarge,
|
style: Theme.of(context).textTheme.bodyLarge,
|
||||||
),
|
),
|
||||||
backgroundColor: Colors.orangeAccent,
|
backgroundColor: Colors.orangeAccent,
|
||||||
|
36
lib/presentation/like_bloc/like_bloc.dart
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:pmu/presentation/like_bloc/like_event.dart';
|
||||||
|
import 'package:pmu/presentation/like_bloc/like_state.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
|
||||||
|
const String _likedPrefsKey = 'liked';
|
||||||
|
|
||||||
|
class LikeBloc extends Bloc<LikeEvent, LikeState> {
|
||||||
|
LikeBloc() : super(const LikeState(likedIds: [])) {
|
||||||
|
on<ChangeLikeEvent>(_onChangeLike);
|
||||||
|
on<LoadLikesEvent>(_onLoadLikes);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _onLoadLikes(LoadLikesEvent event, Emitter<LikeState> emit) async {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
final data = prefs.getStringList(_likedPrefsKey);
|
||||||
|
|
||||||
|
emit(state.copyWith(likedIds: data));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _onChangeLike(ChangeLikeEvent event, Emitter<LikeState> emit) async {
|
||||||
|
final updatedList = List<String>.from(state.likedIds ?? []);
|
||||||
|
|
||||||
|
if (updatedList.contains(event.id)) {
|
||||||
|
updatedList.remove(event.id);
|
||||||
|
} else {
|
||||||
|
updatedList.add(event.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
prefs.setStringList(_likedPrefsKey, updatedList);
|
||||||
|
|
||||||
|
emit(state.copyWith(likedIds: updatedList));
|
||||||
|
}
|
||||||
|
}
|
13
lib/presentation/like_bloc/like_event.dart
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
abstract class LikeEvent {
|
||||||
|
const LikeEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
class LoadLikesEvent extends LikeEvent {
|
||||||
|
const LoadLikesEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
class ChangeLikeEvent extends LikeEvent {
|
||||||
|
final String id;
|
||||||
|
|
||||||
|
const ChangeLikeEvent(this.id);
|
||||||
|
}
|
18
lib/presentation/like_bloc/like_state.dart
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
|
||||||
|
@CopyWith()
|
||||||
|
class LikeState extends Equatable {
|
||||||
|
final List<String>? likedIds;
|
||||||
|
|
||||||
|
const LikeState({required this.likedIds});
|
||||||
|
|
||||||
|
LikeState copyWith({List<String>? likedIds}) {
|
||||||
|
return LikeState(
|
||||||
|
likedIds: likedIds ?? this.likedIds,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object?> get props => [likedIds];
|
||||||
|
}
|
19
lib/presentation/locale_bloc/locale_bloc.dart
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:pmu/components/locale/l10n/app_locale.dart';
|
||||||
|
import 'package:pmu/presentation/locale_bloc/locale_events.dart';
|
||||||
|
import 'package:pmu/presentation/locale_bloc/locale_state.dart';
|
||||||
|
|
||||||
|
class LocaleBloc extends Bloc<LocaleEvent, LocaleState> {
|
||||||
|
LocaleBloc(Locale defaultLocale)
|
||||||
|
: super(LocaleState(currentLocale: defaultLocale)) {
|
||||||
|
on<ChangeLocaleEvent>(_onChangeLocale);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _onChangeLocale(
|
||||||
|
ChangeLocaleEvent event, Emitter<LocaleState> emit) async {
|
||||||
|
final toChange = AppLocale.supportedLocales
|
||||||
|
.firstWhere((e) => e.languageCode != state.currentLocale.languageCode);
|
||||||
|
emit(state.copyWith(currentLocale: toChange));
|
||||||
|
}
|
||||||
|
}
|
7
lib/presentation/locale_bloc/locale_events.dart
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
abstract class LocaleEvent {
|
||||||
|
const LocaleEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
class ChangeLocaleEvent extends LocaleEvent {
|
||||||
|
const ChangeLocaleEvent();
|
||||||
|
}
|
19
lib/presentation/locale_bloc/locale_state.dart
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
|
||||||
|
class LocaleState extends Equatable {
|
||||||
|
final Locale currentLocale;
|
||||||
|
|
||||||
|
const LocaleState({required this.currentLocale});
|
||||||
|
|
||||||
|
LocaleState copyWith({Locale? currentLocale}) {
|
||||||
|
return LocaleState(
|
||||||
|
currentLocale: currentLocale ?? this.currentLocale,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object?> get props => [currentLocale];
|
||||||
|
}
|
@ -5,6 +5,8 @@
|
|||||||
import FlutterMacOS
|
import FlutterMacOS
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
import shared_preferences_foundation
|
||||||
|
|
||||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||||
|
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||||
}
|
}
|
||||||
|
236
pubspec.lock
@ -22,6 +22,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.7.0"
|
version: "6.7.0"
|
||||||
|
archive:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: archive
|
||||||
|
sha256: "08064924cbf0ab88280a0c3f60db9dd24fec693927e725ecb176f16c629d1cb8"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "4.0.1"
|
||||||
args:
|
args:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -134,6 +142,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.3"
|
version: "2.0.3"
|
||||||
|
cli_util:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: cli_util
|
||||||
|
sha256: ff6785f7e9e3c38ac98b2fb035701789de90154024a75b6cb926445e83197d1c
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.4.2"
|
||||||
clock:
|
clock:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -238,6 +254,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.1"
|
version: "1.3.1"
|
||||||
|
ffi:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: ffi
|
||||||
|
sha256: "16ed7b077ef01ad6170a3d0c57caa4a112a38d7a2ed5602e0aca9ca6f3d98da6"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.3"
|
||||||
file:
|
file:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -267,6 +291,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "8.1.6"
|
version: "8.1.6"
|
||||||
|
flutter_launcher_icons:
|
||||||
|
dependency: "direct dev"
|
||||||
|
description:
|
||||||
|
name: flutter_launcher_icons
|
||||||
|
sha256: "526faf84284b86a4cb36d20a5e45147747b7563d921373d4ee0559c54fcdbcea"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.13.1"
|
||||||
flutter_lints:
|
flutter_lints:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
@ -275,11 +307,29 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.0.0"
|
version: "4.0.0"
|
||||||
|
flutter_localizations:
|
||||||
|
dependency: "direct main"
|
||||||
|
description: flutter
|
||||||
|
source: sdk
|
||||||
|
version: "0.0.0"
|
||||||
|
flutter_svg:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: flutter_svg
|
||||||
|
sha256: "8c5d68a82add3ca76d792f058b186a0599414f279f00ece4830b9b231b570338"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.7"
|
||||||
flutter_test:
|
flutter_test:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
flutter_web_plugins:
|
||||||
|
dependency: transitive
|
||||||
|
description: flutter
|
||||||
|
source: sdk
|
||||||
|
version: "0.0.0"
|
||||||
frontend_server_client:
|
frontend_server_client:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -304,6 +354,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.3.2"
|
version: "2.3.2"
|
||||||
|
http:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: http
|
||||||
|
sha256: b9c29a161230ee03d3ccf545097fccd9b87a5264228c5d348202e0f0c28f9010
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.2.2"
|
||||||
http_multi_server:
|
http_multi_server:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -320,6 +378,22 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.0.2"
|
version: "4.0.2"
|
||||||
|
image:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: image
|
||||||
|
sha256: "20842a5ad1555be624c314b0c0cc0566e8ece412f61e859a42efeb6d4101a26c"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "4.5.0"
|
||||||
|
intl:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: intl
|
||||||
|
sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.19.0"
|
||||||
io:
|
io:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -456,6 +530,62 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.9.0"
|
version: "1.9.0"
|
||||||
|
path_parsing:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: path_parsing
|
||||||
|
sha256: "883402936929eac138ee0a45da5b0f2c80f89913e6dc3bf77eb65b84b409c6ca"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.0"
|
||||||
|
path_provider_linux:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: path_provider_linux
|
||||||
|
sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.2.1"
|
||||||
|
path_provider_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: path_provider_platform_interface
|
||||||
|
sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.2"
|
||||||
|
path_provider_windows:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: path_provider_windows
|
||||||
|
sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.3.0"
|
||||||
|
petitparser:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: petitparser
|
||||||
|
sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "6.0.2"
|
||||||
|
platform:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: platform
|
||||||
|
sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.1.6"
|
||||||
|
plugin_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: plugin_platform_interface
|
||||||
|
sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.8"
|
||||||
pool:
|
pool:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -464,6 +594,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.5.1"
|
version: "1.5.1"
|
||||||
|
posix:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: posix
|
||||||
|
sha256: a0117dc2167805aa9125b82eee515cc891819bac2f538c83646d355b16f58b9a
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "6.0.1"
|
||||||
pretty_dio_logger:
|
pretty_dio_logger:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -496,6 +634,62 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.0"
|
version: "1.3.0"
|
||||||
|
shared_preferences:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: shared_preferences
|
||||||
|
sha256: "95f9997ca1fb9799d494d0cb2a780fd7be075818d59f00c43832ed112b158a82"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.3.3"
|
||||||
|
shared_preferences_android:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_android
|
||||||
|
sha256: "02a7d8a9ef346c9af715811b01fbd8e27845ad2c41148eefd31321471b41863d"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.0"
|
||||||
|
shared_preferences_foundation:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_foundation
|
||||||
|
sha256: "6a52cfcdaeac77cad8c97b539ff688ccfc458c007b4db12be584fbe5c0e49e03"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.5.4"
|
||||||
|
shared_preferences_linux:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_linux
|
||||||
|
sha256: "580abfd40f415611503cae30adf626e6656dfb2f0cee8f465ece7b6defb40f2f"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.1"
|
||||||
|
shared_preferences_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_platform_interface
|
||||||
|
sha256: "57cbf196c486bc2cf1f02b85784932c6094376284b3ad5779d1b1c6c6a816b80"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.1"
|
||||||
|
shared_preferences_web:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_web
|
||||||
|
sha256: d2ca4132d3946fec2184261726b355836a82c33d7d5b67af32692aff18a4684e
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.2"
|
||||||
|
shared_preferences_windows:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_windows
|
||||||
|
sha256: "94ef0f72b2d71bc3e700e025db3710911bd51a71cefb65cc609dd0d9a982e3c1"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.1"
|
||||||
shelf:
|
shelf:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -605,6 +799,30 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.4.0"
|
version: "1.4.0"
|
||||||
|
vector_graphics:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: vector_graphics
|
||||||
|
sha256: "27d5fefe86fb9aace4a9f8375b56b3c292b64d8c04510df230f849850d912cb7"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.15"
|
||||||
|
vector_graphics_codec:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: vector_graphics_codec
|
||||||
|
sha256: "2430b973a4ca3c4dbc9999b62b8c719a160100dcbae5c819bae0cacce32c9cdb"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.12"
|
||||||
|
vector_graphics_compiler:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: vector_graphics_compiler
|
||||||
|
sha256: "1b4b9e706a10294258727674a340ae0d6e64a7231980f9f9a3d12e4b42407aad"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.16"
|
||||||
vector_math:
|
vector_math:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -653,6 +871,22 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.1"
|
version: "3.0.1"
|
||||||
|
xdg_directories:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: xdg_directories
|
||||||
|
sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.0"
|
||||||
|
xml:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: xml
|
||||||
|
sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "6.5.0"
|
||||||
yaml:
|
yaml:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -663,4 +897,4 @@ packages:
|
|||||||
version: "3.1.2"
|
version: "3.1.2"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.5.3 <4.0.0"
|
dart: ">=3.5.3 <4.0.0"
|
||||||
flutter: ">=3.18.0-18.0.pre.54"
|
flutter: ">=3.24.0"
|
||||||
|
20
pubspec.yaml
@ -40,6 +40,14 @@ dependencies:
|
|||||||
# Use with the CupertinoIcons class for iOS style icons.
|
# Use with the CupertinoIcons class for iOS style icons.
|
||||||
cupertino_icons: ^1.0.8
|
cupertino_icons: ^1.0.8
|
||||||
|
|
||||||
|
flutter_svg: 2.0.7
|
||||||
|
|
||||||
|
flutter_localizations:
|
||||||
|
sdk: flutter
|
||||||
|
intl: 0.19.0
|
||||||
|
|
||||||
|
shared_preferences: ^2.2.3
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
@ -51,6 +59,8 @@ dev_dependencies:
|
|||||||
flutter_bloc: ^8.1.5
|
flutter_bloc: ^8.1.5
|
||||||
copy_with_extension_gen: ^5.0.4
|
copy_with_extension_gen: ^5.0.4
|
||||||
|
|
||||||
|
flutter_launcher_icons: 0.13.1
|
||||||
|
|
||||||
# The "flutter_lints" package below contains a set of recommended lints to
|
# The "flutter_lints" package below contains a set of recommended lints to
|
||||||
# encourage good coding practices. The lint set provided by the package is
|
# 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
|
# activated in the `analysis_options.yaml` file located at the root of your
|
||||||
@ -63,12 +73,15 @@ dev_dependencies:
|
|||||||
|
|
||||||
# The following section is specific to Flutter packages.
|
# The following section is specific to Flutter packages.
|
||||||
flutter:
|
flutter:
|
||||||
|
generate: true
|
||||||
# The following line ensures that the Material Icons font is
|
# The following line ensures that the Material Icons font is
|
||||||
# included with your application, so that you can use the icons in
|
# included with your application, so that you can use the icons in
|
||||||
# the material Icons class.
|
# the material Icons class.
|
||||||
uses-material-design: true
|
uses-material-design: true
|
||||||
|
|
||||||
|
assets:
|
||||||
|
- assets/svg/
|
||||||
|
|
||||||
# To add assets to your application, add an assets section, like this:
|
# To add assets to your application, add an assets section, like this:
|
||||||
# assets:
|
# assets:
|
||||||
# - images/a_dot_burr.jpeg
|
# - images/a_dot_burr.jpeg
|
||||||
@ -99,3 +112,8 @@ flutter:
|
|||||||
#
|
#
|
||||||
# For details regarding fonts from package dependencies,
|
# For details regarding fonts from package dependencies,
|
||||||
# see https://flutter.dev/to/font-from-package
|
# see https://flutter.dev/to/font-from-package
|
||||||
|
flutter_icons:
|
||||||
|
android: "ic_launcher"
|
||||||
|
ios: true
|
||||||
|
image_path: "assets/icon2.png"
|
||||||
|
min_sdk_android: 21
|
||||||
|