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

Commit

Permalink
Prototype quote note feature
Browse files Browse the repository at this point in the history
  • Loading branch information
bfollington committed Jan 15, 2024
1 parent ba20217 commit 396e7cc
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,8 @@ extension DetailStackAction {
)
)
)
case let .requestQuoteInNewDetail(address):
return .pushDetail(.editor(MemoEditorDetailDescription(fallback: "\(address.markup)\n\n")))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1418,7 +1418,9 @@ struct MemoEditorDetailModel: ModelProtocol {
text: fallback,
saveState: .unsaved,
modified: Date.now
)
),
.setEditorSelectionAtEnd,
.requestEditorFocus(true)
],
environment: environment
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,23 @@ struct MemoViewerDetailMetaSheetView: View {

Divider()

if let address = store.state.address {
Button(
action: {
store.send(.requestQuoteInNewNote(address))
},
label: {
Label(
"Quote in new note",
systemImage: "quote.opening"
)
}
)
.buttonStyle(RowButtonStyle())
}

Divider()

if let author = store.state.author {
Button(
action: {
Expand Down Expand Up @@ -76,6 +93,7 @@ enum MemoViewerDetailMetaSheetAction: Hashable {
case setAuthor(_ author: UserProfile)
case requestDismiss
case requestAuthorDetail(_ author: UserProfile)
case requestQuoteInNewNote(_ address: Slashlink)
}

struct MemoViewerDetailMetaSheetModel: ModelProtocol {
Expand Down Expand Up @@ -122,6 +140,8 @@ struct MemoViewerDetailMetaSheetModel: ModelProtocol {
return Update(state: state)
case .requestAuthorDetail:
return Update(state: state)
case .requestQuoteInNewNote:
return Update(state: state)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,16 @@ enum MemoViewerDetailNotification: Hashable {
)
case requestFindLinkDetail(EntryLink)
case requestUserProfileDetail(_ address: Slashlink)
case requestQuoteInNewDetail(_ address: Slashlink)
}

extension MemoViewerDetailNotification {
static func from(_ action: MemoViewerDetailAction) -> Self? {
switch action {
case let .requestAuthorDetail(user):
return .requestUserProfileDetail(user.address)
case let .requestQuoteInNewNote(address):
return .requestQuoteInNewDetail(address)
default:
return nil
}
Expand Down Expand Up @@ -225,6 +228,7 @@ enum MemoViewerDetailAction: Hashable {

case succeedIndexBackgroundSphere
case requestAuthorDetail(_ author: UserProfile)
case requestQuoteInNewNote(_ address: Slashlink)

/// Synonym for `.metaSheet(.setAddress(_))`
static func setMetaSheetAddress(_ address: Slashlink) -> Self {
Expand Down Expand Up @@ -379,6 +383,12 @@ struct MemoViewerDetailModel: ModelProtocol {
action: .presentMetaSheet(false),
environment: environment
)
case .requestQuoteInNewNote:
return update(
state: state,
action: .presentMetaSheet(false),
environment: environment
)
}
}

Expand Down Expand Up @@ -608,6 +618,8 @@ struct MemoViewerDetailMetaSheetCursor: CursorProtocol {
return .presentMetaSheet(false)
case let .requestAuthorDetail(user):
return .requestAuthorDetail(user)
case let .requestQuoteInNewNote(address):
return .requestQuoteInNewNote(address)
default:
return .metaSheet(action)
}
Expand Down

0 comments on commit 396e7cc

Please sign in to comment.