79 lines
2.9 KiB
Dart
79 lines
2.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_android_app/components/extensions/context_x.dart';
|
|
import 'package:flutter_android_app/presentation/currency_bloc/currency_bloc.dart';
|
|
import 'package:flutter_android_app/presentation/currency_bloc/currency_events.dart';
|
|
import 'package:flutter_android_app/presentation/currency_bloc/currency_state.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
import '../common/svg_objects.dart';
|
|
import '../locale_bloc/locale_bloc.dart';
|
|
import '../locale_bloc/locale_events.dart';
|
|
import '../locale_bloc/locale_state.dart';
|
|
|
|
class SettingsPage extends StatelessWidget {
|
|
const SettingsPage({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Padding(
|
|
padding: const EdgeInsets.only(left: 20, right: 16, top: 8),
|
|
child: Column(
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
'${context.locale.settingsLanguage}:',
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
),
|
|
GestureDetector(
|
|
onTap: () => context.read<LocaleBloc>().add(const ChangeLocaleEvent()),
|
|
child: SizedBox.square(
|
|
dimension: 50,
|
|
child: Padding(
|
|
padding: const EdgeInsets.only(right: 0),
|
|
child: BlocBuilder<LocaleBloc, LocaleState>(
|
|
builder: (context, state) {
|
|
return state.currentLocale.languageCode == 'ru'
|
|
? const SvgRu()
|
|
: const SvgUs();
|
|
}),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
'${context.locale.settingsCurrency}:',
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
),
|
|
BlocBuilder<CurrencyBloc, CurrencyState>(
|
|
builder: (context, currencyState) => GestureDetector(
|
|
onTap: () => context.read<CurrencyBloc>().add(const ToggleLocalCurrencyEvent()),
|
|
child: SizedBox.square(
|
|
dimension: 50,
|
|
child: Padding(
|
|
padding: const EdgeInsets.only(right: 0),
|
|
child: BlocBuilder<LocaleBloc, LocaleState>(
|
|
builder: (context, state) {
|
|
return switch (currencyState.currencyId) {
|
|
'rub' => const SvgRu(),
|
|
'usd' => const SvgUs(),
|
|
_ => const SvgUs(),
|
|
};
|
|
}),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|