feat: changing language done

This commit is contained in:
jahongireshonqulov
2025-10-25 20:13:11 +05:00
parent 2750564b08
commit 651a7e5e9d
31 changed files with 621 additions and 57 deletions

View File

@@ -651,6 +651,108 @@ abstract class AppLocalizations {
/// In en, this message translates to:
/// **'Food, shopping, drinks, etc.'**
String get categoriesShort;
/// No description provided for @yourFavourites.
///
/// In en, this message translates to:
/// **'Your favourites'**
String get yourFavourites;
/// No description provided for @wallet.
///
/// In en, this message translates to:
/// **'Wallet'**
String get wallet;
/// No description provided for @sendAGift.
///
/// In en, this message translates to:
/// **'Send a gift'**
String get sendAGift;
/// No description provided for @businessPreferences.
///
/// In en, this message translates to:
/// **'Business preferences'**
String get businessPreferences;
/// No description provided for @businessSub.
///
/// In en, this message translates to:
/// **'Make work meals quicker and easier'**
String get businessSub;
/// No description provided for @help.
///
/// In en, this message translates to:
/// **'Help'**
String get help;
/// No description provided for @promotions.
///
/// In en, this message translates to:
/// **'Promotions'**
String get promotions;
/// No description provided for @uberPass.
///
/// In en, this message translates to:
/// **'Uber Pass'**
String get uberPass;
/// No description provided for @uberPassSub.
///
/// In en, this message translates to:
/// **'Join free for 1 month'**
String get uberPassSub;
/// No description provided for @deliverWithUber.
///
/// In en, this message translates to:
/// **'Deliver with Uber'**
String get deliverWithUber;
/// No description provided for @settings.
///
/// In en, this message translates to:
/// **'Settings'**
String get settings;
/// No description provided for @home.
///
/// In en, this message translates to:
/// **'Home'**
String get home;
/// No description provided for @browse.
///
/// In en, this message translates to:
/// **'Browse'**
String get browse;
/// No description provided for @baskets.
///
/// In en, this message translates to:
/// **'Baskets'**
String get baskets;
/// No description provided for @account.
///
/// In en, this message translates to:
/// **'Account'**
String get account;
/// No description provided for @changeLanguage.
///
/// In en, this message translates to:
/// **'Change language'**
String get changeLanguage;
/// No description provided for @language.
///
/// In en, this message translates to:
/// **'Language'**
String get language;
}
class _AppLocalizationsDelegate

View File

@@ -295,4 +295,55 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get categoriesShort => 'Food, shopping, drinks, etc.';
@override
String get yourFavourites => 'Your favourites';
@override
String get wallet => 'Wallet';
@override
String get sendAGift => 'Send a gift';
@override
String get businessPreferences => 'Business preferences';
@override
String get businessSub => 'Make work meals quicker and easier';
@override
String get help => 'Help';
@override
String get promotions => 'Promotions';
@override
String get uberPass => 'Uber Pass';
@override
String get uberPassSub => 'Join free for 1 month';
@override
String get deliverWithUber => 'Deliver with Uber';
@override
String get settings => 'Settings';
@override
String get home => 'Home';
@override
String get browse => 'Browse';
@override
String get baskets => 'Baskets';
@override
String get account => 'Account';
@override
String get changeLanguage => 'Change language';
@override
String get language => 'Language';
}

View File

@@ -271,7 +271,7 @@ class AppLocalizationsRu extends AppLocalizations {
String get latestDeals => 'Новые предложения';
@override
String get restaurantRewards => 'Ресторанные бонусы';
String get restaurantRewards => 'Бонусы ресторанов';
@override
String get nationwideShipping => 'Доставка по всей стране';
@@ -296,4 +296,55 @@ class AppLocalizationsRu extends AppLocalizations {
@override
String get categoriesShort => 'Еда, покупки, напитки и т.д.';
@override
String get yourFavourites => 'Избранное';
@override
String get wallet => 'Кошелёк';
@override
String get sendAGift => 'Отправить подарок';
@override
String get businessPreferences => 'Рабочие предпочтения';
@override
String get businessSub => 'Сделайте рабочие обеды быстрее и проще';
@override
String get help => 'Помощь';
@override
String get promotions => 'Акции';
@override
String get uberPass => 'Uber Pass';
@override
String get uberPassSub => 'Присоединяйтесь бесплатно на 1 месяц';
@override
String get deliverWithUber => 'Доставляйте с Uber';
@override
String get settings => 'Настройки';
@override
String get home => 'Главная';
@override
String get browse => 'Категории';
@override
String get baskets => 'Корзина';
@override
String get account => 'Аккаунт';
@override
String get changeLanguage => 'Сменить язык';
@override
String get language => 'Язык';
}

View File

@@ -271,7 +271,7 @@ class AppLocalizationsUz extends AppLocalizations {
String get latestDeals => 'Yangi chegirmalar';
@override
String get restaurantRewards => 'Restoran mukofotlari';
String get restaurantRewards => 'Restoran bonuslari';
@override
String get nationwideShipping => 'Butun mamlakat boylab yetkazib berish';
@@ -296,4 +296,55 @@ class AppLocalizationsUz extends AppLocalizations {
@override
String get categoriesShort => 'Ovqat, xaridlar, ichimliklar va boshqalar.';
@override
String get yourFavourites => 'Sevimlilar';
@override
String get wallet => 'Hamyon';
@override
String get sendAGift => 'Sovga yuborish';
@override
String get businessPreferences => 'Biznes sozlamalari';
@override
String get businessSub => 'Ishdagi ovqatlarni tezroq va osonroq qiling';
@override
String get help => 'Yordam';
@override
String get promotions => 'Aksiyalar';
@override
String get uberPass => 'Uber Pass';
@override
String get uberPassSub => '1 oy bepul ulaning';
@override
String get deliverWithUber => 'Uber bilan yetkazib bering';
@override
String get settings => 'Sozlamalar';
@override
String get home => 'Bosh sahifa';
@override
String get browse => 'Kategoriya';
@override
String get baskets => 'Savatcha';
@override
String get account => 'Profil';
@override
String get changeLanguage => 'Tilni o\'zgartirish';
@override
String get language => 'Til';
}

View File

@@ -34,10 +34,20 @@ abstract class AppIcons {
static const String icCurrentLocation = "$baseUrl/ic_current_loc.svg";
static const String icEdit = "$baseUrl/ic_edit.svg";
static const String icSearch = "$baseUrl/ic_search.svg";
static const String icCheck= "$baseUrl/ic_check.svg";
static const String icCheck1= "$baseUrl/ic_check1.svg";
static const String icArrowRight= "$baseUrl/ic_arrow_right.svg";
static const String icCheck = "$baseUrl/ic_check.svg";
static const String icCheck1 = "$baseUrl/ic_check1.svg";
static const String icArrowRight = "$baseUrl/ic_arrow_right.svg";
static const String icDeliver = "$baseUrl/ic_deliver.svg";
static const String icGift = "$baseUrl/ic_gift.svg";
static const String icHelp = "$baseUrl/ic_help.svg";
static const String icLike = "$baseUrl/ic_like.svg";
static const String icPromotions = "$baseUrl/ic_promotions.svg";
static const String icSettings = "$baseUrl/ic_settings.svg";
static const String icRewards = "$baseUrl/ic_rewards.svg";
static const String icUberPass = "$baseUrl/ic_uber_pass.svg";
static const String icWallet = "$baseUrl/ic_wallet.svg";
static const String icOrdersSvg = "$baseUrl/ic_orders_svg.svg";
static const String icLanguage = "$baseUrl/ic_language.svg";
///.png icons
static const String icBestOverall = "$baseUrl/ic_best.png";
@@ -46,6 +56,8 @@ abstract class AppIcons {
static const String icGlutenFree = "$baseUrl/ic_gluten_free.png";
static const String icAllergyFriendly = "$baseUrl/ic_allergy_friendly.png";
static const String icClock = "$baseUrl/ic_clock.svg";
static const String icOrders= "$baseUrl/ic_orders.png";
static const String icOrders = "$baseUrl/ic_orders.png";
static const String icUz = "$baseUrl/ic_uzb.png";
static const String icRu = "$baseUrl/ic_rus.png";
static const String icEn = "$baseUrl/ic_eng.png";
}

View File

@@ -11,17 +11,16 @@ abstract class AppImages {
static const String imgTakeout = "$baseUrl/img_takeout.png";
static const String imgAsian = "$baseUrl/img_asian.png";
static const String imgIceCream = "$baseUrl/img_ice_cream.png";
static const String imgHalal= "$baseUrl/img_halal.png";
static const String imgRetails= "$baseUrl/img_retails.png";
static const String imgCarribean= "$baseUrl/img_carribean.png";
static const String imgIndian= "$baseUrl/img_indian.png";
static const String imgHalal = "$baseUrl/img_halal.png";
static const String imgRetails = "$baseUrl/img_retails.png";
static const String imgCarribean = "$baseUrl/img_carribean.png";
static const String imgIndian = "$baseUrl/img_indian.png";
static const String imgFrench = "$baseUrl/img_french.png";
static const String imgFastFoods = "$baseUrl/img_fast_food.png";
static const String imgBurger = "$baseUrl/img_burger.png";
static const String imgRide = "$baseUrl/img_ride.png";
static const String imgChinese= "$baseUrl/img_chinese.png";
static const String imgChinese = "$baseUrl/img_chinese.png";
static const String imgDesert = "$baseUrl/img_desert.png";
static const String imgPickUp= "$baseUrl/img_pick_up.png";
static const String imgPickUp = "$baseUrl/img_pick_up.png";
static const String imgAvatar = "$baseUrl/img_avatar.jpg";
}

View File

@@ -0,0 +1,21 @@
import '../../../../core/theme/app_icons.dart';
mixin AccountMixins {
final List<String> leadingIcons = [
AppIcons.icOrdersSvg,
AppIcons.icLike,
AppIcons.icRewards,
AppIcons.icWallet,
AppIcons.icGift,
AppIcons.icHelp,
AppIcons.icPromotions,
AppIcons.icUberPass,
AppIcons.icDeliver,
AppIcons.icLanguage,
AppIcons.icSettings,
];
final List<String> flags = [AppIcons.icEn, AppIcons.icUz, AppIcons.icRu];
final List<String> languages = ["English", "O'zbekcha", "Русский"];
}

View File

@@ -1,3 +1,5 @@
import 'package:food_delivery_client/feature/account/presentation/pages/account_page/widgets/w_account_body.dart';
import '../../../../../food_delivery_client.dart';
class AccountPage extends StatelessWidget {
@@ -5,38 +7,7 @@ class AccountPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocBuilder<LanguageBloc, LanguageState>(
builder: (context, state) {
return WLayout(
child: Scaffold(
body: Center(
child: Column(
children: [
Text(context.loc.iCantSignIn),
TextButton(
onPressed: () {
if (state.currentLocale == Locale("uz")) {
context.read<LanguageBloc>().add(
LanguageEvent.changed(Locale('ru')),
);
} else if (state.currentLocale == Locale("ru")) {
context.read<LanguageBloc>().add(
LanguageEvent.changed(Locale('en')),
);
} else {
context.read<LanguageBloc>().add(
LanguageEvent.changed(Locale('uz')),
);
}
},
child: Text("changelang"),
),
],
),
),
),
);
},
);
return WAccountBody();
}
}

View File

@@ -0,0 +1,208 @@
import 'package:flutter/cupertino.dart';
import 'package:food_delivery_client/feature/account/presentation/mixins/account_mixins.dart';
import '../../../../../../food_delivery_client.dart';
class WAccountBody extends StatelessWidget with AccountMixins {
WAccountBody({super.key});
@override
Widget build(BuildContext context) {
final List<String> titles = [
context.loc.orders,
context.loc.yourFavourites,
context.loc.restaurantRewards,
context.loc.wallet,
context.loc.sendAGift,
context.loc.help,
context.loc.promotions,
context.loc.uberPass,
context.loc.deliverWithUber,
context.loc.changeLanguage,
context.loc.settings,
];
return WLayout(
child: Scaffold(
appBar: PreferredSize(
preferredSize: Size.fromHeight(56),
child: WAccountAppBar().paddingSymmetric(horizontal: 19),
),
body: LayoutBuilder(
builder: (context, constraints) => ConstrainedBox(
constraints: BoxConstraints(minHeight: constraints.maxHeight),
child: ListView.builder(
shrinkWrap: true,
itemCount: leadingIcons.length,
padding: EdgeInsets.symmetric(vertical: 15),
physics: const AlwaysScrollableScrollPhysics(),
scrollDirection: Axis.vertical,
itemBuilder: (context, index) => WAccountRowItem(
onTap: () {
if (index == 9) {
WChangeLanguage().show(context);
}
},
svgPath: leadingIcons[index],
title: titles[index],
),
),
),
),
),
);
}
}
class WAccountAppBar extends StatelessWidget {
const WAccountAppBar({super.key});
@override
Widget build(BuildContext context) {
return AppBar(
centerTitle: false,
leading: ClipRRect(
borderRadius: AppUtils.kBorderRadius40,
child: SizedBox(
child: Image.asset(
AppImages.imgAvatar,
height: 36,
width: 36,
fit: BoxFit.cover,
),
),
),
title: Text('Felix', style: AppTextStyles.size18Medium),
);
}
}
class WAccountRowItem extends StatelessWidget {
const WAccountRowItem({
super.key,
required this.svgPath,
required this.title,
this.subTitle,
this.leadingIcon,
required this.onTap,
});
final String svgPath;
final String title;
final String? subTitle;
final Widget? leadingIcon;
final VoidCallback onTap;
@override
Widget build(BuildContext context) {
return InkWell(
onTap: onTap,
child: Ink(
child: Row(
spacing: 24,
mainAxisAlignment: MainAxisAlignment.start,
children: [
leadingIcon ??
SizedBox(
height: 24,
width: 24,
child: SvgPicture.asset(svgPath),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(title, style: AppTextStyles.size14Medium),
if (subTitle != null)
Text(
subTitle!,
style: AppTextStyles.size14Medium.copyWith(
color: AppColors.c34A853,
),
),
],
),
],
).paddingSymmetric(vertical: 16, horizontal: 22),
),
);
}
}
class WChangeLanguage extends StatelessWidget with AccountMixins {
WChangeLanguage({super.key});
show(BuildContext context) {
showModalBottomSheet(
context: context,
builder: (context) => Wrap(children: [this]),
);
}
@override
Widget build(BuildContext context) {
return BlocBuilder<LanguageBloc, LanguageState>(
builder: (context, state) {
return Material(
color: AppColors.cFFFFFF,
borderRadius: AppUtils.kBorderRadiusTop20,
child: SizedBox(
width: context.w,
child: SafeArea(
child: Column(
children: [
10.verticalSpace,
SizedBox(
height: 6,
width: 100,
child: DecoratedBox(
decoration: BoxDecoration(
color: AppColors.cEEEEEE,
borderRadius: AppUtils.kBorderRadius8,
),
),
),
10.verticalSpace,
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
context.loc.changeLanguage,
style: AppTextStyles.size24Medium,
),
IconButton(
onPressed: () {
context.pop();
},
icon: SvgPicture.asset(AppIcons.icClose),
),
],
).paddingSymmetric(horizontal: 16),
15.verticalSpace,
Column(
children: List.generate(3, (index) {
return AppListTile(
onPressed: () {
context.read<LanguageBloc>().add(
LanguageEvent.changed(L10n.locales[index]),
);
},
isSelected: L10n.locales[index] == state.currentLocale,
svgPath: '',
leading: SizedBox(
height: 24,
width: 24,
child: Image.asset(flags[index]),
),
title: languages[index],
titleTextStyle: AppTextStyles.size16Medium,
);
}),
),
],
),
),
),
);
},
);
}
}

View File

@@ -33,7 +33,7 @@ class AppListTile extends StatelessWidget {
subtitle: subTitle,
contentPadding:
contentPadding ?? EdgeInsetsGeometry.only(left: 20, right: 27),
leading: leading ?? SvgPicture.asset(svgPath),
leading:leading ?? SvgPicture.asset(svgPath),
title:
titleWidget ??
Text(title, style: titleTextStyle ?? AppTextStyles.size16Regular),

View File

@@ -24,5 +24,4 @@ mixin MainPageMixin {
SvgPicture.asset(AppIcons.icAccountActive),
];
final List<String> labels = ["Home", "Browse", "Baskets", 'Account'];
}

View File

@@ -5,6 +5,12 @@ class MainPage extends StatelessWidget with MainPageMixin {
@override
Widget build(BuildContext context) {
final List<String> labels = [
context.loc.home,
context.loc.browse,
context.loc.baskets,
context.loc.account,
];
return BlocProvider(
create: (context) => sl<MainBloc>(),
child: BlocBuilder<MainBloc, MainState>(