-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
195 additions
and
84 deletions.
There are no files selected for viewing
7 changes: 0 additions & 7 deletions
7
Packages/BeMatch/GraphQL/Queries/ActiveInvitationCampaign.graphql
This file was deleted.
Oops, something went wrong.
51 changes: 0 additions & 51 deletions
51
...es/BeMatch/Sources/BeMatch/Operations/Queries/ActiveInvitationCampaignQuery.graphql.swift
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
...ages/BeMatch/Sources/MembershipFeature/Assets.xcassets/bematch-pro.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 added
BIN
+19.5 KB
...es/BeMatch/Sources/MembershipFeature/Assets.xcassets/bematch-pro.imageset/bematch-pro.pdf
Binary file not shown.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
Packages/BeMatch/Sources/MembershipFeature/InvitationCampaignPrice.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters