Create repo, add feature to set username
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// ContentView.swift
|
||||
// Peered
|
||||
//
|
||||
// Created by Oskar Chybowski on 11/05/2025.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ContentView: View {
|
||||
@AppStorage("peered_username") private var username: String = ""
|
||||
@State var browser: CommunicationProvider? = nil
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
if let browser {
|
||||
ForEach(browser.availablePeers, id: \.displayName) { peer in
|
||||
Text(peer.displayName)
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
.sheet(isPresented: .constant(username.isEmpty)) {
|
||||
SetUserNameBottomSheetView(username: $username)
|
||||
}
|
||||
.onChange(of: username) { _, newValue in
|
||||
guard !newValue.isEmpty else { return }
|
||||
browser = .init(id: newValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
ContentView()
|
||||
}
|
||||
Reference in New Issue
Block a user