Skip to content

Instantly share code, notes, and snippets.

@yuchuanfeng
Created September 5, 2017 03:54
Show Gist options
  • Save yuchuanfeng/c8bedffa001508b8bfd06b275c045514 to your computer and use it in GitHub Desktop.
Save yuchuanfeng/c8bedffa001508b8bfd06b275c045514 to your computer and use it in GitHub Desktop.
enum LivePlatform: Int, RawRepresentable {
case yingke = 1
case douyu
typealias RawValue = (name: String, color: UIColor)
var rawValue: RawValue {
switch self {
case .yingke:
return RawValue("映客", YZJColor_16(0x6ee6d3))
case .douyu:
return RawValue("斗鱼", YZJColor_16(0xff727a))
// default:
// return RawValue("无", YZJColor_16(0xffffff))
}
}
init?(rawValue: LivePlatform.RawValue) {
return nil
}
}
private enum TypeName:String{
case longTerm = "LongTerm"
case targeted = "Targeted"
case allTheTime = "AllTheTime"
case critical = "Critical"
case urgent = "Urgent"
}
enum type:RawRepresentable{
case longTerm,targeted,allTheTime,critical,urgent
static let allTypes:[type] = [.longTerm,.targeted,.allTheTime,.critical,.urgent]
typealias RawValue = (name:String,logo:String)
var rawValue: (name:String, logo:String){
switch self{
case .longTerm:
return (TypeName.longTerm.rawValue,"��")
case .targeted:
return (TypeName.targeted.rawValue,"��")
case .allTheTime:
return (TypeName.allTheTime.rawValue,"��")
case .critical:
return (TypeName.critical.rawValue,"��")
case .urgent:
return (TypeName.urgent.rawValue,"⏰")
}
}
init?(rawValue: type.RawValue) {
switch rawValue.name{
case TypeName.longTerm.rawValue:
self = .longTerm
case TypeName.targeted.rawValue:
self = .targeted
case TypeName.allTheTime.rawValue:
self = .allTheTime
case TypeName.critical.rawValue:
self = .critical
case TypeName.urgent.rawValue:
self = .urgent
default:
return nil
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment