Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
longhoang2984 committed Nov 26, 2021
1 parent dfeccb4 commit b5f08b7
Show file tree
Hide file tree
Showing 4 changed files with 434 additions and 391 deletions.
4 changes: 2 additions & 2 deletions lib/domain/core/value_validators.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Either<ValueFailure<String>, String> validateEmail(String value) {
const String pattern =
r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$';
final RegExp regex = RegExp(pattern);
if (!regex.hasMatch(value) && value.isNotEmpty) {
if (!regex.hasMatch(value)) {
return left(
ValueFailure.invalidEmail(failedValue: value),
);
Expand All @@ -16,7 +16,7 @@ Either<ValueFailure<String>, String> validateEmail(String value) {
}

Either<ValueFailure<String>, String> validatePassword(String value) {
if (value.isNotEmpty && value.length < 6) {
if (value.length < 6) {
return left(
ValueFailure.shortPassword(failedValue: value),
);
Expand Down
122 changes: 64 additions & 58 deletions lib/presentation/home/widgets/notes_body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,67 +48,73 @@ class NoteBody extends HookWidget {
),
),
),
body: BlocBuilder<NoteWatcherBloc, NoteWatcherState>(
builder: (context, state) {
return WidgetHUD(
showHUD: state == const NoteWatcherState.loadInProgress(),
hud: HUD(
progressIndicator: const CircularProgressIndicator(
color: ColorName.primarySecond,
),
),
builder: (context) {
return Container(
padding: const EdgeInsets.only(
top: 70.0,
bottom: 40.0,
left: 48.0,
right: 8.0,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: Text(
LocaleKeys.notes.tr(),
style: BaseTextStyle.style(
style: FontStyle.extrabold,
fontSize: 40.0,
),
),
),
GestureDetector(
onTap: () => context
.read<AuthBloc>()
.add(const AuthEvent.logout()),
child: Container(
width: 40,
height: 40,
padding: const EdgeInsets.all(8.0),
child: Assets.images.icLogout.image(
height: 20.0,
),
),
)
],
body: Container(
padding: const EdgeInsets.only(
top: 70.0,
bottom: 40.0,
left: 48.0,
right: 8.0,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: Text(
LocaleKeys.notes.tr(),
style: BaseTextStyle.style(
style: FontStyle.extrabold,
fontSize: 40.0,
),
NoteStatus(
onNoteStatusChanged: (status) {
toggleState.value = status;
},
),
),
GestureDetector(
onTap: () =>
context.read<AuthBloc>().add(const AuthEvent.logout()),
child: Container(
width: 40,
height: 40,
padding: const EdgeInsets.all(8.0),
child: Assets.images.icLogout.image(
height: 20.0,
),
NotesList(
onNoteChanged: () =>
_onNoteChanged(context, toggleState.value),
),
)
],
),
NoteStatus(
onNoteStatusChanged: (status) {
toggleState.value = status;
},
),
const SizedBox(
height: 20,
),
BlocBuilder<NoteWatcherBloc, NoteWatcherState>(
builder: (context, state) {
return WidgetHUD(
showHUD: state == const NoteWatcherState.loadInProgress(),
hud: HUD(
color: Colors.transparent,
opacity: 0,
progressIndicator: const LinearProgressIndicator(
color: ColorName.primarySecond,
),
],
),
);
},
);
},
),
builder: (context) {
return NotesList(
onNoteChanged: () {
toggleState.value = false;
_onNoteChanged(context, toggleState.value);
},
);
},
);
},
),
],
),
),
);
}
Expand Down
Loading

0 comments on commit b5f08b7

Please sign in to comment.