Skip to content

Commit

Permalink
add: Add swiftformat and swiftlint
Browse files Browse the repository at this point in the history
  • Loading branch information
WhiteHyun committed Jul 15, 2024
1 parent 5ab049a commit efcf75e
Show file tree
Hide file tree
Showing 11 changed files with 176 additions and 46 deletions.
21 changes: 21 additions & 0 deletions 멤버-개발-폴더/홍승현/pillyze/.swiftformat
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--swiftversion 6.0

# format options

--indent 2
--selfrequired
--importgrouping alpha
--emptybraces "linebreak"
--enable acronyms
--acronyms "URL, ID, UUID"
--enable blankLineAfterImports
--enable blankLinesAroundMark
--enable blockComments
--enable docComments
--enable isEmpty
--enable markTypes
--enable sortSwitchCases
--enable wrapEnumCases
--enable wrapSwitchCases

--disable wrapMultilineStatementBraces
41 changes: 41 additions & 0 deletions 멤버-개발-폴더/홍승현/pillyze/.swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
opt_in_rules:
- toggle_bool
- modifier_order
- yoda_condition
- trailing_closure
- vertical_parameter_alignment_on_call
- redundant_nil_coalescing
- prefer_self_type_over_type_of_self
- implicit_return
- empty_string

disabled_rules:
- trailing_comma
- line_length
- unused_closure_parameter
- multiple_closures_with_trailing_closure
- large_tuple
- todo # This is silly - todos are there for a reason
#######################
## Rule configs
#######################

force_cast: warning
force_try: warning

nesting:
type_level:
warning: 4

type_name:
allowed_symbols: "_"

identifier_name:
min_length:
warning: 3
error: 0
max_length:
warning: 40
error: 50
allowed_symbols: "_"
reporter: "xcode" # reporter type (xcode, json, csv, checkstyle, junit, html, emoji, sonarqube, markdown)
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,11 @@
isa = PBXNativeTarget;
buildConfigurationList = BAD7D1402C41753200E00E16 /* Build configuration list for PBXNativeTarget "pillyze" */;
buildPhases = (
BA5022232C456CB2008E7F9B /* Swift Format */,
BAD7D1182C41752F00E00E16 /* Sources */,
BAD7D1192C41752F00E00E16 /* Frameworks */,
BAD7D11A2C41752F00E00E16 /* Resources */,
BA5022242C456CC8008E7F9B /* SwiftLint */,
);
buildRules = (
);
Expand Down Expand Up @@ -183,6 +185,8 @@
Base,
);
mainGroup = BAD7D1132C41752F00E00E16;
packageReferences = (
);
productRefGroup = BAD7D11D2C41752F00E00E16 /* Products */;
projectDirPath = "";
projectRoot = "";
Expand Down Expand Up @@ -218,6 +222,45 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
BA5022232C456CB2008E7F9B /* Swift Format */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Swift Format";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "export PATH=\"$PATH:/opt/homebrew/bin\"\nif which swiftformat > /dev/null; then\n if [ \"${ENABLE_PREVIEWS}\" = \"YES\" ]; then\n echo \"Not running Swift Format for Xcode Previews\"\n exit 0;\n fi\n swiftformat .\nelse\n echo \"warning: SwiftFormat not installed, download from https://github.com/nicklockwood/SwiftFormat\"\nfi\n";
};
BA5022242C456CC8008E7F9B /* SwiftLint */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = SwiftLint;
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "export PATH=\"$PATH:/opt/homebrew/bin\"\nif which swiftlint > /dev/null; then\n swiftlint --config \"$SRCROOT/.swiftlint.yml\"\n # swiftlint --fix && swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
BAD7D1182C41752F00E00E16 /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand Down Expand Up @@ -293,7 +336,7 @@
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GCC_C_LANGUAGE_STANDARD = gnu17;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand Down Expand Up @@ -357,7 +400,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GCC_C_LANGUAGE_STANDARD = gnu17;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,48 @@

import SwiftUI

// MARK: - PillyzeTabBar

struct PillyzeTabBar: View {
@Binding var activeTab: Tabs

var body: some View {
HStack(alignment: .top, spacing: 115) {
ForEach(Tabs.allCases, id: \.rawValue) { tab in
TabBarItem(tab: tab, activeTab: $activeTab
)
}
}
.padding(.horizontal, 48)
.background {
UnevenRoundedRectangle(
topLeadingRadius: Metrics.cornerRadius,
topTrailingRadius: Metrics.cornerRadius
)
.fill(.white)
.ignoresSafeArea()
.shadow(color: .pillyzePrimary.opacity(0.1), radius: 8)
HStack(alignment: .top, spacing: 115) {
ForEach(Tabs.allCases, id: \.rawValue) { tab in
TabBarItem(tab: tab, activeTab: $activeTab)
}
.background(.white) // 위 모서리가 rounded된 것이 검은 배경으로 보이는 현상 방지
.overlay {
Button {
print("plus 버튼 탭")
} label: {
Image(.plus)
.frame(
maxWidth: Metrics.centerButtonSize,
maxHeight: Metrics.centerButtonSize
)
.foregroundStyle(.white)
.background(.pillyzePrimary)
.clipShape(Circle())
.offset(y: Metrics.centerButtonSize - Metrics.tabBarHeight - Metrics.centerButtonOffset)
}
}
.padding(.horizontal, 48)
.background {
UnevenRoundedRectangle(
topLeadingRadius: Metrics.cornerRadius,
topTrailingRadius: Metrics.cornerRadius
)
.fill(.white)
.ignoresSafeArea()
.shadow(color: .pillyzePrimary.opacity(0.1), radius: 8)
}
.background(.white) // 위 모서리가 rounded된 것이 검은 배경으로 보이는 현상 방지
.overlay {
Button {
print("plus 버튼 탭")
} label: {
Image(.plus)
.frame(
maxWidth: Metrics.centerButtonSize,
maxHeight: Metrics.centerButtonSize
)
.foregroundStyle(.white)
.background(.pillyzePrimary)
.clipShape(Circle())
.offset(y: Metrics.centerButtonSize - Metrics.tabBarHeight - Metrics.centerButtonOffset)
}
}
}
}

// MARK: - TabBarItem

private struct TabBarItem: View {
var tab: Tabs
@Binding var activeTab: Tabs
Expand All @@ -64,6 +67,8 @@ private struct TabBarItem: View {
}
}

// MARK: - Metrics

private enum Metrics {
static let centerButtonOffset: CGFloat = 8
static let cornerRadius: CGFloat = 24
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct ContentView: View {
var body: some View {
VStack(spacing: 0) {
TabView(selection: $selection) {
Text("MyHealth")
HomeView()
.tag(Tabs.myHealth)
.toolbar(.hidden, for: .tabBar)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ enum Tabs: String, Hashable, CaseIterable {
var image: Image {
switch self {
case .myHealth:
.init(.myHealth)
.init(.myHealth)
case .nutrients:
.init(.nutrients)
.init(.nutrients)
}
}

var index: Int {
Tabs.allCases.firstIndex(of: self) ?? 0
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// HomeView.swift
// pillyze
//
// Created by 홍승현 on 7/15/24.
//

import SwiftUI

struct HomeView: View {
var body: some View {
ZStack {
ScrollView {
}
}
}
}

#Preview {
HomeView()
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// pillyzeApp.swift
// PillyzeApp.swift
// pillyze
//
// Created by 홍승현 on 7/12/24.
Expand All @@ -8,7 +8,7 @@
import SwiftUI

@main
struct pillyzeApp: App {
struct PillyzeApp: App {
var body: some Scene {
WindowGroup {
ContentView()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//
// pillyzeTests.swift
// PillyzeTests.swift
// pillyzeTests
//
// Created by 홍승현 on 7/12/24.
//

import Testing
@testable import pillyze
import Testing

struct pillyzeTests {
struct PillyzeTests {
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//
// pillyzeUITests.swift
// PillyzeUITests.swift
// pillyzeUITests
//
// Created by 홍승현 on 7/12/24.
//

import XCTest

final class pillyzeUITests: XCTestCase {
final class PillyzeUITests: XCTestCase {
override func setUpWithError() throws {
continueAfterFailure = false
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
//
// pillyzeUITestsLaunchTests.swift
// PillyzeUITestsLaunchTests.swift
// pillyzeUITests
//
// Created by 홍승현 on 7/12/24.
//

import XCTest

final class pillyzeUITestsLaunchTests: XCTestCase {

final class PillyzeUITestsLaunchTests: XCTestCase {
override class var runsForEachTargetApplicationUIConfiguration: Bool {
true
}
Expand Down

0 comments on commit efcf75e

Please sign in to comment.