Skip to content

Commit

Permalink
IOS-2585 Show constructed display name in space settings
Browse files Browse the repository at this point in the history
  • Loading branch information
ignatovv committed Apr 12, 2024
1 parent a9755f3 commit 20533b0
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ struct MembershipTierSelectionView: View {
case .appStore(let product):
MembershipNameSheetView(tier: model.tierToDisplay, anyName: model.userMembership.anyName, product: product, onSuccessfulPurchase: model.onSuccessfulPurchase)
case .external(let info):
// TODO: Add proper wording
StandardButton("More info", style: .primaryLarge) {
openURL(info.paymentUrl)
}.padding()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,12 @@ final class SpaceSettingsViewModel: ObservableObject {
anytypeAssert(owner.isNotNil, "Could not find owner for space)", info: ["SpaceView": participantSpaceView.debugDescription])

if let owner {
let displayName = owner.globalName.isNotEmpty ? owner.globalName : owner.identity

info.append(
SettingsInfoModel(title: creatorDetails.name, subtitle: owner.globalName, onTap: { [weak self] in
SettingsInfoModel(title: creatorDetails.name, subtitle: displayName, onTap: { [weak self] in
guard let self else { return }
UIPasteboard.general.string = owner.globalName
UIPasteboard.general.string = displayName
snackBarData = .init(text: Loc.copiedToClipboard(creatorDetails.name), showSnackBar: true)
})
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,49 @@ struct SettingsInfoBlockView: View {
let model: SettingsInfoModel

var body: some View {
Button {
model.onTap?()
} label: {
label
}
.disabled(model.onTap.isNil)
}

var label: some View {
VStack(alignment: .leading, spacing: 4) {
AnytypeText(model.title, style: .uxTitle1Semibold)
.foregroundColor(.Text.primary)
HStack {
AnytypeText(model.subtitle, style: .previewTitle2Regular)
.foregroundColor(.Text.primary)
.multilineTextAlignment(.leading)
Spacer()
if let onTap = model.onTap {
if model.onTap.isNotNil {
Image(asset: .X24.copy)
.foregroundColor(.Button.active)
.onTapGesture {
onTap()
}
}
}
}
.padding(.vertical, 12)
.frame(maxWidth: .infinity, alignment: .leading)
}
}

#Preview {
VStack {
SettingsInfoBlockView(
model: SettingsInfoModel(
title: "Description",
subtitle: "Setting without action",
onTap: nil
)
)
SettingsInfoBlockView(
model: SettingsInfoModel(
title: "AnytypeId",
subtitle: "Setting with action",
onTap: { }
)
)
}.padding()
}

0 comments on commit 20533b0

Please sign in to comment.