mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Add the option to select the user interface color palette. Issue #1900
This commit is contained in:
42
iOS/Settings/ColorPaletteTableViewController.swift
Normal file
42
iOS/Settings/ColorPaletteTableViewController.swift
Normal file
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// ColorPaletteTableViewController.swift
|
||||
// NetNewsWire-iOS
|
||||
//
|
||||
// Created by Maurice Parker on 3/15/20.
|
||||
// Copyright © 2020 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class ColorPaletteTableViewController: UITableViewController {
|
||||
|
||||
// MARK: - Table view data source
|
||||
|
||||
override func numberOfSections(in tableView: UITableView) -> Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
return UserInterfaceColorPalette.allCases.count
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
|
||||
let rowColorPalette = UserInterfaceColorPalette.allCases[indexPath.row]
|
||||
cell.textLabel?.text = String(describing: rowColorPalette)
|
||||
if rowColorPalette == AppDefaults.userInterfaceColorPalette {
|
||||
cell.accessoryType = .checkmark
|
||||
} else {
|
||||
cell.accessoryType = .none
|
||||
}
|
||||
return cell
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||
if let colorPalette = UserInterfaceColorPalette(rawValue: indexPath.row) {
|
||||
AppDefaults.userInterfaceColorPalette = colorPalette
|
||||
}
|
||||
navigationController?.popViewController(animated: true)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user