diff options
| author | Dustin Mierau <dustin@mierau.me> | 2024-01-03 11:04:49 -0800 |
|---|---|---|
| committer | Dustin Mierau <dustin@mierau.me> | 2024-01-03 11:04:49 -0800 |
| commit | 4d31accad9d6bf901928f4293f29cb62f6f77260 (patch) | |
| tree | d0d181f0c3f3f1c006c633f76da03bddd7ffdfe9 /Hotline | |
| parent | f6d9799b80d59e4f8abf5464f358a867137102e6 (diff) | |
Add user icons to iOS app. Bump build number.1.0beta5
Diffstat (limited to 'Hotline')
| -rw-r--r-- | Hotline/Models/Hotline.swift | 13 | ||||
| -rw-r--r-- | Hotline/iOS/UsersView.swift | 23 | ||||
| -rw-r--r-- | Hotline/macOS/SettingsView.swift | 2 |
3 files changed, 25 insertions, 13 deletions
diff --git a/Hotline/Models/Hotline.swift b/Hotline/Models/Hotline.swift index 8fecf0b..3e3bf26 100644 --- a/Hotline/Models/Hotline.swift +++ b/Hotline/Models/Hotline.swift @@ -6,16 +6,18 @@ import SwiftUI #if os(macOS) static func getClassicIcon(_ index: Int) -> NSImage? { - if let icon = NSImage(named: "Classic/\(index)") { - return icon - } - return nil + return NSImage(named: "Classic/\(index)") + } + #elseif os(iOS) + static func getClassicIcon(_ index: Int) -> UIImage? { + return UIImage(named: "Classic/\(index)") } + #endif // The icon ordering here was painsakenly pulled manually // from the original Hotline client to display the classic icons // in the same order as the original client. - static let classicIcons: [Int] = [ + static let classicIconSet: [Int] = [ 141, 149, 150, 151, 172, 184, 204, 2013, 2036, 2037, 2055, 2400, 2505, 2534, 2578, 2592, 4004, 4015, 4022, 4104, 4131, @@ -98,7 +100,6 @@ import SwiftUI 6017, 6018, 6023, 6025, 6026, 6027, 6028, 6029, 6030, 6031, 6032, 6033, 6034, 6035 ] - #endif static let defaultIconSet: [Int: String] = [ 414: "🙂", diff --git a/Hotline/iOS/UsersView.swift b/Hotline/iOS/UsersView.swift index d1f3318..5d7a198 100644 --- a/Hotline/iOS/UsersView.swift +++ b/Hotline/iOS/UsersView.swift @@ -6,12 +6,23 @@ struct UsersView: View { var body: some View { NavigationStack { List(model.users) { u in - Text("🤖 \(u.name)") - .fontWeight(.medium) - .lineLimit(1) - .truncationMode(.tail) - .foregroundStyle(u.status.contains(.admin) ? Color(hex: 0xE10000) : Color.accentColor) - .opacity(u.status.contains(.idle) ? 0.5 : 1.0) + HStack(alignment: .center, spacing: 4) { + HStack(alignment: .center, spacing: 0) { + if let iconImage = Hotline.getClassicIcon(Int(u.iconID)) { + Image(uiImage: iconImage) + .interpolation(.none) + .frame(width: 32, height: 16, alignment: .center) + .scaledToFit() + } + } + .frame(width: 32) + Text(u.name) + .fontWeight(.medium) + .lineLimit(1) + .truncationMode(.tail) + .foregroundStyle(u.isAdmin ? Color(hex: 0xE10000) : Color.accentColor) + } + .opacity(u.isIdle ? 0.5 : 1.0) } .scrollBounceBehavior(.basedOnSize) .navigationBarTitleDisplayMode(.inline) diff --git a/Hotline/macOS/SettingsView.swift b/Hotline/macOS/SettingsView.swift index 19b64aa..54710d1 100644 --- a/Hotline/macOS/SettingsView.swift +++ b/Hotline/macOS/SettingsView.swift @@ -47,7 +47,7 @@ struct IconSettingsView: View { GridItem(.fixed(4+64+4)), GridItem(.fixed(4+64+4)) ], spacing: 0) { - ForEach(Hotline.classicIcons, id: \.self) { iconID in + ForEach(Hotline.classicIconSet, id: \.self) { iconID in HStack { Image("Classic/\(iconID)") .resizable() |