mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-05 08:25:32 +00:00
45 lines
1.3 KiB
Swift
45 lines
1.3 KiB
Swift
//
|
|
// KeyboardNameTableViewCell.swift
|
|
// KeymanEngine
|
|
//
|
|
// Created by Gabriel Wong on 2017-09-12.
|
|
// Copyright © 2017 SIL International. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
private let cellSelectedTag = 4576 // arbitrary number
|
|
|
|
class KeyboardNameTableViewCell: UITableViewCell, UIAlertViewDelegate {
|
|
var indexPath: IndexPath?
|
|
|
|
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
|
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
|
indentationLevel = 0
|
|
}
|
|
|
|
required init?(coder aDecoder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
|
|
func setInstallState(_ state: KeymanPackage.InstallationState, selected isSelected: Bool,
|
|
defaultAccessoryType accessoryType: UITableViewCell.AccessoryType) {
|
|
if state != .downloading {
|
|
accessoryView = nil
|
|
}
|
|
self.accessoryType = accessoryType
|
|
|
|
let selectedView = viewWithTag(cellSelectedTag)
|
|
if isSelected {
|
|
if selectedView == nil {
|
|
let view = UIView(frame: CGRect(x: 0, y: 0, width: bounds.width, height: bounds.height))
|
|
view.tag = cellSelectedTag
|
|
view.backgroundColor = UIColor.green
|
|
view.autoresizingMask = UIView.AutoresizingMask.flexibleWidth.union(.flexibleHeight)
|
|
addSubview(view)
|
|
}
|
|
} else {
|
|
selectedView?.removeFromSuperview()
|
|
}
|
|
}
|
|
}
|