feat: register page
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../common/theme/theme.dart';
|
||||
import '../../../components/button/button.dart';
|
||||
import '../../../router/app_router.gr.dart';
|
||||
import 'widgets/phone_field.dart';
|
||||
|
||||
@RoutePage()
|
||||
@@ -12,7 +13,6 @@ class LoginPage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColor.backgroundLight,
|
||||
appBar: AppBar(title: const Text('Masuk')),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24.0),
|
||||
@@ -27,7 +27,12 @@ class LoginPage extends StatelessWidget {
|
||||
const SizedBox(height: 50),
|
||||
|
||||
// Continue Button
|
||||
AppElevatedButton(onPressed: null, title: 'Lanjutkan'),
|
||||
AppElevatedButton(
|
||||
onPressed: () {
|
||||
context.router.push(RegisterRoute());
|
||||
},
|
||||
title: 'Lanjutkan',
|
||||
),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../components/button/button.dart';
|
||||
import 'widgets/name_field.dart';
|
||||
import 'widgets/phone_field.dart';
|
||||
|
||||
@RoutePage()
|
||||
class RegisterPage extends StatelessWidget {
|
||||
const RegisterPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Masuk')),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 40),
|
||||
|
||||
// Title
|
||||
RegisterPhoneField(),
|
||||
SizedBox(height: 24),
|
||||
RegisterNameField(),
|
||||
|
||||
const SizedBox(height: 50),
|
||||
|
||||
Spacer(),
|
||||
|
||||
// Continue Button
|
||||
AppElevatedButton(onPressed: () {}, title: 'Daftar & Lanjutkan'),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../components/field/field.dart';
|
||||
|
||||
class RegisterNameField extends StatelessWidget {
|
||||
const RegisterNameField({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AppTextFormField(title: 'Masukkan nama', hintText: 'John Doe');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../../common/theme/theme.dart';
|
||||
import '../../../../components/field/field.dart';
|
||||
|
||||
class RegisterPhoneField extends StatefulWidget {
|
||||
const RegisterPhoneField({super.key});
|
||||
|
||||
@override
|
||||
State<RegisterPhoneField> createState() => _RegisterPhoneFieldState();
|
||||
}
|
||||
|
||||
class _RegisterPhoneFieldState extends State<RegisterPhoneField> {
|
||||
final TextEditingController _controller = TextEditingController();
|
||||
final FocusNode _focusNode = FocusNode();
|
||||
bool _hasFocus = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_focusNode.addListener(() {
|
||||
setState(() {
|
||||
_hasFocus = _focusNode.hasFocus;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
_focusNode.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _clearText() {
|
||||
_controller.clear();
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AppTextFormField(
|
||||
title: 'Masukkan no telepon',
|
||||
hintText: '8712671212',
|
||||
controller: _controller,
|
||||
focusNode: _focusNode,
|
||||
keyboardType: TextInputType.phone,
|
||||
prefixIcon: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
child: Text(
|
||||
'+62',
|
||||
style: AppStyle.md.copyWith(
|
||||
color: AppColor.textPrimary,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
suffixIcon: (_hasFocus && _controller.text.isNotEmpty)
|
||||
? IconButton(
|
||||
onPressed: _clearText,
|
||||
icon: Icon(Icons.close, color: AppColor.primary, size: 20),
|
||||
constraints: const BoxConstraints(),
|
||||
padding: const EdgeInsets.all(8),
|
||||
)
|
||||
: null,
|
||||
onChanged: (value) {
|
||||
setState(() {});
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user