ganti tema anjay
This commit is contained in:
parent
8cc89199c7
commit
8b93978fa1
|
|
@ -14,7 +14,7 @@ class SignUpBloc extends Bloc<SignUpEvent, SignUpState> {
|
||||||
try {
|
try {
|
||||||
MyUser myUser = await _userRepository.signUp(event.user, event.password);
|
MyUser myUser = await _userRepository.signUp(event.user, event.password);
|
||||||
await _userRepository.setUserData(myUser);
|
await _userRepository.setUserData(myUser);
|
||||||
emit(SignUpProcess());
|
emit(SignUpSuccess());
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(SignUpFailure());
|
emit(SignUpFailure());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
import '../../../components/my_text_field.dart';
|
import '../../../components/my_text_field.dart';
|
||||||
import '../blocs/sign_in_bloc/sign_in_bloc.dart';
|
import '../blocs/sign_in_bloc/sign_in_bloc.dart';
|
||||||
// import '../blocs/sing_in_bloc/sign_in_bloc.dart';
|
|
||||||
|
|
||||||
class SignInScreen extends StatefulWidget {
|
class SignInScreen extends StatefulWidget {
|
||||||
const SignInScreen({super.key});
|
const SignInScreen({super.key});
|
||||||
|
|
|
||||||
|
|
@ -16,17 +16,12 @@ class _SignUpScreenState extends State<SignUpScreen> {
|
||||||
final passwordController = TextEditingController();
|
final passwordController = TextEditingController();
|
||||||
final emailController = TextEditingController();
|
final emailController = TextEditingController();
|
||||||
final nameController = TextEditingController();
|
final nameController = TextEditingController();
|
||||||
|
final confirmPasswordController = TextEditingController();
|
||||||
final _formKey = GlobalKey<FormState>();
|
final _formKey = GlobalKey<FormState>();
|
||||||
IconData iconPassword = CupertinoIcons.eye_fill;
|
IconData iconPassword = CupertinoIcons.eye_fill;
|
||||||
bool obscurePassword = true;
|
bool obscurePassword = true;
|
||||||
bool signUpRequired = false;
|
bool signUpRequired = false;
|
||||||
|
|
||||||
bool containsUpperCase = false;
|
|
||||||
bool containsLowerCase = false;
|
|
||||||
bool containsNumber = false;
|
|
||||||
bool containsSpecialChar = false;
|
|
||||||
bool contains8Length = false;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocListener<SignUpBloc, SignUpState>(
|
return BlocListener<SignUpBloc, SignUpState>(
|
||||||
|
|
@ -45,189 +40,147 @@ class _SignUpScreenState extends State<SignUpScreen> {
|
||||||
},
|
},
|
||||||
child: Form(
|
child: Form(
|
||||||
key: _formKey,
|
key: _formKey,
|
||||||
child: Center(
|
child: Scaffold(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
body: Center(
|
||||||
|
child: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 30),
|
||||||
|
Container(
|
||||||
|
width: MediaQuery.of(context).size.width * 0.92,
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 22),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.black.withOpacity(0.04),
|
||||||
|
blurRadius: 10,
|
||||||
|
offset: const Offset(0, 4),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const SizedBox(height: 6),
|
||||||
|
const Center(
|
||||||
|
child: Text(
|
||||||
|
'Buat Akun',
|
||||||
|
style: TextStyle(fontSize: 22, fontWeight: FontWeight.w700),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 6),
|
||||||
|
const Center(
|
||||||
|
child: Text(
|
||||||
|
'Daftar untuk mulai monitoring',
|
||||||
|
style: TextStyle(fontSize: 13, color: Colors.black54),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 14),
|
||||||
|
|
||||||
|
// Name
|
||||||
|
SizedBox(
|
||||||
|
width: MediaQuery.of(context).size.width * 0.9,
|
||||||
|
child: MyTextField(
|
||||||
|
controller: nameController,
|
||||||
|
hintText: 'Masukkan nama lengkap',
|
||||||
|
obscureText: false,
|
||||||
|
keyboardType: TextInputType.name,
|
||||||
|
prefixIcon: const Icon(CupertinoIcons.person_fill),
|
||||||
|
validator: (val) {
|
||||||
|
if (val == null || val.isEmpty) {
|
||||||
|
return 'Please fill in this field';
|
||||||
|
} else if (val.length > 50) {
|
||||||
|
return 'Name too long';
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
|
||||||
|
// Email
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: MediaQuery.of(context).size.width * 0.9,
|
width: MediaQuery.of(context).size.width * 0.9,
|
||||||
child: MyTextField(
|
child: MyTextField(
|
||||||
controller: emailController,
|
controller: emailController,
|
||||||
hintText: 'Email',
|
hintText: 'nama@email.com',
|
||||||
obscureText: false,
|
obscureText: false,
|
||||||
keyboardType: TextInputType.emailAddress,
|
keyboardType: TextInputType.emailAddress,
|
||||||
prefixIcon: const Icon(CupertinoIcons.mail_solid),
|
prefixIcon: const Icon(CupertinoIcons.mail_solid),
|
||||||
validator: (val) {
|
validator: (val) {
|
||||||
if(val!.isEmpty) {
|
if (val == null || val.isEmpty) {
|
||||||
return 'Please fill in this field';
|
return 'Please fill in this field';
|
||||||
} else if(!RegExp(r'^[\w-\.]+@([\w-]+.)+[\w-]{2,4}$').hasMatch(val)) {
|
} else if (!RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$').hasMatch(val)) {
|
||||||
return 'Please enter a valid email';
|
return 'Please enter a valid email';
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
|
|
||||||
|
// Password
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: MediaQuery.of(context).size.width * 0.9,
|
width: MediaQuery.of(context).size.width * 0.9,
|
||||||
child: MyTextField(
|
child: MyTextField(
|
||||||
controller: passwordController,
|
controller: passwordController,
|
||||||
hintText: 'Password',
|
hintText: 'Minimal 6 karakter',
|
||||||
obscureText: obscurePassword,
|
obscureText: obscurePassword,
|
||||||
keyboardType: TextInputType.visiblePassword,
|
keyboardType: TextInputType.visiblePassword,
|
||||||
prefixIcon: const Icon(CupertinoIcons.lock_fill),
|
prefixIcon: const Icon(CupertinoIcons.lock_fill),
|
||||||
onChanged: (val) {
|
|
||||||
if(val!.contains(RegExp(r'[A-Z]'))) {
|
|
||||||
setState(() {
|
|
||||||
containsUpperCase = true;
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
setState(() {
|
|
||||||
containsUpperCase = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if(val.contains(RegExp(r'[a-z]'))) {
|
|
||||||
setState(() {
|
|
||||||
containsLowerCase = true;
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
setState(() {
|
|
||||||
containsLowerCase = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if(val.contains(RegExp(r'[0-9]'))) {
|
|
||||||
setState(() {
|
|
||||||
containsNumber = true;
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
setState(() {
|
|
||||||
containsNumber = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if(val.contains(RegExp(r'^(?=.*?[!@#$&*~`)\%\-(_+=;:,.<>/?"[{\]}\|^])'))) {
|
|
||||||
setState(() {
|
|
||||||
containsSpecialChar = true;
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
setState(() {
|
|
||||||
containsSpecialChar = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if(val.length >= 8) {
|
|
||||||
setState(() {
|
|
||||||
contains8Length = true;
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
setState(() {
|
|
||||||
contains8Length = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
suffixIcon: IconButton(
|
suffixIcon: IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
obscurePassword = !obscurePassword;
|
obscurePassword = !obscurePassword;
|
||||||
if(obscurePassword) {
|
iconPassword = obscurePassword
|
||||||
iconPassword = CupertinoIcons.eye_fill;
|
? CupertinoIcons.eye_fill
|
||||||
} else {
|
: CupertinoIcons.eye_slash_fill;
|
||||||
iconPassword = CupertinoIcons.eye_slash_fill;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
icon: Icon(iconPassword),
|
icon: Icon(iconPassword),
|
||||||
),
|
),
|
||||||
validator: (val) {
|
validator: (val) {
|
||||||
if(val!.isEmpty) {
|
if (val == null || val.isEmpty) {
|
||||||
return 'Please fill in this field';
|
return 'Please fill in this field';
|
||||||
} else if(!RegExp(r'^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#\$&*~`)\%\-(_+=;:,.<>/?"[{\]}\|^]).{8,}$').hasMatch(val)) {
|
} else if (val.length < 6) {
|
||||||
return 'Please enter a valid password';
|
return 'Password minimal 6 karakter';
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
// Confirm Password
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
"⚈ 1 uppercase",
|
|
||||||
style: TextStyle(
|
|
||||||
color: containsUpperCase
|
|
||||||
? Colors.green
|
|
||||||
: Theme.of(context).colorScheme.onBackground
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
"⚈ 1 lowercase",
|
|
||||||
style: TextStyle(
|
|
||||||
color: containsLowerCase
|
|
||||||
? Colors.green
|
|
||||||
: Theme.of(context).colorScheme.onBackground
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
"⚈ 1 number",
|
|
||||||
style: TextStyle(
|
|
||||||
color: containsNumber
|
|
||||||
? Colors.green
|
|
||||||
: Theme.of(context).colorScheme.onBackground
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
"⚈ 1 special character",
|
|
||||||
style: TextStyle(
|
|
||||||
color: containsSpecialChar
|
|
||||||
? Colors.green
|
|
||||||
: Theme.of(context).colorScheme.onBackground
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
"⚈ 8 minimum character",
|
|
||||||
style: TextStyle(
|
|
||||||
color: contains8Length
|
|
||||||
? Colors.green
|
|
||||||
: Theme.of(context).colorScheme.onBackground
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: MediaQuery.of(context).size.width * 0.9,
|
width: MediaQuery.of(context).size.width * 0.9,
|
||||||
child: MyTextField(
|
child: MyTextField(
|
||||||
controller: nameController,
|
controller: confirmPasswordController,
|
||||||
hintText: 'Name',
|
hintText: 'Ulangi password',
|
||||||
obscureText: false,
|
obscureText: obscurePassword,
|
||||||
keyboardType: TextInputType.name,
|
keyboardType: TextInputType.visiblePassword,
|
||||||
prefixIcon: const Icon(CupertinoIcons.person_fill),
|
prefixIcon: const Icon(CupertinoIcons.lock_fill),
|
||||||
validator: (val) {
|
validator: (val) {
|
||||||
if(val!.isEmpty) {
|
if (val == null || val.isEmpty) {
|
||||||
return 'Please fill in this field';
|
return 'Please fill in this field';
|
||||||
} else if(val.length > 30) {
|
} else if (val != passwordController.text) {
|
||||||
return 'Name too long';
|
return 'Password tidak cocok';
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: MediaQuery.of(context).size.height * 0.02),
|
|
||||||
|
const SizedBox(height: 18),
|
||||||
|
|
||||||
|
// Button
|
||||||
!signUpRequired
|
!signUpRequired
|
||||||
? SizedBox(
|
? SizedBox(
|
||||||
width: MediaQuery.of(context).size.width * 0.5,
|
width: MediaQuery.of(context).size.width * 0.92,
|
||||||
child: TextButton(
|
child: ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (_formKey.currentState!.validate()) {
|
if (_formKey.currentState!.validate()) {
|
||||||
MyUser myUser = MyUser.empty;
|
MyUser myUser = MyUser.empty;
|
||||||
|
|
@ -238,38 +191,52 @@ class _SignUpScreenState extends State<SignUpScreen> {
|
||||||
context.read<SignUpBloc>().add(
|
context.read<SignUpBloc>().add(
|
||||||
SignUpRequired(
|
SignUpRequired(
|
||||||
myUser,
|
myUser,
|
||||||
passwordController.text
|
passwordController.text,
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
style: TextButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
elevation: 3.0,
|
backgroundColor: Colors.black87,
|
||||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
|
||||||
foregroundColor: Colors.white,
|
foregroundColor: Colors.white,
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(60)
|
borderRadius: BorderRadius.circular(8),
|
||||||
)
|
|
||||||
),
|
),
|
||||||
child: const Padding(
|
),
|
||||||
padding: EdgeInsets.symmetric(horizontal: 25, vertical: 5),
|
child: const Text(
|
||||||
child: Text(
|
'Daftar',
|
||||||
'Sign Up',
|
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600),
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.w600
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
),
|
: const CircularProgressIndicator(),
|
||||||
|
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
Center(
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
const Text('Sudah punya akun? '),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
child: const Text('Login di sini'),
|
||||||
)
|
)
|
||||||
: const CircularProgressIndicator()
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 30),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
import 'dart:ui';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import '../../../blocs/authentication_bloc/authentication_bloc.dart';
|
import '../../../blocs/authentication_bloc/authentication_bloc.dart';
|
||||||
|
|
@ -31,38 +30,12 @@ class _WelcomeScreenState extends State<WelcomeScreen> with TickerProviderStateM
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Theme.of(context).colorScheme.background,
|
backgroundColor: Colors.white,
|
||||||
body: SingleChildScrollView(
|
body: SingleChildScrollView(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: MediaQuery.of(context).size.height,
|
height: MediaQuery.of(context).size.height,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
Align(
|
|
||||||
alignment: const AlignmentDirectional(20, -1.2),
|
|
||||||
child: Container(
|
|
||||||
height: MediaQuery.of(context).size.width,
|
|
||||||
width: MediaQuery.of(context).size.width,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
color: Theme.of(context).colorScheme.tertiary
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Align(
|
|
||||||
alignment: const AlignmentDirectional(2.7, -1.2),
|
|
||||||
child: Container(
|
|
||||||
height: MediaQuery.of(context).size.width / 1.3,
|
|
||||||
width: MediaQuery.of(context).size.width / 1.3,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
color: Theme.of(context).colorScheme.primary
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
BackdropFilter(
|
|
||||||
filter: ImageFilter.blur(sigmaX: 100.0, sigmaY: 100.0),
|
|
||||||
child: Container(),
|
|
||||||
),
|
|
||||||
Align(
|
Align(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
|
|
|
||||||
|
|
@ -2,35 +2,26 @@ name: klimatologiot
|
||||||
description: "A new Flutter project."
|
description: "A new Flutter project."
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
version: 1.0.0+1
|
version: 1.0.0+1
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.1.0
|
sdk: ^3.1.0
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|
||||||
firebase_core: ^4.3.0
|
firebase_core: ^4.3.0
|
||||||
firebase_auth: ^6.1.3
|
firebase_auth: ^6.1.3
|
||||||
cloud_firestore: ^6.1.1
|
cloud_firestore: ^6.1.1
|
||||||
rxdart: ^0.27.7
|
rxdart: ^0.27.7
|
||||||
google_sign_in: ^7.2.0
|
google_sign_in: ^7.2.0
|
||||||
|
|
||||||
bloc: ^8.1.0
|
bloc: ^8.1.0
|
||||||
flutter_bloc: ^8.1.0
|
flutter_bloc: ^8.1.0
|
||||||
equatable: ^2.0.5
|
equatable: ^2.0.5
|
||||||
|
|
||||||
user_repository:
|
user_repository:
|
||||||
path: packages/user_repository
|
path: packages/user_repository
|
||||||
|
|
||||||
cupertino_icons: ^1.0.8
|
cupertino_icons: ^1.0.8
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|
||||||
flutter_lints: ^3.0.0
|
flutter_lints: ^3.0.0
|
||||||
|
|
||||||
flutter:
|
flutter:
|
||||||
uses-material-design: true
|
uses-material-design: true
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue