From 4d31accad9d6bf901928f4293f29cb62f6f77260 Mon Sep 17 00:00:00 2001 From: Dustin Mierau Date: Wed, 3 Jan 2024 11:04:49 -0800 Subject: [PATCH] Add user icons to iOS app. Bump build number. --- Hotline.xcodeproj/project.pbxproj | 6 +++--- Hotline/Models/Hotline.swift | 13 +++++++------ Hotline/iOS/UsersView.swift | 23 +++++++++++++++++------ Hotline/macOS/SettingsView.swift | 2 +- 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/Hotline.xcodeproj/project.pbxproj b/Hotline.xcodeproj/project.pbxproj index 0f85b662..3d68a6ca 100644 --- a/Hotline.xcodeproj/project.pbxproj +++ b/Hotline.xcodeproj/project.pbxproj @@ -10,7 +10,7 @@ DA0D698D2B1E7CF700C71DF5 /* UsersView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA0D698C2B1E7CF700C71DF5 /* UsersView.swift */; platformFilter = ios; }; DA0D698F2B1E841600C71DF5 /* MessageBoardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA0D698E2B1E841600C71DF5 /* MessageBoardView.swift */; platformFilter = ios; }; DA0D69912B1E894800C71DF5 /* FilesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA0D69902B1E894800C71DF5 /* FilesView.swift */; platformFilter = ios; }; - DA2863D82B37AD1C00A7D050 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA2863D72B37AD1C00A7D050 /* SettingsView.swift */; }; + DA2863D82B37AD1C00A7D050 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA2863D72B37AD1C00A7D050 /* SettingsView.swift */; platformFilters = (macos, ); }; DA2863DA2B37BF6E00A7D050 /* Preferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA2863D92B37BF6E00A7D050 /* Preferences.swift */; }; DA2863DD2B3E8B7000A7D050 /* FilePreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA2863DC2B3E8B7000A7D050 /* FilePreview.swift */; }; DA32CD492B2931640053B98B /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA32CD482B2931640053B98B /* User.swift */; }; @@ -456,7 +456,7 @@ CODE_SIGN_ENTITLEMENTS = Hotline/Hotline.entitlements; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 4; + CURRENT_PROJECT_VERSION = 5; DEVELOPMENT_ASSET_PATHS = "\"Hotline/Preview Content\""; DEVELOPMENT_TEAM = 5AEEV7QB2U; "ENABLE_HARDENED_RUNTIME[sdk=macosx*]" = YES; @@ -495,7 +495,7 @@ CODE_SIGN_ENTITLEMENTS = Hotline/Hotline.entitlements; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 4; + CURRENT_PROJECT_VERSION = 5; DEVELOPMENT_ASSET_PATHS = "\"Hotline/Preview Content\""; DEVELOPMENT_TEAM = 5AEEV7QB2U; "ENABLE_HARDENED_RUNTIME[sdk=macosx*]" = YES; diff --git a/Hotline/Models/Hotline.swift b/Hotline/Models/Hotline.swift index 8fecf0b4..3e3bf26c 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 d1f3318a..5d7a1988 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 19b64aac..54710d1d 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()