Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

Block editor: change block type #1047

Draft
wants to merge 47 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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 Dec 21, 2023
bbc1577
Set height as multiple of AppTheme.unit
gordonbrander Dec 21, 2023
b893001
Stub in drag gesture (unfinished)
gordonbrander Dec 21, 2023
1f8fda1
Wrap select menu in frame view
gordonbrander Dec 21, 2023
c422288
Horizontally scroll items
gordonbrander Dec 21, 2023
1104451
Stub in delete action
gordonbrander Dec 21, 2023
804d87a
Update delete action
gordonbrander Dec 21, 2023
ea01d26
Introduce Theme, ButtonTheme, and ButtonRoleTheme
gordonbrander Dec 22, 2023
3480909
Rename view
gordonbrander Dec 22, 2023
65af9fd
Make top level block editor a SwiftUI View
gordonbrander Dec 22, 2023
eac5495
Factor out ControllerModelProtocol
gordonbrander Dec 22, 2023
90c37e7
Share store with select menu
gordonbrander Dec 22, 2023
ec4740e
Remove ControllerModelProtocol
gordonbrander Dec 22, 2023
c4fff47
Wire drag/dismiss gesture into store
gordonbrander Dec 26, 2023
b1960fb
Introduce selected stroke to buttons
gordonbrander Dec 26, 2023
f57504e
Allow including a border color with Theme
gordonbrander Dec 26, 2023
4b4e93e
Stub in select mode menu item
gordonbrander Dec 28, 2023
2a1dae3
Iron out some of the select/select menu transition
gordonbrander Jan 3, 2024
82f6c6e
Allow exit select mode by dragging block menu
gordonbrander Jan 3, 2024
dd0a24f
Fix tests
gordonbrander Jan 8, 2024
c90a782
Toggle cell selection on tap
gordonbrander Jan 8, 2024
d1c0676
Animate selection
gordonbrander Jan 8, 2024
9d42106
Update block views using fluent helpers
gordonbrander Jan 29, 2024
2890c32
Set background on all cells
gordonbrander Jan 30, 2024
6e3ea03
Add Color extension to define dynamic light/dark
gordonbrander Jan 30, 2024
6ff6d30
Fix tertiary label
gordonbrander Jan 30, 2024
f5bec4f
Tighten up padding on blocks
gordonbrander Jan 30, 2024
5500a25
Add hStack helper
gordonbrander Jan 30, 2024
a2825b7
Add radio button view for block selection
gordonbrander Jan 30, 2024
557e436
Refactor blocks to share more model
gordonbrander Jan 31, 2024
689fe2f
Layer select view under block
gordonbrander Jan 31, 2024
9852410
Set background of hosting view clear
gordonbrander Jan 31, 2024
f35fa55
Begin theming editor
gordonbrander Jan 31, 2024
ab823fa
Fix bullet alignment
gordonbrander Feb 1, 2024
bcb13d0
Set opacity on select view as well as background
gordonbrander Feb 1, 2024
d8d6ad8
Exit block select mode when deselecting last block
gordonbrander Feb 1, 2024
f2cfe98
Resolve some block editor menu state issues
gordonbrander Feb 1, 2024
d077ee7
Fix some missing animations in state transition
gordonbrander Feb 1, 2024
1cfc533
Stub in text block conversion
gordonbrander Feb 2, 2024
6c1f868
Stub in block conversion code
gordonbrander Feb 2, 2024
20e38c0
Set alpha, not opacity
gordonbrander Feb 2, 2024
ac4c58e
Fix loading bug for new drafts
gordonbrander Feb 2, 2024
7225721
Stub in audience
gordonbrander Feb 5, 2024
6defb25
Merge remote-tracking branch 'origin/main' into 2023-12-21-block-edit…
gordonbrander Feb 7, 2024
3c64c46
Fix test
gordonbrander Feb 7, 2024
2d25137
Set theme color on outer block editor element
gordonbrander Feb 7, 2024
27e22ab
Make background clear
gordonbrander Feb 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions xcode/Subconscious/Shared/AppTheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,16 @@ extension UIColor {
UIColor(Color.accentColor)
}
}

extension ShadowStyle {
static func brandShadowLg(
Copy link
Collaborator Author

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.

_ colorScheme: ColorScheme
) -> ShadowStyle {
ShadowStyle(
color: Color.brandDropShadow(colorScheme).opacity(0.5),
radius: 8,
x: 0,
y: 4
)
}
}
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 }
)
}
}
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())
}
}
8 changes: 8 additions & 0 deletions xcode/Subconscious/Subconscious.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@
B856521E2975B7F100B7FCA0 /* Audience.swift in Sources */ = {isa = PBXBuildFile; fileRef = B856521D2975B7F100B7FCA0 /* Audience.swift */; };
B85652202975BA9000B7FCA0 /* MetaTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B856521F2975BA9000B7FCA0 /* MetaTableView.swift */; };
B85652222975F16B00B7FCA0 /* BylineView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B85652212975F16B00B7FCA0 /* BylineView.swift */; };
B856EF212B34B3BE00C87BD3 /* BlockEditorBlockSelectMenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B856EF202B34B3BE00C87BD3 /* BlockEditorBlockSelectMenuView.swift */; };
B856EF252B34C23A00C87BD3 /* PaletteButtonStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = B856EF242B34C23A00C87BD3 /* PaletteButtonStyle.swift */; };
B85A8059296E31860007F957 /* AudienceMenuButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B85A8057296E31860007F957 /* AudienceMenuButtonView.swift */; };
B85A805E296F08720007F957 /* AudienceMenuButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B85A8057296E31860007F957 /* AudienceMenuButtonView.swift */; };
B85BF46F27BB0FA800F55730 /* RowViewModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = B85BF46E27BB0FA800F55730 /* RowViewModifier.swift */; };
Expand Down Expand Up @@ -712,6 +714,8 @@
B856521D2975B7F100B7FCA0 /* Audience.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Audience.swift; sourceTree = "<group>"; };
B856521F2975BA9000B7FCA0 /* MetaTableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MetaTableView.swift; sourceTree = "<group>"; };
B85652212975F16B00B7FCA0 /* BylineView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BylineView.swift; sourceTree = "<group>"; };
B856EF202B34B3BE00C87BD3 /* BlockEditorBlockSelectMenuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlockEditorBlockSelectMenuView.swift; sourceTree = "<group>"; };
B856EF242B34C23A00C87BD3 /* PaletteButtonStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaletteButtonStyle.swift; sourceTree = "<group>"; };
B85A8057296E31860007F957 /* AudienceMenuButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudienceMenuButtonView.swift; sourceTree = "<group>"; };
B85BF46E27BB0FA800F55730 /* RowViewModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RowViewModifier.swift; sourceTree = "<group>"; };
B85BF47427BB3D6E00F55730 /* ToolbarTitleGroupView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToolbarTitleGroupView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1491,6 +1495,7 @@
B8E0BBA62AAB913A00FBCB57 /* Blocks */ = {
isa = PBXGroup;
children = (
B856EF202B34B3BE00C87BD3 /* BlockEditorBlockSelectMenuView.swift */,
B834C0422AB4D40200705F2F /* BlockEditorBlockSelectView.swift */,
B8AB08C62A9D50E700998099 /* BlockFormatMenu.swift */,
B8AB08B02A9D4FC300998099 /* BlockModel.swift */,
Expand All @@ -1502,6 +1507,7 @@
B8AB08B62A9D500C00998099 /* QuoteBlockCell.swift */,
B8AB08B82A9D501600998099 /* TextBlockCell.swift */,
B8AB08BA2A9D502300998099 /* TextBlockModel.swift */,
B856EF242B34C23A00C87BD3 /* PaletteButtonStyle.swift */,
);
path = Blocks;
sourceTree = "<group>";
Expand Down Expand Up @@ -2163,6 +2169,7 @@
B88A91A12A4C9C0100422ABF /* EntryListEmptyView.swift in Sources */,
B58FD6732A4E4C0E00826548 /* InviteCodeSettingsSection.swift in Sources */,
B86DD56C2A9FF77600E1DEA5 /* ErrorCell.swift in Sources */,
B856EF212B34B3BE00C87BD3 /* BlockEditorBlockSelectMenuView.swift in Sources */,
B5F6ADC929C02F4A00690DE4 /* AddressBookService.swift in Sources */,
B8AB08D42A9D524300998099 /* UIViewSpacer.swift in Sources */,
B8925B2F29C23017001F9503 /* MemoViewerDetailView.swift in Sources */,
Expand Down Expand Up @@ -2212,6 +2219,7 @@
B8B3EE77297AEE8B00779B7F /* FirstRunDoneView.swift in Sources */,
B8099F002A3B5A820014FC2E /* MemoRecord.swift in Sources */,
B5C918EE2A67A16A004C6CD5 /* AuthorizationSettingsView.swift in Sources */,
B856EF252B34C23A00C87BD3 /* PaletteButtonStyle.swift in Sources */,
B85319EA2AAA3D8A0085044A /* UIViewPreviewRepresentable.swift in Sources */,
B85A805E296F08720007F957 /* AudienceMenuButtonView.swift in Sources */,
B8AE34C8276BF77000777FF0 /* SearchTextField.swift in Sources */,
Expand Down
Loading