From 243c628fc4dec6f621907fd2d1967c04479dfbb3 Mon Sep 17 00:00:00 2001 From: maxxkim Date: Thu, 25 Jan 2024 18:00:11 +0300 Subject: [PATCH] Settings page layout and API info display --- .../my_profile_screen/my_settings_screen.dart | 178 +++++++++++++++++- 1 file changed, 173 insertions(+), 5 deletions(-) diff --git a/lib/presentation/profile/my_profile_screen/my_settings_screen.dart b/lib/presentation/profile/my_profile_screen/my_settings_screen.dart index a6466b62..107fdb43 100644 --- a/lib/presentation/profile/my_profile_screen/my_settings_screen.dart +++ b/lib/presentation/profile/my_profile_screen/my_settings_screen.dart @@ -24,14 +24,35 @@ class MySettingsScreen extends StatelessWidget { mediaQueryData = MediaQuery.of(context); return BlocBuilder( builder: (context, state) { + print(state.userDetails); + final List 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( child: Scaffold( appBar: _buildAppBar(context, "my_settings".tr), - body: Container( - width: double.maxFinite, - padding: - EdgeInsets.symmetric(horizontal: 8.h, vertical: 18.v), - child: Column(children: [])), + body: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + SectionTitle('Язык'), + LanguageDropdown(), + SectionTitle('Уведомления'), + NotificationSwitch('Уведомление о новых обновлениях'), + NotificationSwitch('Напоминания о заполнении дневника'), + SectionTitle('Дополнительная информация'), + ExpandableList('Персональные данные', userDetails), + ExpandableList('О нас', ['Контакты', 'Адрес']), + ], + ), + ), bottomNavigationBar: _buildBottomBar(context))); }); } @@ -65,3 +86,150 @@ class MySettingsScreen extends StatelessWidget { 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 { + String selectedLanguage = 'Русский'; + + @override + Widget build(BuildContext context) { + return DropdownButton( + value: selectedLanguage, + onChanged: (newValue) { + setState(() { + selectedLanguage = newValue!; + }); + }, + isDense: false, // Установите isDense в false + selectedItemBuilder: (BuildContext context) { + return ['Русский'].map((String language) { + return Align( + alignment: Alignment.center, // Выравнивание текста по центру + child: Text( + language, + style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), + ), + ); + }).toList(); + }, + items: ['Русский'].map((String language) { + return DropdownMenuItem( + value: language, + child: Text(language), + ); + }).toList(), + ); + } +} + +class NotificationSwitch extends StatefulWidget { + final String title; + + NotificationSwitch(this.title); + + @override + _NotificationSwitchState createState() => _NotificationSwitchState(); +} + +class _NotificationSwitchState extends State { + 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 items; + + ExpandableList(this.title, this.items); + + @override + _ExpandableListState createState() => _ExpandableListState(); +} + +class _ExpandableListState extends State { + 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(), + ], + ); + } +}