Skip to content

Commit

Permalink
Merge pull request #1127 from anyproto/ios-2594-implement-payments-su…
Browse files Browse the repository at this point in the history
…pport-for-ios

IOS-2594 Membership | Use price data from StoreKit and Middelware
  • Loading branch information
ignatovv authored Apr 4, 2024
2 parents de636c5 + 33cb17e commit 167afb9
Show file tree
Hide file tree
Showing 18 changed files with 415 additions and 59 deletions.
14 changes: 10 additions & 4 deletions Anytype.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,6 @@
2A39F3CB29ED97F3005DE8F5 /* BlockTextStyle+Analytics.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A39F3CA29ED97F2005DE8F5 /* BlockTextStyle+Analytics.swift */; };
2A39F3CD29ED9A7E005DE8F5 /* LayoutAlignment+Analytics.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A39F3CC29ED9A7E005DE8F5 /* LayoutAlignment+Analytics.swift */; };
2A3AFF552A7CEB9F004F7E09 /* SpaceAccessibility+Localization.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A3AFF542A7CEB9F004F7E09 /* SpaceAccessibility+Localization.swift */; };
2A4063632A5D480E00ECEA79 /* AsyncHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A4063622A5D480E00ECEA79 /* AsyncHelpers.swift */; };
2A4063652A5D9D8A00ECEA79 /* EventBunchSubscribtion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A4063642A5D9D8A00ECEA79 /* EventBunchSubscribtion.swift */; };
2A40F59F2BB1997D00F0220E /* PresentedDismiss.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A40F59E2BB1997D00F0220E /* PresentedDismiss.swift */; };
2A41A6782B84E57B00EAE6E6 /* DeepLinks in Frameworks */ = {isa = PBXBuildFile; productRef = 2A41A6772B84E57B00EAE6E6 /* DeepLinks */; };
Expand Down Expand Up @@ -1381,6 +1380,8 @@
3DE0CFE126F860EF003A606A /* StringExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DE0CFE026F860EF003A606A /* StringExtension.swift */; };
3DE296472617439C00EADB0A /* ServiceLocator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DE296462617439C00EADB0A /* ServiceLocator.swift */; };
3DE3C91D26F464BF0012AF51 /* MentionObjectsService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DE3C91926F464BF0012AF51 /* MentionObjectsService.swift */; };
3DE3DE652BBDBAA300C9E6D3 /* MembershipPricingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DE3DE642BBDBAA300C9E6D3 /* MembershipPricingView.swift */; };
3DE3DE672BBDBC1F00C9E6D3 /* MembershipTierPaymentTypeExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DE3DE662BBDBC1F00C9E6D3 /* MembershipTierPaymentTypeExtension.swift */; };
3DE5121626728C0F00153962 /* BaseDocumentProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DE5121526728C0F00153962 /* BaseDocumentProtocol.swift */; };
3DE6924F27301C3E00A4CD4E /* AccessoryViewType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DE6924E27301C3E00A4CD4E /* AccessoryViewType.swift */; };
3DE6926827302D5800A4CD4E /* AccessoryViewStateManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DE6926727302D5800A4CD4E /* AccessoryViewStateManager.swift */; };
Expand Down Expand Up @@ -2208,7 +2209,6 @@
2A39F3CA29ED97F2005DE8F5 /* BlockTextStyle+Analytics.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BlockTextStyle+Analytics.swift"; sourceTree = "<group>"; };
2A39F3CC29ED9A7E005DE8F5 /* LayoutAlignment+Analytics.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "LayoutAlignment+Analytics.swift"; sourceTree = "<group>"; };
2A3AFF542A7CEB9F004F7E09 /* SpaceAccessibility+Localization.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SpaceAccessibility+Localization.swift"; sourceTree = "<group>"; };
2A4063622A5D480E00ECEA79 /* AsyncHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AsyncHelpers.swift; sourceTree = "<group>"; };
2A4063642A5D9D8A00ECEA79 /* EventBunchSubscribtion.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventBunchSubscribtion.swift; sourceTree = "<group>"; };
2A40F59E2BB1997D00F0220E /* PresentedDismiss.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PresentedDismiss.swift; sourceTree = "<group>"; };
2A41A6762B84D43C00EAE6E6 /* DeepLinks */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = DeepLinks; path = Modules/DeepLinks; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3170,6 +3170,9 @@
3DE0CFE026F860EF003A606A /* StringExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringExtension.swift; sourceTree = "<group>"; };
3DE296462617439C00EADB0A /* ServiceLocator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServiceLocator.swift; sourceTree = "<group>"; };
3DE3C91926F464BF0012AF51 /* MentionObjectsService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MentionObjectsService.swift; sourceTree = "<group>"; };
3DE3DE632BBD7E6F00C9E6D3 /* LocalStoreKitConfiguration.storekit */ = {isa = PBXFileReference; lastKnownFileType = text; path = LocalStoreKitConfiguration.storekit; sourceTree = "<group>"; };
3DE3DE642BBDBAA300C9E6D3 /* MembershipPricingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MembershipPricingView.swift; sourceTree = "<group>"; };
3DE3DE662BBDBC1F00C9E6D3 /* MembershipTierPaymentTypeExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MembershipTierPaymentTypeExtension.swift; sourceTree = "<group>"; };
3DE5121526728C0F00153962 /* BaseDocumentProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = BaseDocumentProtocol.swift; path = Anytype/Sources/Models/Documents/Document/BaseDocumentProtocol.swift; sourceTree = SOURCE_ROOT; };
3DE6924E27301C3E00A4CD4E /* AccessoryViewType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccessoryViewType.swift; sourceTree = "<group>"; };
3DE6926727302D5800A4CD4E /* AccessoryViewStateManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccessoryViewStateManager.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3753,6 +3756,7 @@
038FB5C522D8F2A0002B90B8 /* Supporting files */ = {
isa = PBXGroup;
children = (
3DE3DE632BBD7E6F00C9E6D3 /* LocalStoreKitConfiguration.storekit */,
0303ED0922D8EDAD005C552B /* LaunchScreen.storyboard */,
0303ED0C22D8EDAD005C552B /* Info.plist */,
);
Expand Down Expand Up @@ -4180,7 +4184,6 @@
1270CE8E26DA848B00B2D443 /* Images */,
EAC5FD4A2657DC3D006BB24E /* UIScrollView */,
0A996BD023F0342A000FDC9C /* PlistReader.swift */,
2A4063622A5D480E00ECEA79 /* AsyncHelpers.swift */,
2AEDACC32B9F3A4600FA757A /* AppContext.swift */,
);
path = Utilities;
Expand Down Expand Up @@ -8735,6 +8738,7 @@
children = (
3D611E952B93779900B33305 /* MembershipTierExtensions.swift */,
3DFD50A32BA0B114002E51F7 /* MembershipStatusExtension.swift */,
3DE3DE662BBDBC1F00C9E6D3 /* MembershipTierPaymentTypeExtension.swift */,
);
path = Models;
sourceTree = "<group>";
Expand Down Expand Up @@ -9228,6 +9232,7 @@
3DD0CEBA2B90E6BB00657402 /* MembershipBannerView.swift */,
3D611E8D2B936B8300B33305 /* MembershipTeirView.swift */,
3D611E922B93775B00B33305 /* MembershipTierListView.swift */,
3DE3DE642BBDBAA300C9E6D3 /* MembershipPricingView.swift */,
);
path = Views;
sourceTree = "<group>";
Expand Down Expand Up @@ -10847,6 +10852,7 @@
3D26AA7E2B9768F500D61479 /* EmailVerificationView.swift in Sources */,
3D22B20E2685DABD00C78C28 /* BlockImageViewModel.swift in Sources */,
2AAF343C29559BF700921320 /* TreeWidgetViewModel.swift in Sources */,
3DE3DE652BBDBAA300C9E6D3 /* MembershipPricingView.swift in Sources */,
2AFF7AC4299CDA6900B7746B /* BinSubscriptionService.swift in Sources */,
2A65E9B42AE1294900D40657 /* InitialCoordinatorViewModel.swift in Sources */,
2A8302BD2B07A058002D6655 /* AnytypeNavigationAdditionalSafeArea.swift in Sources */,
Expand Down Expand Up @@ -11568,6 +11574,7 @@
2A376F5A2B85F30600CF444A /* SpacesManagerRowView.swift in Sources */,
2AE906E9296FFE820044A10A /* TextIconPickerModuleAssembly.swift in Sources */,
2A85B0432AA637F100988ABD /* ApplicationCoordinatorViewModel.swift in Sources */,
3DE3DE672BBDBC1F00C9E6D3 /* MembershipTierPaymentTypeExtension.swift in Sources */,
125683D527DF17CE003A8251 /* TagSearchRowView.swift in Sources */,
3DCEE135273C18FC00BC5565 /* BeginingOfTextMarkdown.swift in Sources */,
122898BD276F112D004B81B8 /* RelationObjectsRowView.swift in Sources */,
Expand Down Expand Up @@ -12047,7 +12054,6 @@
2A8C00F729C4AAF200309C14 /* SettingsView.swift in Sources */,
EA57F41D26B99937007D4292 /* MarkupViewModelProtocol.swift in Sources */,
2ACB798E2BAAD7B0003A2A56 /* ActiveSpaceParticipantStorage.swift in Sources */,
2A4063632A5D480E00ECEA79 /* AsyncHelpers.swift in Sources */,
C9C536AD276C9040003CD3F3 /* Color+Assets.swift in Sources */,
C9A59DEF27E0F4D30063D3E1 /* TextBlockLeadingView.swift in Sources */,
2E98634F2937B55800304645 /* GroupsSubscriptionData.swift in Sources */,
Expand Down
3 changes: 3 additions & 0 deletions Anytype.xcodeproj/xcshareddata/xcschemes/Anytype.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
<StoreKitConfigurationFileReference
identifier = "../../Anytype/Supporting files/LocalStoreKitConfiguration.storekit">
</StoreKitConfigurationFileReference>
</LaunchAction>
<ProfileAction
buildConfiguration = "Debug"
Expand Down
26 changes: 19 additions & 7 deletions Anytype/Generated/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,6 @@ internal enum Loc {
internal static let deselectAll = Loc.tr("Localizable", "Deselect all", fallback: "Deselect all")
/// Designed to capture thoughts quickly
internal static let designedToCaptureThoughtsQuickly = Loc.tr("Localizable", "Designed to capture thoughts quickly", fallback: "Designed to capture thoughts quickly")
/// Details upon request
internal static let detailsUponRequest = Loc.tr("Localizable", "Details upon request", fallback: "Details upon request")
/// Done
internal static let done = Loc.tr("Localizable", "Done", fallback: "Done")
/// Download
Expand Down Expand Up @@ -398,12 +396,24 @@ internal enum Loc {
internal static let pending = Loc.tr("Localizable", "Pending", fallback: "Pending...")
/// We're sorry to see you go. You have 30 days to cancel this request. After 30 days, your encrypted account data is permanently removed from the backup node.
internal static let pendingDeletionText = Loc.tr("Localizable", "Pending deletion text", fallback: "We're sorry to see you go. You have 30 days to cancel this request. After 30 days, your encrypted account data is permanently removed from the backup node.")
/// per %@ years
internal static func perXYears(_ p1: Any) -> String {
return Loc.tr("Localizable", "per x years", String(describing: p1), fallback: "per %@ years")
/// per
internal static let per = Loc.tr("Localizable", "per", fallback: "per")
/// Plural format key: "per %#@day@"
internal static func perDay(_ p1: Int) -> String {
return Loc.tr("Localizable", "Per Day", p1, fallback: "Plural format key: \"per %#@day@\"")
}
/// Plural format key: "per %#@month@"
internal static func perMonth(_ p1: Int) -> String {
return Loc.tr("Localizable", "Per Month", p1, fallback: "Plural format key: \"per %#@month@\"")
}
/// Plural format key: "per %#@week@"
internal static func perWeek(_ p1: Int) -> String {
return Loc.tr("Localizable", "Per Week", p1, fallback: "Plural format key: \"per %#@week@\"")
}
/// Plural format key: "per %#@year@"
internal static func perYear(_ p1: Int) -> String {
return Loc.tr("Localizable", "Per Year", p1, fallback: "Plural format key: \"per %#@year@\"")
}
/// per year
internal static let perYear = Loc.tr("Localizable", "per year", fallback: "per year")
/// Personalization
internal static let personalization = Loc.tr("Localizable", "Personalization", fallback: "Personalization")
/// Picture
Expand Down Expand Up @@ -569,6 +579,8 @@ internal enum Loc {
internal static let unknown = Loc.tr("Localizable", "Unknown", fallback: "Unknown")
/// Unknown error
internal static let unknownError = Loc.tr("Localizable", "Unknown error", fallback: "Unknown error")
/// Unlimited
internal static let unlimited = Loc.tr("Localizable", "unlimited", fallback: "Unlimited")
/// Unlock
internal static let unlock = Loc.tr("Localizable", "Unlock", fallback: "Unlock")
/// Unpin
Expand Down
7 changes: 4 additions & 3 deletions Anytype/Resources/Strings/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1038,8 +1038,10 @@
"Just e-mail" = "Just e-mail";
"E-mail" = "E-mail";
"Learn more" = "Learn more";
"per year" = "per year";
"per x years" = "per %@ years";
"per" = "per";
"unlimited" = "Unlimited";


"What’s included" = "What’s included";
"Submit" = "Submit";
"Resend" = "Resend";
Expand All @@ -1053,7 +1055,6 @@
"Paid by" = "Paid by %@";
"Myself" = "Myself";
"Pay by Card" = "Pay by Card";
"Details upon request" = "Details upon request";
"Min X characters" = "Min %@ characters";
"Pending" = "Pending...";

Expand Down
64 changes: 64 additions & 0 deletions Anytype/Resources/Strings/en.lproj/Localizable.stringsdict
Original file line number Diff line number Diff line change
Expand Up @@ -212,5 +212,69 @@
<string>%d request</string>
</dict>
</dict>
<key>Per Month</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>per %#@month@</string>
<key>month</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>d</string>
<key>one</key>
<string>month</string>
<key>other</key>
<string>%d months</string>
</dict>
</dict>
<key>Per Week</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>per %#@week@</string>
<key>week</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>d</string>
<key>one</key>
<string>week</string>
<key>other</key>
<string>%d weeks</string>
</dict>
</dict>
<key>Per Year</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>per %#@year@</string>
<key>year</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>d</string>
<key>one</key>
<string>year</string>
<key>other</key>
<string>%d years</string>
</dict>
</dict>
<key>Per Day</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>per %#@day@</string>
<key>day</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>d</string>
<key>one</key>
<string>day</string>
<key>other</key>
<string>%d days</string>
</dict>
</dict>
</dict>
</plist>
2 changes: 2 additions & 0 deletions Anytype/Sources/Helpers/Extensions/StringExtensions.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import UIKit
import AnytypeCore


extension String {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct MembershipCoordinator: View {
} else {
MembershipModuleView(
membership: model.userMembership,
tiers: model.tiers
tiers: model.tiers
) { tier in
model.onTierSelected(tier: tier)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import SwiftUI
import Services


struct MembershipPricingView: View {
let tier: MembershipTier

var body: some View {
switch tier.paymentType {
case .email:
AnytypeText(Loc.justEMail, style: .bodySemibold, color: .Text.primary)
case .appStore(let product):
AnytypeText("\(product.anytypeDisplayPrice) ", style: .bodySemibold, color: .Text.primary) +
AnytypeText(product.localizedPeriod ?? "", style: .caption1Regular, color: .Text.primary)
case .external(let info):
AnytypeText("\(info.displayPrice) ", style: .bodySemibold, color: .Text.primary) +
AnytypeText(info.localizedPeriod ?? "", style: .caption1Regular, color: .Text.primary)
}
}
}

#Preview {
MembershipPricingView(tier: .mockBuilder)
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,26 +77,11 @@ struct MembershipTeirView: View {
AnytypeText(Loc.pending, style: .caption1Regular, color: .Text.primary)
}
} else {
priceText
MembershipPricingView(tier: tierToDisplay)
}
}
}

var priceText: some View {
switch tierToDisplay.type {
case .explorer:
AnytypeText(Loc.justEMail, style: .bodySemibold, color: .Text.primary)
case .builder:
AnytypeText("$99 ", style: .bodySemibold, color: .Text.primary) +
AnytypeText(Loc.perYear, style: .caption1Regular, color: .Text.primary)
case .coCreator:
AnytypeText("$299 ", style: .bodySemibold, color: .Text.primary) +
AnytypeText(Loc.perXYears(3), style: .caption1Regular, color: .Text.primary)
case .custom:
AnytypeText(Loc.detailsUponRequest, style: .caption1Regular, color: .Text.primary)
}
}

var expirationText: some View {
Group {
switch tierToDisplay.type {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ extension MembershipTier {
Loc.Membership.Feature.sharedSpaces(3),
Loc.Membership.Feature.spaceWriters(3),
Loc.Membership.Feature.viewers(3)
]
],
paymentType: .email
)
}

Expand All @@ -93,7 +94,8 @@ extension MembershipTier {
Loc.Membership.Feature.sharedSpaces(3),
Loc.Membership.Feature.spaceWriters(10),
Loc.Membership.Feature.viewers("Unlimited")
]
],
paymentType: .mockExternal
)
}

Expand All @@ -107,7 +109,8 @@ extension MembershipTier {
Loc.Membership.Feature.sharedSpaces(3),
Loc.Membership.Feature.spaceWriters(10),
Loc.Membership.Feature.viewers("Unlimited")
]
],
paymentType: .mockExternal
)
}

Expand All @@ -121,7 +124,8 @@ extension MembershipTier {
Loc.Membership.Feature.sharedSpaces(333),
Loc.Membership.Feature.spaceWriters(100),
Loc.Membership.Feature.viewers("Unlimited")
]
],
paymentType: .mockExternal
)
}
}
Loading

0 comments on commit 167afb9

Please sign in to comment.