Skip to content

Commit

Permalink
Merge pull request #718 from 0x1-company/fix
Browse files Browse the repository at this point in the history
Fix
  • Loading branch information
tomokisun authored Oct 9, 2023
2 parents fcf8efb + 81a6e06 commit bbb19ac
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 48 deletions.
67 changes: 32 additions & 35 deletions Packages/GodPackage/Sources/GodFeature/ShareTheApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public struct ShareTheAppLogic: Reducer {
public init() {}

public struct State: Equatable {
var currentUser: God.CurrentUserQuery.Data.CurrentUser?
var shareURL = URL(string: "https://godapp.jp")!
public init() {}
}

Expand All @@ -35,26 +35,26 @@ public struct ShareTheAppLogic: Reducer {
}

case .shareTheAppButtonTapped:
return .run { _ in
// await openURL(url)
}
case let .currentUserResponse(.success(data)):
guard
let schoolName = state.currentUser?.school?.name,
let username = state.currentUser?.username
let schoolName = data.currentUser.school?.name,
let username = data.currentUser.username
else { return .none }
let text = """
\(schoolName)向けの新しいアプリダウンロードしてみて!
https://godapp.jp/invite/\(username)?utm_source=line&utm_campaign=invite
https://godapp.jp/invite/\(username)?utm_source=line&utm_campaign=share_the_app
"""
guard let url = URL(string: "https://line.me/R/share?text=\(text)")
guard let shareURL = URL(string: "https://line.me/R/share?text=\(text)")
else { return .none }

return .run { _ in
await openURL(url)
}
case let .currentUserResponse(.success(data)):
state.currentUser = data.currentUser

state.shareURL = shareURL

return .none

case .currentUserResponse(.failure):
state.currentUser = nil
return .none
}
}
Expand All @@ -69,33 +69,30 @@ public struct ShareTheAppView: View {
}

public var body: some View {
ZStack {
Color.godService
.ignoresSafeArea()
VStack(spacing: 20) {
Image(ImageResource.upsideDownFace)
.resizable()
.aspectRatio(1, contentMode: .fit)
.frame(width: 100)
WithViewStore(store, observe: { $0 }) { viewStore in
ZStack {
Color.godService
.ignoresSafeArea()
VStack(spacing: 20) {
Text("Get more\nfriends to play")
.font(.title2)
.foregroundStyle(Color.white)

Text("Get more\nfriends to play", bundle: .module)
.font(.title2)
.foregroundStyle(Color.white)

ShareLink(
item: URL(string: "https://godapp.jp")!
) {
Text("Share the app", bundle: .module)
.bold()
.frame(width: 188, height: 54)
.background(Color.white)
.clipShape(Capsule())
ShareLink(
item: viewStore.shareURL
) {
Text("Share the app")
.bold()
.frame(width: 188, height: 54)
.background(Color.white)
.clipShape(Capsule())
}
.buttonStyle(HoldDownButtonStyle())
}
.buttonStyle(HoldDownButtonStyle())
.multilineTextAlignment(.center)
}
.multilineTextAlignment(.center)
.task { await store.send(.onTask).finish() }
}
.task { await store.send(.onTask).finish() }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public struct SchoolSettingView: View {
Text(school.usersCount.description)
.bold()
.foregroundColor(Color.godService)
Text("MEMBERS")
Text("MEMBERS", bundle: .module)
.foregroundColor(Color.godTextSecondaryLight)
}
.font(.footnote)
Expand Down
24 changes: 13 additions & 11 deletions Packages/GodPackage/Sources/ProfileShareFeature/ProfileShare.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public struct ProfileShareLogic: Reducer {
public struct State: Equatable {
var lineURL = URL(string: "https://godapp.jp")!
var shareURL = URL(string: "https://godapp.jp")!
var invitationText = ""
var smsText = ""
var currentUser: God.CurrentUserQuery.Data.CurrentUser?
@PresentationState var destination: Destination.State?
@PresentationState var message: CupertinoMessageLogic.State?
Expand Down Expand Up @@ -51,19 +51,12 @@ public struct ProfileShareLogic: Reducer {
return .none

case .contentButtonTapped(.line):
guard
let text = state.invitationText.addingPercentEncoding(withAllowedCharacters: .urlFragmentAllowed),
let url = URL(string: "https://line.me/R/share?text=\(text)")
else { return .none }
return .run { _ in
return .run { [url = state.lineURL] _ in
await openURL(url)
}

case .contentButtonTapped(.messages):
state.message = .init(
recipients: [],
body: state.invitationText
)
state.message = .init(recipients: [], body: state.smsText)
return .none

case .closeButtonTapped:
Expand All @@ -78,10 +71,19 @@ public struct ProfileShareLogic: Reducer {
let shareURL = URL(string: "https://godapp.jp/add/\(username)?utm_source=share&utm_campaign=profile")
else { return .none }
state.shareURL = shareURL
state.invitationText = """
state.smsText = """
\(schoolName)向けの新しいアプリダウンロードしてみて!
https://godapp.jp/add/\(username)?utm_source=sms&utm_campaign=profile
"""
let lineText = """
\(schoolName)向けの新しいアプリダウンロードしてみて!
https://godapp.jp/add/\(username)?utm_source=line&utm_campaign=profile
"""
guard
let text = lineText.addingPercentEncoding(withAllowedCharacters: .urlFragmentAllowed),
let lineURL = URL(string: "https://line.me/R/share?text=\(text)")
else { return .none }
state.lineURL = lineURL
return .none

default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
"sourceLanguage" : "en",
"strings" : {
"Close" : {

"localizations" : {
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "閉じる"
}
}
}
}
},
"version" : "1.0"
Expand Down

0 comments on commit bbb19ac

Please sign in to comment.