Compare commits
2 Commits
94c34e03dd
...
37563b6afd
Author | SHA1 | Date |
---|---|---|
Shadowfacts | 37563b6afd | |
Shadowfacts | 937afc0dfd |
|
@ -321,7 +321,9 @@ class MastodonController: ObservableObject {
|
||||||
let request = Client.getCustomEmoji()
|
let request = Client.getCustomEmoji()
|
||||||
run(request) { (response) in
|
run(request) { (response) in
|
||||||
if case let .success(emojis, _) = response {
|
if case let .success(emojis, _) = response {
|
||||||
|
DispatchQueue.main.async {
|
||||||
self.customEmojis = emojis
|
self.customEmojis = emojis
|
||||||
|
}
|
||||||
completion(emojis)
|
completion(emojis)
|
||||||
} else {
|
} else {
|
||||||
completion([])
|
completion([])
|
||||||
|
|
|
@ -38,6 +38,7 @@ class Preferences: Codable, ObservableObject {
|
||||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
|
||||||
self.theme = try container.decode(UIUserInterfaceStyle.self, forKey: .theme)
|
self.theme = try container.decode(UIUserInterfaceStyle.self, forKey: .theme)
|
||||||
|
self.accentColor = try container.decodeIfPresent(AccentColor.self, forKey: .accentColor) ?? .default
|
||||||
self.avatarStyle = try container.decode(AvatarStyle.self, forKey: .avatarStyle)
|
self.avatarStyle = try container.decode(AvatarStyle.self, forKey: .avatarStyle)
|
||||||
self.hideCustomEmojiInUsernames = try container.decode(Bool.self, forKey: .hideCustomEmojiInUsernames)
|
self.hideCustomEmojiInUsernames = try container.decode(Bool.self, forKey: .hideCustomEmojiInUsernames)
|
||||||
self.showIsStatusReplyIcon = try container.decode(Bool.self, forKey: .showIsStatusReplyIcon)
|
self.showIsStatusReplyIcon = try container.decode(Bool.self, forKey: .showIsStatusReplyIcon)
|
||||||
|
@ -90,6 +91,7 @@ class Preferences: Codable, ObservableObject {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
|
||||||
try container.encode(theme, forKey: .theme)
|
try container.encode(theme, forKey: .theme)
|
||||||
|
try container.encode(accentColor, forKey: .accentColor)
|
||||||
try container.encode(avatarStyle, forKey: .avatarStyle)
|
try container.encode(avatarStyle, forKey: .avatarStyle)
|
||||||
try container.encode(hideCustomEmojiInUsernames, forKey: .hideCustomEmojiInUsernames)
|
try container.encode(hideCustomEmojiInUsernames, forKey: .hideCustomEmojiInUsernames)
|
||||||
try container.encode(showIsStatusReplyIcon, forKey: .showIsStatusReplyIcon)
|
try container.encode(showIsStatusReplyIcon, forKey: .showIsStatusReplyIcon)
|
||||||
|
@ -136,6 +138,7 @@ class Preferences: Codable, ObservableObject {
|
||||||
|
|
||||||
// MARK: Appearance
|
// MARK: Appearance
|
||||||
@Published var theme = UIUserInterfaceStyle.unspecified
|
@Published var theme = UIUserInterfaceStyle.unspecified
|
||||||
|
@Published var accentColor = AccentColor.default
|
||||||
@Published var avatarStyle = AvatarStyle.roundRect
|
@Published var avatarStyle = AvatarStyle.roundRect
|
||||||
@Published var hideCustomEmojiInUsernames = false
|
@Published var hideCustomEmojiInUsernames = false
|
||||||
@Published var showIsStatusReplyIcon = false
|
@Published var showIsStatusReplyIcon = false
|
||||||
|
@ -196,6 +199,7 @@ class Preferences: Codable, ObservableObject {
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
case theme
|
case theme
|
||||||
|
case accentColor
|
||||||
case avatarStyle
|
case avatarStyle
|
||||||
case hideCustomEmojiInUsernames
|
case hideCustomEmojiInUsernames
|
||||||
case showIsStatusReplyIcon
|
case showIsStatusReplyIcon
|
||||||
|
@ -299,3 +303,83 @@ extension Preferences {
|
||||||
}
|
}
|
||||||
|
|
||||||
extension UIUserInterfaceStyle: Codable {}
|
extension UIUserInterfaceStyle: Codable {}
|
||||||
|
|
||||||
|
extension Preferences {
|
||||||
|
enum AccentColor: String, Codable, CaseIterable {
|
||||||
|
case `default`
|
||||||
|
case purple
|
||||||
|
case indigo
|
||||||
|
case blue
|
||||||
|
case cyan
|
||||||
|
case teal
|
||||||
|
case mint
|
||||||
|
case green
|
||||||
|
// case yellow
|
||||||
|
case orange
|
||||||
|
case red
|
||||||
|
case pink
|
||||||
|
// case brown
|
||||||
|
|
||||||
|
var color: UIColor? {
|
||||||
|
switch self {
|
||||||
|
case .default:
|
||||||
|
return nil
|
||||||
|
case .blue:
|
||||||
|
return .systemBlue
|
||||||
|
// case .brown:
|
||||||
|
// return .systemBrown
|
||||||
|
case .cyan:
|
||||||
|
return .systemCyan
|
||||||
|
case .green:
|
||||||
|
return .systemGreen
|
||||||
|
case .indigo:
|
||||||
|
return .systemIndigo
|
||||||
|
case .mint:
|
||||||
|
return .systemMint
|
||||||
|
case .orange:
|
||||||
|
return .systemOrange
|
||||||
|
case .pink:
|
||||||
|
return .systemPink
|
||||||
|
case .purple:
|
||||||
|
return .systemPurple
|
||||||
|
case .red:
|
||||||
|
return .systemRed
|
||||||
|
case .teal:
|
||||||
|
return .systemTeal
|
||||||
|
// case .yellow:
|
||||||
|
// return .systemYellow
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var name: String {
|
||||||
|
switch self {
|
||||||
|
case .default:
|
||||||
|
return "Default"
|
||||||
|
case .blue:
|
||||||
|
return "Blue"
|
||||||
|
// case .brown:
|
||||||
|
// return "Brown"
|
||||||
|
case .cyan:
|
||||||
|
return "Cyan"
|
||||||
|
case .green:
|
||||||
|
return "Green"
|
||||||
|
case .indigo:
|
||||||
|
return "Indigo"
|
||||||
|
case .mint:
|
||||||
|
return "Mint"
|
||||||
|
case .orange:
|
||||||
|
return "Orange"
|
||||||
|
case .pink:
|
||||||
|
return "Pink"
|
||||||
|
case .purple:
|
||||||
|
return "Purple"
|
||||||
|
case .red:
|
||||||
|
return "Red"
|
||||||
|
case .teal:
|
||||||
|
return "Teal"
|
||||||
|
// case .yellow:
|
||||||
|
// return "Yellow"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -113,5 +113,6 @@ class AuxiliarySceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||||
|
|
||||||
@objc private func themePrefChanged() {
|
@objc private func themePrefChanged() {
|
||||||
window?.overrideUserInterfaceStyle = Preferences.shared.theme
|
window?.overrideUserInterfaceStyle = Preferences.shared.theme
|
||||||
|
window?.tintColor = Preferences.shared.accentColor.color
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,6 +101,7 @@ class ComposeSceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||||
|
|
||||||
@objc private func themePrefChanged() {
|
@objc private func themePrefChanged() {
|
||||||
window?.overrideUserInterfaceStyle = Preferences.shared.theme
|
window?.overrideUserInterfaceStyle = Preferences.shared.theme
|
||||||
|
window?.tintColor = Preferences.shared.accentColor.color
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -244,6 +244,7 @@ class MainSceneDelegate: UIResponder, UIWindowSceneDelegate, TuskerSceneDelegate
|
||||||
|
|
||||||
@objc func themePrefChanged() {
|
@objc func themePrefChanged() {
|
||||||
window?.overrideUserInterfaceStyle = Preferences.shared.theme
|
window?.overrideUserInterfaceStyle = Preferences.shared.theme
|
||||||
|
window?.tintColor = Preferences.shared.accentColor.color
|
||||||
}
|
}
|
||||||
|
|
||||||
func showAddAccount() {
|
func showAddAccount() {
|
||||||
|
|
|
@ -10,14 +10,20 @@ import SwiftUI
|
||||||
struct AppearancePrefsView : View {
|
struct AppearancePrefsView : View {
|
||||||
@ObservedObject var preferences = Preferences.shared
|
@ObservedObject var preferences = Preferences.shared
|
||||||
|
|
||||||
var theme: Binding<UIUserInterfaceStyle> = Binding(get: {
|
private var theme: Binding<UIUserInterfaceStyle> = Binding(get: {
|
||||||
Preferences.shared.theme
|
Preferences.shared.theme
|
||||||
}, set: {
|
}, set: {
|
||||||
Preferences.shared.theme = $0
|
Preferences.shared.theme = $0
|
||||||
NotificationCenter.default.post(name: .themePreferenceChanged, object: nil)
|
NotificationCenter.default.post(name: .themePreferenceChanged, object: nil)
|
||||||
})
|
})
|
||||||
|
private var accentColor: Binding<Preferences.AccentColor> = Binding {
|
||||||
|
Preferences.shared.accentColor
|
||||||
|
} set: {
|
||||||
|
Preferences.shared.accentColor = $0
|
||||||
|
NotificationCenter.default.post(name: .themePreferenceChanged, object: nil)
|
||||||
|
}
|
||||||
|
|
||||||
var useCircularAvatars: Binding<Bool> = Binding(get: {
|
private var useCircularAvatars: Binding<Bool> = Binding(get: {
|
||||||
Preferences.shared.avatarStyle == .circle
|
Preferences.shared.avatarStyle == .circle
|
||||||
}) {
|
}) {
|
||||||
Preferences.shared.avatarStyle = $0 ? .circle : .roundRect
|
Preferences.shared.avatarStyle = $0 ? .circle : .roundRect
|
||||||
|
@ -25,11 +31,7 @@ struct AppearancePrefsView : View {
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
List {
|
List {
|
||||||
Picker(selection: theme, label: Text("Theme")) {
|
themeSection
|
||||||
Text("Use System Theme").tag(UIUserInterfaceStyle.unspecified)
|
|
||||||
Text("Light").tag(UIUserInterfaceStyle.light)
|
|
||||||
Text("Dark").tag(UIUserInterfaceStyle.dark)
|
|
||||||
}
|
|
||||||
accountsSection
|
accountsSection
|
||||||
postsSection
|
postsSection
|
||||||
}
|
}
|
||||||
|
@ -37,6 +39,29 @@ struct AppearancePrefsView : View {
|
||||||
.navigationBarTitle(Text("Appearance"))
|
.navigationBarTitle(Text("Appearance"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var themeSection: some View {
|
||||||
|
Section {
|
||||||
|
Picker(selection: theme, label: Text("Theme")) {
|
||||||
|
Text("Use System Theme").tag(UIUserInterfaceStyle.unspecified)
|
||||||
|
Text("Light").tag(UIUserInterfaceStyle.light)
|
||||||
|
Text("Dark").tag(UIUserInterfaceStyle.dark)
|
||||||
|
}
|
||||||
|
|
||||||
|
Picker(selection: accentColor, label: Text("Accent Color")) {
|
||||||
|
ForEach(Preferences.AccentColor.allCases, id: \.rawValue) { color in
|
||||||
|
HStack {
|
||||||
|
Text(color.name)
|
||||||
|
if let color = color.color {
|
||||||
|
Spacer()
|
||||||
|
Image(uiImage: UIImage(systemName: "circle.fill")!.withTintColor(color, renderingMode: .alwaysTemplate).withRenderingMode(.alwaysOriginal))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.tag(color)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private var accountsSection: some View {
|
private var accountsSection: some View {
|
||||||
Section(header: Text("Accounts")) {
|
Section(header: Text("Accounts")) {
|
||||||
Toggle(isOn: useCircularAvatars) {
|
Toggle(isOn: useCircularAvatars) {
|
||||||
|
|
|
@ -48,12 +48,12 @@ class BaseStatusTableViewCell: UITableViewCell {
|
||||||
|
|
||||||
private var favorited = false {
|
private var favorited = false {
|
||||||
didSet {
|
didSet {
|
||||||
favoriteButton.tintColor = favorited ? UIColor(displayP3Red: 1, green: 0.8, blue: 0, alpha: 1) : tintColor
|
favoriteButton.tintColor = favorited ? UIColor(displayP3Red: 1, green: 0.8, blue: 0, alpha: 1) : .tintColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private var reblogged = false {
|
private var reblogged = false {
|
||||||
didSet {
|
didSet {
|
||||||
reblogButton.tintColor = reblogged ? UIColor(displayP3Red: 1, green: 0.8, blue: 0, alpha: 1) : tintColor
|
reblogButton.tintColor = reblogged ? UIColor(displayP3Red: 1, green: 0.8, blue: 0, alpha: 1) : .tintColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@
|
||||||
</label>
|
</label>
|
||||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="8r8-O8-Agh" customClass="StatusCollapseButton" customModule="Tusker" customModuleProvider="target">
|
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="8r8-O8-Agh" customClass="StatusCollapseButton" customModule="Tusker" customModuleProvider="target">
|
||||||
<rect key="frame" x="0.0" y="86.5" width="361" height="30"/>
|
<rect key="frame" x="0.0" y="86.5" width="361" height="30"/>
|
||||||
<color key="backgroundColor" systemColor="systemBlueColor"/>
|
<color key="backgroundColor" systemColor="tintColor"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<constraint firstAttribute="height" constant="30" id="icD-3q-uJ6"/>
|
<constraint firstAttribute="height" constant="30" id="icD-3q-uJ6"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
|
@ -169,6 +169,7 @@
|
||||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" pointerInteraction="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2cc-lE-AdG">
|
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" pointerInteraction="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2cc-lE-AdG">
|
||||||
<rect key="frame" x="0.0" y="0.0" width="90.5" height="26"/>
|
<rect key="frame" x="0.0" y="0.0" width="90.5" height="26"/>
|
||||||
<accessibility key="accessibilityConfiguration" label="Reply"/>
|
<accessibility key="accessibilityConfiguration" label="Reply"/>
|
||||||
|
<color key="tintColor" systemColor="tintColor"/>
|
||||||
<state key="normal">
|
<state key="normal">
|
||||||
<imageReference key="image" image="arrowshape.turn.up.left.fill" catalog="system" symbolScale="large"/>
|
<imageReference key="image" image="arrowshape.turn.up.left.fill" catalog="system" symbolScale="large"/>
|
||||||
</state>
|
</state>
|
||||||
|
@ -179,6 +180,7 @@
|
||||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" pointerInteraction="YES" translatesAutoresizingMaskIntoConstraints="NO" id="DhN-rJ-jdA">
|
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" pointerInteraction="YES" translatesAutoresizingMaskIntoConstraints="NO" id="DhN-rJ-jdA">
|
||||||
<rect key="frame" x="90.5" y="0.0" width="90" height="26"/>
|
<rect key="frame" x="90.5" y="0.0" width="90" height="26"/>
|
||||||
<accessibility key="accessibilityConfiguration" label="Favorite"/>
|
<accessibility key="accessibilityConfiguration" label="Favorite"/>
|
||||||
|
<color key="tintColor" systemColor="tintColor"/>
|
||||||
<state key="normal">
|
<state key="normal">
|
||||||
<imageReference key="image" image="star.fill" catalog="system" symbolScale="large"/>
|
<imageReference key="image" image="star.fill" catalog="system" symbolScale="large"/>
|
||||||
</state>
|
</state>
|
||||||
|
@ -189,6 +191,7 @@
|
||||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" pointerInteraction="YES" translatesAutoresizingMaskIntoConstraints="NO" id="GUG-f7-Hdy">
|
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" pointerInteraction="YES" translatesAutoresizingMaskIntoConstraints="NO" id="GUG-f7-Hdy">
|
||||||
<rect key="frame" x="180.5" y="0.0" width="90.5" height="26"/>
|
<rect key="frame" x="180.5" y="0.0" width="90.5" height="26"/>
|
||||||
<accessibility key="accessibilityConfiguration" label="Reblog"/>
|
<accessibility key="accessibilityConfiguration" label="Reblog"/>
|
||||||
|
<color key="tintColor" systemColor="tintColor"/>
|
||||||
<state key="normal">
|
<state key="normal">
|
||||||
<imageReference key="image" image="repeat" catalog="system" symbolScale="large"/>
|
<imageReference key="image" image="repeat" catalog="system" symbolScale="large"/>
|
||||||
</state>
|
</state>
|
||||||
|
@ -199,6 +202,7 @@
|
||||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" pointerInteraction="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Ujo-Ap-dmK">
|
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" pointerInteraction="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Ujo-Ap-dmK">
|
||||||
<rect key="frame" x="271" y="0.0" width="90" height="26"/>
|
<rect key="frame" x="271" y="0.0" width="90" height="26"/>
|
||||||
<accessibility key="accessibilityConfiguration" label="More Actions"/>
|
<accessibility key="accessibilityConfiguration" label="More Actions"/>
|
||||||
|
<color key="tintColor" systemColor="tintColor"/>
|
||||||
<state key="normal">
|
<state key="normal">
|
||||||
<imageReference key="image" image="ellipsis" catalog="system" symbolScale="large"/>
|
<imageReference key="image" image="ellipsis" catalog="system" symbolScale="large"/>
|
||||||
</state>
|
</state>
|
||||||
|
@ -278,7 +282,7 @@
|
||||||
<systemColor name="systemBackgroundColor">
|
<systemColor name="systemBackgroundColor">
|
||||||
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||||
</systemColor>
|
</systemColor>
|
||||||
<systemColor name="systemBlueColor">
|
<systemColor name="tintColor">
|
||||||
<color red="0.0" green="0.47843137254901963" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
<color red="0.0" green="0.47843137254901963" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||||
</systemColor>
|
</systemColor>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -46,7 +46,7 @@ class ToastView: UIView {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func setupView() {
|
private func setupView() {
|
||||||
backgroundColor = .systemBlue
|
backgroundColor = .tintColor
|
||||||
layer.shadowColor = UIColor.black.cgColor
|
layer.shadowColor = UIColor.black.cgColor
|
||||||
layer.shadowRadius = 5
|
layer.shadowRadius = 5
|
||||||
layer.shadowOffset = CGSize(width: 0, height: 2.5)
|
layer.shadowOffset = CGSize(width: 0, height: 2.5)
|
||||||
|
|
Loading…
Reference in New Issue