-
Notifications
You must be signed in to change notification settings - Fork 330
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add servers as filter to pick entities in the EntityPicker flow (#3444)
- Loading branch information
Showing
7 changed files
with
150 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import SwiftUI | ||
|
||
public struct PillView: View { | ||
private let selected: Bool | ||
private let text: String | ||
|
||
public init(text: String, selected: Bool) { | ||
self.text = text | ||
self.selected = selected | ||
} | ||
|
||
public var body: some View { | ||
Text(text) | ||
.foregroundStyle(selected ? .white : Color(uiColor: .label)) | ||
.padding(Spaces.one) | ||
.padding(.horizontal) | ||
.background(selected ? Color.asset(Asset.Colors.haPrimary) : Color.secondary.opacity(0.1)) | ||
.clipShape(Capsule()) | ||
} | ||
} | ||
|
||
#Preview { | ||
HStack { | ||
PillView(text: "Value1", selected: true) | ||
PillView(text: "Value2", selected: false) | ||
PillView(text: "Value3", selected: false) | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
Sources/Shared/DesignSystem/Components/ServersPickerPillList.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import SwiftUI | ||
|
||
public struct ServersPickerPillList: View { | ||
@Binding private var selectedServerId: String? | ||
|
||
public init(selectedServerId: Binding<String?>) { | ||
self._selectedServerId = selectedServerId | ||
} | ||
|
||
public var body: some View { | ||
serversList | ||
} | ||
|
||
@ViewBuilder | ||
private var serversList: some View { | ||
if Current.servers.all.count > 1 { | ||
Section { | ||
ScrollView(.horizontal) { | ||
HStack { | ||
ForEach(Current.servers.all.sorted(by: { lhs, rhs in | ||
lhs.info.sortOrder < rhs.info.sortOrder | ||
}), id: \.identifier) { server in | ||
Button { | ||
selectedServerId = server.identifier.rawValue | ||
} label: { | ||
PillView( | ||
text: server.info.name, | ||
selected: selectedServerId == server.identifier.rawValue | ||
) | ||
} | ||
} | ||
} | ||
.frame(maxWidth: .infinity, alignment: .leading) | ||
} | ||
.frame(maxWidth: .infinity, alignment: .leading) | ||
} | ||
.listRowBackground(Color.clear) | ||
.listRowInsets(.init(top: 0, leading: 0, bottom: 0, trailing: 0)) | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
List { | ||
ServersPickerPillList(selectedServerId: .constant("1")) | ||
} | ||
} |