Skip to content

Commit

Permalink
Fix selecting document settings
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Dec 30, 2024
1 parent 7546bd7 commit 8dfd63a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions app/lib/selections/file.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of 'selection.dart';

class FileSelection extends Selection<Null> {
FileSelection() : super([null]);
class FileSelection extends Selection<CurrentIndexCubit> {
FileSelection(CurrentIndexCubit cubit) : super([cubit]);

@override
IconGetter get icon => PhosphorIcons.wrench;
Expand All @@ -15,7 +15,7 @@ class FileSelection extends Selection<Null> {

@override
List<Widget> buildProperties(BuildContext context) {
final cubit = context.read<CurrentIndexCubit>();
final cubit = selected.first;
final currentIndex = cubit.state;
return [
...super.buildProperties(context),
Expand Down
4 changes: 2 additions & 2 deletions app/lib/selections/selection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ abstract class Selection<T> {
if (selected is Area) {
return AreaSelection([selected]) as Selection<T>;
}
if (selected == null) {
return FileSelection() as Selection<T>;
if (selected is CurrentIndexCubit) {
return FileSelection(selected) as Selection<T>;
}
throw UnsupportedError('Unsupported selection type: $T');
}
Expand Down
4 changes: 2 additions & 2 deletions app/lib/views/edit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -377,11 +377,11 @@ class _EditToolbarState extends State<EditToolbar> {
tooltip: AppLocalizations.of(context).tools,
selectedIcon: const PhosphorIcon(PhosphorIconsFill.wrench),
isSelected: currentIndex.selection?.selected
.any((element) => element is UtilitiesState) ??
.any((element) => element is CurrentIndexCubit) ??
false,
onPressed: () {
final cubit = context.read<CurrentIndexCubit>();
cubit.changeSelection(null);
cubit.changeSelection(cubit);
},
),
if (windowState.fullScreen &&
Expand Down
2 changes: 1 addition & 1 deletion app/lib/visualizer/icon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ enum DisplayIcons {
return recommended(tool).firstOrNull?.icon ?? PhosphorIcons.question;
}

static List<DisplayIcons> recommended(Object tool) {
static List<DisplayIcons> recommended(Object? tool) {
return switch (tool) {
PenTool _ => [
DisplayIcons.pen,
Expand Down

0 comments on commit 8dfd63a

Please sign in to comment.