Configured and applied SwiftFormat

This commit is contained in:
Stefan Ceriu
2022-09-27 10:17:22 +03:00
committed by Stefan Ceriu
parent ff2e6ddfa7
commit 43c28d23b7
663 changed files with 2329 additions and 2840 deletions
@@ -14,15 +14,14 @@
// limitations under the License.
//
import SwiftUI
import CommonKit
import SwiftUI
protocol OnboardingSplashScreenCoordinatorProtocol: Coordinator, Presentable {
var completion: ((OnboardingSplashScreenViewModelResult) -> Void)? { get set }
}
final class OnboardingSplashScreenCoordinator: OnboardingSplashScreenCoordinatorProtocol {
// MARK: - Properties
// MARK: Private
@@ -52,6 +51,7 @@ final class OnboardingSplashScreenCoordinator: OnboardingSplashScreenCoordinator
}
// MARK: - Public
func start() {
MXLog.debug("[OnboardingSplashScreenCoordinator] did start.")
onboardingSplashScreenViewModel.completion = { [weak self] result in
@@ -68,7 +68,7 @@ final class OnboardingSplashScreenCoordinator: OnboardingSplashScreenCoordinator
}
func toPresentable() -> UIViewController {
return onboardingSplashScreenHostingController
onboardingSplashScreenHostingController
}
/// Stops any ongoing activities in the coordinator.
@@ -1,4 +1,4 @@
//
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -36,7 +36,7 @@ enum MockOnboardingSplashScreenScreenState: MockScreenState, CaseIterable {
}
/// Generate the view struct for the screen state.
var screenView: ([Any], AnyView) {
var screenView: ([Any], AnyView) {
let viewModel = OnboardingSplashScreenViewModel()
// can simulate service and viewModel actions here if needs be.
@@ -1,4 +1,4 @@
//
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -36,7 +36,6 @@ enum OnboardingSplashScreenViewModelResult {
// MARK: View
struct OnboardingSplashScreenViewState: BindableState, CustomDebugStringConvertible {
/// The colours of the background gradient shown behind the 4 pages.
private let gradientColors = [
Color(red: 0.95, green: 0.98, blue: 0.96),
@@ -67,7 +66,7 @@ struct OnboardingSplashScreenViewState: BindableState, CustomDebugStringConverti
let locale = Locale.current
let page4Title = locale.identifier.hasPrefix("en") ? "Cut the slack from teams." : VectorL10n.onboardingSplashPage4TitleNoPun
self.content = [
content = [
OnboardingSplashScreenPageContent(title: VectorL10n.onboardingSplashPage1Title,
message: VectorL10n.onboardingSplashPage1Message,
image: Asset.Images.onboardingSplashScreenPage1,
@@ -83,9 +82,9 @@ struct OnboardingSplashScreenViewState: BindableState, CustomDebugStringConverti
OnboardingSplashScreenPageContent(title: page4Title,
message: VectorL10n.onboardingSplashPage4Message,
image: Asset.Images.onboardingSplashScreenPage4,
darkImage: Asset.Images.onboardingSplashScreenPage4Dark),
darkImage: Asset.Images.onboardingSplashScreenPage4Dark)
]
self.bindings = OnboardingSplashScreenBindings()
bindings = OnboardingSplashScreenBindings()
}
}
@@ -14,12 +14,12 @@
// limitations under the License.
//
import SwiftUI
import Combine
import SwiftUI
typealias OnboardingSplashScreenViewModelType = StateStoreViewModel<OnboardingSplashScreenViewState,
Never,
OnboardingSplashScreenViewAction>
Never,
OnboardingSplashScreenViewAction>
protocol OnboardingSplashScreenViewModelProtocol {
var completion: ((OnboardingSplashScreenViewModelResult) -> Void)? { get set }
@@ -27,7 +27,6 @@ protocol OnboardingSplashScreenViewModelProtocol {
}
class OnboardingSplashScreenViewModel: OnboardingSplashScreenViewModelType, OnboardingSplashScreenViewModelProtocol {
// MARK: - Properties
// MARK: Private
@@ -55,7 +54,7 @@ class OnboardingSplashScreenViewModel: OnboardingSplashScreenViewModelType, Onbo
state.bindings.pageIndex = (state.bindings.pageIndex + 1) % state.content.count
case .previousPage:
// Prevent the hidden page at index -1 from being shown.
state.bindings.pageIndex = max(0, (state.bindings.pageIndex - 1))
state.bindings.pageIndex = max(0, state.bindings.pageIndex - 1)
case .hiddenPage:
// Hidden page for a nicer animation when looping back to the start.
state.bindings.pageIndex = -1
@@ -1,4 +1,4 @@
//
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,11 +14,9 @@
// limitations under the License.
//
import XCTest
import Combine
import XCTest
@testable import RiotSwiftUI
class OnboardingSplashScreenViewModelTests: XCTestCase {
}
class OnboardingSplashScreenViewModelTests: XCTestCase { }
@@ -1,4 +1,4 @@
//
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,7 +18,6 @@ import SwiftUI
/// The splash screen shown at the beginning of the onboarding flow.
struct OnboardingSplashScreen: View {
// MARK: - Properties
// MARK: Private
@@ -46,7 +45,6 @@ struct OnboardingSplashScreen: View {
// The main content of the carousel
HStack(alignment: .top, spacing: 0) {
// Add a hidden page at the start of the carousel duplicating the content of the last page
OnboardingSplashScreenPage(content: viewModel.viewState.content[pageCount - 1])
.frame(width: geometry.size.width)
@@ -55,7 +53,6 @@ struct OnboardingSplashScreen: View {
OnboardingSplashScreenPage(content: viewModel.viewState.content[index])
.frame(width: geometry.size.width)
}
}
.offset(x: pageOffset(in: geometry))
@@ -63,8 +60,8 @@ struct OnboardingSplashScreen: View {
OnboardingSplashScreenPageIndicator(pageCount: pageCount,
pageIndex: viewModel.pageIndex)
.frame(width: geometry.size.width)
.padding(.bottom)
.frame(width: geometry.size.width)
.padding(.bottom)
Spacer()
@@ -130,7 +127,7 @@ struct OnboardingSplashScreen: View {
private func startTimer() {
guard pageTimer == nil else { return }
pageTimer = Timer.scheduledTimer(withTimeInterval: 5, repeats: true) { timer in
pageTimer = Timer.scheduledTimer(withTimeInterval: 5, repeats: true) { _ in
if viewModel.pageIndex == pageCount - 1 {
viewModel.send(viewAction: .hiddenPage)
@@ -164,7 +161,7 @@ struct OnboardingSplashScreen: View {
/// - Parameter width: The gesture's translation width.
/// - Returns: `true` if there is another page to drag to.
private func shouldSwipeForTranslation(_ width: CGFloat) -> Bool {
if viewModel.pageIndex == 0 {
if viewModel.pageIndex == 0 {
return isLeftToRight ? width < 0 : width > 0
} else if viewModel.pageIndex == pageCount - 1 {
return isLeftToRight ? width > 0 : width < 0
@@ -1,4 +1,4 @@
//
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,13 +17,14 @@
import SwiftUI
struct OnboardingSplashScreenPage: View {
// MARK: - Properties
// MARK: Private
@Environment(\.theme) private var theme
// MARK: Public
/// The content that this page should display.
let content: OnboardingSplashScreenPageContent
@@ -35,8 +36,8 @@ struct OnboardingSplashScreenPage: View {
.resizable()
.scaledToFit()
.frame(maxWidth: 310) // This value is problematic. 300 results in dropped frames
// on iPhone 12/13 Mini. 305 the same on iPhone 12/13. As of
// iOS 15, 310 seems fine on all supported screen widths 🤞.
// on iPhone 12/13 Mini. 305 the same on iPhone 12/13. As of
// iOS 15, 310 seems fine on all supported screen widths 🤞.
.padding(20)
.accessibilityHidden(true)
@@ -60,7 +61,7 @@ struct OnboardingSplashScreenPage: View {
struct OnboardingSplashScreenPage_Previews: PreviewProvider {
static let content = OnboardingSplashScreenViewState().content
static var previews: some View {
ForEach(0..<content.count, id:\.self) { index in
ForEach(0..<content.count, id: \.self) { index in
OnboardingSplashScreenPage(content: content[index])
}
}
@@ -1,4 +1,4 @@
//
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,13 +17,14 @@
import SwiftUI
struct OnboardingSplashScreenPageIndicator: View {
// MARK: - Properties
// MARK: Private
@Environment(\.theme) private var theme
// MARK: Public
/// The number of pages that are shown.
let pageCount: Int
/// The index of the current page
@@ -44,7 +45,7 @@ struct OnboardingSplashScreenPageIndicator: View {
var body: some View {
HStack {
ForEach(0..<pageCount) { index in
ForEach(0..<pageCount, id: \.self) { index in
Circle()
.frame(width: 8, height: 8)
.foregroundColor(index == pageIndex ? .accentColor : theme.colors.quarterlyContent)