86 lines
2.4 KiB
Dart
86 lines
2.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:mobile_monitoring/core/constants/strings.dart';
|
|
import 'package:mobile_monitoring/ui/shared/components/components.dart';
|
|
|
|
class ProfileForm extends StatefulWidget {
|
|
final TextEditingController nameController;
|
|
final bool isLoading;
|
|
final String? userEmail;
|
|
final VoidCallback onUpdate;
|
|
|
|
const ProfileForm({
|
|
super.key,
|
|
required this.nameController,
|
|
required this.isLoading,
|
|
required this.userEmail,
|
|
required this.onUpdate,
|
|
});
|
|
|
|
@override
|
|
State<ProfileForm> createState() => _ProfileFormState();
|
|
}
|
|
|
|
class _ProfileFormState extends State<ProfileForm> {
|
|
final _formKey = GlobalKey<FormState>();
|
|
|
|
@override
|
|
void dispose() {
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return CustomCard(
|
|
elevation: 2,
|
|
borderRadius: 12,
|
|
padding: const EdgeInsets.all(16),
|
|
child: Form(
|
|
key: _formKey,
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
const Text(
|
|
'Informasi Akun',
|
|
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
|
),
|
|
const SizedBox(height: 16),
|
|
CustomTextField(
|
|
controller: widget.nameController,
|
|
labelText: AppStrings.fullName,
|
|
prefixIcon: Icons.person,
|
|
validator: (value) {
|
|
if (value == null || value.isEmpty) {
|
|
return 'Nama tidak boleh kosong';
|
|
}
|
|
return null;
|
|
},
|
|
),
|
|
const SizedBox(height: 16),
|
|
TextFormField(
|
|
initialValue: widget.userEmail ?? '',
|
|
decoration: const InputDecoration(
|
|
labelText: AppStrings.email,
|
|
prefixIcon: Icon(Icons.email),
|
|
),
|
|
enabled: false,
|
|
),
|
|
const SizedBox(height: 24),
|
|
CustomButton(
|
|
text: 'Perbarui Profile',
|
|
onPressed: widget.isLoading
|
|
? null
|
|
: () {
|
|
if (_formKey.currentState!.validate()) {
|
|
widget.onUpdate();
|
|
}
|
|
},
|
|
isLoading: widget.isLoading,
|
|
width: double.infinity,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|