Skip to content

Commit

Permalink
Fix display icon
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Dec 28, 2023
1 parent 264fc40 commit 2c0937e
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 91 deletions.
9 changes: 5 additions & 4 deletions api/lib/src/models/element.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ abstract class PathElement {
PathProperty get property;
}

mixin LabelElement on PadElement {
@override
mixin LabelElement {
String get layer;
Point<double> get position;
double get scale;
Expand All @@ -63,15 +62,17 @@ mixin LabelElement on PadElement {
int get foreground;

AreaProperty get areaProperty {
return maybeMap(
final element = this as PadElement;
return element.maybeMap(
markdown: (e) => e.areaProperty,
text: (e) => e.area.areaProperty,
orElse: () => throw UnimplementedError(),
);
}

String get text {
return maybeMap(
final element = this as PadElement;
return element.maybeMap(
markdown: (e) => e.text,
text: (e) => e.area.paragraph.text,
orElse: () => throw UnimplementedError(),
Expand Down
2 changes: 1 addition & 1 deletion app/lib/handlers/label.dart
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class LabelHandler extends Handler<LabelTool>
} else {
final page = context.getPage();
if (page == null) return;
final index = page.content.indexOf(labelRenderer.element);
final index = page.content.indexOf(labelRenderer.element as PadElement);
context.getDocumentBloc().add(ElementsRemoved([index]));
_context = _createContext(document, element: labelRenderer.element);
}
Expand Down
7 changes: 4 additions & 3 deletions app/lib/selections/elements/text.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
part of '../selection.dart';

class LabelElementSelection extends ElementSelection<LabelElement> {
class LabelElementSelection extends ElementSelection<PadElement> {
LabelElementSelection(super.selected);

@override
List<Widget> buildProperties(BuildContext context) {
final element = selected.first.element;
final element = selected.first.element as LabelElement;
return [
...super.buildProperties(context),
ExactSlider(
Expand Down Expand Up @@ -40,7 +40,8 @@ class LabelElementSelection extends ElementSelection<LabelElement> {
@override
Selection insert(element) {
if (element is Renderer<LabelElement>) {
return LabelElementSelection([...selected, element]);
return LabelElementSelection(
[...selected, element as Renderer<PadElement>]);
}
return super.insert(element);
}
Expand Down
75 changes: 0 additions & 75 deletions app/lib/selections/tools/label.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,8 @@ class LabelToolSelection extends ToolSelection<LabelTool> {
final bloc = context.read<DocumentBloc>();
final state = bloc.state;
if (state is! DocumentLoadSuccess) return [];
final packs = state.data.getPacks();
final packName = selected.first.styleSheet.pack;
final currentPack = state.data.getPack(packName);
return [
...super.buildProperties(context),
CheckboxListTile(
value: selected.first.zoomDependent,
title: Text(AppLocalizations.of(context).zoomDependent),
onChanged: (value) => update(
context,
selected
.map((e) => e.copyWith(
zoomDependent: value ?? selected.first.zoomDependent))
.toList())),
ExactSlider(
header: Text(AppLocalizations.of(context).scale),
min: 0.1,
max: 15,
value: selected.first.scale,
defaultValue: 5,
onChangeEnd: (value) => update(
context, selected.map((e) => e.copyWith(scale: value)).toList()),
),
ColorField(
value: Color(selected.first.foreground),
onChanged: (value) => update(context,
Expand All @@ -52,60 +31,6 @@ class LabelToolSelection extends ToolSelection<LabelTool> {
Color(e.foreground).withAlpha(value.toInt()).value))
.toList()),
),
const SizedBox(height: 16),
DropdownButtonFormField<String>(
items: packs
.map((e) => DropdownMenuItem<String>(value: e, child: Text(e)))
.toList(),
decoration: InputDecoration(
labelText: AppLocalizations.of(context).pack,
filled: true,
counterText:
packs.isEmpty ? AppLocalizations.of(context).noPacks : null,
suffixIcon: IconButton(
icon: const PhosphorIcon(PhosphorIconsLight.package),
tooltip: AppLocalizations.of(context).packs,
onPressed: () {
Actions.maybeInvoke<PacksIntent>(context, PacksIntent(context));
},
),
),
value: currentPack?.name,
onChanged: (pack) {
if (pack == null) return;
update(
context,
selected
.map((e) => e.copyWith(styleSheet: PackAssetLocation(pack)))
.toList());
},
),
const SizedBox(height: 8),
const Divider(),
const SizedBox(height: 8),
Column(
children: currentPack
?.getStyles()
.map((style) => Dismissible(
key: ValueKey(style),
background: Container(color: Colors.red),
onDismissed: (direction) {
bloc.add(PackUpdated(
packName, currentPack.removeStyle(style)));
},
child: ListTile(
title: Text(style),
selected: style == selected.first.styleSheet.name,
onTap: () => update(
context,
selected
.map((e) => e.copyWith(
styleSheet:
PackAssetLocation(packName, style)))
.toList()),
)))
.toList() ??
[]),
];
}

Expand Down
4 changes: 1 addition & 3 deletions app/lib/views/app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -569,9 +569,7 @@ class _MainPopupMenu extends StatelessWidget {
),
),
),
builder: (BuildContext context, MenuController controller,
Widget? child) =>
Align(
builder: (context, controller, child) => Align(
child: AspectRatio(
aspectRatio: 1,
child: IconButton(
Expand Down
4 changes: 3 additions & 1 deletion app/lib/views/property.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ class _PropertyViewState extends State<PropertyView>
: MenuAnchor(
controller: controller,
builder: defaultFilledMenuButton(
icon: Row(
iconBuilder:
(context, controller, child) =>
Row(
children: [
icon,
const SizedBox(width: 8),
Expand Down
4 changes: 2 additions & 2 deletions app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -796,8 +796,8 @@ packages:
dependency: "direct main"
description:
path: "packages/material_leap"
ref: "524e4189e7b36bda022b6b153778e701a74f4dc1"
resolved-ref: "524e4189e7b36bda022b6b153778e701a74f4dc1"
ref: "0ec9d6cdeffd298f1f8165059d8df1aecb5e7cb9"
resolved-ref: "0ec9d6cdeffd298f1f8165059d8df1aecb5e7cb9"
url: "https://github.com/LinwoodDev/dart_pkgs.git"
source: git
version: "0.0.1"
Expand Down
2 changes: 1 addition & 1 deletion app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ dependencies:
material_leap:
git:
url: https://github.com/LinwoodDev/dart_pkgs.git
ref: 524e4189e7b36bda022b6b153778e701a74f4dc1
ref: 0ec9d6cdeffd298f1f8165059d8df1aecb5e7cb9
path: packages/material_leap
lw_sysinfo:
git:
Expand Down
3 changes: 2 additions & 1 deletion fastlane/metadata/android/en-US/changelogs/86.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
* Add scale to label selection view
* Add markdown element selection view
* Fix moving data directory ([#562](https://github.com/LinwoodDev/Butterfly/issues/562))
* Fix various issues with the label tool
* Fix various issues with the label tool
* Fix display icon

0 comments on commit 2c0937e

Please sign in to comment.