This repository has been archived by the owner on Aug 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Block editor: change block type #1047
Draft
gordonbrander
wants to merge
47
commits into
main
Choose a base branch
from
2023-12-21-block-editor-select-menu
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
3d63d04
Begin stubbing out block select menu view
gordonbrander bbc1577
Set height as multiple of AppTheme.unit
gordonbrander b893001
Stub in drag gesture (unfinished)
gordonbrander 1f8fda1
Wrap select menu in frame view
gordonbrander c422288
Horizontally scroll items
gordonbrander 1104451
Stub in delete action
gordonbrander 804d87a
Update delete action
gordonbrander ea01d26
Introduce Theme, ButtonTheme, and ButtonRoleTheme
gordonbrander 3480909
Rename view
gordonbrander 65af9fd
Make top level block editor a SwiftUI View
gordonbrander eac5495
Factor out ControllerModelProtocol
gordonbrander 90c37e7
Share store with select menu
gordonbrander ec4740e
Remove ControllerModelProtocol
gordonbrander c4fff47
Wire drag/dismiss gesture into store
gordonbrander b1960fb
Introduce selected stroke to buttons
gordonbrander f57504e
Allow including a border color with Theme
gordonbrander 4b4e93e
Stub in select mode menu item
gordonbrander 2a1dae3
Iron out some of the select/select menu transition
gordonbrander 82f6c6e
Allow exit select mode by dragging block menu
gordonbrander dd0a24f
Fix tests
gordonbrander c90a782
Toggle cell selection on tap
gordonbrander d1c0676
Animate selection
gordonbrander 9d42106
Update block views using fluent helpers
gordonbrander 2890c32
Set background on all cells
gordonbrander 6e3ea03
Add Color extension to define dynamic light/dark
gordonbrander 6ff6d30
Fix tertiary label
gordonbrander f5bec4f
Tighten up padding on blocks
gordonbrander 5500a25
Add hStack helper
gordonbrander a2825b7
Add radio button view for block selection
gordonbrander 557e436
Refactor blocks to share more model
gordonbrander 689fe2f
Layer select view under block
gordonbrander 9852410
Set background of hosting view clear
gordonbrander f35fa55
Begin theming editor
gordonbrander ab823fa
Fix bullet alignment
gordonbrander bcb13d0
Set opacity on select view as well as background
gordonbrander d8d6ad8
Exit block select mode when deselecting last block
gordonbrander f2cfe98
Resolve some block editor menu state issues
gordonbrander d077ee7
Fix some missing animations in state transition
gordonbrander 1cfc533
Stub in text block conversion
gordonbrander 6c1f868
Stub in block conversion code
gordonbrander 20e38c0
Set alpha, not opacity
gordonbrander ac4c58e
Fix loading bug for new drafts
gordonbrander 7225721
Stub in audience
gordonbrander 6defb25
Merge remote-tracking branch 'origin/main' into 2023-12-21-block-edit…
gordonbrander 3c64c46
Fix test
gordonbrander 2d25137
Set theme color on outer block editor element
gordonbrander 27e22ab
Make background clear
gordonbrander File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
xcode/Subconscious/Shared/UIKit/BlockEditor/Blocks/BlockEditorBlockSelectMenuView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
// | ||
// BlockEditorBlockSelectMenu.swift | ||
// Subconscious (iOS) | ||
// | ||
// Created by Gordon Brander on 12/21/23. | ||
// | ||
|
||
import SwiftUI | ||
|
||
extension BlockEditor { | ||
/// Actions for block select menu | ||
enum BlockSelectMenuAction { | ||
case becomeTextBlock | ||
case becomeHeadingBlock | ||
case becomeListBlock | ||
case becomeQuoteBlock | ||
} | ||
} | ||
|
||
extension BlockEditor { | ||
/// Block select mode menu containing controls to change type and otherwise | ||
/// interact with blocks. | ||
struct BlockSelectMenuView: View { | ||
@Environment(\.colorScheme) private var colorScheme | ||
var send: (BlockSelectMenuAction) -> Void | ||
|
||
var body: some View { | ||
VStack(alignment: .center, spacing: AppTheme.unit2) { | ||
DragHandleView() | ||
HStack(spacing: AppTheme.unit2) { | ||
Button( | ||
action: { | ||
send(.becomeTextBlock) | ||
}, | ||
label: { | ||
Label( | ||
title: { | ||
Text("Body") | ||
}, | ||
icon: { | ||
Image(systemName: "text.alignleft") | ||
} | ||
) | ||
} | ||
) | ||
Button( | ||
action: { | ||
send(.becomeHeadingBlock) | ||
}, | ||
label: { | ||
Label( | ||
title: { | ||
Text("Heading") | ||
}, | ||
icon: { | ||
Image(systemName: "textformat.size.larger") | ||
} | ||
) | ||
} | ||
) | ||
Button( | ||
action: { | ||
send(.becomeListBlock) | ||
}, | ||
label: { | ||
Label( | ||
title: { | ||
Text("List") | ||
}, | ||
icon: { | ||
Image(systemName: "list.bullet") | ||
} | ||
) | ||
} | ||
) | ||
Button( | ||
action: { | ||
send(.becomeQuoteBlock) | ||
}, | ||
label: { | ||
Label( | ||
title: { | ||
Text("Quote") | ||
}, | ||
icon: { | ||
Image(systemName: "quote.opening") | ||
} | ||
) | ||
} | ||
) | ||
Spacer() | ||
} | ||
.buttonStyle(PaletteButtonStyle()) | ||
.frame( | ||
maxWidth: .infinity | ||
) | ||
} | ||
.padding(AppTheme.unit2) | ||
.background(.background) | ||
.cornerRadius(AppTheme.cornerRadiusLg) | ||
.shadow(style: .brandShadowLg(colorScheme)) | ||
} | ||
} | ||
|
||
} | ||
|
||
struct BlockEditorBlockSelectMenuView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
BlockEditor.BlockSelectMenuView( | ||
send: { action in } | ||
) | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
xcode/Subconscious/Shared/UIKit/BlockEditor/Blocks/PaletteButtonStyle.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// | ||
// PaletteButtonStyle.swift | ||
// Subconscious (iOS) | ||
// | ||
// Created by Gordon Brander on 12/21/23. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct PaletteButtonStyle: ButtonStyle { | ||
var size: CGFloat = 72 | ||
|
||
func makeBody(configuration: Configuration) -> some View { | ||
VStack { | ||
configuration.label | ||
.labelStyle(PaletteLabelStyle()) | ||
} | ||
.frame( | ||
width: size, | ||
height: size | ||
) | ||
.background(Color.secondaryBackground) | ||
.cornerRadius(AppTheme.cornerRadius) | ||
} | ||
} | ||
|
||
struct PaletteLabelStyle: LabelStyle { | ||
func makeBody(configuration: Configuration) -> some View { | ||
VStack { | ||
configuration.icon | ||
.frame(width: AppTheme.icon, height: AppTheme.icon) | ||
.padding(.bottom, AppTheme.unitHalf) | ||
configuration.title | ||
.font(.caption) | ||
} | ||
.padding(AppTheme.unit2) | ||
} | ||
} | ||
|
||
struct PaletteButtonStyle_Previews: PreviewProvider { | ||
static var previews: some View { | ||
Button( | ||
action: {}, | ||
label: { | ||
Label( | ||
title: { Text("Label") }, | ||
icon: { Image(systemName: "doc.on.doc") } | ||
) | ||
} | ||
) | ||
.buttonStyle(PaletteButtonStyle()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Introduce the concept of shadow presets. In future we will want to systematize our shadows so as to have a coherent sense of distance and lighting.