diff --git a/APIExample_RTM2x/Examples/Advanced/AudioCallKit/AudioCallKitView.swift b/APIExample_RTM2x/Examples/Advanced/AudioCallKit/AudioCallKitView.swift index 92cd8b0..b85bee3 100644 --- a/APIExample_RTM2x/Examples/Advanced/AudioCallKit/AudioCallKitView.swift +++ b/APIExample_RTM2x/Examples/Advanced/AudioCallKit/AudioCallKitView.swift @@ -100,8 +100,7 @@ struct AudioCallKitView: View { } .navigationDestination(for: String.self) { value in if value == CallState.incall.rawValue { - InCallAudioView(path: $path) - .environmentObject(agoraVM) + InCallAudioView(agoraVM: agoraVM, path: $path) } } diff --git a/APIExample_RTM2x/Examples/Advanced/AudioCallKit/InCallAudioView.swift b/APIExample_RTM2x/Examples/Advanced/AudioCallKit/InCallAudioView.swift index 55e5b93..8979bac 100644 --- a/APIExample_RTM2x/Examples/Advanced/AudioCallKit/InCallAudioView.swift +++ b/APIExample_RTM2x/Examples/Advanced/AudioCallKit/InCallAudioView.swift @@ -9,8 +9,7 @@ import SwiftUI import Foundation struct InCallAudioView: View { -// @Environment(\.presentationMode) var mode: Binding // For the custom back button - @EnvironmentObject var agoraVM: AudioCallKitViewModel + @ObservedObject var agoraVM: AudioCallKitViewModel @Binding var path: NavigationPath let columns: [GridItem] = [ @@ -129,6 +128,5 @@ struct InCallAudioView: View { } #Preview { - InCallAudioView(path: .constant(NavigationPath())) - .environmentObject(AudioCallKitViewModel()) + InCallAudioView(agoraVM: AudioCallKitViewModel(), path: .constant(NavigationPath())) } diff --git a/APIExample_RTM2x/Examples/Advanced/Minigame-Go/GoBoardView.swift b/APIExample_RTM2x/Examples/Advanced/Minigame-Go/GoBoardView.swift index 50be45f..f50d40d 100644 --- a/APIExample_RTM2x/Examples/Advanced/Minigame-Go/GoBoardView.swift +++ b/APIExample_RTM2x/Examples/Advanced/Minigame-Go/GoBoardView.swift @@ -8,7 +8,7 @@ import SwiftUI struct GoBoardView: View { - @EnvironmentObject var agoraRTMVM: MiniGoViewModel + @ObservedObject var agoraRTMVM: MiniGoViewModel @State var cellSize : CGFloat = 30 @State var virtualIndex = 0 var virtualgifts : [String] = [ @@ -370,8 +370,7 @@ struct GoBoardView: View { } #Preview { - GoBoardView() - .environmentObject(MiniGoViewModel()) + GoBoardView(agoraRTMVM: MiniGoViewModel()) } extension AnyTransition { diff --git a/APIExample_RTM2x/Examples/Advanced/Minigame-Go/MiniGoView.swift b/APIExample_RTM2x/Examples/Advanced/Minigame-Go/MiniGoView.swift index 9a168d7..64437d9 100644 --- a/APIExample_RTM2x/Examples/Advanced/Minigame-Go/MiniGoView.swift +++ b/APIExample_RTM2x/Examples/Advanced/Minigame-Go/MiniGoView.swift @@ -50,8 +50,7 @@ struct MiniGoView: View { if agoraRTMVM.isLoggedIn { VStack { Spacer() - GoBoardView() - .environmentObject(agoraRTMVM) + GoBoardView(agoraRTMVM: agoraRTMVM) Spacer() Text("Logged in as \(agoraRTMVM.userID)") .font(.caption) diff --git a/APIExample_RTM2x/Examples/Advanced/Minigame-TicTacToe/MiniTicTacToeView.swift b/APIExample_RTM2x/Examples/Advanced/Minigame-TicTacToe/MiniTicTacToeView.swift index 6cf9a96..3521ad3 100644 --- a/APIExample_RTM2x/Examples/Advanced/Minigame-TicTacToe/MiniTicTacToeView.swift +++ b/APIExample_RTM2x/Examples/Advanced/Minigame-TicTacToe/MiniTicTacToeView.swift @@ -48,8 +48,7 @@ struct MiniTicTacToeView: View { // MARK: Display TicTacToe Board if agoraRTMVM.isLoggedIn { - TicTacToeBoardView() - .environmentObject(agoraRTMVM) + TicTacToeBoardView(agoraRTMVM: agoraRTMVM) } // MARK: SHOW CUSTOM ALERT diff --git a/APIExample_RTM2x/Examples/Advanced/Minigame-TicTacToe/TicTacToeBoardView.swift b/APIExample_RTM2x/Examples/Advanced/Minigame-TicTacToe/TicTacToeBoardView.swift index 4746d50..d8da772 100644 --- a/APIExample_RTM2x/Examples/Advanced/Minigame-TicTacToe/TicTacToeBoardView.swift +++ b/APIExample_RTM2x/Examples/Advanced/Minigame-TicTacToe/TicTacToeBoardView.swift @@ -9,7 +9,7 @@ import SwiftUI struct TicTacToeBoardView: View { - @EnvironmentObject var agoraRTMVM: MiniTicTacToeViewModel + @ObservedObject var agoraRTMVM: MiniTicTacToeViewModel @State var virtualIndex = 0 var virtualgifts : [String] = [ "flower1", "flowers2", "present", "fireworks1" @@ -298,6 +298,5 @@ struct TicTacToeBoardView: View { #Preview { - TicTacToeBoardView() - .environmentObject(MiniTicTacToeViewModel()) + TicTacToeBoardView(agoraRTMVM: MiniTicTacToeViewModel()) } diff --git a/APIExample_RTM2x/Examples/Basic/ChannelMessaging/ChannelMessagingView.swift b/APIExample_RTM2x/Examples/Basic/ChannelMessaging/ChannelMessagingView.swift index 9bc33c0..c8bf165 100644 --- a/APIExample_RTM2x/Examples/Basic/ChannelMessaging/ChannelMessagingView.swift +++ b/APIExample_RTM2x/Examples/Basic/ChannelMessaging/ChannelMessagingView.swift @@ -150,8 +150,7 @@ struct ChannelMessagingView: View { .navigationDestination(for: CustomChildNavType.self) { value in switch value { case .ChannelMessagingDetailedView(let selectedChannel): - ChannelMessagingDetailedView(selectedChannel: selectedChannel, path: $path) - .environmentObject(agoraRTMVM) + ChannelMessagingDetailedView(agoraRTMVM: agoraRTMVM, selectedChannel: selectedChannel, path: $path) default: Text("ChannelMessagingView Not found") } @@ -166,7 +165,7 @@ struct ChannelMessagingView: View { // MARK: TO SHOW THE LIST OF MESSAGES OF SPECIFIED CHANNEL struct ChannelMessagingDetailedView: View { - @EnvironmentObject var agoraRTMVM: ChannelMessagingViewModel + @ObservedObject var agoraRTMVM: ChannelMessagingViewModel @FocusState private var keyboardIsFocused: Bool @State var selectedChannel: String = "" @State var newMessage: String = "" @@ -299,9 +298,5 @@ struct ChannelMessagingDetailedView: View { #Preview { - ChannelMessagingView(path: .constant(NavigationPath())) - .environmentObject(ChannelMessagingViewModel()) - -// ChannelMessagingDetailedView(path: .constant(NavigationPath())) -// .environmentObject(ChannelMessagingViewModel()) + ChannelMessagingView(agoraRTMVM: ChannelMessagingViewModel() ,path: .constant(NavigationPath())) } diff --git a/APIExample_RTM2x/Examples/Basic/P2PMessaging/P2PMessagingView.swift b/APIExample_RTM2x/Examples/Basic/P2PMessaging/P2PMessagingView.swift index 93658ee..6c8eac2 100644 --- a/APIExample_RTM2x/Examples/Basic/P2PMessaging/P2PMessagingView.swift +++ b/APIExample_RTM2x/Examples/Basic/P2PMessaging/P2PMessagingView.swift @@ -138,8 +138,7 @@ struct P2PMessagingView: View { .navigationDestination(for: CustomChildNavType.self) { value in switch value { case .P2PMessagingDetailedView(let selectedUser): - P2PMessagingDetailedView(selectedUser: selectedUser, path: $path) - .environmentObject(agoraRTMVM) + P2PMessagingDetailedView(agoraRTMVM: agoraRTMVM, selectedUser: selectedUser, path: $path) default: Text("ChannelMessagingView Not found") } @@ -152,14 +151,12 @@ struct P2PMessagingView: View { #Preview { P2PMessagingView(path: .constant(NavigationPath())) - .environmentObject(P2PMessagingViewModel()) - } // MARK: TO SHOW THE LIST OF MESSAGES OF SPECIFIED CHANNEL struct P2PMessagingDetailedView: View { - @EnvironmentObject var agoraRTMVM: P2PMessagingViewModel + @ObservedObject var agoraRTMVM: P2PMessagingViewModel @FocusState private var keyboardIsFocused: Bool @State var selectedUser: String = "" @State var message: String = "" diff --git a/APIExample_RTM2x/Examples/Basic/StreamMessaging/StreamMessagingView.swift b/APIExample_RTM2x/Examples/Basic/StreamMessaging/StreamMessagingView.swift index 4d692ba..af47c94 100644 --- a/APIExample_RTM2x/Examples/Basic/StreamMessaging/StreamMessagingView.swift +++ b/APIExample_RTM2x/Examples/Basic/StreamMessaging/StreamMessagingView.swift @@ -137,8 +137,7 @@ struct StreamMessagingView: View { .navigationDestination(for: CustomChildNavType.self) { value in switch value { case .StreamMessagingDetailedView(let selectedTopic): - StreamMessagingDetailedView(selectedTopic: selectedTopic, path: $path) - .environmentObject(agoraRTMVM) + StreamMessagingDetailedView(agoraRTMVM: agoraRTMVM, selectedTopic: selectedTopic, path: $path) default: Text("ChannelMessagingView Not found") } @@ -153,7 +152,7 @@ struct StreamMessagingView: View { // MARK: TO SHOW THE LIST OF MESSAGES OF SPECIFIED CHANNEL struct StreamMessagingDetailedView: View { - @EnvironmentObject var agoraRTMVM: StreamMessagingViewModel + @ObservedObject var agoraRTMVM: StreamMessagingViewModel @FocusState private var keyboardIsFocused: Bool @State var selectedTopic: String = "" @State var message: String = "" @@ -219,7 +218,6 @@ struct StreamMessagingDetailedView: View { #Preview { - StreamMessagingDetailedView(path: .constant(NavigationPath())) - .environmentObject(StreamMessagingViewModel()) + StreamMessagingDetailedView(agoraRTMVM: StreamMessagingViewModel(), path: .constant(NavigationPath())) } diff --git a/APIExample_RTM2x/Examples/LoginRTMView.swift b/APIExample_RTM2x/Examples/LoginRTMView.swift index 2e8bcb9..c7eeda5 100644 --- a/APIExample_RTM2x/Examples/LoginRTMView.swift +++ b/APIExample_RTM2x/Examples/LoginRTMView.swift @@ -9,7 +9,6 @@ import SwiftUI struct LoginRTMView: View { - // @EnvironmentObject var agoraRTMVM: AgoraRTMViewModel @Binding var isLoading: Bool @Binding var userID: String @Binding var token: String diff --git a/APIExample_RTM2x/TestingView.swift b/APIExample_RTM2x/TestingView.swift index 64a50ab..ffd481e 100644 --- a/APIExample_RTM2x/TestingView.swift +++ b/APIExample_RTM2x/TestingView.swift @@ -9,28 +9,22 @@ import SwiftUI import AVFoundation struct TestingView: View { - let items = ["Item 1", "Item 2", "Item 3", "Item 4", "Item 5"] + @State private var scale: CGFloat = 0.1 // Start small + @State private var offset: CGSize = CGSize(width: UIScreen.main.bounds.width, height: 0) // Offset to the top right - var body: some View { - NavigationView { - List(items, id: \.self) { item in - Text(item) - .padding() - .background(Color.blue) - .foregroundColor(.white) - .cornerRadius(10) - .padding(.vertical, 5) // Adds spacing between items - .onTapGesture { - - print("Hello World \(item)") - } - - - } - .listStyle(.plain) - .navigationTitle("Items List") - } - } + var body: some View { + Rectangle() + .fill(Color.blue) // Change to your desired color or view + .scaleEffect(scale, anchor: .topTrailing) // Scale from the top right + .offset(x: offset.width, y: offset.height) // Initial offset + .onAppear { + withAnimation(.easeInOut(duration: 0.5)) { + scale = 1.0 // Scale to full size + offset = CGSize.zero // Reset offset + } + } + .edgesIgnoringSafeArea(.all) // Make sure it fills the entire screen + } }