some code refactoring
parent
8120ebda3d
commit
a6d5d1107a
|
@ -13,6 +13,7 @@ import '../models/language.dart';
|
|||
import '../models/language_setting.dart';
|
||||
import '../models/location.dart';
|
||||
import '../services/auth/auth_service.dart';
|
||||
import '../utils/helper.dart';
|
||||
import '../utils/math.dart';
|
||||
|
||||
class UserDataPage extends StatefulWidget {
|
||||
|
@ -590,17 +591,6 @@ class _UserDataPageState extends State<UserDataPage> {
|
|||
);
|
||||
|
||||
void _showSnackBar(String message) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(message),
|
||||
backgroundColor: Colors.red,
|
||||
action: SnackBarAction(
|
||||
label: 'Dismiss',
|
||||
onPressed: () {
|
||||
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
showErrorSnackBar(context, message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -276,14 +276,7 @@ class _UserProfilePageState extends State<UserProfilePage> {
|
|||
if (isOwner)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: Align(
|
||||
alignment: Alignment.topRight,
|
||||
child: OutlinedButton.icon(
|
||||
label: const Text('Edit'),
|
||||
icon: const Icon(Icons.edit),
|
||||
onPressed: editUserCommunicationInfo,
|
||||
),
|
||||
),
|
||||
child: _editButton(context, editUserCommunicationInfo),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -344,14 +337,7 @@ class _UserProfilePageState extends State<UserProfilePage> {
|
|||
if (isOwner)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: Align(
|
||||
alignment: Alignment.topRight,
|
||||
child: OutlinedButton.icon(
|
||||
label: const Text('Edit'),
|
||||
icon: const Icon(Icons.edit),
|
||||
onPressed: editUserWorkCultureInfo,
|
||||
),
|
||||
),
|
||||
child: _editButton(context, editUserWorkCultureInfo),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -412,15 +398,7 @@ class _UserProfilePageState extends State<UserProfilePage> {
|
|||
],
|
||||
),
|
||||
),
|
||||
if (isOwner)
|
||||
Align(
|
||||
alignment: Alignment.topRight,
|
||||
child: OutlinedButton.icon(
|
||||
label: const Text('Edit'),
|
||||
icon: const Icon(Icons.edit),
|
||||
onPressed: editUserVisionInfo,
|
||||
),
|
||||
),
|
||||
if (isOwner) _editButton(context, editUserVisionInfo),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
@ -480,15 +458,7 @@ class _UserProfilePageState extends State<UserProfilePage> {
|
|||
],
|
||||
),
|
||||
),
|
||||
if (isOwner)
|
||||
Align(
|
||||
alignment: Alignment.topRight,
|
||||
child: OutlinedButton.icon(
|
||||
label: const Text('Edit'),
|
||||
icon: const Icon(Icons.edit),
|
||||
onPressed: editUserSkillsInfo,
|
||||
),
|
||||
),
|
||||
if (isOwner) _editButton(context, editUserSkillsInfo),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
@ -513,15 +483,7 @@ class _UserProfilePageState extends State<UserProfilePage> {
|
|||
],
|
||||
),
|
||||
),
|
||||
if (isOwner)
|
||||
Align(
|
||||
alignment: Alignment.topRight,
|
||||
child: OutlinedButton.icon(
|
||||
label: const Text('Edit'),
|
||||
icon: const Icon(Icons.edit),
|
||||
onPressed: editUserSkillsSoughtInfo,
|
||||
),
|
||||
),
|
||||
if (isOwner) _editButton(context, editUserSkillsSoughtInfo),
|
||||
],
|
||||
),
|
||||
],
|
||||
|
@ -560,14 +522,8 @@ class _UserProfilePageState extends State<UserProfilePage> {
|
|||
style: const TextStyle(fontSize: 16)),
|
||||
],
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.bottomRight,
|
||||
child: OutlinedButton.icon(
|
||||
label: const Text('Edit'),
|
||||
icon: const Icon(Icons.edit),
|
||||
onPressed: editUserDataInfo,
|
||||
),
|
||||
),
|
||||
_editButton(context, editUserDataInfo,
|
||||
alignment: Alignment.bottomRight),
|
||||
],
|
||||
),
|
||||
if (isOwner) const SizedBox(height: 16),
|
||||
|
@ -632,14 +588,7 @@ class _UserProfilePageState extends State<UserProfilePage> {
|
|||
return Column(
|
||||
children: [
|
||||
if (isOwner)
|
||||
Align(
|
||||
alignment: Alignment.bottomRight,
|
||||
child: OutlinedButton.icon(
|
||||
label: const Text('Edit'),
|
||||
icon: const Icon(Icons.edit),
|
||||
onPressed: editNameInfo,
|
||||
),
|
||||
),
|
||||
_editButton(context, editNameInfo, alignment: Alignment.bottomRight),
|
||||
CircleAvatar(
|
||||
radius: 80,
|
||||
backgroundImage:
|
||||
|
@ -683,4 +632,16 @@ class _UserProfilePageState extends State<UserProfilePage> {
|
|||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _editButton(BuildContext context, void Function()? onPressedFunction,
|
||||
{Alignment alignment = Alignment.topRight}) {
|
||||
return Align(
|
||||
alignment: alignment,
|
||||
child: OutlinedButton.icon(
|
||||
label: const Text('Edit'),
|
||||
icon: const Icon(Icons.edit),
|
||||
onPressed: onPressedFunction,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import '../constants.dart';
|
|||
import '../enumerations.dart';
|
||||
import '../forms/corporate_culture_form.dart';
|
||||
import '../services/auth/auth_service.dart';
|
||||
import '../utils/helper.dart';
|
||||
|
||||
class UserVisionPage extends StatefulWidget {
|
||||
const UserVisionPage(
|
||||
|
@ -87,9 +88,7 @@ class UserVisionPageState extends State<UserVisionPage> {
|
|||
}
|
||||
|
||||
void _showSnackBar(String message) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(message)),
|
||||
);
|
||||
showErrorSnackBar(context, message);
|
||||
}
|
||||
|
||||
bool isVisionSelected() {
|
||||
|
|
|
@ -96,3 +96,18 @@ void showMsg(BuildContext context, String title, String content) {
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
void showErrorSnackBar(BuildContext context, String message) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(message),
|
||||
backgroundColor: Colors.red,
|
||||
action: SnackBarAction(
|
||||
label: 'Dismiss',
|
||||
onPressed: () {
|
||||
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
Loading…
Reference in New Issue