Skip to content

Commit

Permalink
fix: 🐛 campaign
Browse files Browse the repository at this point in the history
  • Loading branch information
tomokisun committed Jan 16, 2024
1 parent 48c5fda commit 682d90b
Show file tree
Hide file tree
Showing 11 changed files with 195 additions and 84 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "bematch-pro.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,16 @@ public struct InvitationCampaignView: View {
Text("Both those who invited and those who were invited.", bundle: .module)

VStack(spacing: 8) {
Text(viewStore.totalBenefit.description)
.foregroundStyle(textGradient)
.font(.system(size: 72, weight: .heavy))
HStack(spacing: 8) {
Text(viewStore.totalBenefit.description)
.font(.system(size: 72, weight: .heavy))
VStack(spacing: 0) {
Text("")
Text("")
}
.font(.system(size: 22, weight: .bold))
}
.foregroundStyle(textGradient)

Text("benefits to each other!", bundle: .module)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import AnalyticsClient
import ComposableArchitecture
import SwiftUI

@Reducer
public struct InvitationCampaignPriceLogic {
public init() {}

public struct State: Equatable {
let durationWeeks: Int
var displayDuration = ""

public init(durationWeeks: Int) {
self.durationWeeks = durationWeeks
}
}

public enum Action {
case onTask
}

@Dependency(\.analytics) var analytics

public var body: some Reducer<State, Action> {
Reduce<State, Action> { state, action in
switch action {
case .onTask:
state.displayDuration = formatDuration(state.durationWeeks)
return .none
}
}
}

func formatDuration(_ durationWeeks: Int) -> String {
if durationWeeks <= 3 {
return "\(durationWeeks)週間"
}

let months = durationWeeks / 4
let remainingWeeks = durationWeeks % 4

let years = months / 12
let remainingMonths = months % 12

var result: [String] = []
if years > 0 {
result.append("\(years)年間")
}
if remainingMonths > 0 {
result.append("\(remainingMonths)ヶ月間")
}
if remainingWeeks > 0 {
result.append("\(remainingWeeks)週間")
}

return result.joined(separator: ", ")
}
}

public struct InvitationCampaignPriceView: View {
let store: StoreOf<InvitationCampaignPriceLogic>

public init(store: StoreOf<InvitationCampaignPriceLogic>) {
self.store = store
}

public var body: some View {
WithViewStore(store, observe: { $0 }) { viewStore in
VStack(spacing: 0) {
Text("When a friend enters your invitation code\nyou will receive a", bundle: .module)
.padding(.top, 24)

Image(ImageResource.bematchPro)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(height: 32)
.padding(.top, 16)

HStack(alignment: .bottom, spacing: 4) {
Text("\(viewStore.displayDuration)")
Text("0")
.font(.system(size: 72, weight: .heavy))
.offset(y: 16)
Text("")
}
.font(.system(size: 22, weight: .bold))
.foregroundStyle(
LinearGradient(
colors: [
Color(0xFFE8_B423),
Color(0xFFF5_D068),
],
startPoint: .leading,
endPoint: .trailing
)
)
}
.background()
.multilineTextAlignment(.center)
.task { await store.send(.onTask).finish() }
}
}
}

#Preview {
InvitationCampaignPriceView(
store: .init(
initialState: InvitationCampaignPriceLogic.State(
durationWeeks: 4
),
reducer: { InvitationCampaignPriceLogic() }
)
)
.environment(\.colorScheme, .dark)
.environment(\.locale, Locale(identifier: "ja-JP"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,35 +48,29 @@ public struct InvitationCodeCampaignView: View {
public var body: some View {
WithViewStore(store, observe: { $0 }) { viewStore in
VStack(spacing: 16) {
Image(ImageResource.bematchCampaign)
Image(ImageResource.inviteTicket)
.resizable()
.padding(.horizontal, 60)

VStack(spacing: 16) {
Image(ImageResource.inviteTicket)
.resizable()
.aspectRatio(contentMode: .fit)
.overlay(alignment: .center) {
Text(viewStore.code)
.foregroundStyle(Color(0xFFFF_CC00))
.font(.system(.largeTitle, design: .rounded, weight: .bold))
.offset(x: -35, y: 8)
}

PrimaryButton(
String(localized: "Send Invitation Code", bundle: .module)
) {
store.send(.invitationCodeButtonTapped)
.aspectRatio(contentMode: .fit)
.overlay(alignment: .center) {
Text(viewStore.code)
.foregroundStyle(Color(0xFFFF_CC00))
.font(.system(.largeTitle, design: .rounded, weight: .bold))
.offset(x: -35, y: 8)
}

PrimaryButton(
String(localized: "Send Invitation Code", bundle: .module)
) {
store.send(.invitationCodeButtonTapped)
}
.padding(.all, 16)
.background(Color(uiColor: UIColor.secondarySystemBackground))
.clipShape(RoundedRectangle(cornerRadius: 16))
.padding(.horizontal, 16)
}
.padding(.all, 16)
.multilineTextAlignment(.center)
.background(Color(uiColor: UIColor.secondarySystemBackground))
.clipShape(RoundedRectangle(cornerRadius: 16))
.padding(.horizontal, 16)
.padding(.vertical, 24)
.background()
.multilineTextAlignment(.center)
}
}
}
Expand Down
22 changes: 22 additions & 0 deletions Packages/BeMatch/Sources/MembershipFeature/Localizable.xcstrings
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"sourceLanguage" : "en",
"strings" : {
"0" : {

},
"benefits to each other!" : {
"localizations" : {
"ja" : {
Expand Down Expand Up @@ -90,6 +93,25 @@
}
}
}
},
"When a friend enters your invitation code\nyou will receive a" : {
"localizations" : {
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "友達があなたの招待コードを\n入力すると、お互いに"
}
}
}
},
"が%@" : {

},
"円" : {

},
"分" : {

}
},
"version" : "1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public struct MembershipCampaignLogic {
let displayPrice: String

var invitationCampaign: InvitationCampaignLogic.State
var invitationCampaignPrice: InvitationCampaignPriceLogic.State
var invitationCodeCampaign: InvitationCodeCampaignLogic.State

public init(
Expand All @@ -25,6 +26,9 @@ public struct MembershipCampaignLogic {
quantity: campaign.quantity,
durationWeeks: campaign.durationWeeks
)
invitationCampaignPrice = InvitationCampaignPriceLogic.State(
durationWeeks: campaign.durationWeeks
)
invitationCodeCampaign = InvitationCodeCampaignLogic.State(code: code)
}
}
Expand All @@ -34,6 +38,7 @@ public struct MembershipCampaignLogic {
case invitationCodeButtonTapped
case upgradeButtonTapped
case invitationCampaign(InvitationCampaignLogic.Action)
case invitationCampaignPrice(InvitationCampaignPriceLogic.Action)
case invitationCodeCampaign(InvitationCodeCampaignLogic.Action)
case delegate(Delegate)

Expand All @@ -52,6 +57,9 @@ public struct MembershipCampaignLogic {
Scope(state: \.invitationCodeCampaign, action: \.invitationCodeCampaign) {
InvitationCodeCampaignLogic()
}
Scope(state: \.invitationCampaignPrice, action: \.invitationCampaignPrice) {
InvitationCampaignPriceLogic()
}
Reduce<State, Action> { _, action in
switch action {
case .onTask:
Expand Down Expand Up @@ -89,6 +97,13 @@ public struct MembershipCampaignView: View {
)
)

InvitationCampaignPriceView(
store: store.scope(
state: \.invitationCampaignPrice,
action: \.invitationCampaignPrice
)
)

InvitationCodeCampaignView(
store: store.scope(
state: \.invitationCodeCampaign,
Expand All @@ -99,6 +114,9 @@ public struct MembershipCampaignView: View {
VStack(spacing: 60) {
Image(ImageResource.membershipBenefit)
.resizable()

Image(ImageResource.howToReceiveBenefit)
.resizable()

PurchaseAboutView()
}
Expand Down

0 comments on commit 682d90b

Please sign in to comment.