-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SwiftUI Navigator #332
base: swiftui-navigator
Are you sure you want to change the base?
SwiftUI Navigator #332
Conversation
struct HierarchicalElement: Identifiable { //Structure creating element (similarity of a binary tree node) | ||
var element: any ArtboardElement | ||
var indentationLevel: Int | ||
var isParent: Bool | ||
var id: UUID { element.id } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Нам бы вот этот интерфейс натянуть прямо на объект, свойства сделать вычисляемыми. Тогда получится что при перетаскивании мы можем влиять на сам фрейм и его обновление будет обновляться и в других частях.
HStack { | ||
Image(systemName: element.isParent ? "folder" : "doc") // Images for creating hiererchy folders | ||
.onTapGesture { | ||
element.isParent.toggle() | ||
} | ||
Text(element.element.label) | ||
} | ||
.padding(.leading, CGFloat(element.indentationLevel * 20)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это стоит вынести в отдельную вью
HStack { | ||
Image(systemName: element.isParent ? "folder" : "doc") // Images for creating hiererchy folders | ||
.onTapGesture { | ||
element.isParent.toggle() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
По тапу необычно, но я думаю, что так не надо. Лучше при редактировании списка дать выделять несколько компонентов, а в тулбаре показывать кнопку group
, так поведение будет более системным, а значит и предсказуемым
func move(from source: IndexSet, to destination: Int) { | ||
hierarchicalElements.move(fromOffsets: source, toOffset: destination) | ||
|
||
updateIndentationLevels() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Само перемещение хорошо работает, но тут лучше вызывать метод перезентера, чтобы он внутри фрейма данные переставлял
if isPreviousElementParent { | ||
currentIndentationLevel += 1 | ||
} else { | ||
currentIndentationLevel = 0 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вот эта логика в презентере уже есть
No description provided.