Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Show the pairing screen while the cast device code is being fetched

Manav Rathifb7170f68435
diff --git a/mobile/native/apple/apps/cast/Cast/ViewModels/CastViewModel.swift b/mobile/native/apple/apps/cast/Cast/ViewModels/CastViewModel.swift
index fd30b437ad..e9804d99b3 100644
--- a/mobile/native/apple/apps/cast/Cast/ViewModels/CastViewModel.swift
+++ b/mobile/native/apple/apps/cast/Cast/ViewModels/CastViewModel.swift
@@ -130,9 +130,9 @@ class CastViewModel: ObservableObject {
func startCastSession() {
castSession.setState(.registering)
- currentView = .connecting
+ deviceCode = ""
+ currentView = .pairing
isLoading = true
- statusMessage = "Registering device..."
Task {
do {
@@ -254,8 +254,8 @@ class CastViewModel: ObservableObject {
currentView = .connecting
case .registering:
- currentView = .connecting
- statusMessage = "Registering device..."
+ deviceCode = ""
+ currentView = .pairing
isLoading = true
case .waitingForPairing(let code):
diff --git a/mobile/native/apple/apps/cast/Cast/Views/PairingView.swift b/mobile/native/apple/apps/cast/Cast/Views/PairingView.swift
index 6df845ac79..2d31e48f9c 100644
--- a/mobile/native/apple/apps/cast/Cast/Views/PairingView.swift
+++ b/mobile/native/apple/apps/cast/Cast/Views/PairingView.swift
@@ -43,17 +43,32 @@ struct PairingView: View {
.frame(height: geometry.size.height * 0.05)
// Pairing code box
- Text(deviceCode)
- .font(.system(size: geometry.size.width * 0.09, weight: .heavy, design: .monospaced))
- .tracking(geometry.size.width * 0.015)
- .foregroundColor(.white)
- .scaleEffect(pulseScale)
- .padding(.horizontal, geometry.size.width * 0.04)
- .padding(.vertical, geometry.size.height * 0.025)
- .background(
- RoundedRectangle(cornerRadius: 32)
- .fill(Color(red: 0/255, green: 150/255, blue: 51/255))
- )
+ ZStack {
+ // Reserve the 6-char code footprint so the box doesn't resize when the code arrives
+ Text(deviceCode.isEmpty ? "000000" : deviceCode)
+ .font(.system(size: geometry.size.width * 0.09, weight: .heavy, design: .monospaced))
+ .tracking(geometry.size.width * 0.015)
+ .opacity(0)
+
+ if deviceCode.isEmpty {
+ ProgressView()
+ .progressViewStyle(.circular)
+ .tint(.white)
+ .scaleEffect(1.8)
+ } else {
+ Text(deviceCode)
+ .font(.system(size: geometry.size.width * 0.09, weight: .heavy, design: .monospaced))
+ .tracking(geometry.size.width * 0.015)
+ .foregroundColor(.white)
+ .scaleEffect(pulseScale)
+ }
+ }
+ .padding(.horizontal, geometry.size.width * 0.04)
+ .padding(.vertical, geometry.size.height * 0.025)
+ .background(
+ RoundedRectangle(cornerRadius: 32)
+ .fill(Color(red: 0/255, green: 150/255, blue: 51/255))
+ )
Spacer()
.frame(height: geometry.size.height * 0.08)