diff --git a/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist b/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist
index 31423978e..33eda54f1 100644
--- a/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist
+++ b/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist
@@ -112,12 +112,12 @@
NotificationService.xcscheme_^#shared#^_
orderHint
- 17
+ 18
ShareActionExtension.xcscheme_^#shared#^_
orderHint
- 18
+ 17
SuppressBuildableAutocreation
diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Scene/Compose/reorder.dot.imageset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Scene/Compose/reorder.dot.imageset/Contents.json
new file mode 100644
index 000000000..0331c75f2
--- /dev/null
+++ b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Scene/Compose/reorder.dot.imageset/Contents.json
@@ -0,0 +1,15 @@
+{
+ "images" : [
+ {
+ "filename" : "reorder.dot.pdf",
+ "idiom" : "universal"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ },
+ "properties" : {
+ "preserves-vector-representation" : true
+ }
+}
diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Scene/Compose/reorder.dot.imageset/reorder.dot.pdf b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Scene/Compose/reorder.dot.imageset/reorder.dot.pdf
new file mode 100644
index 000000000..3a8ee867d
--- /dev/null
+++ b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Scene/Compose/reorder.dot.imageset/reorder.dot.pdf
@@ -0,0 +1,101 @@
+%PDF-1.7
+
+1 0 obj
+ << >>
+endobj
+
+2 0 obj
+ << /Length 3 0 R >>
+stream
+/DeviceRGB CS
+/DeviceRGB cs
+q
+1.000000 0.000000 -0.000000 1.000000 7.000000 4.000000 cm
+0.000000 0.000000 0.000000 scn
+8.500000 3.000000 m
+9.328427 3.000000 10.000000 2.328427 10.000000 1.500000 c
+10.000000 0.671574 9.328427 0.000000 8.500000 0.000000 c
+7.671573 0.000000 7.000000 0.671574 7.000000 1.500000 c
+7.000000 2.328427 7.671573 3.000000 8.500000 3.000000 c
+h
+1.500000 3.000000 m
+2.328427 3.000000 3.000000 2.328427 3.000000 1.500000 c
+3.000000 0.671574 2.328427 0.000000 1.500000 0.000000 c
+0.671573 0.000000 0.000000 0.671574 0.000000 1.500000 c
+0.000000 2.328427 0.671573 3.000000 1.500000 3.000000 c
+h
+8.500000 10.000000 m
+9.328427 10.000000 10.000000 9.328427 10.000000 8.500000 c
+10.000000 7.671573 9.328427 7.000000 8.500000 7.000000 c
+7.671573 7.000000 7.000000 7.671573 7.000000 8.500000 c
+7.000000 9.328427 7.671573 10.000000 8.500000 10.000000 c
+h
+1.500000 10.000000 m
+2.328427 10.000000 3.000000 9.328427 3.000000 8.500000 c
+3.000000 7.671573 2.328427 7.000000 1.500000 7.000000 c
+0.671573 7.000000 0.000000 7.671573 0.000000 8.500000 c
+0.000000 9.328427 0.671573 10.000000 1.500000 10.000000 c
+h
+8.500000 17.000000 m
+9.328427 17.000000 10.000000 16.328426 10.000000 15.500000 c
+10.000000 14.671573 9.328427 14.000000 8.500000 14.000000 c
+7.671573 14.000000 7.000000 14.671573 7.000000 15.500000 c
+7.000000 16.328426 7.671573 17.000000 8.500000 17.000000 c
+h
+1.500000 17.000000 m
+2.328427 17.000000 3.000000 16.328426 3.000000 15.500000 c
+3.000000 14.671573 2.328427 14.000000 1.500000 14.000000 c
+0.671573 14.000000 0.000000 14.671573 0.000000 15.500000 c
+0.000000 16.328426 0.671573 17.000000 1.500000 17.000000 c
+h
+f
+n
+Q
+
+endstream
+endobj
+
+3 0 obj
+ 1644
+endobj
+
+4 0 obj
+ << /Annots []
+ /Type /Page
+ /MediaBox [ 0.000000 0.000000 24.000000 24.000000 ]
+ /Resources 1 0 R
+ /Contents 2 0 R
+ /Parent 5 0 R
+ >>
+endobj
+
+5 0 obj
+ << /Kids [ 4 0 R ]
+ /Count 1
+ /Type /Pages
+ >>
+endobj
+
+6 0 obj
+ << /Pages 5 0 R
+ /Type /Catalog
+ >>
+endobj
+
+xref
+0 7
+0000000000 65535 f
+0000000010 00000 n
+0000000034 00000 n
+0000001734 00000 n
+0000001757 00000 n
+0000001930 00000 n
+0000002004 00000 n
+trailer
+<< /ID [ (some) (id) ]
+ /Root 6 0 R
+ /Size 7
+>>
+startxref
+2063
+%%EOF
\ No newline at end of file
diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/compose.poll.row.background.colorset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/compose.poll.row.background.colorset/Contents.json
new file mode 100644
index 000000000..bc3fb38b9
--- /dev/null
+++ b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/Mastodon/Background/compose.poll.row.background.colorset/Contents.json
@@ -0,0 +1,38 @@
+{
+ "colors" : [
+ {
+ "color" : {
+ "color-space" : "srgb",
+ "components" : {
+ "alpha" : "1.000",
+ "blue" : "0xF7",
+ "green" : "0xF2",
+ "red" : "0xF2"
+ }
+ },
+ "idiom" : "universal"
+ },
+ {
+ "appearances" : [
+ {
+ "appearance" : "luminosity",
+ "value" : "dark"
+ }
+ ],
+ "color" : {
+ "color-space" : "srgb",
+ "components" : {
+ "alpha" : "1.000",
+ "blue" : "0.263",
+ "green" : "0.208",
+ "red" : "0.192"
+ }
+ },
+ "idiom" : "universal"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ }
+}
diff --git a/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/system/Background/compose.poll.row.background.colorset/Contents.json b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/system/Background/compose.poll.row.background.colorset/Contents.json
new file mode 100644
index 000000000..bc3fb38b9
--- /dev/null
+++ b/MastodonSDK/Sources/MastodonAsset/Assets.xcassets/Theme/system/Background/compose.poll.row.background.colorset/Contents.json
@@ -0,0 +1,38 @@
+{
+ "colors" : [
+ {
+ "color" : {
+ "color-space" : "srgb",
+ "components" : {
+ "alpha" : "1.000",
+ "blue" : "0xF7",
+ "green" : "0xF2",
+ "red" : "0xF2"
+ }
+ },
+ "idiom" : "universal"
+ },
+ {
+ "appearances" : [
+ {
+ "appearance" : "luminosity",
+ "value" : "dark"
+ }
+ ],
+ "color" : {
+ "color-space" : "srgb",
+ "components" : {
+ "alpha" : "1.000",
+ "blue" : "0.263",
+ "green" : "0.208",
+ "red" : "0.192"
+ }
+ },
+ "idiom" : "universal"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ }
+}
diff --git a/MastodonSDK/Sources/MastodonAsset/Generated/Assets.swift b/MastodonSDK/Sources/MastodonAsset/Generated/Assets.swift
index 7fda6061f..f9db9d32f 100644
--- a/MastodonSDK/Sources/MastodonAsset/Generated/Assets.swift
+++ b/MastodonSDK/Sources/MastodonAsset/Generated/Assets.swift
@@ -143,6 +143,7 @@ public enum Asset {
public static let people = ImageAsset(name: "Scene/Compose/people")
public static let pollFill = ImageAsset(name: "Scene/Compose/poll.fill")
public static let poll = ImageAsset(name: "Scene/Compose/poll")
+ public static let reorderDot = ImageAsset(name: "Scene/Compose/reorder.dot")
}
public enum Discovery {
public static let profileCardBackground = ColorAsset(name: "Scene/Discovery/profile.card.background")
@@ -209,6 +210,7 @@ public enum Asset {
}
public enum Theme {
public enum Mastodon {
+ public static let composePollRowBackground = ColorAsset(name: "Theme/Mastodon/compose.poll.row.background")
public static let composeToolbarBackground = ColorAsset(name: "Theme/Mastodon/compose.toolbar.background")
public static let contentWarningOverlayBackground = ColorAsset(name: "Theme/Mastodon/content.warning.overlay.background")
public static let navigationBarBackground = ColorAsset(name: "Theme/Mastodon/navigation.bar.background")
@@ -229,6 +231,7 @@ public enum Asset {
public static let tabBarItemInactiveIconColor = ColorAsset(name: "Theme/Mastodon/tab.bar.item.inactive.icon.color")
}
public enum System {
+ public static let composePollRowBackground = ColorAsset(name: "Theme/system/compose.poll.row.background")
public static let composeToolbarBackground = ColorAsset(name: "Theme/system/compose.toolbar.background")
public static let contentWarningOverlayBackground = ColorAsset(name: "Theme/system/content.warning.overlay.background")
public static let navigationBarBackground = ColorAsset(name: "Theme/system/navigation.bar.background")
diff --git a/MastodonSDK/Sources/MastodonCore/Model/Poll/PollComposeItem.swift b/MastodonSDK/Sources/MastodonCore/Model/Poll/PollComposeItem.swift
index 5673f600d..53f25a036 100644
--- a/MastodonSDK/Sources/MastodonCore/Model/Poll/PollComposeItem.swift
+++ b/MastodonSDK/Sources/MastodonCore/Model/Poll/PollComposeItem.swift
@@ -21,11 +21,19 @@ extension PollComposeItem {
public weak var textField: UITextField?
+ // input
@Published public var text = ""
@Published public var shouldBecomeFirstResponder = false
+ // output
+ @Published public var backgroundColor = ThemeService.shared.currentTheme.value.composePollRowBackgroundColor
+
public override init() {
super.init()
+
+ ThemeService.shared.currentTheme
+ .map { $0.composePollRowBackgroundColor }
+ .assign(to: &$backgroundColor)
}
}
}
diff --git a/MastodonSDK/Sources/MastodonCore/Service/Theme/MastodonTheme.swift b/MastodonSDK/Sources/MastodonCore/Service/Theme/MastodonTheme.swift
index 76173590e..563c3d48a 100644
--- a/MastodonSDK/Sources/MastodonCore/Service/Theme/MastodonTheme.swift
+++ b/MastodonSDK/Sources/MastodonCore/Service/Theme/MastodonTheme.swift
@@ -41,5 +41,6 @@ struct MastodonTheme: Theme {
let contentWarningOverlayBackgroundColor = Asset.Theme.Mastodon.contentWarningOverlayBackground.color
let profileFieldCollectionViewBackgroundColor = Asset.Theme.Mastodon.profileFieldCollectionViewBackground.color
let composeToolbarBackgroundColor = Asset.Theme.Mastodon.composeToolbarBackground.color
+ let composePollRowBackgroundColor = Asset.Theme.Mastodon.composePollRowBackground.color
let notificationStatusBorderColor = Asset.Theme.System.notificationStatusBorderColor.color
}
diff --git a/MastodonSDK/Sources/MastodonCore/Service/Theme/SystemTheme.swift b/MastodonSDK/Sources/MastodonCore/Service/Theme/SystemTheme.swift
index cea10a281..ab297780b 100644
--- a/MastodonSDK/Sources/MastodonCore/Service/Theme/SystemTheme.swift
+++ b/MastodonSDK/Sources/MastodonCore/Service/Theme/SystemTheme.swift
@@ -41,5 +41,6 @@ struct SystemTheme: Theme {
let contentWarningOverlayBackgroundColor = Asset.Theme.System.contentWarningOverlayBackground.color
let profileFieldCollectionViewBackgroundColor = Asset.Theme.System.profileFieldCollectionViewBackground.color
let composeToolbarBackgroundColor = Asset.Theme.System.composeToolbarBackground.color
+ let composePollRowBackgroundColor = Asset.Theme.System.composePollRowBackground.color
let notificationStatusBorderColor = Asset.Theme.System.notificationStatusBorderColor.color
}
diff --git a/MastodonSDK/Sources/MastodonCore/Service/Theme/Theme.swift b/MastodonSDK/Sources/MastodonCore/Service/Theme/Theme.swift
index ae555da00..bfe8e9c6e 100644
--- a/MastodonSDK/Sources/MastodonCore/Service/Theme/Theme.swift
+++ b/MastodonSDK/Sources/MastodonCore/Service/Theme/Theme.swift
@@ -40,6 +40,7 @@ public protocol Theme {
var contentWarningOverlayBackgroundColor: UIColor { get }
var profileFieldCollectionViewBackgroundColor: UIColor { get }
var composeToolbarBackgroundColor: UIColor { get }
+ var composePollRowBackgroundColor: UIColor { get }
var notificationStatusBorderColor: UIColor { get }
}
diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Poll/PollAddOptionRow.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Poll/PollAddOptionRow.swift
new file mode 100644
index 000000000..5a8ae58d1
--- /dev/null
+++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Poll/PollAddOptionRow.swift
@@ -0,0 +1,59 @@
+//
+// PollAddOptionRow.swift
+//
+//
+// Created by MainasuK on 2022/10/26.
+//
+
+import SwiftUI
+import MastodonAsset
+import MastodonCore
+
+public struct PollAddOptionRow: View {
+
+ @StateObject var viewModel = ViewModel()
+
+ public var body: some View {
+ HStack(alignment: .center, spacing: 16) {
+ HStack(alignment: .center, spacing: .zero) {
+ Image(systemName: "plus.circle")
+ .frame(width: 20, height: 20)
+ .padding(.leading, 16)
+ .padding(.trailing, 16 - 10) // 8pt for TextField leading
+ .font(.system(size: 17))
+ PollOptionTextField(
+ text: $viewModel.text,
+ index: 999,
+ delegate: nil
+ ) { textField in
+ // do nothing
+ }
+ .hidden()
+ }
+ .background(Color(viewModel.backgroundColor))
+ .cornerRadius(10)
+ .shadow(color: .black.opacity(0.3), radius: 2, x: 0, y: 1)
+ Image(uiImage: Asset.Scene.Compose.reorderDot.image.withRenderingMode(.alwaysTemplate))
+ .foregroundColor(Color(UIColor.label))
+ .hidden()
+ }
+ .background(Color.clear)
+ }
+
+}
+
+extension PollAddOptionRow {
+ public class ViewModel: ObservableObject {
+ // input
+ @Published public var text: String = ""
+
+ // output
+ @Published public var backgroundColor = ThemeService.shared.currentTheme.value.composePollRowBackgroundColor
+
+ public init() {
+ ThemeService.shared.currentTheme
+ .map { $0.composePollRowBackgroundColor }
+ .assign(to: &$backgroundColor)
+ }
+ }
+}
diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Poll/PollOptionRow.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Poll/PollOptionRow.swift
index 89482ddef..0cf451d8d 100644
--- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Poll/PollOptionRow.swift
+++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Poll/PollOptionRow.swift
@@ -6,6 +6,7 @@
//
import SwiftUI
+import MastodonAsset
import MastodonCore
public struct PollOptionRow: View {
@@ -17,19 +18,34 @@ public struct PollOptionRow: View {
let configurationHandler: (DeleteBackwardResponseTextField) -> Void
public var body: some View {
- PollOptionTextField(
- text: $viewModel.text,
- index: index ?? -1,
- delegate: deleteBackwardResponseTextFieldRelayDelegate
- ) { textField in
- viewModel.textField = textField
- configurationHandler(textField)
- }
- .onReceive(viewModel.$shouldBecomeFirstResponder) { shouldBecomeFirstResponder in
- guard shouldBecomeFirstResponder else { return }
- viewModel.shouldBecomeFirstResponder = false
- viewModel.textField?.becomeFirstResponder()
+ HStack(alignment: .center, spacing: 16) {
+ HStack(alignment: .center, spacing: .zero) {
+ Image(systemName: "circle")
+ .frame(width: 20, height: 20)
+ .padding(.leading, 16)
+ .padding(.trailing, 16 - 10) // 8pt for TextField leading
+ .font(.system(size: 17))
+ PollOptionTextField(
+ text: $viewModel.text,
+ index: index ?? -1,
+ delegate: deleteBackwardResponseTextFieldRelayDelegate
+ ) { textField in
+ viewModel.textField = textField
+ configurationHandler(textField)
+ }
+ .onReceive(viewModel.$shouldBecomeFirstResponder) { shouldBecomeFirstResponder in
+ guard shouldBecomeFirstResponder else { return }
+ viewModel.shouldBecomeFirstResponder = false
+ viewModel.textField?.becomeFirstResponder()
+ }
+ }
+ .background(Color(viewModel.backgroundColor))
+ .cornerRadius(10)
+ .shadow(color: .black.opacity(0.3), radius: 2, x: 0, y: 1)
+ Image(uiImage: Asset.Scene.Compose.reorderDot.image.withRenderingMode(.alwaysTemplate))
+ .foregroundColor(Color(UIColor.label))
}
+ .background(Color.clear)
}
}
diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Poll/PollOptionTextField.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Poll/PollOptionTextField.swift
index 0b2065008..5143bea35 100644
--- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Poll/PollOptionTextField.swift
+++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/Poll/PollOptionTextField.swift
@@ -26,8 +26,11 @@ public struct PollOptionTextField: UIViewRepresentable {
textField.setContentHuggingPriority(.defaultHigh, for: .vertical)
textField.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
textField.textInset = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
- textField.borderStyle = .roundedRect
+ textField.borderStyle = .none
+ textField.backgroundColor = .clear
textField.returnKeyType = .next
+ textField.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 16, weight: .regular))
+ textField.adjustsFontForContentSizeCategory = true
return textField
}
diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentToolbarView.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentToolbarView.swift
index 679df22c0..732e3b509 100644
--- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentToolbarView.swift
+++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentToolbarView.swift
@@ -75,6 +75,7 @@ struct ComposeContentToolbarView: View {
}
Spacer()
Text("Hello")
+ .font(.system(size: 16, weight: .regular))
}
.padding(.leading, 4) // 4 + 12 = 16
.padding(.trailing, 16)
diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentView.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentView.swift
index 91f3923aa..569bd7a8e 100644
--- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentView.swift
+++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/View/ComposeContentView.swift
@@ -80,7 +80,7 @@ extension ComposeContentView {
metaContent: viewModel.name
)
Text(viewModel.username)
- .font(.subheadline)
+ .font(.system(size: 15, weight: .regular))
.foregroundColor(.secondary)
Spacer()
}
@@ -107,6 +107,12 @@ extension ComposeContentView {
// viewModel.customEmojiPickerInputViewModel.configure(textInput: textField)
}
}
+ if viewModel.maxPollOptionLimit != viewModel.pollOptions.count {
+ PollAddOptionRow()
+ .onTapGesture {
+ viewModel.createNewPollOptionIfCould()
+ }
+ }
}
VStack(spacing: .zero) {
// expire configuration