iPhone client for network-computer: see and drive a remote Linux/Mac desktop over WebRTC, phone as trackpad and keyboard, desktop on a TV via AirPlay.

0 downloads

network-computer-ios/Sources/Views/ConnectView.swift
Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/network-computer-ios.git
HTTPS
https://gitstable.com/git/askrobots/network-computer-ios.git
SSH
ssh://git@gitstable.com:2222/askrobots/network-computer-ios.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

Dan Quellhorst First cut of the iPhone client cc1f67f 2 months ago History
ConnectView.swift · 2.8 KB · 63 lines
1import SwiftUI
2
3struct ConnectView: View {
4 @ObservedObject var settings = Settings.shared
5 @ObservedObject var store = SessionStore.shared
6
7 var body: some View {
8 NavigationStack {
9 Form {
10 Section("Rendezvous") {
11 TextField("http://host:8765", text: $settings.rendezvousURL)
12 .keyboardType(.URL).textInputAutocapitalization(.never).autocorrectionDisabled()
13 TextField("user", text: $settings.user)
14 .textInputAutocapitalization(.never).autocorrectionDisabled()
15 SecureField("password", text: $settings.password)
16 }
17 Section("Host") {
18 HStack {
19 if store.hosts.isEmpty {
20 TextField("host name", text: $settings.hostName)
21 .textInputAutocapitalization(.never).autocorrectionDisabled()
22 } else {
23 Picker("host", selection: $settings.hostName) {
24 ForEach(store.hosts, id: \.self) { Text($0).tag($0) }
25 }
26 }
27 Button { Task { await store.refreshHosts() } } label: { Image(systemName: "arrow.clockwise") }
28 .buttonStyle(.borderless)
29 }
30 SecureField("host PIN", text: $settings.pin).keyboardType(.numberPad)
31 }
32 Section("Options") {
33 Toggle("Trackpad mode (off = direct touch)", isOn: $settings.trackpadMode)
34 Toggle("Force TURN relay (test fallback)", isOn: $settings.relayOnly)
35 }
36 Section {
37 Button {
38 Task { await store.connect() }
39 } label: {
40 HStack {
41 Spacer()
42 if case .connecting(let what) = store.state {
43 ProgressView().padding(.trailing, 6); Text(what)
44 } else {
45 Text("Connect").bold()
46 }
47 Spacer()
48 }
49 }
50 .disabled({ if case .connecting = store.state { return true } else { return false } }())
51 if case .failed(let why) = store.state {
52 Text(why).foregroundStyle(.red).font(.footnote)
53 }
54 if store.externalDisplayConnected {
55 Label("External display connected", systemImage: "tv").font(.footnote)
56 }
57 }
58 }
59 .navigationTitle("Network Computer")
60 .task { await store.refreshHosts() }
61 }
62 }
63}