feat: Add a Documents menu item, refactor DocumentsPage to use BlocProvider and UiAppBar, and capitalize the 'KROWER I' profile level badge text.
This commit is contained in:
@@ -19,7 +19,7 @@ class ProfileLevelBadge extends StatelessWidget {
|
||||
switch (status) {
|
||||
case StaffStatus.active:
|
||||
case StaffStatus.verified:
|
||||
return 'Krower I';
|
||||
return 'KROWER I';
|
||||
case StaffStatus.pending:
|
||||
case StaffStatus.completedProfile:
|
||||
return 'Pending';
|
||||
|
||||
@@ -56,6 +56,11 @@ class OnboardingSection extends StatelessWidget {
|
||||
label: i18n.menu_items.attire,
|
||||
onTap: () => Modular.to.toAttire(),
|
||||
),
|
||||
ProfileMenuItem(
|
||||
icon: UiIcons.file,
|
||||
label: i18n.menu_items.documents,
|
||||
onTap: () => Modular.to.toDocuments(),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import 'package:core_localization/core_localization.dart';
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_modular/flutter_modular.dart';
|
||||
import 'package:krow_core/core.dart';
|
||||
import 'package:krow_domain/krow_domain.dart';
|
||||
// ignore: depend_on_referenced_packages
|
||||
import 'package:core_localization/core_localization.dart';
|
||||
|
||||
import '../blocs/documents/documents_cubit.dart';
|
||||
import '../blocs/documents/documents_state.dart';
|
||||
@@ -14,89 +14,80 @@ import '../widgets/documents_progress_card.dart';
|
||||
class DocumentsPage extends StatelessWidget {
|
||||
const DocumentsPage({super.key});
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final DocumentsCubit cubit = Modular.get<DocumentsCubit>();
|
||||
|
||||
if (cubit.state.status == DocumentsStatus.initial) {
|
||||
cubit.loadDocuments();
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
elevation: 0,
|
||||
leading: IconButton(
|
||||
icon: const Icon(UiIcons.arrowLeft, color: UiColors.iconSecondary),
|
||||
onPressed: () => Modular.to.pop(),
|
||||
),
|
||||
title: Text(
|
||||
t.staff_documents.title,
|
||||
style: UiTypography.headline3m.copyWith(
|
||||
color: UiColors.textPrimary,
|
||||
),
|
||||
),
|
||||
bottom: PreferredSize(
|
||||
preferredSize: const Size.fromHeight(1.0),
|
||||
child: Container(color: UiColors.border, height: 1.0),
|
||||
),
|
||||
appBar: UiAppBar(
|
||||
title: t.staff_documents.title,
|
||||
showBackButton: true,
|
||||
onLeadingPressed: () => Modular.to.toProfile(),
|
||||
),
|
||||
body: BlocBuilder<DocumentsCubit, DocumentsState>(
|
||||
bloc: cubit,
|
||||
builder: (BuildContext context, DocumentsState state) {
|
||||
if (state.status == DocumentsStatus.loading) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(
|
||||
valueColor: AlwaysStoppedAnimation<Color>(UiColors.primary),
|
||||
),
|
||||
);
|
||||
}
|
||||
if (state.status == DocumentsStatus.failure) {
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(UiConstants.space4),
|
||||
body: BlocProvider<DocumentsCubit>(
|
||||
create: (BuildContext context) =>
|
||||
Modular.get<DocumentsCubit>()..loadDocuments(),
|
||||
child: BlocBuilder<DocumentsCubit, DocumentsState>(
|
||||
builder: (BuildContext context, DocumentsState state) {
|
||||
if (state.status == DocumentsStatus.loading) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(
|
||||
valueColor: AlwaysStoppedAnimation<Color>(UiColors.primary),
|
||||
),
|
||||
);
|
||||
}
|
||||
if (state.status == DocumentsStatus.failure) {
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(UiConstants.space4),
|
||||
child: Text(
|
||||
state.errorMessage != null
|
||||
? (state.errorMessage!.contains('errors.')
|
||||
? translateErrorKey(state.errorMessage!)
|
||||
: t.staff_documents.list.error(
|
||||
message: state.errorMessage!,
|
||||
))
|
||||
: t.staff_documents.list.error(message: 'Unknown'),
|
||||
textAlign: TextAlign.center,
|
||||
style: UiTypography.body1m.copyWith(
|
||||
color: UiColors.textSecondary,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
if (state.documents.isEmpty) {
|
||||
return Center(
|
||||
child: Text(
|
||||
state.errorMessage != null
|
||||
? (state.errorMessage!.contains('errors.')
|
||||
? translateErrorKey(state.errorMessage!)
|
||||
: t.staff_documents.list.error(message: state.errorMessage!))
|
||||
: t.staff_documents.list.error(message: 'Unknown'),
|
||||
textAlign: TextAlign.center,
|
||||
style: UiTypography.body1m.copyWith(color: UiColors.textSecondary),
|
||||
t.staff_documents.list.empty,
|
||||
style: UiTypography.body1m.copyWith(
|
||||
color: UiColors.textSecondary,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
if (state.documents.isEmpty) {
|
||||
return Center(
|
||||
child: Text(
|
||||
t.staff_documents.list.empty,
|
||||
style: UiTypography.body1m.copyWith(color: UiColors.textSecondary),
|
||||
),
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return ListView(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: UiConstants.space5,
|
||||
vertical: UiConstants.space6,
|
||||
),
|
||||
children: <Widget>[
|
||||
DocumentsProgressCard(
|
||||
completedCount: state.completedCount,
|
||||
totalCount: state.totalCount,
|
||||
progress: state.progress,
|
||||
return ListView(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: UiConstants.space5,
|
||||
vertical: UiConstants.space6,
|
||||
),
|
||||
const SizedBox(height: UiConstants.space4),
|
||||
...state.documents.map(
|
||||
(StaffDocument doc) => DocumentCard(
|
||||
document: doc,
|
||||
onTap: () => Modular.to.pushNamed('./details', arguments: doc.id),
|
||||
children: <Widget>[
|
||||
DocumentsProgressCard(
|
||||
completedCount: state.completedCount,
|
||||
totalCount: state.totalCount,
|
||||
progress: state.progress,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
const SizedBox(height: UiConstants.space4),
|
||||
...state.documents.map(
|
||||
(StaffDocument doc) => DocumentCard(
|
||||
document: doc,
|
||||
onTap: () =>
|
||||
Modular.to.pushNamed('./details', arguments: doc.id),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user