Skip to content

Commit adafddc

Browse files
committed
Updated devices cell and profile screen. Updated higlight cells.
1 parent 839ff6e commit adafddc

File tree

5 files changed

+40
-18
lines changed

5 files changed

+40
-18
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ let package = Package(
1616
],
1717
dependencies: [
1818
.package(url: "https://github.com/ivanvorobei/SPAlert", .upToNextMajor(from: "4.2.0")),
19-
.package(url: "https://github.com/ivanvorobei/NativeUIKit", .upToNextMajor(from: "1.3.9")),
19+
.package(url: "https://github.com/ivanvorobei/NativeUIKit", .upToNextMajor(from: "1.4.0")),
2020
.package(url: "https://github.com/ivanvorobei/SPFirebase", .upToNextMajor(from: "1.0.6")),
2121
.package(url: "https://github.com/sparrowcode/SPSafeSymbols", .upToNextMajor(from: "1.0.5")),
2222
.package(url: "https://github.com/kean/Nuke", .upToNextMajor(from: "10.7.1"))

Sources/SPProfiling/Data/Texts.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ enum Texts {
7474
static var header: String { NSLocalizedString("profile devices header", bundle: .module, comment: "") }
7575
static var footer: String { NSLocalizedString("profile devices footer", bundle: .module, comment: "") }
7676

77+
static var manage_devices: String { NSLocalizedString("profile devices manage devices", bundle: .module, comment: "") }
78+
7779
static func added_date(date: Date) -> String {
7880
let localisedDate = date.formatted(dateStyle: .medium)
7981
return String(format: NSLocalizedString("profile devices added date", bundle: .module, comment: ""), localisedDate)
@@ -109,6 +111,7 @@ enum Texts {
109111
enum Delete {
110112

111113
static var title: String { NSLocalizedString("profile actions delete title", bundle: .module, comment: "") }
114+
static var header: String { NSLocalizedString("profile actions delete header", bundle: .module, comment: "") }
112115
static var description: String { NSLocalizedString("profile actions delete description", bundle: .module, comment: "") }
113116

114117
enum Confirm {

Sources/SPProfiling/Interface/Devices/DeviceTableCell.swift

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@
1919
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2020
// SOFTWARE.
2121

22-
2322
import UIKit
2423
import SparrowKit
2524
import SPDiffable
2625

2726
class DeviceTableCell: SPTableViewCell {
2827

28+
// MARK: - Init
29+
2930
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
3031
super.init(style: .subtitle, reuseIdentifier: reuseIdentifier)
3132
}
@@ -36,21 +37,33 @@ class DeviceTableCell: SPTableViewCell {
3637

3738
override func commonInit() {
3839
super.commonInit()
39-
textLabel?.font = UIFont.preferredFont(forTextStyle: .title3, weight: .semibold, addPoints: -2).rounded
40+
textLabel?.font = UIFont.preferredFont(forTextStyle: .title3, weight: .medium)
4041
textLabel?.textColor = .label
4142
textLabel?.numberOfLines = .zero
4243
detailTextLabel?.font = UIFont.preferredFont(forTextStyle: .footnote)
4344
detailTextLabel?.textColor = .secondaryLabel
4445
detailTextLabel?.numberOfLines = .zero
46+
higlightStyle = .content
4547
}
4648

4749
// MARK: - Public
4850

4951
func setDevice(_ model: ProfileDeviceModel) {
5052
textLabel?.text = model.name
5153
detailTextLabel?.text = Texts.Profile.Devices.added_date(date: model.addedDate)
52-
let font = UIFont.preferredFont(forTextStyle: .title3, weight: .semibold).rounded
53-
imageView?.image = UIImage.system("iphone", font: font)
54+
let font = UIFont.preferredFont(forTextStyle: .title3, weight: .medium)
55+
56+
imageView?.image = {
57+
switch model.type {
58+
case .phone:
59+
return UIImage.system("iphone", font: font)
60+
case .pad:
61+
return UIImage.system("ipad", font: font)
62+
case .desktop:
63+
return UIImage.system("laptopcomputer", font: font)
64+
}
65+
}()
66+
5467
imageView?.tintColor = .tint
5568
}
5669
}

Sources/SPProfiling/Interface/Profile/ProfileController.swift

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class ProfileController: NativeProfileController {
3030

3131
internal var profileModel: ProfileModel
3232

33+
// MARK: - Init
34+
3335
init() {
3436
if let currentProfile = ProfileModel.currentProfile {
3537
self.profileModel = currentProfile
@@ -47,6 +49,8 @@ class ProfileController: NativeProfileController {
4749
NotificationCenter.default.removeObserver(self)
4850
}
4951

52+
// MARK: - Lifecycle
53+
5054
override func viewDidLoad() {
5155
super.viewDidLoad()
5256

@@ -116,7 +120,20 @@ class ProfileController: NativeProfileController {
116120
id: Item.devices.section_id,
117121
header: SPDiffableTextHeaderFooter(text: Texts.Profile.Devices.header),
118122
footer: SPDiffableTextHeaderFooter(text: Texts.Profile.Devices.footer),
119-
items: profileModel.devices.map({ SPDiffableWrapperItem(id: $0.id, model: $0) })
123+
items: profileModel.devices.prefix(3).map({ SPDiffableWrapperItem(id: $0.id, model: $0) }) + [
124+
NativeDiffableLeftButton(
125+
text: Texts.Profile.Devices.manage_devices,
126+
textColor: .tint,
127+
detail: "\(profileModel.devices.count) Devices",
128+
detailColor: .secondaryLabel,
129+
icon: nil,
130+
accessoryType: .disclosureIndicator,
131+
higlightStyle: .content,
132+
action: { item, indexPath in
133+
guard let navigationController = self.navigationController else { return }
134+
navigationController.pushViewController(DevicesController())
135+
})
136+
]
120137
),
121138
.init(
122139
id: Item.sign_out.section_id,
@@ -163,7 +180,7 @@ class ProfileController: NativeProfileController {
163180
),
164181
.init(
165182
id: Item.delete_account.section_id,
166-
header: nil,
183+
header: SPDiffableTextHeaderFooter(text: Texts.Profile.Actions.Delete.header),
167184
footer: SPDiffableTextHeaderFooter(text: Texts.Profile.Actions.Delete.description),
168185
items: [
169186
NativeDiffableLeftButton(

Sources/SPProfiling/Interface/Profile/Table/ProfileTableViewCell.swift

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,6 @@ open class ProfileTableViewCell: SPTableViewCell {
5858
NotificationCenter.default.removeObserver(self)
5959
}
6060

61-
// MARK: - Ovveride
62-
63-
#warning("change to subbiews")
64-
open override func setHighlighted(_ highlighted: Bool, animated: Bool) {
65-
super.setHighlighted(highlighted, animated: animated)
66-
let higlightContent = (higlightStyle == .content)
67-
if higlightContent {
68-
[avatarView, profileLabelsView, authLabelsView].forEach({ $0?.alpha = highlighted ? 0.6 : 1 })
69-
}
70-
}
71-
7261
// MARK: - Layout
7362

7463
open override func layoutSubviews() {

0 commit comments

Comments
 (0)