Compare commits

..

No commits in common. "37563b6afd0258f5d4cc0b455f55ce507b1c88b6" and "94c34e03ddc44fe13388f7ad94b054a5665acadf" have entirely different histories.

9 changed files with 12 additions and 130 deletions

View File

@ -321,9 +321,7 @@ 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([])

View File

@ -38,7 +38,6 @@ 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)
@ -91,7 +90,6 @@ 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)
@ -138,7 +136,6 @@ 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
@ -199,7 +196,6 @@ 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
@ -303,83 +299,3 @@ 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"
}
}
}
}

View File

@ -113,6 +113,5 @@ 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
} }
} }

View File

@ -101,7 +101,6 @@ 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
} }
} }

View File

@ -244,7 +244,6 @@ 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() {

View File

@ -10,20 +10,14 @@ import SwiftUI
struct AppearancePrefsView : View { struct AppearancePrefsView : View {
@ObservedObject var preferences = Preferences.shared @ObservedObject var preferences = Preferences.shared
private var theme: Binding<UIUserInterfaceStyle> = Binding(get: { 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)
}
private var useCircularAvatars: Binding<Bool> = Binding(get: { 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
@ -31,35 +25,16 @@ struct AppearancePrefsView : View {
var body: some View { var body: some View {
List { List {
themeSection
accountsSection
postsSection
}
.listStyle(InsetGroupedListStyle())
.navigationBarTitle(Text("Appearance"))
}
private var themeSection: some View {
Section {
Picker(selection: theme, label: Text("Theme")) { Picker(selection: theme, label: Text("Theme")) {
Text("Use System Theme").tag(UIUserInterfaceStyle.unspecified) Text("Use System Theme").tag(UIUserInterfaceStyle.unspecified)
Text("Light").tag(UIUserInterfaceStyle.light) Text("Light").tag(UIUserInterfaceStyle.light)
Text("Dark").tag(UIUserInterfaceStyle.dark) Text("Dark").tag(UIUserInterfaceStyle.dark)
} }
accountsSection
Picker(selection: accentColor, label: Text("Accent Color")) { postsSection
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)
}
}
} }
.listStyle(InsetGroupedListStyle())
.navigationBarTitle(Text("Appearance"))
} }
private var accountsSection: some View { private var accountsSection: some View {

View File

@ -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
} }
} }

View File

@ -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="tintColor"/> <color key="backgroundColor" systemColor="systemBlueColor"/>
<constraints> <constraints>
<constraint firstAttribute="height" constant="30" id="icD-3q-uJ6"/> <constraint firstAttribute="height" constant="30" id="icD-3q-uJ6"/>
</constraints> </constraints>
@ -169,7 +169,6 @@
<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>
@ -180,7 +179,6 @@
<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>
@ -191,7 +189,6 @@
<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>
@ -202,7 +199,6 @@
<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>
@ -282,7 +278,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="tintColor"> <systemColor name="systemBlueColor">
<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>

View File

@ -46,7 +46,7 @@ class ToastView: UIView {
} }
private func setupView() { private func setupView() {
backgroundColor = .tintColor backgroundColor = .systemBlue
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)