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