fix: SMB share enumeration, BrowseView polish, sign out, Login branding
- Fix "Bad Network Name": BrowseView at root "/" for SMB now calls listShares() instead of listDirectory with empty share name. SMBClient.listShares() filters IPC/admin/hidden ($) shares. - Add listShares() to NASTransferProtocol; implement in SMB (filters ipc/special/$-suffix) and SFTP (returns []). - BrowseView: premium error state (wifi.exclamationmark icon + Retry button with ScaleButtonStyle), empty state, safeAreaInset bottom bar replacing toolbar bottomBar (shows current path chip + compact Select button), proper disabled state for root selection on SMB. - FolderRow: replace hardcoded .white with AppTheme.inkInverse for dark mode correctness; use folder.fill icon; ScaleButtonStyle for tap feedback. - LoginView: larger logo (80pt), bolder "Kisani" wordmark (32pt bold), tagline, staggered spring entrance animations (0.08-0.36s delay). - SettingsView: Sign Out button in ACCOUNT section with confirmationDialog (destructive, clears connection + resets session). - ConnectionStore: signOut() resets isSessionActive, onboardingPhotoShown, and clears savedConnection (triggers Keychain delete). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -18,13 +18,13 @@ struct BrowseView: View {
|
||||
AppTheme.background.ignoresSafeArea()
|
||||
|
||||
VStack(spacing: 0) {
|
||||
// Path bar
|
||||
HStack(spacing: 8) {
|
||||
// Path breadcrumb bar
|
||||
HStack(spacing: 6) {
|
||||
Image(systemName: "externaldrive")
|
||||
.font(.system(size: 12, weight: .medium))
|
||||
.font(.system(size: 11, weight: .medium))
|
||||
.foregroundStyle(AppTheme.inkTertiary)
|
||||
Text(currentPath)
|
||||
.font(AppTheme.caption())
|
||||
.font(.system(size: 12, weight: .regular))
|
||||
.foregroundStyle(AppTheme.inkSecondary)
|
||||
.lineLimit(1)
|
||||
.truncationMode(.middle)
|
||||
@@ -39,71 +39,13 @@ struct BrowseView: View {
|
||||
.frame(height: 0.5)
|
||||
|
||||
if isLoading {
|
||||
Spacer()
|
||||
VStack(spacing: 10) {
|
||||
ProgressView()
|
||||
.tint(AppTheme.inkTertiary)
|
||||
Text("Loading…")
|
||||
.font(AppTheme.caption())
|
||||
.foregroundStyle(AppTheme.inkTertiary)
|
||||
}
|
||||
Spacer()
|
||||
} else if let error {
|
||||
Spacer()
|
||||
VStack(spacing: 12) {
|
||||
Image(systemName: "exclamationmark.triangle")
|
||||
.font(.system(size: 28, weight: .ultraLight))
|
||||
.foregroundStyle(AppTheme.inkQuaternary)
|
||||
VStack(spacing: 4) {
|
||||
Text("Could not load folder")
|
||||
.font(.system(size: 14, weight: .medium))
|
||||
.foregroundStyle(AppTheme.inkSecondary)
|
||||
Text(error)
|
||||
.font(AppTheme.caption())
|
||||
.foregroundStyle(AppTheme.inkTertiary)
|
||||
.multilineTextAlignment(.center)
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 32)
|
||||
Spacer()
|
||||
loadingState
|
||||
} else if let err = error {
|
||||
errorState(err)
|
||||
} else if items.isEmpty {
|
||||
emptyState
|
||||
} else {
|
||||
List {
|
||||
if currentPath != "/" {
|
||||
Button(action: navigateUp) {
|
||||
HStack(spacing: 10) {
|
||||
Image(systemName: "arrow.up")
|
||||
.font(.system(size: 13, weight: .medium))
|
||||
.foregroundStyle(AppTheme.inkSecondary)
|
||||
.frame(width: 22)
|
||||
Text("Parent folder")
|
||||
.font(AppTheme.body())
|
||||
.foregroundStyle(AppTheme.inkSecondary)
|
||||
Spacer()
|
||||
}
|
||||
.padding(.horizontal, 16)
|
||||
.padding(.vertical, 12)
|
||||
}
|
||||
.buttonStyle(PlainButtonStyle())
|
||||
.listRowInsets(EdgeInsets())
|
||||
.listRowSeparator(.hidden)
|
||||
}
|
||||
|
||||
ForEach(items) { item in
|
||||
FolderRow(
|
||||
item: item,
|
||||
isSelected: selectedPath == item.path
|
||||
) {
|
||||
if item.isDirectory {
|
||||
navigate(to: item.path)
|
||||
} else {
|
||||
selectedPath = item.path
|
||||
}
|
||||
}
|
||||
.listRowInsets(EdgeInsets())
|
||||
.listRowSeparator(.hidden)
|
||||
}
|
||||
}
|
||||
.listStyle(.plain)
|
||||
folderList
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -123,15 +65,11 @@ struct BrowseView: View {
|
||||
Image(systemName: "folder.badge.plus")
|
||||
.foregroundStyle(AppTheme.inkSecondary)
|
||||
}
|
||||
.disabled(currentPath == "/" && connection.nasProtocol == .smb)
|
||||
}
|
||||
ToolbarItem(placement: .bottomBar) {
|
||||
Button("Select this folder") {
|
||||
selectedPath = currentPath
|
||||
dismiss()
|
||||
}
|
||||
.font(.system(size: 15, weight: .semibold))
|
||||
.foregroundStyle(AppTheme.ink)
|
||||
}
|
||||
}
|
||||
.safeAreaInset(edge: .bottom) {
|
||||
selectButton
|
||||
}
|
||||
.alert("New folder", isPresented: $showCreateFolder) {
|
||||
TextField("Folder name", text: $newFolderName)
|
||||
@@ -139,17 +77,193 @@ struct BrowseView: View {
|
||||
Button("Cancel", role: .cancel) {}
|
||||
}
|
||||
}
|
||||
.task { await loadDirectory(path: currentPath) }
|
||||
.task { await loadItems(path: currentPath) }
|
||||
}
|
||||
|
||||
private func loadDirectory(path: String) async {
|
||||
// MARK: — Sub-views
|
||||
|
||||
private var loadingState: some View {
|
||||
VStack {
|
||||
Spacer()
|
||||
VStack(spacing: 12) {
|
||||
ProgressView()
|
||||
.tint(AppTheme.inkTertiary)
|
||||
.scaleEffect(1.1)
|
||||
Text("Loading…")
|
||||
.font(AppTheme.caption())
|
||||
.foregroundStyle(AppTheme.inkTertiary)
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
|
||||
private func errorState(_ message: String) -> some View {
|
||||
VStack {
|
||||
Spacer()
|
||||
VStack(spacing: 20) {
|
||||
// Icon
|
||||
ZStack {
|
||||
Circle()
|
||||
.fill(AppTheme.surfaceSunken)
|
||||
.frame(width: 64, height: 64)
|
||||
Image(systemName: "wifi.exclamationmark")
|
||||
.font(.system(size: 24, weight: .light))
|
||||
.foregroundStyle(AppTheme.inkSecondary)
|
||||
}
|
||||
|
||||
VStack(spacing: 6) {
|
||||
Text("Could not load folder")
|
||||
.font(.system(size: 15, weight: .semibold))
|
||||
.foregroundStyle(AppTheme.ink)
|
||||
Text(message)
|
||||
.font(AppTheme.caption())
|
||||
.foregroundStyle(AppTheme.inkTertiary)
|
||||
.multilineTextAlignment(.center)
|
||||
.padding(.horizontal, 40)
|
||||
}
|
||||
|
||||
Button(action: { Task { await loadItems(path: currentPath) } }) {
|
||||
HStack(spacing: 6) {
|
||||
Image(systemName: "arrow.clockwise")
|
||||
.font(.system(size: 12, weight: .medium))
|
||||
Text("Try again")
|
||||
.font(.system(size: 13, weight: .medium))
|
||||
}
|
||||
.foregroundStyle(AppTheme.ink)
|
||||
.padding(.horizontal, 16)
|
||||
.padding(.vertical, 8)
|
||||
.background(AppTheme.surfaceSunken)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 8, style: .continuous))
|
||||
}
|
||||
.buttonStyle(ScaleButtonStyle())
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
|
||||
private var emptyState: some View {
|
||||
VStack {
|
||||
Spacer()
|
||||
VStack(spacing: 10) {
|
||||
Image(systemName: "folder")
|
||||
.font(.system(size: 28, weight: .ultraLight))
|
||||
.foregroundStyle(AppTheme.inkQuaternary)
|
||||
Text("Empty folder")
|
||||
.font(AppTheme.caption())
|
||||
.foregroundStyle(AppTheme.inkTertiary)
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
|
||||
private var folderList: some View {
|
||||
List {
|
||||
if currentPath != "/" {
|
||||
Button(action: navigateUp) {
|
||||
HStack(spacing: 10) {
|
||||
Image(systemName: "arrow.up")
|
||||
.font(.system(size: 13, weight: .medium))
|
||||
.foregroundStyle(AppTheme.inkSecondary)
|
||||
.frame(width: 22)
|
||||
Text("Parent folder")
|
||||
.font(AppTheme.body())
|
||||
.foregroundStyle(AppTheme.inkSecondary)
|
||||
Spacer()
|
||||
}
|
||||
.padding(.horizontal, 16)
|
||||
.padding(.vertical, 13)
|
||||
}
|
||||
.buttonStyle(ScaleButtonStyle())
|
||||
.listRowInsets(EdgeInsets())
|
||||
.listRowSeparator(.hidden)
|
||||
.listRowBackground(Color.clear)
|
||||
}
|
||||
|
||||
ForEach(items) { item in
|
||||
FolderRow(
|
||||
item: item,
|
||||
isSelected: selectedPath == item.path
|
||||
) {
|
||||
if item.isDirectory {
|
||||
navigate(to: item.path)
|
||||
} else {
|
||||
selectedPath = item.path
|
||||
}
|
||||
}
|
||||
.listRowInsets(EdgeInsets())
|
||||
.listRowSeparator(.hidden)
|
||||
.listRowBackground(Color.clear)
|
||||
}
|
||||
}
|
||||
.listStyle(.plain)
|
||||
.background(AppTheme.background)
|
||||
}
|
||||
|
||||
private var selectButton: some View {
|
||||
VStack(spacing: 0) {
|
||||
Rectangle()
|
||||
.fill(AppTheme.separator)
|
||||
.frame(height: 0.5)
|
||||
|
||||
HStack(spacing: 12) {
|
||||
// Current path chip
|
||||
HStack(spacing: 5) {
|
||||
Image(systemName: "folder.fill")
|
||||
.font(.system(size: 11, weight: .medium))
|
||||
.foregroundStyle(selectedPath == currentPath ? AppTheme.interactive : AppTheme.inkQuaternary)
|
||||
Text(currentPath == "/" ? "Root" : (currentPath as NSString).lastPathComponent)
|
||||
.font(.system(size: 12, weight: .medium))
|
||||
.foregroundStyle(selectedPath == currentPath ? AppTheme.interactive : AppTheme.inkTertiary)
|
||||
.lineLimit(1)
|
||||
}
|
||||
.padding(.horizontal, 10)
|
||||
.padding(.vertical, 6)
|
||||
.background(
|
||||
RoundedRectangle(cornerRadius: 7, style: .continuous)
|
||||
.fill(selectedPath == currentPath ? AppTheme.interactive.opacity(0.1) : AppTheme.surfaceSunken)
|
||||
)
|
||||
|
||||
Spacer()
|
||||
|
||||
Button(action: {
|
||||
selectedPath = currentPath
|
||||
dismiss()
|
||||
}) {
|
||||
Text("Select")
|
||||
.font(.system(size: 14, weight: .semibold))
|
||||
.foregroundStyle(AppTheme.inkInverse)
|
||||
.padding(.horizontal, 20)
|
||||
.padding(.vertical, 10)
|
||||
.background(currentPath == "/" && connection.nasProtocol == .smb ? AppTheme.inkQuaternary : AppTheme.ink)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 10, style: .continuous))
|
||||
}
|
||||
.buttonStyle(ScaleButtonStyle())
|
||||
.disabled(currentPath == "/" && connection.nasProtocol == .smb)
|
||||
}
|
||||
.padding(.horizontal, AppTheme.hPad)
|
||||
.padding(.vertical, 12)
|
||||
.background(AppTheme.background)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: — Data
|
||||
|
||||
private func loadItems(path: String) async {
|
||||
isLoading = true
|
||||
error = nil
|
||||
items = []
|
||||
do {
|
||||
let s: any NASTransferProtocol = connection.nasProtocol == .smb ? SMBService() : SFTPService()
|
||||
try await s.connect(to: connection.host, port: connection.port,
|
||||
username: connection.username, password: connection.password)
|
||||
items = try await s.listDirectory(at: path).filter { $0.isDirectory }
|
||||
if path == "/" && connection.nasProtocol == .smb {
|
||||
let shareNames = try await s.listShares()
|
||||
items = shareNames.map { name in
|
||||
NASItem(name: name, path: "/\(name)", isDirectory: true, size: 0, modifiedDate: nil)
|
||||
}
|
||||
} else {
|
||||
items = try await s.listDirectory(at: path).filter { $0.isDirectory }
|
||||
}
|
||||
s.disconnect()
|
||||
} catch let e as BackupError {
|
||||
self.error = e.errorDescription
|
||||
@@ -161,7 +275,7 @@ struct BrowseView: View {
|
||||
|
||||
private func navigate(to path: String) {
|
||||
currentPath = path
|
||||
Task { await loadDirectory(path: path) }
|
||||
Task { await loadItems(path: path) }
|
||||
}
|
||||
|
||||
private func navigateUp() {
|
||||
@@ -171,14 +285,14 @@ struct BrowseView: View {
|
||||
|
||||
private func createFolder() async {
|
||||
guard !newFolderName.isEmpty else { return }
|
||||
let newPath = "\(currentPath)/\(newFolderName)"
|
||||
let newPath = currentPath == "/" ? "/\(newFolderName)" : "\(currentPath)/\(newFolderName)"
|
||||
do {
|
||||
let s: any NASTransferProtocol = connection.nasProtocol == .smb ? SMBService() : SFTPService()
|
||||
try await s.connect(to: connection.host, port: connection.port,
|
||||
username: connection.username, password: connection.password)
|
||||
try await s.createDirectory(at: newPath)
|
||||
s.disconnect()
|
||||
await loadDirectory(path: currentPath)
|
||||
await loadItems(path: currentPath)
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user