Skip to content

Commit

Permalink
🚨 (swiftformat): --enable organizeDeclarations
Browse files Browse the repository at this point in the history
  • Loading branch information
ladislas committed Dec 6, 2023
1 parent f7044a0 commit 4dfbab1
Show file tree
Hide file tree
Showing 222 changed files with 3,017 additions and 1,799 deletions.
2 changes: 2 additions & 0 deletions .swiftformat
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@

--enable opaqueGenericParameters

--enable organizeDeclarations

# Disabled rules

--disable blankLinesBetweenImports
Expand Down
33 changes: 19 additions & 14 deletions Apps/BLEKitExample/Sources/Models/Commands.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ import Foundation
// MARK: - LKCommand

enum LKCommand {
static let startByte: UInt8 = 0x2A
static let startByteLength: UInt8 = 0x04
static let ledFull: UInt8 = 0x13
static let motor: UInt8 = 0x20
static let motivator: UInt8 = 0x50

// MARK: - LKCommand Led Full

enum LedFull {
Expand Down Expand Up @@ -45,6 +39,12 @@ enum LKCommand {
static let spinBlink: UInt8 = 0x54
static let blinkGreen: UInt8 = 0x55
}

static let startByte: UInt8 = 0x2A
static let startByteLength: UInt8 = 0x04
static let ledFull: UInt8 = 0x13
static let motor: UInt8 = 0x20
static let motivator: UInt8 = 0x50
}

func checksum8(_ values: [UInt8]) -> UInt8 {
Expand All @@ -60,9 +60,22 @@ func checksum8(_ values: [UInt8]) -> UInt8 {
// MARK: - CommandKit

class CommandKit {
// MARK: Lifecycle

// MARK: - Initialisation

init() {
for _ in 0...LKCommand.startByteLength - 1 {
self.startSequence.append(LKCommand.startByte)
}
}

// MARK: Internal

// MARK: - Singleton

static let sharedSingleton = CommandKit()

let command = LKCommand.self

// MARK: - Variables
Expand All @@ -73,14 +86,6 @@ class CommandKit {
var numberOfCommands: Int = 0
var isEncapsulated: Bool = false

// MARK: - Initialisation

init() {
for _ in 0...LKCommand.startByteLength - 1 {
self.startSequence.append(LKCommand.startByte)
}
}

// MARK: - Led Functions

func addAllLeds(of earOrBelt: UInt8, rgbColor red: UInt8, _ green: UInt8, _ blue: UInt8) {
Expand Down
16 changes: 10 additions & 6 deletions Apps/BLEKitExample/Sources/Models/Robot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@ import BLEKit
import Foundation

class Robot: ObservableObject {
var robotPeripheral: RobotPeripheral? {
didSet {
updateDeviceInformation()
subscribeToDeviceUpdates()
}
}
// MARK: Internal

@Published var manufacturer: String = ""
@Published var modelNumber: String = ""
Expand All @@ -26,6 +21,13 @@ class Robot: ObservableObject {

let commands = CommandKit()

var robotPeripheral: RobotPeripheral? {
didSet {
updateDeviceInformation()
subscribeToDeviceUpdates()
}
}

func updateDeviceInformation() {
guard let robotPeripheral = self.robotPeripheral else { return }

Expand All @@ -51,6 +53,8 @@ class Robot: ObservableObject {
robotPeripheral.sendCommand(data)
}

// MARK: Private

private func registerReadOnlyCharacteristicClosures() {
for char in kDefaultReadOnlyCharacteristics {
var newChar = char
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import SwiftUI
// MARK: - BotFaceView

struct BotFaceView: View {
// MARK: Internal

@Binding var isSelected: Bool
@Binding var isConnected: Bool
@Binding var name: String
@Binding var battery: Int
@Binding var isCharging: Bool
@Binding var osVersion: String

@State private var rotation: CGFloat = 0.0

var body: some View {
VStack {
Image("robot_connexion_bluetooth")
Expand Down Expand Up @@ -50,6 +50,10 @@ struct BotFaceView: View {
}
.animation(.default, value: isConnected)
}

// MARK: Private

@State private var rotation: CGFloat = 0.0
}

// MARK: - BotFaceView_Previews
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ struct NoFeedback_ButtonStyle: ButtonStyle {
// MARK: - BotStore

struct BotStore: View {
// MARK: Internal

@EnvironmentObject var bleManager: BLEManager
@EnvironmentObject var robot: Robot
@ObservedObject var botVM: BotViewModel
Expand Down Expand Up @@ -57,6 +59,8 @@ struct BotStore: View {
.frame(height: 500)
}

// MARK: Private

private var availableBots: some View {
ForEach(0..<bleManager.peripherals.count, id: \.self) { item in
Button {
Expand Down
4 changes: 4 additions & 0 deletions Apps/BLEKitExample/Sources/View/RobotListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import BLEKit
import SwiftUI

struct RobotListView: View {
// MARK: Internal

@EnvironmentObject var bleManager: BLEManager
@EnvironmentObject var robot: Robot
@EnvironmentObject var botVM: BotViewModel
Expand All @@ -30,6 +32,8 @@ struct RobotListView: View {
}
}

// MARK: Private

private var searchButton: some View {
Button(
action: {
Expand Down
25 changes: 19 additions & 6 deletions Apps/LekaActivityUIExplorer/Sources/DesignSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ struct DesignSystem: View {

struct TitleView: View {
let title: String

var body: some View {
Text(title)
.padding(.horizontal)
Expand All @@ -77,6 +78,8 @@ struct TitleView: View {

struct FontsView: View {
struct FontView: View {
// MARK: Internal

let font: Font

var body: some View {
Expand All @@ -87,6 +90,8 @@ struct FontsView: View {
.font(font)
}

// MARK: Private

private var fontName: String {
switch font {
case .largeTitle:
Expand Down Expand Up @@ -138,9 +143,7 @@ struct FontsView: View {

struct ColorsView: View {
struct ColorView: View {
@Environment(\.self) var environment

let color: Color
// MARK: Lifecycle

init(color: Color) {
self.color = color
Expand All @@ -150,6 +153,12 @@ struct ColorsView: View {
self.color = Color(uiColor: uiColor)
}

// MARK: Internal

@Environment(\.self) var environment

let color: Color

var body: some View {
HStack {
Rectangle()
Expand Down Expand Up @@ -212,14 +221,18 @@ extension Color {

struct UIColorsView: View {
struct ColorView: View {
@Environment(\.self) var environment

let color: UIColor
// MARK: Lifecycle

init(color: UIColor) {
self.color = color
}

// MARK: Internal

@Environment(\.self) var environment

let color: UIColor

var body: some View {
HStack {
Rectangle()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ let kActivities: [Activity] = [
// MARK: - GEKNewSystemView

struct GEKNewSystemView: View {
// MARK: Internal

@EnvironmentObject var router: Router

@State var currentActivity: Activity?
Expand Down Expand Up @@ -72,6 +74,8 @@ struct GEKNewSystemView: View {
}
}

// MARK: Private

private var navigationTitleView: some View {
HStack(spacing: 4) {
Text("Leka Activity UI Explorer")
Expand Down
4 changes: 4 additions & 0 deletions Apps/LekaActivityUIExplorer/Sources/SwitchBoard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ struct SwitchBoard: View {
// MARK: - UIExplorerVersionSelector

struct UIExplorerVersionSelector: View {
// MARK: Internal

@EnvironmentObject var router: Router

@State var presentRobotConnection: Bool = false
Expand Down Expand Up @@ -102,6 +104,8 @@ struct UIExplorerVersionSelector: View {
}
}

// MARK: Private

private var logoLeka: some View {
DesignKitAsset.Assets.lekaLogo.swiftUIImage
.resizable()
Expand Down
2 changes: 2 additions & 0 deletions Apps/LekaApp/Sources/Data/AvatarsData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ struct AvatarCategory: Identifiable, Hashable {
enum AvatarSets: Int, CaseIterable, Hashable {
case girls, boys, lekaGirls, lekaBoys, jobs, weather, sunglasses, animals, fruits, vegies

// MARK: Internal

var id: Self { self }

var content: AvatarCategory {
Expand Down
6 changes: 3 additions & 3 deletions Apps/LekaApp/Sources/Data/DiscoveryCompany.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import DesignKit
import SwiftUI

class DiscoveryCompany {
let discoveryCompany = Company(
mail: "[email protected]", password: "Password1234", teachers: discoveryTeachers, users: discoveryUsers)

static var discoveryTeachers: [Teacher] =
[
Teacher(
Expand Down Expand Up @@ -131,4 +128,7 @@ class DiscoveryCompany {
reinforcer: 3
),
]

let discoveryCompany = Company(
mail: "[email protected]", password: "Password1234", teachers: discoveryTeachers, users: discoveryUsers)
}
2 changes: 2 additions & 0 deletions Apps/LekaApp/Sources/Data/TilesContent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ enum TileData: Int, CaseIterable, Hashable {
case discovery, curriculums, activities, commands
case signupBravo, signupStep1, signupStep2, signupFinalStep

// MARK: Internal

var id: Self { self }

var content: TileContent {
Expand Down
4 changes: 4 additions & 0 deletions Apps/LekaApp/Sources/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import SwiftUI
// MARK: - HomeView

struct HomeView: View {
// MARK: Internal

@EnvironmentObject var navigationVM: NavigationViewModel
@EnvironmentObject var settings: SettingsViewModel
@EnvironmentObject var metrics: UIMetrics
Expand Down Expand Up @@ -63,6 +65,8 @@ struct HomeView: View {
}
}

// MARK: Private

private var toolbarTitle: some View {
HStack(spacing: 4) {
Text(navigationVM.setNavTitle())
Expand Down
Loading

0 comments on commit 4dfbab1

Please sign in to comment.