Revised UserDataPage
parent
86bacaa9f5
commit
a2a7ae5fc6
|
@ -6,6 +6,7 @@ import 'package:flutter_svg/flutter_svg.dart';
|
|||
|
||||
import '../components/location_dialog.dart';
|
||||
import '../components/my_button.dart';
|
||||
import '../components/text_with_bold.dart';
|
||||
import '../constants.dart';
|
||||
import '../enumerations.dart';
|
||||
import '../forms/skills_form.dart';
|
||||
|
@ -206,6 +207,9 @@ class _UserDataPageState extends State<UserDataPage> {
|
|||
await locationsRef
|
||||
.doc(Constants.dbDocMainLocation)
|
||||
.set(_mainLocation!.toMap());
|
||||
} else {
|
||||
_showSnackBar('No location selected');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -375,6 +379,13 @@ class _UserDataPageState extends State<UserDataPage> {
|
|||
AuthService().signOut();
|
||||
},
|
||||
icon: const Icon(Icons.logout),
|
||||
),
|
||||
if (widget.isEditMode && !widget.isRegProcess)
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
_saveButtonClicked(context);
|
||||
},
|
||||
icon: const Icon(Icons.save),
|
||||
)
|
||||
],
|
||||
),
|
||||
|
@ -410,15 +421,23 @@ class _UserDataPageState extends State<UserDataPage> {
|
|||
const SizedBox(height: 10),
|
||||
],
|
||||
// Button to set main location
|
||||
Center(
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
_showLocationDialog(true);
|
||||
},
|
||||
child: Text(_mainLocation != null
|
||||
? 'Change Main Location'
|
||||
: 'Set Main Location'),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Center(
|
||||
child: ElevatedButton.icon(
|
||||
icon: _mainLocation != null
|
||||
? const Icon(Icons.edit_location_alt_outlined)
|
||||
: const Icon(Icons.location_on_outlined),
|
||||
label: Text(_mainLocation != null
|
||||
? 'Edit Main Location'
|
||||
: 'Set Main Location'),
|
||||
onPressed: () {
|
||||
_showLocationDialog(true);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
// Display selected secondary location
|
||||
|
@ -430,29 +449,39 @@ class _UserDataPageState extends State<UserDataPage> {
|
|||
Text(_secondaryLocation!.toString()),
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
if (_mainLocation != null) ...[
|
||||
// Button to set secondary location
|
||||
Center(
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
_showLocationDialog(false);
|
||||
},
|
||||
child: Text(_secondaryLocation != null
|
||||
? 'Change Secondary Location'
|
||||
: 'Add Secondary Location'),
|
||||
),
|
||||
),
|
||||
],
|
||||
// Display selected secondary location or remove button
|
||||
if (_secondaryLocation != null) ...[
|
||||
const SizedBox(height: 12),
|
||||
Center(
|
||||
child: ElevatedButton(
|
||||
onPressed: _removeSecondaryLocation,
|
||||
child: const Text('Remove Secondary Location'),
|
||||
),
|
||||
),
|
||||
],
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
if (_mainLocation != null) ...[
|
||||
// Button to set secondary location
|
||||
Center(
|
||||
child: ElevatedButton.icon(
|
||||
icon: _secondaryLocation != null
|
||||
? const Icon(Icons.edit_location_alt_outlined)
|
||||
: const Icon(Icons.add_location),
|
||||
onPressed: () {
|
||||
_showLocationDialog(false);
|
||||
},
|
||||
label: Text(_secondaryLocation != null
|
||||
? 'Edit'
|
||||
: 'Add location'),
|
||||
),
|
||||
),
|
||||
],
|
||||
const SizedBox(width: 10),
|
||||
// Display selected secondary location or remove button
|
||||
if (_secondaryLocation != null) ...[
|
||||
const SizedBox(height: 12),
|
||||
Center(
|
||||
child: ElevatedButton.icon(
|
||||
onPressed: _removeSecondaryLocation,
|
||||
label: const Text('Remove'),
|
||||
icon: const Icon(Icons.wrong_location_outlined),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const Text(
|
||||
'Age',
|
||||
|
@ -463,7 +492,7 @@ class _UserDataPageState extends State<UserDataPage> {
|
|||
const Padding(padding: EdgeInsets.symmetric(horizontal: 8)),
|
||||
Text(_selectedYear != null
|
||||
? '${calcAge(_selectedYear)} years old'
|
||||
: 'undefined age'),
|
||||
: 'not specified'),
|
||||
const SizedBox(width: 20),
|
||||
DropdownMenu(
|
||||
initialSelection: _selectedYear,
|
||||
|
@ -483,12 +512,15 @@ class _UserDataPageState extends State<UserDataPage> {
|
|||
],
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
'Gender (${genderView.name} selected)',
|
||||
style:
|
||||
const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||
const Text(
|
||||
'Gender',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Center(
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: SegmentedButton<Gender>(
|
||||
style: SegmentedButton.styleFrom(
|
||||
selectedBackgroundColor: Colors.blue,
|
||||
|
@ -523,7 +555,7 @@ class _UserDataPageState extends State<UserDataPage> {
|
|||
style:
|
||||
const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||
),
|
||||
...languagesList.map(buildSingleCheckbox), // ... spread operator
|
||||
...languagesList.map(buildSingleCheckbox),
|
||||
const Divider(),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
|
@ -564,7 +596,8 @@ class _UserDataPageState extends State<UserDataPage> {
|
|||
required VoidCallback onClicked,
|
||||
}) =>
|
||||
ListTile(
|
||||
tileColor: Theme.of(context).colorScheme.secondary,
|
||||
selected: languageSetting.isSelected,
|
||||
selectedColor: Colors.blue,
|
||||
onTap: onClicked,
|
||||
leading: SizedBox(
|
||||
width: 48,
|
||||
|
@ -573,11 +606,10 @@ class _UserDataPageState extends State<UserDataPage> {
|
|||
languageSetting.language.iconFile,
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
languageSetting.language.nativeName,
|
||||
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
title: TextWithBold(
|
||||
boldText: languageSetting.language.nativeName,
|
||||
trailingText: ' / ${languageSetting.language.name}',
|
||||
),
|
||||
subtitle: Text(languageSetting.language.name),
|
||||
trailing: Checkbox(
|
||||
value: languageSetting.isSelected,
|
||||
onChanged: (value) => onClicked(),
|
||||
|
|
Loading…
Reference in New Issue