Initial commit
This commit is contained in:
154
app_code/lib/screens/setting.dart
Normal file
154
app_code/lib/screens/setting.dart
Normal file
@@ -0,0 +1,154 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:grostore/app_lang.dart';
|
||||
import 'package:grostore/configs/style_config.dart';
|
||||
import 'package:grostore/configs/theme_config.dart';
|
||||
import 'package:grostore/custom_ui/BoxDecorations.dart';
|
||||
import 'package:grostore/custom_ui/common_appbar.dart';
|
||||
import 'package:grostore/helpers/device_info_helper.dart';
|
||||
import 'package:grostore/models/currency_response.dart';
|
||||
import 'package:grostore/models/language_response.dart';
|
||||
import 'package:grostore/presenters/setting_presenter.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../presenters/bloc/lang/lang_bloc.dart';
|
||||
|
||||
class Setting extends StatefulWidget {
|
||||
const Setting({super.key});
|
||||
|
||||
@override
|
||||
State<Setting> createState() => _SettingState();
|
||||
}
|
||||
|
||||
class _SettingState extends State<Setting> {
|
||||
@override
|
||||
void initState() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||
Provider.of<SettingPresenter>(context, listen: false).initState();
|
||||
});
|
||||
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
}
|
||||
|
||||
String datas = "uz";
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: ThemeConfig.xxlightGrey,
|
||||
appBar: CommonAppbar.show(
|
||||
title: AppLang.local(context).settings, context: context),
|
||||
body: Consumer<SettingPresenter>(builder: (context, data, child) {
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: StyleConfig.padding,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
/* DropdownButton<LanguageInfo>(
|
||||
value: data.selectedLanguage,
|
||||
icon: const Icon(Icons.arrow_downward),
|
||||
elevation: 16,
|
||||
style: const TextStyle(color: Colors.deepPurple),
|
||||
underline: Container(
|
||||
height: 2,
|
||||
color: Colors.deepPurpleAccent,
|
||||
),
|
||||
onChanged: (LanguageInfo? value) {
|
||||
// This is called when the user selects an item.
|
||||
if(value!=null) {
|
||||
data.setLocale(value);
|
||||
}
|
||||
},
|
||||
items: data.languageList.map<DropdownMenuItem<LanguageInfo>>((LanguageInfo value) {
|
||||
return DropdownMenuItem<LanguageInfo>(
|
||||
value: value,
|
||||
child: Text(value.name),
|
||||
);
|
||||
}).toList(),
|
||||
),*/
|
||||
Text(
|
||||
AppLang.local(context).currency,
|
||||
style: StyleConfig.fs14fwBold,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 14,
|
||||
),
|
||||
Container(
|
||||
width: getWidth(context),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14),
|
||||
decoration: BoxDecorations.customRadius(
|
||||
radius: BorderRadius.circular(5))
|
||||
.copyWith(
|
||||
color: ThemeConfig.white,
|
||||
),
|
||||
child: DropdownButton<CurrencyInfo>(
|
||||
isExpanded: true,
|
||||
value: data.selectedCurrency,
|
||||
elevation: 16,
|
||||
underline: const SizedBox.shrink(),
|
||||
style: const TextStyle(color: Colors.deepPurple),
|
||||
onChanged: (CurrencyInfo? value) {
|
||||
// This is called when the user selects an item.
|
||||
if (value != null) {
|
||||
data.onChange(value);
|
||||
}
|
||||
},
|
||||
items: data.currencyList.map<DropdownMenuItem<CurrencyInfo>>(
|
||||
(CurrencyInfo value) {
|
||||
return DropdownMenuItem<CurrencyInfo>(
|
||||
value: value,
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
value.name,
|
||||
style: StyleConfig.fs14fwNormal,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10,),
|
||||
// BlocBuilder<LangBloc, LangState>(
|
||||
// builder: (context, state) {
|
||||
// return Container(
|
||||
// height: 100,
|
||||
// margin: const EdgeInsets.only(top: 20),
|
||||
// width: getWidth(context),
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 14),
|
||||
// decoration: BoxDecoration(
|
||||
// color: Colors.white,
|
||||
// borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||
// ),
|
||||
// child: DropdownButton<String>(
|
||||
// value: datas ?? "uz",
|
||||
// icon: Icon(Icons.arrow_drop_down_rounded),
|
||||
// style: const TextStyle(color: Colors.deepPurple),
|
||||
// onChanged: (String? value) {
|
||||
// datas = value ?? "uz";
|
||||
// context
|
||||
// .read<LangBloc>()
|
||||
// .add(LanguageEvent(locale: Locale(datas)));
|
||||
// },
|
||||
// items: const [
|
||||
// DropdownMenuItem<String>(value: "uz", child: Text("Uz")),
|
||||
// DropdownMenuItem<String>(value: 'en', child: Text("En")),
|
||||
// DropdownMenuItem<String>(value: "ru", child: Text("Ru")),
|
||||
// ]));
|
||||
// },
|
||||
// )
|
||||
],
|
||||
),
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user