Skip to content

Commit

Permalink
g1g1 banner
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipthelen committed Sep 11, 2024
1 parent 90fdbc7 commit ae814bf
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 66 deletions.
116 changes: 58 additions & 58 deletions HabitRPG/Generated/Storyboard Scenes.swift

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion HabitRPG/Generated/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,10 @@ public enum L10n {
public static var giftOneGetOne: String { return L10n.tr("Mainstrings", "gift_one_get_one") }
/// Gift a subscription now and you’ll get the same sub for yourself free!
public static var giftOneGetOneDescription: String { return L10n.tr("Mainstrings", "gift_one_get_one_description") }
/// Gift a sub and get a sub for free until %@
public static func giftOneGetOneDescriptionDate(_ p1: String) -> String {
return L10n.tr("Mainstrings", "gift_one_get_one_description_date", p1)
}
/// Gift One, Get One Event
public static var giftOneGetOneEvent: String { return L10n.tr("Mainstrings", "gift_one_get_one_event") }
/// Gift One, Get One
Expand Down Expand Up @@ -1342,7 +1346,7 @@ public enum L10n {
public static func xToY(_ p1: String, _ p2: String) -> String {
return L10n.tr("Mainstrings", "x_to_y", p1, p2)
}
/// %d/%d Gem Cap
/// %d / %d Gem Cap
public static func xxGemCap(_ p1: Int, _ p2: Int) -> String {
return L10n.tr("Mainstrings", "x_x_gem_cap", p1, p2)
}
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 @@ -988,6 +988,7 @@
"gift_one_get_one_title" = "Gift One, Get One";
"gift_one_get_one_event" = "Gift One, Get One Event";
"gift_one_get_one_description" = "Gift a subscription now and you’ll get the same sub for yourself free!";
"gift_one_get_one_description_date" = "Gift a sub and get a sub for free until %@";
"gems_support_developers" = "Purchasing Gems supports our small team and helps keep Habitica running";
"gem_benefits_title" = "Gems allow you to buy fun extras for your account, including:";
"unpin" = "Unpin";
Expand Down
34 changes: 34 additions & 0 deletions HabitRPG/UI/Purchases/G1G1Banner.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// G1G1Banner.swift
// Habitica
//
// Created by Phillip Thelen on 11.09.24.
// Copyright © 2024 HabitRPG Inc. All rights reserved.
//

import Foundation
import SwiftUI

struct G1G1Banner: View {
var endDate: Date

private let formatter = DateFormatter()

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

#Preview {
G1G1Banner(endDate: Date())
}
10 changes: 9 additions & 1 deletion HabitRPG/UI/Purchases/SubscriptionPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class SubscriptionViewModel: BaseSubscriptionViewModel {
let itunesSharedSecret = Secrets.itunesSharedSecret
let userRepository = UserRepository()
let inventoryRepository = InventoryRepository()
let configRepository = ConfigRepository.shared

var onSubscriptionSuccessful: (() -> Void)?
var onGiftButtonTapped: (() -> Void)?
Expand All @@ -95,6 +96,8 @@ class SubscriptionViewModel: BaseSubscriptionViewModel {
@Published var selectedSubscription: String = PurchaseHandler.subscriptionIdentifiers[0]
@Published var availableSubscriptions = PurchaseHandler.subscriptionIdentifiers

@Published var activePromo: HabiticaPromotion?

init(presentationPoint: PresentationPoint?) {
#if DEBUG
appleValidator = AppleReceiptValidator(service: .production, sharedSecret: itunesSharedSecret)
Expand All @@ -119,6 +122,8 @@ class SubscriptionViewModel: BaseSubscriptionViewModel {
}).start())

retrieveProductList()

activePromo = configRepository.activePromotion()
}

func retrieveProductList() {
Expand Down Expand Up @@ -280,6 +285,9 @@ struct SubscriptionPage: View {

var body: some View {
LazyVStack(spacing: 0) {
if let endDate = viewModel.activePromo?.endDate, viewModel.activePromo?.identifier == "g1g1" {
G1G1Banner(endDate: endDate)
}
if let point = viewModel.presentationPoint {
Text(point.headerText)
.multilineTextAlignment(.center)
Expand Down Expand Up @@ -498,7 +506,7 @@ class SubscriptionModalViewController: HostingPanModal<SubscriptionPage> {
class SubscriptionPageController: UIHostingController<ScrollableSubscriptionPage> {
let viewModel: SubscriptionViewModel
let userRepository = UserRepository()

init(presentationPoint: PresentationPoint?) {
viewModel = SubscriptionViewModel(presentationPoint: presentationPoint)
super.init(rootView: ScrollableSubscriptionPage(viewModel: viewModel))
Expand Down
21 changes: 21 additions & 0 deletions Habitica.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@
296CB4EE218C99FD0044A33E /* HabiticaButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 296CB4ED218C99FD0044A33E /* HabiticaButton.swift */; };
296D6F1D20A0908B00D9CAB5 /* PartyQuestView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 296D6F1C20A0908B00D9CAB5 /* PartyQuestView.swift */; };
296E480821BE86F800D15E4A /* GiftSubscriptionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 296E480721BE86F800D15E4A /* GiftSubscriptionViewController.swift */; };
296E4F0D2C91A05A00D9CBDE /* G1G1Banner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 296E4F0C2C91A05A00D9CBDE /* G1G1Banner.swift */; };
296E4F0F2C91A6A800D9CBDE /* Habitica_Models.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 296E4F0E2C91A6A800D9CBDE /* Habitica_Models.framework */; };
296E4F102C91A6A800D9CBDE /* Habitica_Models.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 296E4F0E2C91A6A800D9CBDE /* Habitica_Models.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
296F51642358E5EF0019C872 /* SubscriptionPromoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 296F51632358E5EF0019C872 /* SubscriptionPromoView.swift */; };
29701FE01F560D310097BBCC /* UIApplication-Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29701FDF1F560D310097BBCC /* UIApplication-Extensions.swift */; };
29701FE21F5617900097BBCC /* ToastView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 29701FE11F5617900097BBCC /* ToastView.xib */; };
Expand Down Expand Up @@ -680,6 +683,17 @@
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
296E4F112C91A6A800D9CBDE /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
296E4F102C91A6A800D9CBDE /* Habitica_Models.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
7A84E1B0228928AD0081E96F /* Embed Foundation Extensions */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 12;
Expand Down Expand Up @@ -907,6 +921,8 @@
296D6F1C20A0908B00D9CAB5 /* PartyQuestView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PartyQuestView.swift; sourceTree = "<group>"; };
296E0E6520F5078200A1E991 /* he */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = he; path = he.lproj/Mainstrings.strings; sourceTree = "<group>"; };
296E480721BE86F800D15E4A /* GiftSubscriptionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GiftSubscriptionViewController.swift; sourceTree = "<group>"; };
296E4F0C2C91A05A00D9CBDE /* G1G1Banner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = G1G1Banner.swift; sourceTree = "<group>"; };
296E4F0E2C91A6A800D9CBDE /* Habitica_Models.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Habitica_Models.framework; sourceTree = BUILT_PRODUCTS_DIR; };
296F51632358E5EF0019C872 /* SubscriptionPromoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionPromoView.swift; sourceTree = "<group>"; };
29701FDF1F560D310097BBCC /* UIApplication-Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIApplication-Extensions.swift"; sourceTree = "<group>"; };
29701FE11F5617900097BBCC /* ToastView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ToastView.xib; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1349,6 +1365,7 @@
2994A8B128FE946A00CEDED7 /* Habitica_Database.framework in Frameworks */,
29252C382AF4FB330003692D /* Habitica_API_Client.framework in Frameworks */,
29BEE62F252CCFE100D456F8 /* SwiftUI.framework in Frameworks */,
296E4F0F2C91A6A800D9CBDE /* Habitica_Models.framework in Frameworks */,
2938ED3E28B4EEB200E995A2 /* KeychainAccess in Frameworks */,
29BEE62D252CCFE100D456F8 /* WidgetKit.framework in Frameworks */,
);
Expand Down Expand Up @@ -2343,6 +2360,7 @@
2922EE832C80774400254106 /* SubscriptionOptionViewUI.swift */,
2922EE812C80772A00254106 /* SubscriptionBenefitView.swift */,
29EFE3A42C8B359A005B66C9 /* SubscriptionDetailViewUI.swift */,
296E4F0C2C91A05A00D9CBDE /* G1G1Banner.swift */,
);
path = Purchases;
sourceTree = "<group>";
Expand Down Expand Up @@ -2652,6 +2670,7 @@
D9EB4E8D18CB4A9400BB2094 /* Frameworks */ = {
isa = PBXGroup;
children = (
296E4F0E2C91A6A800D9CBDE /* Habitica_Models.framework */,
29252C372AF4FB330003692D /* Habitica_API_Client.framework */,
29995A6026CBCB0B0063D4C9 /* AdServices.framework */,
292DEE4D204DA1830086D5F7 /* Habitica_API_Client.framework */,
Expand Down Expand Up @@ -2767,6 +2786,7 @@
29BEE627252CCFE100D456F8 /* Sources */,
29BEE628252CCFE100D456F8 /* Frameworks */,
29BEE629252CCFE100D456F8 /* Resources */,
296E4F112C91A6A800D9CBDE /* Embed Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -3664,6 +3684,7 @@
297D15FA20B803D30048101F /* UserProfileViewController.swift in Sources */,
D9525F9B1E5F559600C529B8 /* ChallengeTableViewCell.swift in Sources */,
D9A63A341E10328A0083ADC4 /* LoginTableViewController.swift in Sources */,
296E4F0D2C91A05A00D9CBDE /* G1G1Banner.swift in Sources */,
299328AB24E5985B003BCE0C /* UIStackview-Extensions.swift in Sources */,
D9BB455D1E71C8C70002AE2E /* CheckedTableViewcell.swift in Sources */,
292DEEA5204F6F6C0086D5F7 /* DailyTableViewDataSource.swift in Sources */,
Expand Down
12 changes: 6 additions & 6 deletions Habitica.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/mattgallagher/CwlCatchException.git",
"state" : {
"revision" : "3ef6999c73b6938cc0da422f2c912d0158abb0a0",
"version" : "2.2.0"
"revision" : "07b2ba21d361c223e25e3c1e924288742923f08c",
"version" : "2.2.1"
}
},
{
"identity" : "cwlpreconditiontesting",
"kind" : "remoteSourceControl",
"location" : "https://github.com/mattgallagher/CwlPreconditionTesting.git",
"state" : {
"revision" : "2ef56b2caf25f55fa7eef8784c30d5a767550f54",
"version" : "2.2.1"
"revision" : "0139c665ebb45e6a9fbdb68aabfd7c39f3fe0071",
"version" : "2.2.2"
}
},
{
Expand Down Expand Up @@ -294,8 +294,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-protobuf.git",
"state" : {
"revision" : "564597ad2fe2513a94dd8f3ba27ea2ff4be3cb37",
"version" : "1.28.0"
"revision" : "edb6ed4919f7756157fe02f2552b7e3850a538e5",
"version" : "1.28.1"
}
},
{
Expand Down

0 comments on commit ae814bf

Please sign in to comment.