mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-28 04:06:57 +02:00
More comments
This commit is contained in:
+6
-1
@@ -18,8 +18,13 @@ import Foundation
|
||||
|
||||
// MARK: View model
|
||||
|
||||
enum ComposerCreateActionListViewModelResult: Equatable {
|
||||
enum ComposerCreateActionListViewAction {
|
||||
// The user selected an action
|
||||
case selectAction(ComposerCreateAction)
|
||||
}
|
||||
|
||||
enum ComposerCreateActionListViewModelResult: Equatable {
|
||||
// The user selected an action and is done with the screen
|
||||
case done(ComposerCreateAction)
|
||||
}
|
||||
|
||||
|
||||
@@ -18,12 +18,20 @@ import Foundation
|
||||
import SwiftUI
|
||||
import WysiwygComposer
|
||||
|
||||
// MARK: View
|
||||
|
||||
/// An item in the toolbar
|
||||
struct FormatItem {
|
||||
|
||||
/// The type of the item
|
||||
let type: FormatType
|
||||
/// Whether it is active(highlighted)
|
||||
let active: Bool
|
||||
/// Whether it is disabled or enabled
|
||||
let disabled: Bool
|
||||
}
|
||||
|
||||
/// The types of formatting actions
|
||||
enum FormatType {
|
||||
case bold
|
||||
case italic
|
||||
@@ -35,12 +43,13 @@ extension FormatType: CaseIterable, Identifiable {
|
||||
var id: Self { self }
|
||||
}
|
||||
|
||||
|
||||
extension FormatItem: Identifiable {
|
||||
var id: FormatType { type }
|
||||
}
|
||||
|
||||
extension FormatItem {
|
||||
|
||||
/// The icon for the item
|
||||
var icon: String {
|
||||
switch type {
|
||||
case .bold:
|
||||
@@ -69,6 +78,7 @@ extension FormatItem {
|
||||
}
|
||||
|
||||
extension FormatType {
|
||||
/// Convenience method to map it to the external ViewModel action
|
||||
var action: WysiwygAction {
|
||||
switch self {
|
||||
case .bold:
|
||||
@@ -82,6 +92,9 @@ extension FormatType {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: We probably don't need to expose this, clean up.
|
||||
|
||||
/// Convenience method to map it to the external rust binging action
|
||||
var composerAction: ComposerAction {
|
||||
switch self {
|
||||
case .bold:
|
||||
|
||||
@@ -19,14 +19,10 @@ import SwiftUI
|
||||
import WysiwygComposer
|
||||
|
||||
struct Composer: View {
|
||||
@Environment(\.theme) private var theme: ThemeSwiftUI
|
||||
|
||||
@ObservedObject var viewModel: WysiwygComposerViewModel
|
||||
let sendMessageAction: (WysiwygComposerContent) -> Void
|
||||
let showSendMediaActions: () -> Void
|
||||
var textColor = Color(.label)
|
||||
// MARK: - Properties
|
||||
|
||||
@State private var showSendButton = false
|
||||
// MARK: Private
|
||||
|
||||
private let borderHeight: CGFloat = 44
|
||||
private let minTextViewHeight: CGFloat = 20
|
||||
@@ -44,6 +40,17 @@ struct Composer: View {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Public
|
||||
|
||||
@Environment(\.theme) private var theme: ThemeSwiftUI
|
||||
|
||||
@ObservedObject var viewModel: WysiwygComposerViewModel
|
||||
let sendMessageAction: (WysiwygComposerContent) -> Void
|
||||
let showSendMediaActions: () -> Void
|
||||
var textColor = Color(.label)
|
||||
|
||||
@State private var showSendButton = false
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
let rect = RoundedRectangle(cornerRadius: borderHeight / 2)
|
||||
@@ -123,13 +130,10 @@ struct Composer: View {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Previews
|
||||
struct Composer_Previews: PreviewProvider {
|
||||
static let stateRenderer = MockComposerScreenState.stateRenderer
|
||||
static var previews: some View {
|
||||
stateRenderer.screenGroup()
|
||||
}
|
||||
}
|
||||
|
||||
enum ComposerCreateActionListViewAction {
|
||||
case selectAction(ComposerCreateAction)
|
||||
}
|
||||
|
||||
@@ -19,16 +19,24 @@ import WysiwygComposer
|
||||
|
||||
struct FormattingToolbar: View {
|
||||
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
// MARK: Private
|
||||
|
||||
// MARK: Public
|
||||
|
||||
@Environment(\.theme) private var theme: ThemeSwiftUI
|
||||
|
||||
/// The list of items to render in the toolbar
|
||||
var formatItems: [FormatItem]
|
||||
/// The action when an item is selected
|
||||
var formatAction: (FormatType) -> ()
|
||||
|
||||
var body: some View {
|
||||
HStack {
|
||||
ForEach(formatItems) { item in
|
||||
Button {
|
||||
print("action")
|
||||
formatAction(item.type)
|
||||
} label: {
|
||||
Image(item.icon)
|
||||
@@ -45,6 +53,8 @@ struct FormattingToolbar: View {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Previews
|
||||
|
||||
struct FormattingToolbar_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
FormattingToolbar(formatItems: [
|
||||
|
||||
Reference in New Issue
Block a user