Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] - Fix Leo QA - 2 #22578

Merged
merged 3 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -177,38 +177,41 @@ struct AIChatPaywallView: View {
.frame(height: 1.0)
.foregroundColor(Color(braveSystemName: .primitivePrimary70))

VStack {
Button(
action: {
Task { await purchaseSubscription() }
},
label: {
Button(
action: {
Task { await purchaseSubscription() }
},
label: {
HStack {
if paymentStatus == .ongoing {
ProgressView()
.tint(Color.white)
.padding()
} else {
Text(Strings.AIChat.paywallPurchaseActionTitle)
.font(.body.weight(.semibold))
.foregroundColor(Color(.white))
.padding()
}
}
)
.frame(maxWidth: .infinity)
.padding()
.background(
LinearGradient(
gradient:
Gradient(colors: [
Color(UIColor(rgb: 0xFF5500)),
Color(UIColor(rgb: 0xFF006B)),
]),
startPoint: .init(x: 0.0, y: 0.0),
endPoint: .init(x: 0.0, y: 1.0)
.frame(maxWidth: .infinity)
.contentShape(ContainerRelativeShape())
.background(
LinearGradient(
gradient:
Gradient(colors: [
Color(UIColor(rgb: 0xFF5500)),
Color(UIColor(rgb: 0xFF006B)),
]),
startPoint: .init(x: 0.0, y: 0.0),
endPoint: .init(x: 0.0, y: 1.0)
)
)
)
.clipShape(RoundedRectangle(cornerRadius: 16.0, style: .continuous))
.disabled(paymentStatus == .ongoing)
}
}
)
.clipShape(RoundedRectangle(cornerRadius: 16.0, style: .continuous))
.disabled(paymentStatus == .ongoing)
.buttonStyle(.plain)
.padding([.horizontal], 16.0)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,22 +200,26 @@ public struct AIChatAdvancedSettingsView: View {
title: Strings.AIChat.advancedSettingsSubscriptionStatusTitle,
detail: subscriptionStatusTitle
)
.listRowBackground(Color(.secondaryBraveGroupedBackground))

AIChatAdvancedSettingsLabelDetailView(
title: Strings.AIChat.advancedSettingsSubscriptionExpiresTitle,
detail: expirationDateTitle
)
.listRowBackground(Color(.secondaryBraveGroupedBackground))
} else {
// Subscription information is loading
AIChatAdvancedSettingsLabelDetailView(
title: Strings.AIChat.advancedSettingsSubscriptionStatusTitle,
detail: nil
)
.listRowBackground(Color(.secondaryBraveGroupedBackground))

AIChatAdvancedSettingsLabelDetailView(
title: Strings.AIChat.advancedSettingsSubscriptionExpiresTitle,
detail: nil
)
.listRowBackground(Color(.secondaryBraveGroupedBackground))
}

// Check subscription is activated with in-app purchase
Expand All @@ -229,8 +233,11 @@ public struct AIChatAdvancedSettingsView: View {
title: Strings.AIChat.advancedSettingsLinkPurchaseActionTitle,
subtitle: Strings.AIChat.advancedSettingsLinkPurchaseActionSubTitle
)
.contentShape(Rectangle())
}
)
.buttonStyle(.plain)
.listRowBackground(Color(.secondaryBraveGroupedBackground))

if viewModel.isDevReceiptLinkingAvailable {
Button(
Expand All @@ -241,8 +248,11 @@ public struct AIChatAdvancedSettingsView: View {
LabelView(
title: "[Staging] Link receipt"
)
.contentShape(Rectangle())
}
)
.buttonStyle(.plain)
.listRowBackground(Color(.secondaryBraveGroupedBackground))

Button(
action: {
Expand All @@ -252,8 +262,11 @@ public struct AIChatAdvancedSettingsView: View {
LabelView(
title: "[Dev] Link receipt"
)
.contentShape(Rectangle())
}
)
.buttonStyle(.plain)
.listRowBackground(Color(.secondaryBraveGroupedBackground))
}

Button(
Expand All @@ -269,8 +282,11 @@ public struct AIChatAdvancedSettingsView: View {
},
label: {
premiumActionView
.contentShape(Rectangle())
}
)
.buttonStyle(.plain)
.listRowBackground(Color(.secondaryBraveGroupedBackground))
}
} else {
Button(
Expand All @@ -283,29 +299,31 @@ public struct AIChatAdvancedSettingsView: View {
},
label: {
premiumActionView
.contentShape(Rectangle())
}
)
.buttonStyle(.plain)
.listRowBackground(Color(.secondaryBraveGroupedBackground))
.sheet(isPresented: $isPaywallPresented) {
AIChatPaywallView(
premiumUpgrageSuccessful: { _ in
Task { @MainActor in
await model.refreshPremiumStatusOrderCredentials()
await viewModel.fetchOrder()
}
})
}
.alert(isPresented: $appStoreConnectionErrorPresented) {
Alert(
title: Text(Strings.AIChat.appStoreErrorTitle),
message: Text(Strings.AIChat.appStoreErrorSubTitle),
dismissButton: .default(Text(Strings.OKString))
)
}
}
} header: {
Text(Strings.AIChat.advancedSettingsSubscriptionHeaderTitle.uppercased())
}
.sheet(isPresented: $isPaywallPresented) {
AIChatPaywallView(
premiumUpgrageSuccessful: { _ in
Task { @MainActor in
await model.refreshPremiumStatusOrderCredentials()
await viewModel.fetchOrder()
}
})
}
.alert(isPresented: $appStoreConnectionErrorPresented) {
Alert(
title: Text(Strings.AIChat.appStoreErrorTitle),
message: Text(Strings.AIChat.appStoreErrorSubTitle),
dismissButton: .default(Text(Strings.OKString))
)
}
.listRowBackground(Color(.secondaryBraveGroupedBackground))

Section {
Button(
Expand All @@ -315,33 +333,36 @@ public struct AIChatAdvancedSettingsView: View {
label: {
Text(Strings.AIChat.resetLeoDataActionTitle)
.foregroundColor(Color(.braveBlurpleTint))
.frame(maxWidth: .infinity)
.contentShape(Rectangle())
}
)
.frame(maxWidth: .infinity)
.listRowBackground(Color(.secondaryBraveGroupedBackground))
.buttonStyle(.plain)
}
.alert(isPresented: $resetAndClearAlertErrorPresented) {
Alert(
title: Text(Strings.AIChat.resetLeoDataErrorTitle),
message: Text(Strings.AIChat.resetLeoDataErrorDescription),
primaryButton: .destructive(Text(Strings.AIChat.resetLeoDataAlertButtonTitle)) {
model.clearAndResetData()
},
secondaryButton: .cancel()
)
.alert(isPresented: $resetAndClearAlertErrorPresented) {
Alert(
title: Text(Strings.AIChat.resetLeoDataErrorTitle),
message: Text(Strings.AIChat.resetLeoDataErrorDescription),
primaryButton: .destructive(Text(Strings.AIChat.resetLeoDataAlertButtonTitle)) {
model.clearAndResetData()
},
secondaryButton: .cancel()
)
}
}
}
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.listBackgroundColor(Color(.braveGroupedBackground))
.listStyle(.insetGrouped)
}

var premiumActionView: some View {
HStack {
LabelView(title: subscriptionMenuTitle)
Spacer()
.frame(maxWidth: .infinity, alignment: .leading)

Image(braveSystemName: "leo.launch")
.foregroundStyle(Color(braveSystemName: .iconDefault))
.frame(alignment: .trailing)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: redundant/no effect

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,19 @@ struct AIChatDefaultModelView: View {
}
}
}
.contentShape(Rectangle())
}
)
.buttonStyle(.plain)
.listRowBackground(Color(.secondaryBraveGroupedBackground))
}
} header: {
Text(Strings.AIChat.defaultModelChatSectionTitle.uppercased())
}
.listRowBackground(Color(.secondaryBraveGroupedBackground))
}
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.listStyle(.insetGrouped)
.navigationTitle(Strings.AIChat.defaultModelViewTitle)
.sheet(isPresented: $isPresentingPaywallPremium) {
AIChatPaywallView(
premiumUpgrageSuccessful: { _ in
Expand All @@ -93,6 +96,5 @@ struct AIChatDefaultModelView: View {
}
})
}
.navigationTitle(Strings.AIChat.defaultModelViewTitle)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ public class BraveSkusSDK {
for group: BraveStoreProductGroup
) async throws -> SkusOrder {
func decode(_ response: String) throws -> SkusOrder {
if response == "{}" {
throw SkusError.decodingError
}

guard let data = response.data(using: .utf8) else {
throw SkusError.decodingError
}
Expand All @@ -271,6 +275,10 @@ public class BraveSkusSDK {
for group: BraveStoreProductGroup
) async throws -> SkusCredentialSummary {
func decode(_ response: String) throws -> SkusCredentialSummary {
if response == "{}" {
throw SkusError.decodingError
}

guard let data = response.data(using: .utf8) else {
throw SkusError.decodingError
}
Expand Down
Loading