Skip to content

Commit

Permalink
Center None if there are no users. Replace Device None Centering (whi…
Browse files Browse the repository at this point in the history
…ch should never get used...) with the same logic instead of 2 spacer()s. Finally, remove all Save New User Button on the AddServerUserView. TODO: The ServerUserView doesn't update when a new user is created
  • Loading branch information
JPKribs committed Oct 31, 2024
1 parent bc72577 commit b360fea
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,6 @@ struct AddServerUserView: View {
.labelStyle(.sectionFooterWithImage(imageStyle: .orange))
}
}

// ListRowButton(L10n.addUser) {
// focusedfield = nil
// viewModel.send(.createUser(username: username, password: newPassword))
// }
// .disabled(!isValid)
// .foregroundStyle(accentColor.overlayColor, accentColor)
// .opacity(newPassword != confirmNewPassword ? 0.5 : 1)
}
.animation(.linear(duration: 0.2), value: isValid)
.interactiveDismissDisabled(viewModel.state == .creatingUser)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,39 +118,36 @@ struct DevicesView: View {
.padding(.vertical, 24)

if viewModel.devices.isEmpty {
HStack {
Spacer()
Text(L10n.none)
Spacer()
}
.listRowSeparator(.hidden)
.listRowInsets(.zero)
}

ForEach(viewModel.devices, id: \.self) { device in
DeviceRow(device: device) {
guard let id = device.id else { return }

if isEditing {
if selectedDevices.contains(id) {
selectedDevices.remove(id)
Text(L10n.none)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center)
.listRowSeparator(.hidden)
.listRowInsets(.zero)
} else {
ForEach(viewModel.devices, id: \.self) { device in
DeviceRow(device: device) {
guard let id = device.id else { return }

if isEditing {
if selectedDevices.contains(id) {
selectedDevices.remove(id)
} else {
selectedDevices.insert(id)
}
} else {
selectedDevices.insert(id)
router.route(to: \.deviceDetails, device)
}
} else {
router.route(to: \.deviceDetails, device)
}
} onDelete: {
guard let id = device.id else { return }
} onDelete: {
guard let id = device.id else { return }

selectedDevices.removeAll()
selectedDevices.insert(id)
isPresentingDeleteConfirmation = true
selectedDevices.removeAll()
selectedDevices.insert(id)
isPresentingDeleteConfirmation = true
}
.environment(\.isEditing, isEditing)
.environment(\.isSelected, selectedDevices.contains(device.id ?? ""))
.listRowSeparator(.hidden)
.listRowInsets(.zero)
}
.environment(\.isEditing, isEditing)
.environment(\.isSelected, selectedDevices.contains(device.id ?? ""))
.listRowSeparator(.hidden)
.listRowInsets(.zero)
}
}
.listStyle(.plain)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,25 +132,28 @@ struct ServerUsersView: View {

if viewModel.users.isEmpty {
Text(L10n.none)
}

ForEach(viewModel.users, id: \.self) { user in
if let userID = user.id {
ServerUsersRow(user: user) {
if isEditing {
selectedUsers.toggle(value: userID)
} else {
router.route(to: \.userDetails, user)
}
} onDelete: {
selectedUsers.removeAll()
selectedUsers.insert(userID)
isPresentingDeleteConfirmation = true
}
.environment(\.isEditing, isEditing)
.environment(\.isSelected, selectedUsers.contains(userID))
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center)
.listRowSeparator(.hidden)
.listRowInsets(.zero)
} else {
ForEach(viewModel.users, id: \.self) { user in
if let userID = user.id {
ServerUsersRow(user: user) {
if isEditing {
selectedUsers.toggle(value: userID)
} else {
router.route(to: \.userDetails, user)
}
} onDelete: {
selectedUsers.removeAll()
selectedUsers.insert(userID)
isPresentingDeleteConfirmation = true
}
.environment(\.isEditing, isEditing)
.environment(\.isSelected, selectedUsers.contains(userID))
.listRowSeparator(.hidden)
.listRowInsets(.zero)
}
}
}
}
Expand Down

0 comments on commit b360fea

Please sign in to comment.