Skip to content

Latest commit

 

History

History
63 lines (44 loc) · 1.22 KB

README.MD

File metadata and controls

63 lines (44 loc) · 1.22 KB

XCA Network Monitor For SwiftUI

Alt text

Simple and extensible NetworkMonitor with UI Solution for Apple Platforms.

Supported Platforms

  • iOS 17
  • macOS 14
  • visionOS 1.x

Installation

Swift Package Manager

  • File > Swift Packages > Add Package Dependency
  • Copy and paste this URL
https://github.com/alfianlosari/XCANetworkMonitor

Import

Import to your project source file.

import XCANetworkMonitor

NetworkMonitor Banner

Simply add networkStatusBanner() modifier to your SwiftUI View.

var body: some View {
    VStack(spacing: 20) {
        Text("XCA Network Monitor Demo")
            .font(.title)
    }
    .networkStatusBanner()

NetworkMonitor Observable

Simply initialize passing the NetworkMonitor as @State in SwiftUI View.

struct ContentView: View {
    
    @State var networkMonitor = NetworkMonitor()
        
    var body: some View {
        HStack {
            Circle()
                .foregroundStyle(networkMonitor.isReachable ? .green : .red)
                .frame(width: 20, height: 20)
            Text(networkMonitor.statusText)
        }
    }
}