From ab4072e4b51ee4659e2663cb5b7628a3f25d3eab Mon Sep 17 00:00:00 2001 From: Hiroshi Horie <548776+hiroshihorie@users.noreply.github.com> Date: Fri, 25 Sep 2026 22:24:00 +0700 Subject: [PATCH] Replace soft-deprecated SwiftUI modifiers foregroundColor to foregroundStyle, cornerRadius to clipShape, autocapitalization to textInputAutocapitalization, and the Alert-based alert to the title/actions/message form. Optional color cases stay on foregroundColor since foregroundStyle has no nil equivalent. --- Multiplatform/Views/AudioControlsPanel.swift | 4 +- Multiplatform/Views/ConnectView.swift | 7 ++-- Multiplatform/Views/MessagesPanel.swift | 4 +- Multiplatform/Views/ParticipantView.swift | 42 ++++++++++---------- Multiplatform/Views/RoomContextView.swift | 2 +- Multiplatform/Views/RoomView.swift | 18 ++++----- Multiplatform/Views/Shared/LKButton.swift | 2 +- Multiplatform/Views/Shared/LKTextField.swift | 2 +- 8 files changed, 41 insertions(+), 40 deletions(-) diff --git a/Multiplatform/Views/AudioControlsPanel.swift b/Multiplatform/Views/AudioControlsPanel.swift index 02e1073..bc12d53 100644 --- a/Multiplatform/Views/AudioControlsPanel.swift +++ b/Multiplatform/Views/AudioControlsPanel.swift @@ -92,7 +92,7 @@ struct AudioControlsPanel: View { Toggle("Always prepared", isOn: $appCtx.isRecordingAlwaysPreparedMode) Text("Keeps mic pipeline warmed for low-latency publish.") .font(.caption) - .foregroundColor(.secondary) + .foregroundStyle(.secondary) } Section(header: Text("Mic mute mode")) { @@ -106,7 +106,7 @@ struct AudioControlsPanel: View { } Text(micMuteModeDescription(for: appCtx.micMuteMode)) .font(.caption) - .foregroundColor(.secondary) + .foregroundStyle(.secondary) } Section(header: Text("Audio Ducking")) { diff --git a/Multiplatform/Views/ConnectView.swift b/Multiplatform/Views/ConnectView.swift index f27e612..71e96f6 100644 --- a/Multiplatform/Views/ConnectView.swift +++ b/Multiplatform/Views/ConnectView.swift @@ -161,9 +161,10 @@ struct ConnectView: View { #if os(macOS) .frame(minWidth: 500, minHeight: 500) #endif - .alert(isPresented: $roomCtx.shouldShowDisconnectReason) { - Alert(title: Text("Disconnected"), - message: Text("Reason: " + String(describing: roomCtx.latestError))) + .alert("Disconnected", isPresented: $roomCtx.shouldShowDisconnectReason) { + Button("OK", role: .cancel) {} + } message: { + Text("Reason: " + String(describing: roomCtx.latestError)) } } } diff --git a/Multiplatform/Views/MessagesPanel.swift b/Multiplatform/Views/MessagesPanel.swift index 178abea..463b26e 100644 --- a/Multiplatform/Views/MessagesPanel.swift +++ b/Multiplatform/Views/MessagesPanel.swift @@ -77,8 +77,8 @@ struct MessagesPanel: View { Text(message.text) .padding(8) .background(isMe ? Color.lkRed : Color.lkGray3) - .foregroundColor(Color.white) - .cornerRadius(18) + .foregroundStyle(Color.white) + .clipShape(RoundedRectangle(cornerRadius: 18)) if !isMe { Spacer() diff --git a/Multiplatform/Views/ParticipantView.swift b/Multiplatform/Views/ParticipantView.swift index 969f986..5373ea5 100644 --- a/Multiplatform/Views/ParticipantView.swift +++ b/Multiplatform/Views/ParticipantView.swift @@ -38,7 +38,7 @@ struct ParticipantView: View { Image(systemSymbol: systemSymbol) .resizable() .aspectRatio(contentMode: .fit) - .foregroundColor(Color.lkGray2) + .foregroundStyle(Color.lkGray2) .frame(width: min(geometry.size.width, geometry.size.height) * 0.3) .frame( maxWidth: .infinity, @@ -121,7 +121,7 @@ struct ParticipantView: View { .background(Color.black) .aspectRatio(contentMode: .fit) .frame(width: min(geometry.size.width, geometry.size.height) * 0.3) - .cornerRadius(8) + .clipShape(RoundedRectangle(cornerRadius: 8)) .padding() } @@ -151,10 +151,10 @@ struct ParticipantView: View { } label: { if case .subscribed = remotePub.subscriptionState { Image(systemSymbol: .videoFill) - .foregroundColor(Color.green) + .foregroundStyle(Color.green) } else if case .notAllowed = remotePub.subscriptionState { Image(systemSymbol: .exclamationmarkCircle) - .foregroundColor(Color.red) + .foregroundStyle(Color.red) } else { Image(systemSymbol: .videoSlashFill) } @@ -169,12 +169,12 @@ struct ParticipantView: View { } else { // local Image(systemSymbol: .videoFill) - .foregroundColor(Color.green) + .foregroundStyle(Color.green) } } else { Image(systemSymbol: .videoSlashFill) - .foregroundColor(Color.white) + .foregroundStyle(Color.white) } if let publication = participant.firstAudioPublication, @@ -195,10 +195,10 @@ struct ParticipantView: View { } label: { if case .subscribed = remotePub.subscriptionState { Image(systemSymbol: .micFill) - .foregroundColor(Color.orange) + .foregroundStyle(Color.orange) } else if case .notAllowed = remotePub.subscriptionState { Image(systemSymbol: .exclamationmarkCircle) - .foregroundColor(Color.red) + .foregroundStyle(Color.red) } else { Image(systemSymbol: .micSlashFill) } @@ -213,12 +213,12 @@ struct ParticipantView: View { } else { // local Image(systemSymbol: .micFill) - .foregroundColor(Color.orange) + .foregroundStyle(Color.orange) } } else { Image(systemSymbol: .micSlashFill) - .foregroundColor(Color.white) + .foregroundStyle(Color.white) } #if !os(tvOS) @@ -231,21 +231,21 @@ struct ParticipantView: View { if participant.connectionQuality == .excellent { Image(systemSymbol: .wifi) - .foregroundColor(.green) + .foregroundStyle(.green) } else if participant.connectionQuality == .good { Image(systemSymbol: .wifi) - .foregroundColor(Color.orange) + .foregroundStyle(Color.orange) } else if participant.connectionQuality == .poor { Image(systemSymbol: .wifiExclamationmark) - .foregroundColor(Color.red) + .foregroundStyle(Color.red) } if participant.firstTrackEncryptionType == .none { Image(systemSymbol: .lockOpenFill) - .foregroundColor(.red) + .foregroundStyle(.red) } else { Image(systemSymbol: .lockFill) - .foregroundColor(.green) + .foregroundStyle(.green) } }.padding(5) @@ -253,7 +253,7 @@ struct ParticipantView: View { .background(Color.black.opacity(0.5)) } } - .cornerRadius(8) + .clipShape(RoundedRectangle(cornerRadius: 8)) // Glow the border when the participant is speaking .overlay( participant.isSpeaking ? @@ -293,7 +293,7 @@ struct RemoteAudioVolumeControl: View { isSliderPresented.toggle() } label: { Image(systemSymbol: volumeSymbol) - .foregroundColor(isSliderPresented ? Color.orange : .white) + .foregroundStyle(isSliderPresented ? Color.orange : .white) } .buttonStyle(.plain) .accessibilityLabel("Remote audio volume") @@ -308,7 +308,7 @@ struct RemoteAudioVolumeControl: View { VStack(alignment: .leading, spacing: 10) { HStack(spacing: 8) { Image(systemSymbol: volumeSymbol) - .foregroundColor(Color.orange) + .foregroundStyle(Color.orange) Text("Volume") .font(.headline) @@ -317,7 +317,7 @@ struct RemoteAudioVolumeControl: View { Text(volumePercentageText) .font(.system(size: 12, weight: .semibold, design: .monospaced)) - .foregroundColor(.secondary) + .foregroundStyle(.secondary) } Slider(value: volumeBinding, in: 0.0 ... Self.maxVolume) @@ -445,10 +445,10 @@ struct StatsView: View { } } .font(.system(size: 10)) - .foregroundColor(Color.white) + .foregroundStyle(Color.white) .padding(5) .background(Color.black.opacity(0.5)) - .cornerRadius(8) + .clipShape(RoundedRectangle(cornerRadius: 8)) } } } diff --git a/Multiplatform/Views/RoomContextView.swift b/Multiplatform/Views/RoomContextView.swift index 906751f..e514ae8 100644 --- a/Multiplatform/Views/RoomContextView.swift +++ b/Multiplatform/Views/RoomContextView.swift @@ -25,7 +25,7 @@ struct RoomContextView: View { RoomSwitchView() .environmentObject(roomCtx) .environmentObject(roomCtx.room) - .foregroundColor(Color.white) + .foregroundStyle(Color.white) .onDisappear { print("\(String(describing: type(of: self))) onDisappear") Task { diff --git a/Multiplatform/Views/RoomView.swift b/Multiplatform/Views/RoomView.swift index 5c2d945..10cc5c4 100644 --- a/Multiplatform/Views/RoomView.swift +++ b/Multiplatform/Views/RoomView.swift @@ -92,7 +92,7 @@ struct RoomView: View { func messagesPanel(geometry: GeometryProxy) -> some View { MessagesPanel() .background(Color.lkGray1) - .cornerRadius(8) + .clipShape(RoundedRectangle(cornerRadius: 8)) .frame( minWidth: 0, maxWidth: geometry.isTall ? .infinity : 320 @@ -103,7 +103,7 @@ struct RoomView: View { func audioControlsPanel(geometry: GeometryProxy) -> some View { AudioControlsPanel() .background(Color.lkGray1) - .cornerRadius(8) + .clipShape(RoundedRectangle(cornerRadius: 8)) .frame( minWidth: 0, maxWidth: geometry.isTall ? .infinity : 320 @@ -124,14 +124,14 @@ struct RoomView: View { if showConnectionTime { Text("Connected (\([room.serverRegion, room.serverNodeId, "\(String(describing: room.connectSpan?.total().rounded(to: 2)))s"].compactMap { $0 }.joined(separator: ", ")))") .multilineTextAlignment(.center) - .foregroundColor(.white) + .foregroundStyle(.white) .padding() } if case .connecting = room.connectionState { Text("Re-connecting...") .multilineTextAlignment(.center) - .foregroundColor(.white) + .foregroundStyle(.white) .padding() } @@ -149,11 +149,11 @@ struct RoomView: View { Text("SELECTED") .font(.system(size: 10)) .fontWeight(.bold) - .foregroundColor(Color.white) + .foregroundStyle(Color.white) .padding(.horizontal, 5) .padding(.vertical, 2) .background(Color.lkRed.opacity(0.7)) - .cornerRadius(8) + .clipShape(RoundedRectangle(cornerRadius: 8)) .padding(.vertical, 35) .padding(.horizontal, 10) } @@ -194,11 +194,11 @@ struct RoomView: View { Text("Your mic is muted") .font(.headline) } - .foregroundColor(.white) + .foregroundStyle(.white) .padding(.horizontal, 22) .padding(.vertical, 16) .background(Color.black.opacity(0.85)) - .cornerRadius(14) + .clipShape(RoundedRectangle(cornerRadius: 14)) .transition(.opacity) .allowsHitTesting(false) } @@ -399,7 +399,7 @@ struct RoomView: View { label: { Image(systemSymbol: .rectangleFillOnRectangleFill) .renderingMode(isScreenShareEnabled ? .original : .template) - .foregroundColor(isScreenShareEnabled ? Color.green : Color.white) + .foregroundStyle(isScreenShareEnabled ? Color.green : Color.white) }).popover(isPresented: $screenPickerPresented) { ScreenShareSourcePickerView { source in Task { diff --git a/Multiplatform/Views/Shared/LKButton.swift b/Multiplatform/Views/Shared/LKButton.swift index caffef0..0f3b3a3 100644 --- a/Multiplatform/Views/Shared/LKButton.swift +++ b/Multiplatform/Views/Shared/LKButton.swift @@ -30,6 +30,6 @@ struct LKButton: View { .padding(.vertical, 10) }) .background(Color.lkRed) - .cornerRadius(8) + .clipShape(RoundedRectangle(cornerRadius: 8)) } } diff --git a/Multiplatform/Views/Shared/LKTextField.swift b/Multiplatform/Views/Shared/LKTextField.swift index e50e5b2..99dbc0a 100644 --- a/Multiplatform/Views/Shared/LKTextField.swift +++ b/Multiplatform/Views/Shared/LKTextField.swift @@ -47,7 +47,7 @@ struct LKTextField: View { .strokeBorder(Color.white.opacity(0.3), style: StrokeStyle(lineWidth: 1.0))) #if os(iOS) - .autocapitalization(.none) + .textInputAutocapitalization(.never) .keyboardType(type.toiOSType()) #endif