Merge branch 'langleyd/6830_wysiwyg_core_formatting' into mauroromito/wysiwyg_edit_reply_UI

# Conflicts:
#	RiotSwiftUI/Modules/Room/Composer/View/Composer.swift
This commit is contained in:
Mauro Romito
2022-10-12 16:48:43 +02:00
9 changed files with 81 additions and 41 deletions
@@ -19,6 +19,11 @@ import SwiftUI
import WysiwygComposer
struct Composer: View {
// MARK: - Properties
// MARK: Private
@State var focused = false
@Environment(\.theme) private var theme: ThemeSwiftUI
@@ -53,6 +58,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: cornerRadius)
@@ -112,6 +128,11 @@ struct Composer: View {
.padding(.horizontal, horizontalPadding)
.padding(.top, 8)
.padding(.bottom, 4)
.onTapGesture {
if !focused {
focused = true
}
}
HStack {
Button {
showSendMediaActions()
@@ -162,13 +183,11 @@ 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)
}
@@ -1,4 +1,4 @@
//
//
// Copyright 2022 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,33 +18,40 @@ import SwiftUI
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]
var formatAction: (FormatType) -> ()
/// The action when an item is selected
var formatAction: (FormatType) -> Void
var body: some View {
HStack {
ForEach(formatItems) { item in
Button {
print("action")
formatAction(item.type)
} label: {
Image(item.icon)
.renderingMode(.template)
.foregroundColor(item.active ? theme.colors.accent : theme.colors.tertiaryContent)
}
.disabled(item.disabled)
.background(item.active ? theme.colors.accent.opacity(0.1) : theme.colors.background)
.cornerRadius(8)
.accessibilityIdentifier(item.accessibilityIdentifier)
}
}
ForEach(formatItems) { item in
Button {
formatAction(item.type)
} label: {
Image(item.icon)
.renderingMode(.template)
.foregroundColor(item.active ? theme.colors.accent : theme.colors.tertiaryContent)
}
.disabled(item.disabled)
.background(item.active ? theme.colors.accent.opacity(0.1) : theme.colors.background)
.cornerRadius(8)
.accessibilityIdentifier(item.accessibilityIdentifier)
}
}
}
}
// MARK: - Previews
struct FormattingToolbar_Previews: PreviewProvider {
static var previews: some View {
FormattingToolbar(formatItems: [