parent
0ebf86bd43
commit
9be8b95aea
|
@ -9,7 +9,6 @@
|
||||||
import Foundation
|
import Foundation
|
||||||
import CoreData
|
import CoreData
|
||||||
|
|
||||||
@objc(SubscriptionAlerts)
|
|
||||||
public final class SubscriptionAlerts: NSManagedObject {
|
public final class SubscriptionAlerts: NSManagedObject {
|
||||||
@NSManaged public var follow: NSNumber?
|
@NSManaged public var follow: NSNumber?
|
||||||
@NSManaged public var favourite: NSNumber?
|
@NSManaged public var favourite: NSNumber?
|
||||||
|
|
|
@ -44,22 +44,10 @@ extension UIButton {
|
||||||
}
|
}
|
||||||
|
|
||||||
extension UIButton {
|
extension UIButton {
|
||||||
// https://stackoverflow.com/questions/14523348/how-to-change-the-background-color-of-a-uibutton-while-its-highlighted
|
|
||||||
private func image(withColor color: UIColor) -> UIImage? {
|
|
||||||
let rect = CGRect(x: 0.0, y: 0.0, width: 1.0, height: 1.0)
|
|
||||||
UIGraphicsBeginImageContext(rect.size)
|
|
||||||
let context = UIGraphicsGetCurrentContext()
|
|
||||||
|
|
||||||
context?.setFillColor(color.cgColor)
|
|
||||||
context?.fill(rect)
|
|
||||||
|
|
||||||
let image = UIGraphicsGetImageFromCurrentImageContext()
|
|
||||||
UIGraphicsEndImageContext()
|
|
||||||
|
|
||||||
return image
|
|
||||||
}
|
|
||||||
|
|
||||||
func setBackgroundColor(_ color: UIColor, for state: UIControl.State) {
|
func setBackgroundColor(_ color: UIColor, for state: UIControl.State) {
|
||||||
self.setBackgroundImage(image(withColor: color), for: state)
|
self.setBackgroundImage(
|
||||||
|
UIImage.placeholder(color: color),
|
||||||
|
for: state
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -311,8 +311,9 @@ extension SettingsViewController: UITableViewDelegate {
|
||||||
|
|
||||||
switch item {
|
switch item {
|
||||||
case .boringZone:
|
case .boringZone:
|
||||||
|
guard let url = viewModel.privacyURL else { break }
|
||||||
coordinator.present(
|
coordinator.present(
|
||||||
scene: .safari(url: URL(string: "https://mastodon.online/terms")!),
|
scene: .safari(url: url),
|
||||||
from: self,
|
from: self,
|
||||||
transition: .safariPresent(animated: true, completion: nil)
|
transition: .safariPresent(animated: true, completion: nil)
|
||||||
)
|
)
|
||||||
|
@ -345,11 +346,9 @@ extension SettingsViewController {
|
||||||
func updateTrigger(by who: String) {
|
func updateTrigger(by who: String) {
|
||||||
guard let setting = self.viewModel.setting.value else { return }
|
guard let setting = self.viewModel.setting.value else { return }
|
||||||
|
|
||||||
context.managedObjectContext.performChanges {
|
_ = context.managedObjectContext.performChanges {
|
||||||
setting.update(triggerBy: who)
|
setting.update(triggerBy: who)
|
||||||
}
|
}
|
||||||
.sink { (_) in
|
|
||||||
}.store(in: &disposeBag)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateAlert(title: String?, isOn: Bool) {
|
func updateAlert(title: String?, isOn: Bool) {
|
||||||
|
|
|
@ -70,6 +70,14 @@ class SettingsViewModel: NSObject, NeedsDependency {
|
||||||
noOne: noOneSwitchItems]
|
noOne: noOneSwitchItems]
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
lazy var privacyURL: URL? = {
|
||||||
|
guard let box = AppContext.shared.authenticationService.activeMastodonAuthenticationBox.value else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return Mastodon.API.privacyURL(domain: box.domain)
|
||||||
|
}()
|
||||||
|
|
||||||
struct Input {
|
struct Input {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ extension Mastodon.API.Subscriptions {
|
||||||
/// - session: `URLSession`
|
/// - session: `URLSession`
|
||||||
/// - domain: Mastodon instance domain. e.g. "example.com"
|
/// - domain: Mastodon instance domain. e.g. "example.com"
|
||||||
/// - authorization: User token. Could be nil if status is public
|
/// - authorization: User token. Could be nil if status is public
|
||||||
/// - Returns: `AnyPublisher` contains `Poll` nested in the response
|
/// - Returns: `AnyPublisher` contains `Subscription` nested in the response
|
||||||
public static func subscription(
|
public static func subscription(
|
||||||
session: URLSession,
|
session: URLSession,
|
||||||
domain: String,
|
domain: String,
|
||||||
|
@ -61,7 +61,7 @@ extension Mastodon.API.Subscriptions {
|
||||||
/// - session: `URLSession`
|
/// - session: `URLSession`
|
||||||
/// - domain: Mastodon instance domain. e.g. "example.com"
|
/// - domain: Mastodon instance domain. e.g. "example.com"
|
||||||
/// - authorization: User token. Could be nil if status is public
|
/// - authorization: User token. Could be nil if status is public
|
||||||
/// - Returns: `AnyPublisher` contains `Poll` nested in the response
|
/// - Returns: `AnyPublisher` contains `Subscription` nested in the response
|
||||||
public static func createSubscription(
|
public static func createSubscription(
|
||||||
session: URLSession,
|
session: URLSession,
|
||||||
domain: String,
|
domain: String,
|
||||||
|
@ -95,7 +95,7 @@ extension Mastodon.API.Subscriptions {
|
||||||
/// - session: `URLSession`
|
/// - session: `URLSession`
|
||||||
/// - domain: Mastodon instance domain. e.g. "example.com"
|
/// - domain: Mastodon instance domain. e.g. "example.com"
|
||||||
/// - authorization: User token. Could be nil if status is public
|
/// - authorization: User token. Could be nil if status is public
|
||||||
/// - Returns: `AnyPublisher` contains `Poll` nested in the response
|
/// - Returns: `AnyPublisher` contains `Subscription` nested in the response
|
||||||
public static func updateSubscription(
|
public static func updateSubscription(
|
||||||
session: URLSession,
|
session: URLSession,
|
||||||
domain: String,
|
domain: String,
|
||||||
|
|
Loading…
Reference in New Issue