Skip to content

Commit

Permalink
Updated devices cell and profile screen. Updated higlight cells.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanvorobei committed Feb 17, 2022
1 parent 839ff6e commit adafddc
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/ivanvorobei/SPAlert", .upToNextMajor(from: "4.2.0")),
.package(url: "https://github.com/ivanvorobei/NativeUIKit", .upToNextMajor(from: "1.3.9")),
.package(url: "https://github.com/ivanvorobei/NativeUIKit", .upToNextMajor(from: "1.4.0")),
.package(url: "https://github.com/ivanvorobei/SPFirebase", .upToNextMajor(from: "1.0.6")),
.package(url: "https://github.com/sparrowcode/SPSafeSymbols", .upToNextMajor(from: "1.0.5")),
.package(url: "https://github.com/kean/Nuke", .upToNextMajor(from: "10.7.1"))
Expand Down
3 changes: 3 additions & 0 deletions Sources/SPProfiling/Data/Texts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ enum Texts {
static var header: String { NSLocalizedString("profile devices header", bundle: .module, comment: "") }
static var footer: String { NSLocalizedString("profile devices footer", bundle: .module, comment: "") }

static var manage_devices: String { NSLocalizedString("profile devices manage devices", bundle: .module, comment: "") }

static func added_date(date: Date) -> String {
let localisedDate = date.formatted(dateStyle: .medium)
return String(format: NSLocalizedString("profile devices added date", bundle: .module, comment: ""), localisedDate)
Expand Down Expand Up @@ -109,6 +111,7 @@ enum Texts {
enum Delete {

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

enum Confirm {
Expand Down
21 changes: 17 additions & 4 deletions Sources/SPProfiling/Interface/Devices/DeviceTableCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.


import UIKit
import SparrowKit
import SPDiffable

class DeviceTableCell: SPTableViewCell {

// MARK: - Init

public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: .subtitle, reuseIdentifier: reuseIdentifier)
}
Expand All @@ -36,21 +37,33 @@ class DeviceTableCell: SPTableViewCell {

override func commonInit() {
super.commonInit()
textLabel?.font = UIFont.preferredFont(forTextStyle: .title3, weight: .semibold, addPoints: -2).rounded
textLabel?.font = UIFont.preferredFont(forTextStyle: .title3, weight: .medium)
textLabel?.textColor = .label
textLabel?.numberOfLines = .zero
detailTextLabel?.font = UIFont.preferredFont(forTextStyle: .footnote)
detailTextLabel?.textColor = .secondaryLabel
detailTextLabel?.numberOfLines = .zero
higlightStyle = .content
}

// MARK: - Public

func setDevice(_ model: ProfileDeviceModel) {
textLabel?.text = model.name
detailTextLabel?.text = Texts.Profile.Devices.added_date(date: model.addedDate)
let font = UIFont.preferredFont(forTextStyle: .title3, weight: .semibold).rounded
imageView?.image = UIImage.system("iphone", font: font)
let font = UIFont.preferredFont(forTextStyle: .title3, weight: .medium)

imageView?.image = {
switch model.type {
case .phone:
return UIImage.system("iphone", font: font)
case .pad:
return UIImage.system("ipad", font: font)
case .desktop:
return UIImage.system("laptopcomputer", font: font)
}
}()

imageView?.tintColor = .tint
}
}
21 changes: 19 additions & 2 deletions Sources/SPProfiling/Interface/Profile/ProfileController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class ProfileController: NativeProfileController {

internal var profileModel: ProfileModel

// MARK: - Init

init() {
if let currentProfile = ProfileModel.currentProfile {
self.profileModel = currentProfile
Expand All @@ -47,6 +49,8 @@ class ProfileController: NativeProfileController {
NotificationCenter.default.removeObserver(self)
}

// MARK: - Lifecycle

override func viewDidLoad() {
super.viewDidLoad()

Expand Down Expand Up @@ -116,7 +120,20 @@ class ProfileController: NativeProfileController {
id: Item.devices.section_id,
header: SPDiffableTextHeaderFooter(text: Texts.Profile.Devices.header),
footer: SPDiffableTextHeaderFooter(text: Texts.Profile.Devices.footer),
items: profileModel.devices.map({ SPDiffableWrapperItem(id: $0.id, model: $0) })
items: profileModel.devices.prefix(3).map({ SPDiffableWrapperItem(id: $0.id, model: $0) }) + [
NativeDiffableLeftButton(
text: Texts.Profile.Devices.manage_devices,
textColor: .tint,
detail: "\(profileModel.devices.count) Devices",
detailColor: .secondaryLabel,
icon: nil,
accessoryType: .disclosureIndicator,
higlightStyle: .content,
action: { item, indexPath in
guard let navigationController = self.navigationController else { return }
navigationController.pushViewController(DevicesController())
})
]
),
.init(
id: Item.sign_out.section_id,
Expand Down Expand Up @@ -163,7 +180,7 @@ class ProfileController: NativeProfileController {
),
.init(
id: Item.delete_account.section_id,
header: nil,
header: SPDiffableTextHeaderFooter(text: Texts.Profile.Actions.Delete.header),
footer: SPDiffableTextHeaderFooter(text: Texts.Profile.Actions.Delete.description),
items: [
NativeDiffableLeftButton(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,6 @@ open class ProfileTableViewCell: SPTableViewCell {
NotificationCenter.default.removeObserver(self)
}

// MARK: - Ovveride

#warning("change to subbiews")
open override func setHighlighted(_ highlighted: Bool, animated: Bool) {
super.setHighlighted(highlighted, animated: animated)
let higlightContent = (higlightStyle == .content)
if higlightContent {
[avatarView, profileLabelsView, authLabelsView].forEach({ $0?.alpha = highlighted ? 0.6 : 1 })
}
}

// MARK: - Layout

open override func layoutSubviews() {
Expand Down

0 comments on commit adafddc

Please sign in to comment.