Created
March 17, 2022 06:27
-
-
Save dmikots/9850368f5078a837e5d0d85667fb241a to your computer and use it in GitHub Desktop.
bug cell
This file contains hidden or 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
//CellView | |
struct LeaderboardCellView: View { | |
let store: Store<LeaderboardCellState, LeaderboardCellAction> | |
var body: some View { | |
WithViewStore(self.store) { viewStore in | |
HStack(spacing: 20) { | |
HStack(spacing: 5) { | |
Image("cup") | |
.resizable() | |
.scaledToFit() | |
.frame(width: 13, height: 16).opacity(viewStore.state.leaderboardCell.isLeader ? 1 : 0) | |
Text(viewStore.state.leaderboardCell.place) | |
.foregroundColor(.white) | |
} | |
.padding(.leading) | |
Text(viewStore.state.leaderboardCell.name) | |
.padding(.vertical) | |
.foregroundColor(.white) | |
.frame(width: UIScreen.main.bounds.width * 0.2133) | |
Image("car1") | |
.resizable() | |
.scaledToFill() | |
.frame(maxHeight: 28) | |
.offset(y: -5) | |
.overlay( | |
Text(viewStore.state.leaderboardCell.racerClass) | |
.foregroundColor(.gray) | |
.font(.caption2) | |
.lineLimit(1) | |
.frame(maxWidth: UIScreen.main.bounds.width * 0.1147) | |
.offset(y: 4), | |
alignment: .bottom | |
) | |
.padding(.vertical) | |
VStack { | |
Text(viewStore.state.leaderboardCell.time) | |
.font(.footnote) | |
.foregroundColor(.white) | |
.lineLimit(1) | |
.frame(width: UIScreen.main.bounds.width * 0.208) | |
HStack(spacing: 10) { | |
HStack(spacing: 1) { | |
if viewStore.state.leaderboardCell.isLeader { | |
Text("Leader") | |
.foregroundColor(.white) | |
.font(.caption) | |
.padding(.leading) | |
.lineLimit(1) | |
.minimumScaleFactor(0.3) | |
} else { | |
Text("int.") | |
.foregroundColor(.gray) | |
.font(.caption2) | |
.lineLimit(1) | |
.minimumScaleFactor(0.3) | |
Text(viewStore.state.leaderboardCell.intTime) | |
.foregroundColor(.white) | |
.font(.caption2) | |
.minimumScaleFactor(0.5) | |
.lineLimit(1) | |
.minimumScaleFactor(0.3) | |
} | |
} | |
.frame(width: UIScreen.main.bounds.width * 0.1173) | |
HStack(spacing: 1) { | |
if viewStore.state.leaderboardCell.isLeader { | |
Text("Leader") | |
.foregroundColor(.white) | |
.font(.caption) | |
.padding(.leading) | |
.lineLimit(1) | |
.minimumScaleFactor(0.3) | |
} else { | |
Text("gap.") | |
.foregroundColor(.gray) | |
.font(.caption2) | |
.lineLimit(1) | |
Text(viewStore.state.leaderboardCell.gapTime) | |
.foregroundColor(.white) | |
.font(.caption2) | |
.lineLimit(1) | |
.minimumScaleFactor(0.3) | |
} | |
} | |
.frame(width: UIScreen.main.bounds.width * 0.1173) | |
} | |
.padding(.trailing, 20) | |
} | |
} | |
.background( | |
ZStack { | |
Color("closeIcon") | |
ZStack { | |
Rectangle() | |
.stroke(Color.white, lineWidth: 2) | |
Rectangle() | |
.fill(Color.white).opacity(0.3) | |
}.opacity(viewStore.state.leaderboardCell.isMyResult ? 1 : 0) | |
ZStack { | |
Rectangle() | |
.stroke(Color.red, lineWidth: 2) | |
}.opacity(viewStore.state.leaderboardCell.isLeader ? 1 : 0) | |
if !viewStore.state.leaderboardCell.isLeader && !viewStore.state.leaderboardCell.isMyResult { | |
ZStack { | |
Rectangle() | |
.stroke(Color.gray, lineWidth: 1) | |
} | |
} | |
} | |
) | |
.overlay( | |
Triangle() | |
.fill(.yellow) | |
.frame(maxWidth: 25, maxHeight: 25) | |
.padding(2) | |
.opacity(viewStore.state.leaderboardCell.isFriend ? 1 : 0), | |
alignment: .topLeading | |
) | |
.padding(.horizontal) | |
} | |
} | |
} | |
//Row View | |
struct PastCompetitionLeaderboardInfoView: View { | |
let store: Store<PastCompetitionLeaderboardInfoState, PastCompetitionLeaderboardInfoAction> | |
var body: some View { | |
WithViewStore(self.store) { viewStore in | |
ZStack { | |
Color.black.ignoresSafeArea() | |
VStack { | |
HStack(spacing: 10) { | |
Text("LEADERBOARD") | |
.foregroundColor(.white).bold() | |
Button(action: { | |
viewStore.send(.closeLeaderboard) | |
}) { | |
Image(systemName: "arrow.down") | |
.foregroundColor(.red) | |
} | |
} | |
CustomGraySegmentedControl( | |
preselectedIndex: viewStore.binding(\.$picker), | |
options: ["Total Leaderboard", "Only My Friends"] | |
) | |
.padding(.horizontal) | |
.padding() | |
.padding(.bottom) | |
.onChange(of: viewStore.state.picker) { value in | |
viewStore.send(.checkControl) | |
} | |
ScrollView(.vertical, showsIndicators: false) { | |
VStack(spacing: 1) { | |
if viewStore.state.picker == 0 { | |
ForEachStore( | |
self.store.scope( | |
state: \.totalLeaderboardRow, | |
action: PastCompetitionLeaderboardInfoAction.totalLeaderboardCellAction(id:action:) | |
), | |
content: LeaderboardCellView.init(store:) | |
) | |
} else { | |
ForEachStore( | |
self.store.scope( | |
state: \.onlyMyFriendsLeaderboardRow, | |
action: PastCompetitionLeaderboardInfoAction | |
.onlyMyFriendsLeaderboardRowCellAction(id:action:) | |
), | |
content: LeaderboardCellView.init(store:) | |
) | |
} | |
} | |
} | |
.animation(.default) | |
.frame(maxWidth: .infinity) | |
} | |
.padding(.top) | |
.onAppear { | |
viewStore.send(.onAppearTotal) | |
} | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
если добавлять правильное расширение .swift то будет работать подсветка