Skip to content

Commit ea2d605

Browse files
committed
[refactor] rename
1 parent e9c9985 commit ea2d605

File tree

6 files changed

+24
-9
lines changed

6 files changed

+24
-9
lines changed

.swift-format

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,17 @@
1313
"lineBreakBeforeEachGenericRequirement" : false,
1414
"lineLength" : 120,
1515
"maximumBlankLines" : 1,
16+
"multiElementCollectionTrailingCommas" : true,
17+
"noAssignmentInExpressions" : {
18+
"allowedFunctions" : [
19+
"XCTAssertNoThrow"
20+
]
21+
},
1622
"prioritizeKeepingFunctionOutputTogether" : false,
1723
"respectsExistingLineBreaks" : true,
1824
"rules" : {
1925
"AllPublicDeclarationsHaveDocumentation" : false,
26+
"AlwaysUseLiteralForEmptyCollectionInit" : false,
2027
"AlwaysUseLowerCamelCase" : true,
2128
"AmbiguousTrailingClosureOverload" : true,
2229
"BeginDocumentationCommentWithOneLineSummary" : false,
@@ -37,12 +44,16 @@
3744
"NoLabelsInCasePatterns" : true,
3845
"NoLeadingUnderscores" : false,
3946
"NoParensAroundConditions" : true,
47+
"NoPlaygroundLiterals" : true,
4048
"NoVoidReturnOnFunctionSignature" : true,
41-
"OneCasePerLine" : false,
49+
"OmitExplicitReturns" : false,
50+
"OneCasePerLine" : true,
4251
"OneVariableDeclarationPerLine" : true,
4352
"OnlyOneTrailingClosureArgument" : false,
4453
"OrderedImports" : true,
54+
"ReplaceForEachWithForLoop" : false,
4555
"ReturnVoidInsteadOfEmptyTuple" : true,
56+
"TypeNamesShouldBeCapitalized" : true,
4657
"UseEarlyExits" : false,
4758
"UseLetInEveryBoundCaseVariable" : true,
4859
"UseShorthandTypeNames" : true,

Example/Example/ContentView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct ContentView: View {
2525
.font(.title3)
2626
Text("Home")
2727
.font(.system(.footnote, design: .rounded).weight(item == 0 ? .bold : .medium))
28-
} actionWillSelect: {
28+
} willSelect: {
2929
if item == 0 {
3030
text = ""
3131
}

Sources/TabBarModule/Internal/PreferenceKey/ItemActionWillSelectPreferenceKey.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ struct ItemActionWillSelectPreferenceKey<Selection: Hashable>: PreferenceKey {
2424
struct TabItemAction<Selection: Hashable>: Hashable, Equatable {
2525
let selectedItemHashValue: Int?
2626
let item: Selection
27-
let action: ActionWillSelect?
27+
let actionWillSelect: ActionWillSelect?
2828

2929
func hash(into hasher: inout Hasher) {
3030
hasher.combine(selectedItemHashValue)

Sources/TabBarModule/Internal/ViewModifier/TabItemViewModifier.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ struct TabItemViewModifier<Selection: Hashable, V: View>: ViewModifier {
1616
@ViewBuilder private let itemBuilder: () -> V
1717
private let actionWillSelect: ActionWillSelect?
1818

19-
init(item: Selection, @ViewBuilder itemBuilder: @escaping () -> V, actionWillSelect: ActionWillSelect?) {
19+
init(item: Selection, @ViewBuilder itemBuilder: @escaping () -> V, willSelect action: ActionWillSelect?) {
2020
self.item = item
2121
self.itemBuilder = itemBuilder
22-
self.actionWillSelect = actionWillSelect
22+
self.actionWillSelect = action
2323
}
2424

2525
func body(content: Content) -> some View {
@@ -40,7 +40,11 @@ struct TabItemViewModifier<Selection: Hashable, V: View>: ViewModifier {
4040
.preference(
4141
key: ItemActionWillSelectPreferenceKey.self,
4242
value: [
43-
item: TabItemAction(selectedItemHashValue: selectionHashValue, item: item, action: actionWillSelect)
43+
item: TabItemAction(
44+
selectedItemHashValue: selectionHashValue,
45+
item: item,
46+
actionWillSelect: actionWillSelect
47+
)
4448
]
4549
)
4650
}

Sources/TabBarModule/Public/TabBar.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public struct TabBar<Selection, Content>: View where Selection: Hashable, Conten
7474
builder()
7575
.contentShape(Rectangle())
7676
.onTapGesture {
77-
tabItemActions[item]?.action?()
77+
tabItemActions[item]?.actionWillSelect?()
7878
selection = item
7979
}
8080
.frame(width: width)

Sources/TabBarModule/Public/View+Extension.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ extension View {
1616
public func tabItem<Selection: Hashable, V: View>(
1717
_ selection: Selection,
1818
@ViewBuilder label: @escaping () -> V,
19-
actionWillSelect: ActionWillSelect? = nil
19+
willSelect action: ActionWillSelect? = nil
2020
) -> some View {
21-
modifier(TabItemViewModifier(item: selection, itemBuilder: label, actionWillSelect: actionWillSelect))
21+
modifier(TabItemViewModifier(item: selection, itemBuilder: label, willSelect: action))
2222
}
2323

2424
public func tabBarFill<S: ShapeStyle>(_ content: S, style: FillStyle = .init()) -> some View {

0 commit comments

Comments
 (0)