check phone impl
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
||||
|
||||
import '../../../common/theme/theme.dart';
|
||||
|
||||
|
||||
@@ -7,12 +7,14 @@ class AppElevatedButton extends StatelessWidget {
|
||||
required this.title,
|
||||
this.width = double.infinity,
|
||||
this.height = 48.0,
|
||||
this.isLoading = false,
|
||||
});
|
||||
|
||||
final Function()? onPressed;
|
||||
final String title;
|
||||
final double width;
|
||||
final double height;
|
||||
final bool isLoading;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -21,13 +23,29 @@ class AppElevatedButton extends StatelessWidget {
|
||||
height: height,
|
||||
child: ElevatedButton(
|
||||
onPressed: onPressed,
|
||||
child: Text(
|
||||
title,
|
||||
style: AppStyle.lg.copyWith(
|
||||
color: AppColor.white,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
child: isLoading
|
||||
? Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
SpinKitFadingCircle(color: AppColor.white, size: 24),
|
||||
SizedBox(width: 8),
|
||||
Text(
|
||||
'Loading',
|
||||
style: AppStyle.lg.copyWith(
|
||||
color: AppColor.white,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: Text(
|
||||
title,
|
||||
style: AppStyle.lg.copyWith(
|
||||
color: AppColor.white,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ class AppTextFormField extends StatelessWidget {
|
||||
this.suffixIcon,
|
||||
this.keyboardType,
|
||||
this.onChanged,
|
||||
this.validator,
|
||||
});
|
||||
|
||||
final String? hintText;
|
||||
@@ -21,6 +22,7 @@ class AppTextFormField extends StatelessWidget {
|
||||
final Widget? suffixIcon;
|
||||
final TextInputType? keyboardType;
|
||||
final ValueChanged<String>? onChanged;
|
||||
final String? Function(String?)? validator;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -39,6 +41,7 @@ class AppTextFormField extends StatelessWidget {
|
||||
color: AppColor.textPrimary,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
validator: validator,
|
||||
decoration: InputDecoration(
|
||||
hintText: hintText,
|
||||
prefixIcon: prefixIcon,
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
import 'package:another_flushbar/flushbar.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../common/theme/theme.dart';
|
||||
import '../../../domain/auth/auth.dart';
|
||||
|
||||
class AppFlushbar {
|
||||
static void showSuccess(BuildContext context, String message) {
|
||||
Flushbar(
|
||||
messageText: Text(
|
||||
message,
|
||||
style: AppStyle.lg.copyWith(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
icon: const Icon(Icons.check_circle, color: Colors.white),
|
||||
duration: const Duration(seconds: 2),
|
||||
flushbarPosition: FlushbarPosition.BOTTOM,
|
||||
backgroundColor: AppColor.secondary,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
margin: const EdgeInsets.all(12),
|
||||
).show(context);
|
||||
}
|
||||
|
||||
static void showError(BuildContext context, String message) {
|
||||
Flushbar(
|
||||
messageText: Text(
|
||||
message,
|
||||
style: AppStyle.lg.copyWith(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
icon: const Icon(Icons.error, color: Colors.white),
|
||||
duration: const Duration(seconds: 3),
|
||||
flushbarPosition: FlushbarPosition.BOTTOM,
|
||||
backgroundColor: AppColor.error,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
margin: const EdgeInsets.all(12),
|
||||
).show(context);
|
||||
}
|
||||
|
||||
static void showAuthFailureToast(BuildContext context, AuthFailure failure) =>
|
||||
showError(
|
||||
context,
|
||||
failure.map(
|
||||
serverError: (value) => value.failure.toStringFormatted(context),
|
||||
dynamicErrorMessage: (value) => value.erroMessage,
|
||||
unexpectedError: (value) => 'Terjadi kesalahan, silahkan coba lagi',
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user