Skip to content
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.

Commit

Permalink
Merge pull request #8 from KU-Stacks/feature/jaesung/apply-swiftlint
Browse files Browse the repository at this point in the history
[1.0.0] SwiftLint 적용
  • Loading branch information
x-0o0 committed Sep 5, 2022
2 parents 9ba7861 + fbff9e8 commit 0ec9aec
Show file tree
Hide file tree
Showing 22 changed files with 234 additions and 113 deletions.
25 changes: 25 additions & 0 deletions KuringLite.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
/* Begin PBXFileReference section */
A95125A7284C973A0072EB8E /* FeedbackView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedbackView.swift; sourceTree = "<group>"; };
A95125AC284CF94F0072EB8E /* KuringLite.docc */ = {isa = PBXFileReference; lastKnownFileType = folder.documentationcatalog; path = KuringLite.docc; sourceTree = "<group>"; };
A95125C22854C2E80072EB8E /* .swiftlint.yml */ = {isa = PBXFileReference; lastKnownFileType = text.yaml; path = .swiftlint.yml; sourceTree = "<group>"; };
A983BABE284BB08F00B96FF1 /* 쿠링 Lite.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "쿠링 Lite.app"; sourceTree = BUILT_PRODUCTS_DIR; };
A983BAC1284BB08F00B96FF1 /* KuringLiteApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KuringLiteApp.swift; sourceTree = "<group>"; };
A983BAC3284BB08F00B96FF1 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -170,6 +171,7 @@
A983BAB5284BB08F00B96FF1 = {
isa = PBXGroup;
children = (
A95125C22854C2E80072EB8E /* .swiftlint.yml */,
A983BAFD284BD2B800B96FF1 /* README.md */,
A983BAC0284BB08F00B96FF1 /* KuringLite */,
A983BABF284BB08F00B96FF1 /* Products */,
Expand Down Expand Up @@ -289,6 +291,7 @@
isa = PBXNativeTarget;
buildConfigurationList = A983BACC284BB08F00B96FF1 /* Build configuration list for PBXNativeTarget "KuringLite" */;
buildPhases = (
A95125C32854C38B0072EB8E /* ShellScript */,
A983BABA284BB08F00B96FF1 /* Sources */,
A983BABB284BB08F00B96FF1 /* Frameworks */,
A983BABC284BB08F00B96FF1 /* Resources */,
Expand Down Expand Up @@ -361,6 +364,26 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
A95125C32854C38B0072EB8E /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\nexport PATH=\"$PATH:/opt/homebrew/bin\"\nif which swiftlint > /dev/null; then\n swiftlint --fix\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
A983BABA284BB08F00B96FF1 /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand Down Expand Up @@ -526,6 +549,7 @@
INFOPLIST_KEY_UILaunchStoryboardName = "Launch Screen";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -556,6 +580,7 @@
INFOPLIST_KEY_UILaunchStoryboardName = "Launch Screen";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down
101 changes: 101 additions & 0 deletions KuringLite/.swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
included:
- KuringLite
# - KuringLiteTests
excluded:
- Tests/SwiftLintFrameworkTests/Resources

analyzer_rules:
- unused_declaration
- unused_import

disabled_rules:
# - line_length
- vertical_whitespace_opening_braces
- vertical_whitespace_closing_braces
- vertical_whitespace_between_cases
- void_return
- file_name
- number_separator
- leading_whitespace
# - sorted_imports
- unneeded_parentheses_in_closure_argument
- redundant_optional_initialization
- todo
- first_where
- closure_spacing
- vertical_parameter_alignment_on_call
- unused_optional_binding
- operator_usage_whitespace
- large_tuple
- vertical_whitespace
- multiple_closures_with_trailing_closure
- control_statement
- statement_position
- closure_end_indentation
- opening_brace
- empty_count
- type_body_length
# - force_try
# - force_cast
- redundant_type_annotation
- orphaned_doc_comment
- trailing_comma

opt_in_rules:
- force_unwrapping
- anyobject_protocol
- array_init
- attributes
- collection_alignment
- contains_over_filter_count
- contains_over_filter_is_empty
- contains_over_first_not_nil
- contains_over_range_nil_comparison
- discouraged_none_name
- discouraged_object_literal
- empty_collection_literal
- empty_string
- empty_xctest_method
- enum_case_associated_values_count
- explicit_init
- extension_access_modifier
- fallthrough
- fatal_error_message
- file_header
- flatmap_over_map_reduce
- identical_operands
- joined_default_parameter
- last_where
- legacy_multiple
- legacy_random
- literal_expression_end_indentation
- lower_acl_than_parent
- modifier_order
- nimble_operator
- nslocalizedstring_key
- number_separator
- object_literal
- overridden_super_call
- override_in_extension
- pattern_matching_keywords
- prefer_self_type_over_type_of_self
- private_action
- private_outlet
- prohibited_interface_builder
- prohibited_super_call
- quick_discouraged_call
- quick_discouraged_focused_test
- quick_discouraged_pending_test
- reduce_into
- redundant_nil_coalescing
- single_test_class
- sorted_first_last
- static_operator
- strong_iboutlet
- test_case_accessibility
- toggle_bool
- unavailable_function
- unowned_variable_capture
- untyped_error_in_catch
- xct_specific_matcher
- yoda_condition
24 changes: 11 additions & 13 deletions KuringLite/Commons/LottieView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,50 +34,48 @@ import Lottie

/// `filename` 을 가지고 Lottie 애니메이션을 제공하는 뷰
struct LottieView: UIViewRepresentable {

// makeCoordinator를 구현하여 제약사항을 구현합니다.
func makeCoordinator() -> Coordinator {
Coordinator(self)
}

// json파일명을 받을 프로퍼티
var filename: String

// lottie View
var animationView = AnimationView()



class Coordinator: NSObject {
var parent: LottieView

init(_ animationView: LottieView) {
// frame을 LottieView로 할당합니다.
self.parent = animationView
super.init()
}
}

func makeUIView(context: UIViewRepresentableContext<LottieView>) -> UIView {
let view = UIView()

// lottie 구현뷰
animationView.animation = Animation.named(filename)
animationView.contentMode = .scaleAspectFit
animationView.translatesAutoresizingMaskIntoConstraints = false

view.addSubview(animationView)

NSLayoutConstraint.activate([
animationView.widthAnchor.constraint(equalTo: view.widthAnchor),
animationView.heightAnchor.constraint(equalTo: view.heightAnchor)
])

// 애니메이션이 계속 반복되게합니다.
animationView.loopMode = .loop
animationView.play()
return view
}

func updateUIView(_ uiView: UIView, context: UIViewRepresentableContext<LottieView>) { }
}

6 changes: 3 additions & 3 deletions KuringLite/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import KuringCommons

struct ContentView: View {
@State private var showsSubscriptionView: Bool = false

var body: some View {
NavigationView {
NoticeList()
Expand All @@ -43,12 +43,12 @@ struct ContentView: View {
ToolbarItemGroup(placement: .navigationBarLeading) {
Image("app.icon.label.horizontal")
}

ToolbarItemGroup(placement: .navigationBarTrailing) {
Button(action: { showsSubscriptionView.toggle() }) {
Image(systemName: "checklist")
}

NavigationLink {
SearchView()
} label: {
Expand Down
4 changes: 2 additions & 2 deletions KuringLite/Extensions/Notice.KuringLite.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extension Notice {
enum NoticeURL {
case original(_ articleID: String)
case library(_ articleID: String)

var urlString: String {
switch self {
case .original(let articleID):
Expand All @@ -47,7 +47,7 @@ extension Notice {
}
}
}

var urlString: String {
switch category {
case .도서관 :
Expand Down
14 changes: 7 additions & 7 deletions KuringLite/Feedback/DataModel/FeedbackState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,23 @@ class FeedbackState: ObservableObject {
@Published private(set) var isOverTextLimit: Bool = false
@Published private(set) var textEditorColor: Color = ColorSet.Label.tertiary.color
@Published private(set) var textLimitColor: Color = ColorSet.Label.secondary.color

let placeholder = "피드백을 남겨주세요"
let textLimit: (min: Int, max: Int) = (min: 5, max: 256)

init() {
feedback = placeholder
textLimitGuide = "\(textLimit.min)글자 이상 입력해주세요"
}

func send(onComplete: @escaping () -> Void) {
guard !feedback.isEmpty, feedback != placeholder else { return }
guard isSendable else { return }
Kuring.sendFeedback(feedback) { [weak self] result in
guard let self = self else { return }
// 전송 완료 시 결과와 상관 없이 `feedback`를 활성화 시킵니다.
self.feedback = self.placeholder

switch result {
case .success: break
case .failure(let error): Logger.debug(error.localizedDescription)
Expand All @@ -68,7 +68,7 @@ class FeedbackState: ObservableObject {
}
isSendable = false
}

private func updateStates() {
isSendable = feedback != placeholder
&& feedback.count >= textLimit.min
Expand All @@ -81,14 +81,14 @@ class FeedbackState: ObservableObject {
? ColorSet.pink.color
: ColorSet.Label.secondary.color
}

func endEditing() {
if feedback.isEmpty {
feedback = placeholder
textEditorColor = ColorSet.Label.tertiary.color
}
}

func startEditing() {
if feedback == placeholder {
feedback = ""
Expand Down
Loading

0 comments on commit 0ec9aec

Please sign in to comment.