Migrated to flutter master channel, some adaptations to new m3 specs

This commit is contained in:
Anton Stubenbord
2022-12-20 00:27:59 +01:00
39 changed files with 554 additions and 442 deletions

View File

@@ -60,7 +60,7 @@ class _StoragePathAutofillFormBuilderFieldState
const SizedBox(height: 8.0),
Text(
"Select to autofill path variable",
style: Theme.of(context).textTheme.caption,
style: Theme.of(context).textTheme.bodySmall,
),
Wrap(
alignment: WrapAlignment.start,

View File

@@ -2,23 +2,21 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_mobile/core/repository/label_repository.dart';
import 'package:paperless_mobile/features/documents/bloc/documents_cubit.dart';
import 'package:paperless_mobile/features/labels/bloc/label_cubit.dart';
import 'package:paperless_mobile/features/labels/bloc/label_state.dart';
import 'package:paperless_mobile/util.dart';
class StoragePathWidget extends StatelessWidget {
final int? pathId;
final void Function()? afterSelected;
final Color? textColor;
final bool isClickable;
final void Function(int? id)? onSelected;
const StoragePathWidget({
Key? key,
this.pathId,
this.afterSelected,
this.textColor,
this.isClickable = true,
this.onSelected,
}) : super(key: key);
@override
@@ -32,12 +30,12 @@ class StoragePathWidget extends StatelessWidget {
child: BlocBuilder<LabelCubit<StoragePath>, LabelState<StoragePath>>(
builder: (context, state) {
return GestureDetector(
onTap: () => _addStoragePathToFilter(context),
onTap: () => onSelected?.call(pathId),
child: Text(
state.getLabel(pathId)?.name ?? "-",
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.bodyText2?.copyWith(
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: textColor ?? Theme.of(context).colorScheme.primary,
),
),
@@ -47,24 +45,4 @@ class StoragePathWidget extends StatelessWidget {
),
);
}
void _addStoragePathToFilter(BuildContext context) {
final cubit = BlocProvider.of<DocumentsCubit>(context);
try {
if (cubit.state.filter.correspondent.id == pathId) {
cubit.updateCurrentFilter(
(filter) =>
filter.copyWith(storagePath: const IdQueryParameter.unset()),
);
} else {
cubit.updateCurrentFilter(
(filter) =>
filter.copyWith(storagePath: IdQueryParameter.fromId(pathId)),
);
}
afterSelected?.call();
} on PaperlessServerException catch (error, stackTrace) {
showErrorMessage(context, error, stackTrace);
}
}
}