Skip to content

Commit

Permalink
Merge pull request #947 from 0x1-company/create-pull-request/patch-21…
Browse files Browse the repository at this point in the history
…c8937

Run swift-format
  • Loading branch information
github-actions[bot] authored Nov 6, 2023
2 parents ee7ac46 + b4a3f62 commit b5c0030
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 35 deletions.
49 changes: 25 additions & 24 deletions Packages/GodPackage/Sources/OnboardFeature/InviteFriend.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import AnalyticsClient
import ComposableArchitecture
import God
import GodClient
import Styleguide
import SwiftUI
import Lottie
import ShareLinkBuilder
import Styleguide
import SwiftUI

public struct InviteFriendLogic: Reducer {
public init() {}

public struct CompletionWithItems: Equatable {
public let activityType: UIActivity.ActivityType?
public let result: Bool
Expand All @@ -19,8 +19,9 @@ public struct InviteFriendLogic: Reducer {
public struct State: Equatable {
var shareURL = URL(string: "https://godapp.jp")!
var remainingInvitationCount: Int {
return invites.filter { !$0 }.count
invites.filter { !$0 }.count
}

var invites = Array(repeating: false, count: 3)
@BindingState var isPresented = false
@PresentationState var alert: AlertState<Action.Alert>?
Expand All @@ -38,19 +39,19 @@ public struct InviteFriendLogic: Reducer {
case binding(BindingAction<State>)
case alert(PresentationAction<Alert>)
case delegate(Delegate)

public enum Alert: Equatable {
case confirmOkay
}

public enum Delegate: Equatable {
case nextScreen
}
}

@Dependency(\.godClient) var godClient
@Dependency(\.analytics) var analytics

enum Cancel {
case currentUser
}
Expand All @@ -72,7 +73,7 @@ public struct InviteFriendLogic: Reducer {
case .onAppear:
analytics.logScreen(screenName: "InviteFriend", of: self)
return .none

case .whyFriendsButtonTapped:
state.alert = AlertState {
TextState("To use God, you need friends from the same school 👥", bundle: .module)
Expand All @@ -84,14 +85,14 @@ public struct InviteFriendLogic: Reducer {
TextState("God is by invitation only; send invitations to 3 people and you will be specifically invited.", bundle: .module)
}
return .none

case .inviteFriendButtonTapped where state.remainingInvitationCount == 0:
return .send(.delegate(.nextScreen))

case .inviteFriendButtonTapped:
state.isPresented = true
return .none

case let .currentUserResponse(.success(data)):
guard let username = data.currentUser.username
else { return .none }
Expand All @@ -102,25 +103,25 @@ public struct InviteFriendLogic: Reducer {
medium: .requiredInvite
)
return .none

case let .onCompletion(completion):
state.isPresented = false
guard
completion.result,
state.remainingInvitationCount > 0
else { return .none }
for i in 0..<state.invites.count {
for i in 0 ..< state.invites.count {
if !state.invites[i] {
state.invites[i] = true
break
}
}
return .none

case .alert(.presented(.confirmOkay)):
state.alert = nil
return .none

default:
return .none
}
Expand All @@ -141,15 +142,15 @@ public struct InviteFriendView: View {
Text("Finally, please invite your friends\nInvite your friends", bundle: .module)
.font(.system(.title, design: .rounded, weight: .black))
.foregroundStyle(Color.white)

Text("INVITE \(viewStore.remainingInvitationCount) FRIENDS", bundle: .module)
.font(.system(.body, design: .rounded, weight: .bold))
.foregroundStyle(Color.white)
.padding(.vertical, 4)
.padding(.horizontal, 12)
.background(Color.godService)
.clipShape(Capsule())

HStack(alignment: .top, spacing: 24) {
ForEach(viewStore.invites, id: \.self) { isInvited in
Button {
Expand All @@ -165,18 +166,18 @@ public struct InviteFriendView: View {
Image(systemName: "person.crop.circle.badge.plus")
}
}
.frame(width: 80, height: 80)
.font(.system(size: 50))
.clipShape(Circle())
.frame(width: 80, height: 80)
.font(.system(size: 50))
.clipShape(Circle())

Text(isInvited ? "invited via\nother app" : "No friend\ninvited yet", bundle: .module)
.font(.system(.body, design: .rounded))
}
.foregroundStyle(Color.godTextSecondaryDark)
}
}
}

Button {
store.send(.whyFriendsButtonTapped)
} label: {
Expand All @@ -188,9 +189,9 @@ public struct InviteFriendView: View {
}
.foregroundStyle(Color.yellow)
}

Spacer()

Button {
store.send(.inviteFriendButtonTapped)
} label: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public struct OnboardPathLogic: Reducer {
case .addFriends(.delegate(.nextScreen)):
state.path.append(.inviteFriend())
return .none

case .inviteFriend(.delegate(.nextScreen)):
state.path.append(.howItWorks())
return .none
Expand Down
19 changes: 9 additions & 10 deletions Packages/UIComponentPackage/Sources/ActivityView/File.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import SwiftUI

public struct ActivityView: UIViewControllerRepresentable {
public typealias UIViewControllerType = UIActivityViewController

let activityViewController: UIActivityViewController

public init(
activityItemsConfiguration: UIActivityItemsConfigurationReading,
completionWithItemsHandler: UIActivityViewController.CompletionWithItemsHandler?
Expand All @@ -13,7 +13,7 @@ public struct ActivityView: UIViewControllerRepresentable {
activityViewController.completionWithItemsHandler = completionWithItemsHandler
self.activityViewController = activityViewController
}

public init(
activityItems: [Any],
applicationActivities: [UIActivity]?,
Expand All @@ -23,24 +23,23 @@ public struct ActivityView: UIViewControllerRepresentable {
activityViewController.completionWithItemsHandler = completionWithItemsHandler
self.activityViewController = activityViewController
}

public func makeUIViewController(context: Context) -> UIActivityViewController {
return activityViewController
}

public func updateUIViewController(_ uiViewController: UIActivityViewController, context: Context) {
activityViewController
}

public func updateUIViewController(_ uiViewController: UIActivityViewController, context: Context) {}
}

#Preview {
Color.clear
.sheet(isPresented: .constant(true)) {
ActivityView(
activityItems: [
"tomokisun"
"tomokisun",
],
applicationActivities: nil
) { activityType, result, _, error in
) { activityType, _, _, _ in
print(activityType)
}
.presentationDetents([.medium, .large])
Expand Down

0 comments on commit b5c0030

Please sign in to comment.