mirror of
https://github.com/passepartoutvpn/passepartout-apple.git
synced 2025-01-18 22:49:10 +00:00
Show quick profile menu rather than just edit (#940)
"Edit" is a less frequent action than "Select provider server". Offer a common place for quick actions. One step towards #933
This commit is contained in:
parent
19da40d3f8
commit
1c1d2502c3
@ -73,7 +73,7 @@ private extension InstalledProfileView {
|
||||
actionableNameView
|
||||
Spacer(minLength: 10.0)
|
||||
} else {
|
||||
nameView
|
||||
nameView()
|
||||
}
|
||||
}
|
||||
statusView
|
||||
@ -82,14 +82,10 @@ private extension InstalledProfileView {
|
||||
}
|
||||
|
||||
var actionableNameView: some View {
|
||||
ThemeDisclosableMenu {
|
||||
menuContent
|
||||
} label: {
|
||||
nameView
|
||||
}
|
||||
ThemeDisclosableMenu(content: menuContent, label: nameView)
|
||||
}
|
||||
|
||||
var nameView: some View {
|
||||
func nameView() -> some View {
|
||||
Text(profile?.name ?? Strings.Views.App.Rows.notInstalled)
|
||||
.font(.title2)
|
||||
.fontWeight(theme.relevantWeight)
|
||||
@ -120,7 +116,7 @@ private extension InstalledProfileView {
|
||||
)
|
||||
}
|
||||
|
||||
var menuContent: some View {
|
||||
func menuContent() -> some View {
|
||||
ProfileContextMenu(
|
||||
profileManager: profileManager,
|
||||
tunnel: tunnel,
|
||||
|
@ -71,16 +71,8 @@ struct ProfileRowView: View, Routable, SizeClassProviding {
|
||||
}
|
||||
Spacer()
|
||||
HStack(spacing: 8) {
|
||||
ProfileAttributesView(
|
||||
attributes: attributes,
|
||||
isRemoteImportingEnabled: profileManager.isRemoteImportingEnabled
|
||||
)
|
||||
.imageScale(isBigDevice ? .large : .medium)
|
||||
|
||||
ProfileInfoButton(preview: preview) {
|
||||
flow?.onEditProfile($0)
|
||||
}
|
||||
.imageScale(.large)
|
||||
attributesView
|
||||
infoButton
|
||||
}
|
||||
}
|
||||
Spacer(minLength: .zero)
|
||||
@ -88,6 +80,33 @@ struct ProfileRowView: View, Routable, SizeClassProviding {
|
||||
}
|
||||
}
|
||||
|
||||
private extension ProfileRowView {
|
||||
var profile: Profile? {
|
||||
profileManager.profile(withId: preview.id)
|
||||
}
|
||||
|
||||
var attributes: [ProfileAttributesView.Attribute] {
|
||||
if isTV {
|
||||
return [.tv]
|
||||
} else if isShared {
|
||||
return [.shared]
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
var requiredFeatures: Set<AppFeature>? {
|
||||
profileManager.requiredFeatures(forProfileWithId: preview.id)
|
||||
}
|
||||
|
||||
var isShared: Bool {
|
||||
profileManager.isRemotelyShared(profileWithId: preview.id)
|
||||
}
|
||||
|
||||
var isTV: Bool {
|
||||
isShared && profileManager.isAvailableForTV(profileWithId: preview.id)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Subviews (observing)
|
||||
|
||||
private struct MarkerView: View {
|
||||
@ -114,10 +133,6 @@ private struct MarkerView: View {
|
||||
}
|
||||
|
||||
private extension ProfileRowView {
|
||||
var profile: Profile? {
|
||||
profileManager.profile(withId: preview.id)
|
||||
}
|
||||
|
||||
var markerView: some View {
|
||||
MarkerView(
|
||||
profileId: preview.id,
|
||||
@ -152,25 +167,36 @@ private extension ProfileRowView {
|
||||
.foregroundStyle(.primary)
|
||||
}
|
||||
|
||||
var attributes: [ProfileAttributesView.Attribute] {
|
||||
if isTV {
|
||||
return [.tv]
|
||||
} else if isShared {
|
||||
return [.shared]
|
||||
var attributesView: some View {
|
||||
ProfileAttributesView(
|
||||
attributes: attributes,
|
||||
isRemoteImportingEnabled: profileManager.isRemoteImportingEnabled
|
||||
)
|
||||
.imageScale(isBigDevice ? .large : .medium)
|
||||
}
|
||||
|
||||
var infoButton: some View {
|
||||
Menu {
|
||||
ProfileContextMenu(
|
||||
profileManager: profileManager,
|
||||
tunnel: tunnel,
|
||||
preview: preview,
|
||||
interactiveManager: interactiveManager,
|
||||
errorHandler: errorHandler,
|
||||
isInstalledProfile: false,
|
||||
flow: flow
|
||||
)
|
||||
} label: {
|
||||
ThemeImage(.moreDetails)
|
||||
.imageScale(.large)
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
var requiredFeatures: Set<AppFeature>? {
|
||||
profileManager.requiredFeatures(forProfileWithId: preview.id)
|
||||
}
|
||||
|
||||
var isShared: Bool {
|
||||
profileManager.isRemotelyShared(profileWithId: preview.id)
|
||||
}
|
||||
|
||||
var isTV: Bool {
|
||||
isShared && profileManager.isAvailableForTV(profileWithId: preview.id)
|
||||
// TODO: #584, necessary to avoid cell selection
|
||||
#if os(iOS)
|
||||
.menuStyle(.borderlessButton)
|
||||
#else
|
||||
.foregroundStyle(.secondary)
|
||||
.buttonStyle(.plain)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user