mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-10 22:07:55 -06:00
fix: Add labels to each cubit using repositories and state properties, remove label cubits
This commit is contained in:
@@ -62,7 +62,7 @@ class _AddSavedViewPageState extends State<AddSavedViewPage> {
|
||||
],
|
||||
),
|
||||
),
|
||||
Divider(),
|
||||
const Divider(),
|
||||
Text(
|
||||
"Review filter",
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
@@ -80,42 +80,6 @@ class _AddSavedViewPageState extends State<AddSavedViewPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Padding _buildOld(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
children: [
|
||||
FormBuilder(
|
||||
key: _savedViewFormKey,
|
||||
child: Expanded(
|
||||
child: ListView(
|
||||
children: [
|
||||
FormBuilderTextField(
|
||||
name: fkName,
|
||||
validator: FormBuilderValidators.required(),
|
||||
decoration: InputDecoration(
|
||||
label: Text(S.of(context)!.name),
|
||||
),
|
||||
),
|
||||
FormBuilderCheckbox(
|
||||
name: fkShowOnDashboard,
|
||||
initialValue: false,
|
||||
title: Text(S.of(context)!.showOnDashboard),
|
||||
),
|
||||
FormBuilderCheckbox(
|
||||
name: fkShowInSidebar,
|
||||
initialValue: false,
|
||||
title: Text(S.of(context)!.showInSidebar),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _onCreate(BuildContext context) {
|
||||
if (_savedViewFormKey.currentState?.saveAndValidate() ?? false) {
|
||||
Navigator.pop(
|
||||
|
||||
@@ -12,52 +12,70 @@ class SavedViewList extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final savedViewCubit = context.read<SavedViewCubit>();
|
||||
return BlocBuilder<ConnectivityCubit, ConnectivityState>(
|
||||
builder: (context, connectivity) {
|
||||
return BlocBuilder<SavedViewCubit, SavedViewState>(
|
||||
builder: (context, state) {
|
||||
if (state.value.isEmpty) {
|
||||
return SliverToBoxAdapter(
|
||||
child: HintCard(
|
||||
hintText:
|
||||
S.of(context)!.createViewsToQuicklyFilterYourDocuments,
|
||||
),
|
||||
);
|
||||
}
|
||||
return SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
final view = state.value.values.elementAt(index);
|
||||
return ListTile(
|
||||
enabled: connectivity.isConnected,
|
||||
title: Text(view.name),
|
||||
subtitle: Text(
|
||||
S.of(context)!.nFiltersSet(view.filterRules.length),
|
||||
return state.when(
|
||||
initial: (correspondents, documentTypes, tags, storagePaths) =>
|
||||
Container(),
|
||||
loading: (correspondents, documentTypes, tags, storagePaths) =>
|
||||
Center(
|
||||
child: Text("Saved views loading..."),
|
||||
),
|
||||
loaded: (savedViews, correspondents, documentTypes, tags,
|
||||
storagePaths) {
|
||||
if (savedViews.isEmpty) {
|
||||
return SliverToBoxAdapter(
|
||||
child: HintCard(
|
||||
hintText: S
|
||||
.of(context)!
|
||||
.createViewsToQuicklyFilterYourDocuments,
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => MultiBlocProvider(
|
||||
providers: [
|
||||
BlocProvider(
|
||||
create: (context) => SavedViewDetailsCubit(
|
||||
context.read(),
|
||||
context.read(),
|
||||
savedView: view,
|
||||
);
|
||||
}
|
||||
return SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
final view = savedViews.values.elementAt(index);
|
||||
return ListTile(
|
||||
enabled: connectivity.isConnected,
|
||||
title: Text(view.name),
|
||||
subtitle: Text(
|
||||
S.of(context)!.nFiltersSet(view.filterRules.length),
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => MultiBlocProvider(
|
||||
providers: [
|
||||
BlocProvider(
|
||||
create: (context) => SavedViewDetailsCubit(
|
||||
context.read(),
|
||||
context.read(),
|
||||
savedView: view,
|
||||
),
|
||||
),
|
||||
],
|
||||
child: SavedViewDetailsPage(
|
||||
onDelete:
|
||||
context.read<SavedViewCubit>().remove,
|
||||
),
|
||||
),
|
||||
],
|
||||
child: SavedViewDetailsPage(
|
||||
onDelete: savedViewCubit.remove,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
childCount: state.value.length,
|
||||
childCount: savedViews.length,
|
||||
),
|
||||
);
|
||||
},
|
||||
error: (correspondents, documentTypes, tags, storagePaths) =>
|
||||
Center(
|
||||
child: Text(
|
||||
"An error occurred while trying to load the saved views.",
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user