forked from eatvio/eatvio_app
Settings page layout and API info display
This commit is contained in:
@@ -24,14 +24,35 @@ class MySettingsScreen extends StatelessWidget {
|
|||||||
mediaQueryData = MediaQuery.of(context);
|
mediaQueryData = MediaQuery.of(context);
|
||||||
return BlocBuilder<MyProfileBloc, MyProfileState>(
|
return BlocBuilder<MyProfileBloc, MyProfileState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
|
print(state.userDetails);
|
||||||
|
final List<String> userDetails = [
|
||||||
|
state.userDetails!['first_name'],
|
||||||
|
state.userDetails!['last_name'],
|
||||||
|
state.userDetails!['weight'].toString(),
|
||||||
|
state.userDetails!['height'].toString(),
|
||||||
|
state.userDetails!['chest_circumference'].toString(),
|
||||||
|
state.userDetails!['waist_circumference'].toString(),
|
||||||
|
state.userDetails!['hip_circumference'].toString(),
|
||||||
|
];
|
||||||
return SafeArea(
|
return SafeArea(
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
appBar: _buildAppBar(context, "my_settings".tr),
|
appBar: _buildAppBar(context, "my_settings".tr),
|
||||||
body: Container(
|
body: Padding(
|
||||||
width: double.maxFinite,
|
padding: const EdgeInsets.all(16.0),
|
||||||
padding:
|
child: Column(
|
||||||
EdgeInsets.symmetric(horizontal: 8.h, vertical: 18.v),
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
child: Column(children: [])),
|
children: [
|
||||||
|
SectionTitle('Язык'),
|
||||||
|
LanguageDropdown(),
|
||||||
|
SectionTitle('Уведомления'),
|
||||||
|
NotificationSwitch('Уведомление о новых обновлениях'),
|
||||||
|
NotificationSwitch('Напоминания о заполнении дневника'),
|
||||||
|
SectionTitle('Дополнительная информация'),
|
||||||
|
ExpandableList('Персональные данные', userDetails),
|
||||||
|
ExpandableList('О нас', ['Контакты', 'Адрес']),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
bottomNavigationBar: _buildBottomBar(context)));
|
bottomNavigationBar: _buildBottomBar(context)));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -65,3 +86,150 @@ class MySettingsScreen extends StatelessWidget {
|
|||||||
NavigatorService.goBack();
|
NavigatorService.goBack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class SectionTitle extends StatelessWidget {
|
||||||
|
final String title;
|
||||||
|
|
||||||
|
SectionTitle(this.title);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||||
|
child: Text(
|
||||||
|
title,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(fontSize: 18),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class LanguageDropdown extends StatefulWidget {
|
||||||
|
@override
|
||||||
|
_LanguageDropdownState createState() => _LanguageDropdownState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LanguageDropdownState extends State<LanguageDropdown> {
|
||||||
|
String selectedLanguage = 'Русский';
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return DropdownButton<String>(
|
||||||
|
value: selectedLanguage,
|
||||||
|
onChanged: (newValue) {
|
||||||
|
setState(() {
|
||||||
|
selectedLanguage = newValue!;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
isDense: false, // Установите isDense в false
|
||||||
|
selectedItemBuilder: (BuildContext context) {
|
||||||
|
return ['Русский'].map<Widget>((String language) {
|
||||||
|
return Align(
|
||||||
|
alignment: Alignment.center, // Выравнивание текста по центру
|
||||||
|
child: Text(
|
||||||
|
language,
|
||||||
|
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList();
|
||||||
|
},
|
||||||
|
items: ['Русский'].map((String language) {
|
||||||
|
return DropdownMenuItem<String>(
|
||||||
|
value: language,
|
||||||
|
child: Text(language),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class NotificationSwitch extends StatefulWidget {
|
||||||
|
final String title;
|
||||||
|
|
||||||
|
NotificationSwitch(this.title);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_NotificationSwitchState createState() => _NotificationSwitchState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _NotificationSwitchState extends State<NotificationSwitch> {
|
||||||
|
bool switchValue = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
widget.title,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.black, fontSize: 14, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
Switch(
|
||||||
|
value: switchValue,
|
||||||
|
onChanged: (value) {
|
||||||
|
setState(() {
|
||||||
|
switchValue = value;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
inactiveThumbColor: appTheme.blueA400,
|
||||||
|
inactiveTrackColor: Colors.white,
|
||||||
|
activeTrackColor: appTheme.blueA400,
|
||||||
|
activeColor: Colors.white,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ExpandableList extends StatefulWidget {
|
||||||
|
final String title;
|
||||||
|
final List<String> items;
|
||||||
|
|
||||||
|
ExpandableList(this.title, this.items);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_ExpandableListState createState() => _ExpandableListState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ExpandableListState extends State<ExpandableList> {
|
||||||
|
bool isExpanded = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
setState(() {
|
||||||
|
isExpanded = !isExpanded;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
widget.title,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.black,
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
Icon(isExpanded ? Icons.arrow_drop_up : Icons.arrow_drop_down),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (isExpanded)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 16.0),
|
||||||
|
child: Column(
|
||||||
|
//children: widget.items.map((item) => Text(item)).toList(),
|
||||||
|
children: [Text(widget.items.join('\n'))]),
|
||||||
|
),
|
||||||
|
Divider(),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user