diff --git a/AsyncC/Source/Presentation/MainStatusView/Components/AppIconBoxContentView.swift b/AsyncC/Source/Presentation/MainStatusView/Components/AppIconBoxContentView.swift index 7e82e94..9c26369 100644 --- a/AsyncC/Source/Presentation/MainStatusView/Components/AppIconBoxContentView.swift +++ b/AsyncC/Source/Presentation/MainStatusView/Components/AppIconBoxContentView.swift @@ -17,17 +17,63 @@ struct AppIconBoxContentView: View { if viewModel.trackingActive[userID] ?? true || viewModel.checkUser(key: key) { ForEach(viewModel.appTrackings[key] ?? [], id: \.self) { appName in if let nsImage = NSImage(named: appName) { - Image(nsImage: nsImage) - .resizable() - .scaledToFit() - .frame(width: 36, height: 36) - .opacity(viewModel.getOpacity(appName: appName, apps: viewModel.appTrackings[key] ?? [])) + ZStack { + Image(nsImage: nsImage) + .resizable() + .scaledToFit() + .frame(width: 36, height: 36) + .opacity(viewModel.getOpacity(appName: appName, apps: viewModel.appTrackings[key] ?? [])) + .onHover { hovering in + viewModel.isAppIconHover = hovering + } + if viewModel.isAppIconHover { + Text("\(appName)") + .font(.system(size: 9, weight: .medium)) + .foregroundStyle(.black) + .frame(width: 36, height: 36) + .allowsHitTesting(!viewModel.isAppIconHover) + .lineLimit(1) + .minimumScaleFactor(0.5) + .offset(x: 0.5, y: -12.5) + Text("\(appName)") + .font(.system(size: 9, weight: .medium)) + .foregroundStyle(.white) + .frame(width: 36, height: 36) + .allowsHitTesting(!viewModel.isAppIconHover) + .lineLimit(1) + .minimumScaleFactor(0.5) + .offset(y: -13) + } + } } else { - Image("etc") - .resizable() - .scaledToFit() - .frame(width: 36, height: 36) - .opacity(viewModel.getOpacity(appName: appName, apps: viewModel.appTrackings[key] ?? [])) + ZStack { + Image("etc") + .resizable() + .scaledToFit() + .frame(width: 36, height: 36) + .opacity(viewModel.getOpacity(appName: appName, apps: viewModel.appTrackings[key] ?? [])) + .onHover { hovering in + viewModel.isAppIconHover = hovering + } + if viewModel.isAppIconHover { + Text("\(appName)") + .font(.system(size: 9, weight: .medium)) + .foregroundStyle(.black) + .frame(width: 36, height: 36) + .allowsHitTesting(!viewModel.isAppIconHover) + .lineLimit(1) + .minimumScaleFactor(0.5) + .offset(x: 0.5, y: -12.5) + Text("\(appName)") + .font(.system(size: 9, weight: .medium)) + .foregroundStyle(.white) + .frame(width: 36, height: 36) + .allowsHitTesting(!viewModel.isAppIconHover) + .lineLimit(1) + .minimumScaleFactor(0.5) + .offset(y: -13) + } + } } } } else { diff --git a/AsyncC/Source/Presentation/MainStatusView/MainStatusViewModel.swift b/AsyncC/Source/Presentation/MainStatusView/MainStatusViewModel.swift index 73bfa88..77a5651 100644 --- a/AsyncC/Source/Presentation/MainStatusView/MainStatusViewModel.swift +++ b/AsyncC/Source/Presentation/MainStatusView/MainStatusViewModel.swift @@ -45,6 +45,7 @@ class MainStatusViewModel: ObservableObject { @Published var userNameAndID: [String: String] = [:] // [userName: userID] @Published var isSelectedButton: Bool = false @Published var buttonStates: [String: Bool] = [:] + @Published var isAppIconHover: Bool = false init(teamManagingUseCase: TeamManagingUseCase, appTrackingUseCase: AppTrackingUseCase, syncUseCase: SyncUseCase, accountUseCase: AccountManagingUseCase) { self.teamManagingUseCase = teamManagingUseCase