Skip to content

Commit

Permalink
Take 2
Browse files Browse the repository at this point in the history
  • Loading branch information
JPKribs committed Jan 21, 2025
1 parent 0ff7cd2 commit c095c8c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
28 changes: 24 additions & 4 deletions Swiftfin tvOS/Components/ListRowButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ import SwiftUI
struct ListRowButton: View {

let title: String
let role: ButtonRole?
let action: () -> Void

init(_ title: String, action: @escaping () -> Void) {
init(_ title: String, role: ButtonRole? = nil, action: @escaping () -> Void) {
self.title = title
self.role = role
self.action = action
}

Expand All @@ -23,15 +25,33 @@ struct ListRowButton: View {
action()
} label: {
ZStack {
Rectangle()
.foregroundStyle(.secondary)
RoundedRectangle(cornerRadius: 10)
.fill(secondaryStyle)

Text(title)
.foregroundStyle(primaryStyle)
.font(.body.weight(.bold))
.foregroundStyle(.primary)
}
}
.buttonStyle(.card)
.frame(height: 75)
}

// MARK: - Styles

private var primaryStyle: some ShapeStyle {
if role == .destructive {
return AnyShapeStyle(Color.red)
} else {
return AnyShapeStyle(.primary)
}
}

private var secondaryStyle: some ShapeStyle {
if role == .destructive {
return AnyShapeStyle(Color.red.opacity(0.2))
} else {
return AnyShapeStyle(.secondary)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,10 @@ extension SelectUserView {
// MARK: - Delete User Button

private var deleteUsersButton: some View {
Button(role: .destructive) {
ListRowButton(L10n.delete, role: .destructive) {
onDelete()
} label: {
Text(L10n.delete)
.foregroundStyle(areUsersSelected ? Color.primary : Color.secondary)
.font(.body.weight(.semibold))
.frame(width: 400, height: 50)
.clipShape(RoundedRectangle(cornerRadius: 10))
}
.opacity(areUsersSelected ? 1.0 : 0.5)
.frame(width: 400, height: 50)
.disabled(!areUsersSelected)
}

Expand Down
7 changes: 3 additions & 4 deletions Swiftfin tvOS/Views/ServerDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,17 @@ struct EditServerView: View {
.foregroundColor(.secondary)
}
}
.buttonStyle(.plain)
.listRowBackground(Color.clear)
.listRowInsets(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0))
}

if isEditing {
Section {
ListRowButton(L10n.delete) {
ListRowButton(L10n.delete, role: .destructive) {
isPresentingConfirmDeletion = true
}
.buttonStyle(.plain)
.listRowBackground(Color.clear)
.listRowInsets(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0))
.foregroundStyle(.primary, .red.opacity(0.5))
}
}
}
Expand Down

0 comments on commit c095c8c

Please sign in to comment.