Skip to content

Commit

Permalink
Swiftformat
Browse files Browse the repository at this point in the history
  • Loading branch information
bourvill committed Aug 30, 2023
1 parent 0bb37d1 commit 14f0723
Show file tree
Hide file tree
Showing 23 changed files with 43 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.7
5.8
13 changes: 6 additions & 7 deletions App/Features/Entry/EntryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,17 @@ struct EntryView: View {
title: Text("Confirm delete?"),
buttons: [
.destructive(Text("Delete")) {
self.context.delete(entry)
context.delete(entry)
dismiss()
},
.cancel(),
]
)
}
}

}
.sheet(isPresented: $showTag) {
TagListFor(tagsForEntry: TagsForEntryPublisher(entry: self.entry))
TagListFor(tagsForEntry: TagsForEntryPublisher(entry: entry))
.environment(\.managedObjectContext, context)
}
#if os(iOS)
Expand All @@ -75,20 +74,20 @@ struct EntryView: View {
@ViewBuilder
private var bottomBarButton: some View {
Button(role: .destructive, action: {
self.showDeleteConfirm = true
showDeleteConfirm = true
}, label: {
Label("Delete", systemImage: "trash")
})
Divider()
Button(action: {
openURL(self.entry.url!.url!)
openURL(entry.url!.url!)
}, label: {
Label("Open in Safari", systemImage: "safari")
})
Button(action: {
self.showTag.toggle()
showTag.toggle()
}, label: {
Label("Tag", systemImage: self.showTag ? "tag.fill" : "tag")
Label("Tag", systemImage: showTag ? "tag.fill" : "tag")
})
Button(action: {
appSync.refresh(entry: entry)
Expand Down
2 changes: 1 addition & 1 deletion App/Features/Entry/UI/ArchiveEntryButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ struct ArchiveEntryButton: View {
var showText: Bool = true
var body: some View {
Button(action: {
self.entry.toggleArchive()
entry.toggleArchive()
}, label: {
if showText {
Label(
Expand Down
2 changes: 1 addition & 1 deletion App/Features/Entry/UI/DeleteEntryButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ struct DeleteEntryButton: View {
var showText: Bool = true
var body: some View {
Button(action: {
self.showConfirm = true
showConfirm = true
}, label: {
if showText {
Text("Delete")
Expand Down
2 changes: 1 addition & 1 deletion App/Features/Entry/UI/FontSizeSelectorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct FontSizeSelectorView: View {
HStack {
Button(action: {
withAnimation {
self.showSelector = !self.showSelector
showSelector = !showSelector
}
}, label: {
Image(systemName: "textformat.size")
Expand Down
2 changes: 1 addition & 1 deletion App/Features/Entry/UI/StarEntryButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ struct StarEntryButton: View {
var showText: Bool = true
var body: some View {
Button(action: {
self.entry.toggleStarred()
entry.toggleStarred()
}, label: {
if showText {
Label(
Expand Down
2 changes: 1 addition & 1 deletion App/Features/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ struct MainView: View {
})
Divider()
Button(role: .destructive, action: {
self.appState.logout()
appState.logout()
}, label: {
Label("Logout", systemImage: "person")
}).foregroundColor(.red)
Expand Down
4 changes: 2 additions & 2 deletions App/Features/PasteBoard/PasteBoardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import SwiftUI
.lineLimit(1)
HStack {
Button(action: {
self.pasteBoardViewModel.addUrl()
pasteBoardViewModel.addUrl()
}, label: {
Text("Add")
})
Button(action: {
self.pasteBoardViewModel.hide()
pasteBoardViewModel.hide()
}, label: {
Text("Cancel")
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class ClientIdSecretViewModel: ObservableObject {
clientSecret = WallabagUserDefaults.clientSecret

cancellable = Publishers.CombineLatest($clientId, $clientSecret).sink { [unowned self] clientId, clientSecret in
self.isValid = !clientId.isEmpty && !clientSecret.isEmpty
if self.isValid {
isValid = !clientId.isEmpty && !clientSecret.isEmpty
if isValid {
WallabagUserDefaults.clientId = clientId.trimmingCharacters(in: .whitespacesAndNewlines)
WallabagUserDefaults.clientSecret = clientSecret.trimmingCharacters(in: .whitespacesAndNewlines)
}
Expand Down
2 changes: 1 addition & 1 deletion App/Features/Registration/Login/LoginView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct LoginView: View {
SecureField("Password", text: $loginViewModel.password)
}
Button("Login") {
self.loginViewModel.tryLogin()
loginViewModel.tryLogin()
}.disabled(!loginViewModel.isValid)
loginViewModel.error.map { error in
VStack {
Expand Down
6 changes: 3 additions & 3 deletions App/Features/Registration/Login/LoginViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ class LoginViewModel: ObservableObject {
init() {
login = WallabagUserDefaults.login
Publishers.CombineLatest($login, $password).sink { [unowned self] login, password in
self.isValid = !login.isEmpty && !password.isEmpty
isValid = !login.isEmpty && !password.isEmpty
}.store(in: &cancellable)

session.$state.receive(on: DispatchQueue.main).sink { [unowned self] state in
switch state {
case let .error(reason):
self.error = reason
error = reason
case .connected:
self.appState.registred = true
appState.registred = true
case .unknown, .connecting, .offline:
break
}
Expand Down
4 changes: 2 additions & 2 deletions App/Features/Registration/Server/ServerViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ final class ServerViewModel: ObservableObject {
init() {
url = WallabagUserDefaults.host
cancellable = $url.sink { [unowned self] url in
self.isValid = self.validateServer(host: url)
if self.isValid {
isValid = validateServer(host: url)
if isValid {
WallabagUserDefaults.host = url
}
}
Expand Down
4 changes: 2 additions & 2 deletions App/Features/Search/SearchView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ struct SearchView: View {
}
Button(action: {
withAnimation {
self.showSearchBar = !self.showSearchBar
showSearchBar = !showSearchBar
}
}, label: {
Image(systemName: self.showSearchBar ? "list.bullet.below.rectangle" : "magnifyingglass")
Image(systemName: showSearchBar ? "list.bullet.below.rectangle" : "magnifyingglass")
.padding(.trailing)
})
.buttonStyle(.plain)
Expand Down
6 changes: 2 additions & 4 deletions App/Features/Sync/CoreDataSync.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ class CoreDataSync {
}
}

// swiftlint:disable force_cast
private func deletedObjects(_ deletedObjects: Set<NSManagedObject>) {
deletedObjects
.filter { $0 is Entry }
.map { entry -> Entry in entry as! Entry }
.compactMap { $0 as? Entry }
.forEach { entry in
self.wallabagSession.delete(entry: entry)
}
Expand All @@ -48,7 +46,7 @@ class CoreDataSync {
changedValues.removeValue(forKey: "tags")
if changedValues.count > 0 {
logger.debug("Push update entry \(entry.id) to remote")
self.wallabagSession.update(
wallabagSession.update(
entry,
parameters:
[
Expand Down
6 changes: 3 additions & 3 deletions App/Features/Tag/TagListFor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ struct TagListFor: View {
HStack {
TextField("New tag", text: $tagLabel)
Button(action: {
self.tagsForEntry.add(tag: self.tagLabel)
self.tagLabel = ""
tagsForEntry.add(tag: tagLabel)
tagLabel = ""
}, label: { Text("Add") })
}.padding(.horizontal)
List(tagsForEntry.tags) { tag in
TagRow(tag: tag, tagsForEntry: self.tagsForEntry)
TagRow(tag: tag, tagsForEntry: tagsForEntry)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions App/Features/Tag/TagRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ struct TagRow: View {
Image(systemName: "checkmark")
}
}.onTapGesture {
if self.tag.isChecked {
self.tagsForEntry.delete(tag: self.tag)
if tag.isChecked {
tagsForEntry.delete(tag: tag)
} else {
self.tagsForEntry.add(tag: self.tag)
tagsForEntry.add(tag: tag)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion App/Features/Tag/TagsForEntryPublisher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import CoreData
import Factory
import Foundation

// swiftlint:disable all
// swiftlint:disable:next all
class TagsForEntryPublisher: ObservableObject {
@Injected(\.wallabagSession) private var session

Expand Down
4 changes: 2 additions & 2 deletions App/Features/Tip/TipView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ struct TipView: View {
HStack {
Spacer()
if tipViewModel.canMakePayments {
if self.tipViewModel.tipProduct != nil {
if tipViewModel.tipProduct != nil {
Button(
action: { Task { await purchase() } },
label: {
self.tipViewModel.tipProduct.map { product in
tipViewModel.tipProduct.map { product in
HStack {
Text(product.displayName)
Text(product.displayPrice)
Expand Down
2 changes: 1 addition & 1 deletion App/Lib/WallabagSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class WallabagSession: ObservableObject {
kit.send(to: WallabagEntryEndpoint.add(url: url))
.catch { _ in Empty<WallabagEntry, Never>() }
.sink { [unowned self] (wallabagEntry: WallabagEntry) in
let entry = Entry(context: self.coreDataContext)
let entry = Entry(context: coreDataContext)
entry.hydrate(from: wallabagEntry)
completion()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,16 @@ public enum WallabagEntryEndpoint: WallabagKitEndpoint {
}
}

// swiftlint:disable force_try
public func getBody() -> Data {
switch self {
case let .add(url):
// swiftlint:disable:next force_try
return try! JSONSerialization.data(withJSONObject: ["url": url], options: .prettyPrinted)
case let .update(_, parameters):
// swiftlint:disable:next force_try
return try! JSONSerialization.data(withJSONObject: parameters, options: .prettyPrinted)
case let .addTag(tag, _):
// swiftlint:disable:next force_try
return try! JSONSerialization.data(withJSONObject: ["tags": tag], options: .prettyPrinted)
default:
return "".data(using: .utf8)!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ enum WallabagOauth: WallabagKitEndpoint {
}
}

// swiftlint:disable force_try
func getBody() -> Data {
switch self {
case let .request(clientId, clientSecret, username, password):
// swiftlint:disable:next force_try
return try! JSONSerialization.data(withJSONObject: [
"grant_type": "password",
"client_id": clientId,
Expand Down
2 changes: 1 addition & 1 deletion bagit/ShareViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ShareViewController: UIViewController {
view.addSubview(backView)
view.addSubview(notificationView)
UIView.animate(withDuration: 0.3) { [unowned self] in
self.backView.alpha = 0.6
backView.alpha = 0.6
}
}

Expand Down
4 changes: 2 additions & 2 deletions wallabag.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"kind" : "remoteSourceControl",
"location" : "[email protected]:hmlongco/Factory.git",
"state" : {
"revision" : "718466174b5e8eb0dc6548260f447d2b5b639111",
"version" : "2.0.0"
"revision" : "061b3afe0358a0da7ce568f8272c847910be3dd7",
"version" : "2.2.0"
}
},
{
Expand Down

0 comments on commit 14f0723

Please sign in to comment.