Skip to content

Commit

Permalink
UI Glitch fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipthelen committed Sep 12, 2024
1 parent 588a39e commit c79b1ad
Show file tree
Hide file tree
Showing 17 changed files with 162 additions and 114 deletions.
116 changes: 58 additions & 58 deletions HabitRPG/Generated/Storyboard Scenes.swift

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions HabitRPG/Generated/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,8 @@ public enum L10n {
public static var resetTips: String { return L10n.tr("Mainstrings", "reset_tips") }
/// Reset Streak
public static var resetStreak: String { return L10n.tr("Mainstrings", "resetStreak") }
/// Restore Purchase
public static var restorePurchase: String { return L10n.tr("Mainstrings", "restore_purchase") }
/// Resubscribe
public static var resubscribe: String { return L10n.tr("Mainstrings", "resubscribe") }
/// Resubscribe to pick up where you left off!
Expand Down
2 changes: 1 addition & 1 deletion HabitRPG/Habitica-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>995</string>
<string>996</string>
<key>CustomDomain</key>
<string>${CUSTOM_DOMAIN}</string>
<key>DisableSSL</key>
Expand Down
2 changes: 1 addition & 1 deletion HabitRPG/Repositories/Implementations/UserRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ class UserRepository: BaseRepository<UserLocalRepository> {
lastClassSelection = Date()
return SelectClassCall(class: habiticaClass).httpResponseSignal
.on(value: { response in
if response.statusCode == 200 {
if response.statusCode == 200 && habiticaClass != nil {
let alert = HabiticaAlertController(
title: L10n.classChangeSuccessTitle(habiticaClass?.translatedName ?? ""),
message: L10n.classChangeSuccessDescription(habiticaClass?.translatedName ?? ""))
Expand Down
1 change: 1 addition & 0 deletions HabitRPG/Strings/Base.lproj/Mainstrings.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1405,3 +1405,4 @@
"continue_benefits" = "Continue Benefits";
"x_x_gem_cap" = "%d / %d Gem Cap";
"resubscribe_to_pick_up" = "Resubscribe to pick up where you left off!";
"restore_purchase" = "Restore Purchase";
19 changes: 15 additions & 4 deletions HabitRPG/UI/Purchases/G1G1Banner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,31 @@ import SwiftUI
struct G1G1Banner: View {
var endDate: Date

private let formatter = DateFormatter()
private let formatter = {
let formatter = DateFormatter()
formatter.dateFormat = "MMM dd"
return formatter
}()

var body: some View {
HStack {
Image(Asset.promoGiftsLeft.name)
VStack {
Spacer()
VStack(spacing: 5) {
Text(L10n.giftOneGetOneTitle)
.font(.system(size: 22, weight: .bold))
Text(L10n.giftOneGetOneDescriptionDate(formatter.string(from: endDate)))
.font(.system(size: 16, weight: .semibold))
.lineSpacing(2)
.multilineTextAlignment(.center)
}
}.padding(.horizontal, 6)
Spacer()
Image(Asset.promoGiftsRight.name)
}.background(LinearGradient(colors: [Color("#3BCAD7"), Color("#925CF3")], startPoint: .topLeading, endPoint: .bottomTrailing))
}
.background(LinearGradient(colors: [Color(UIColor("#3BCAD7")), Color(UIColor("#925CF3"))], startPoint: .topLeading, endPoint: .bottomTrailing))
.onTapGesture {

}
}
}

Expand Down
2 changes: 1 addition & 1 deletion HabitRPG/UI/Purchases/SubscriptionBenefitView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct SubscriptionBenefitView<Icon: View, Title: View, Description: View>: View
.cornerRadius(8)
VStack(alignment: .leading, spacing: 4) {
title.font(.system(size: 15, weight: .semibold))
description.font(.system(size: 13))
description.font(.system(size: 13)).lineSpacing(3)
}.frame(maxWidth: .infinity, alignment: .leading)
}.padding(.leading, 12)
.padding(.vertical, 8)
Expand Down
40 changes: 38 additions & 2 deletions HabitRPG/UI/Purchases/SubscriptionPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ class SubscriptionViewModel: BaseSubscriptionViewModel {
retrieveProductList()

activePromo = configRepository.activePromotion()

activePromo = GiftOneGetOnePromotion(startDate: nil, endDate: Date())
}

func retrieveProductList() {
Expand Down Expand Up @@ -225,6 +227,30 @@ class SubscriptionViewModel: BaseSubscriptionViewModel {
}
}
}

func checkForExistingSubscription() {
SwiftyStoreKit.verifyReceipt(using: self.appleValidator, forceRefresh: true) { result in
switch result {
case .success(let verifiedReceipt):
guard let purchases = verifiedReceipt["latest_receipt_info"] as? [ReceiptInfo] else {
return
}
for purchase in purchases {
if let identifier = purchase["product_id"] as? String {
if self.isValidSubscription(identifier, receipt: verifiedReceipt) {
self.activateSubscription(identifier, receipt: verifiedReceipt) {status in
if status {
return
}
}
}
}
}
case .error(let error):
logger.log("Receipt verification failed: \(error)", level: .error)
}
}
}
}

struct SubscriptionSeparator: View {
Expand Down Expand Up @@ -287,6 +313,10 @@ struct SubscriptionPage: View {
LazyVStack(spacing: 0) {
if let endDate = viewModel.activePromo?.endDate, viewModel.activePromo?.identifier == "g1g1" {
G1G1Banner(endDate: endDate)
.frame(height: 96)
.cornerRadius(8)
.padding(.horizontal, 20)
.padding(.bottom, 30)
}
if let point = viewModel.presentationPoint {
Text(point.headerText)
Expand All @@ -309,7 +339,7 @@ struct SubscriptionPage: View {
SubscriptionSeparator()
.padding(.horizontal, 24)
if (viewModel.subscriptionPlan?.consecutive?.gemCapExtra ?? 0) > 0 {
VStack(spacing: 0) {
VStack(spacing: 1) {
HStack(spacing: 10) {
Image(Asset.gemcapLeft.name)
Text(L10n.xxGemCap(viewModel.subscriptionPlan?.gemCapTotal ?? 0, 50))
Expand Down Expand Up @@ -355,7 +385,6 @@ struct SubscriptionPage: View {
}
}
}
.padding(.horizontal, 24)
.padding(.bottom, 24)
Rectangle()
.frame(height: viewModel.showHourglassPromo && viewModel.selectedSubscription == viewModel.availableSubscriptions.last ? 186 : 126)
Expand Down Expand Up @@ -417,6 +446,13 @@ struct SubscriptionPage: View {
.multilineTextAlignment(.center)
.padding(.horizontal, 32)

if !viewModel.isSubscribed {
Button(L10n.restorePurchase) {
viewModel.checkForExistingSubscription()
}.buttonStyle(.borderless)
.accentColor(.yellow100)
}

Image(Asset.subscriptionBackground.name)
}
}
Expand Down
10 changes: 9 additions & 1 deletion HabitRPG/UI/User/ClassSelectionViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,14 @@ class ClassSelectionViewController: UIViewController, Themeable {

override func dismiss(animated flag: Bool, completion: (() -> Void)? = nil) {
UserManager.shared.classSelectionViewController = nil
super.dismiss(animated: flag, completion: completion)
if !isPresenting {
super.dismiss(animated: flag, completion: completion)
} else if let presented = presentedViewController as? HabiticaAlertController {
presented.onDismissAction = {[weak self] in
DispatchQueue.main.asyncAfter(deadline: .now() + 1, execute: {
self?.dismiss(animated: true)
})
}
}
}
}
2 changes: 1 addition & 1 deletion HabitRPG/Utilities/Theme Engine/Themes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public struct DysheatenerTheme: Theme {

public struct DefaultDarkTheme: DarkTheme {
public var backgroundTintColor: UIColor { return UIColor.purple400 }
public var tintColor: UIColor { return UIColor.purple500 }
public var tintColor: UIColor { return UIColor.purple600 }
public var fixedTintColor: UIColor { return UIColor.purple400 }
public var dimmBackgroundColor: UIColor { return UIColor.purple10 }
public var taskOverlayTint: UIColor { return UIColor.blackPurple50.withAlphaComponent(0.15) }
Expand Down
7 changes: 6 additions & 1 deletion HabitRPG/Views/HabiticaAlertController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ class HabiticaAlertController: UIViewController, Themeable {
var buttonAxis: NSLayoutConstraint.Axis?
var dismissOnBackgroundTap = true
var maxAlertWidth: CGFloat = 340

var onKeyboardChange: ((Bool) -> Void)?

var onDismissAction: (() -> Void)?

var contentView: UIView? {
didSet {
configureContentView()
Expand Down Expand Up @@ -418,6 +420,9 @@ class HabiticaAlertController: UIViewController, Themeable {
override func dismiss(animated flag: Bool, completion: (() -> Void)? = nil) {
super.dismiss(animated: flag, completion: completion)
HabiticaAlertController.showNextInQueue(currentAlert: self)
if let action = onDismissAction {
action()
}
}

@objc
Expand Down
2 changes: 1 addition & 1 deletion Habitica Intents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>995</string>
<string>996</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
Expand Down
2 changes: 1 addition & 1 deletion Habitica IntentsUI/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>995</string>
<string>996</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
Expand Down
2 changes: 1 addition & 1 deletion Habitica Snapshots/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>995</string>
<string>996</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion Habitica Widgets/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>995</string>
<string>996</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
Expand Down
Loading

0 comments on commit c79b1ad

Please sign in to comment.