Skip to content

Commit

Permalink
IOS-1738 Get rid of compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
bududomasidet committed Sep 20, 2023
1 parent 5caf83c commit a30fdd5
Show file tree
Hide file tree
Showing 22 changed files with 170 additions and 185 deletions.
11 changes: 4 additions & 7 deletions Anytype.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,6 @@
3DAE1CB0273EA208009A72F3 /* EditorSetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DAE1CAF273EA208009A72F3 /* EditorSetView.swift */; };
3DB1C9CA2726A6E7000D2779 /* BlockLinkState+Text.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DB1C9C92726A6E7000D2779 /* BlockLinkState+Text.swift */; };
3DB1C9DC2726C248000D2779 /* DeletedLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DB1C9DB2726C248000D2779 /* DeletedLabel.swift */; };
3DB1C9DF2726D0E5000D2779 /* EditorPageDeletedScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DB1C9DE2726D0E5000D2779 /* EditorPageDeletedScreen.swift */; };
3DB1C9E12727DAEF000D2779 /* UIView+SpookyShake.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DB1C9E02727DAEF000D2779 /* UIView+SpookyShake.swift */; };
3DB1C9E32727FE2E000D2779 /* MentionData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DB1C9E22727FE2E000D2779 /* MentionData.swift */; };
3DB1C9F527283FA0000D2779 /* DashboardClearCacheAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DB1C9F427283FA0000D2779 /* DashboardClearCacheAlert.swift */; };
Expand Down Expand Up @@ -2636,7 +2635,6 @@
3DAE1CAF273EA208009A72F3 /* EditorSetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditorSetView.swift; sourceTree = "<group>"; };
3DB1C9C92726A6E7000D2779 /* BlockLinkState+Text.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BlockLinkState+Text.swift"; sourceTree = "<group>"; };
3DB1C9DB2726C248000D2779 /* DeletedLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeletedLabel.swift; sourceTree = "<group>"; };
3DB1C9DE2726D0E5000D2779 /* EditorPageDeletedScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditorPageDeletedScreen.swift; sourceTree = "<group>"; };
3DB1C9E02727DAEF000D2779 /* UIView+SpookyShake.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+SpookyShake.swift"; sourceTree = "<group>"; };
3DB1C9E22727FE2E000D2779 /* MentionData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MentionData.swift; sourceTree = "<group>"; };
3DB1C9F427283FA0000D2779 /* DashboardClearCacheAlert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashboardClearCacheAlert.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -7580,7 +7578,6 @@
3DB1C9DD2726D0A7000D2779 /* PlaceholderScreens */ = {
isa = PBXGroup;
children = (
3DB1C9DE2726D0E5000D2779 /* EditorPageDeletedScreen.swift */,
3DB1C9E02727DAEF000D2779 /* UIView+SpookyShake.swift */,
);
path = PlaceholderScreens;
Expand Down Expand Up @@ -9235,6 +9232,7 @@
};
C9C89788276CA25900EB7585 /* SwiftGen */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand Down Expand Up @@ -9309,7 +9307,6 @@
2A673C1D29B0FA2800E3D672 /* AnytypeDismiss.swift in Sources */,
12CAF37226D6A9E3001E56B2 /* ImageStorageProtocol.swift in Sources */,
12C0592E27F3274E004FFAAB /* DownloadableContentProtocol.swift in Sources */,
3DB1C9DF2726D0E5000D2779 /* EditorPageDeletedScreen.swift in Sources */,
EAAD6E0026CD436F005CE1E7 /* BlockMarkupChanger.swift in Sources */,
039F669923C7FD1D00DBE36A /* GeometryExtension.swift in Sources */,
3DB1CA5F272BF43F000D2779 /* DashboardWallpaper.swift in Sources */,
Expand Down Expand Up @@ -11293,7 +11290,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 0.24.0;
MARKETING_VERSION = 0.26.0;
PRODUCT_BUNDLE_IDENTIFIER = io.anytype.app.dev.homewidget;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -11327,7 +11324,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 0.24.0;
MARKETING_VERSION = 0.26.0;
PRODUCT_BUNDLE_IDENTIFIER = io.anytype.app.homewidget;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -11361,7 +11358,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 0.24.0;
MARKETING_VERSION = 0.26.0;
PRODUCT_BUNDLE_IDENTIFIER = io.anytype.app.dev.homewidget;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,23 @@ import UIKit
extension UIButton {

func setImageAndTitleSpacing(_ spacing: CGFloat) {
let insetAmount = spacing / 2
var configuration = self.configuration
let isRTL = UIView.userInterfaceLayoutDirection(for: semanticContentAttribute) == .rightToLeft

configuration?.imagePadding = spacing
configuration?.contentInsets = .init(
top: 0,
leading: spacing / 2,
bottom: 0,
trailing: spacing / 2
)

if isRTL {
imageEdgeInsets = UIEdgeInsets(top: 0, left: insetAmount, bottom: 0, right: -insetAmount)
titleEdgeInsets = UIEdgeInsets(top: 0, left: -insetAmount, bottom: 0, right: insetAmount)
contentEdgeInsets = UIEdgeInsets(top: 0, left: -insetAmount, bottom: 0, right: -insetAmount)
configuration?.imagePlacement = .trailing
} else {
imageEdgeInsets = UIEdgeInsets(top: 0, left: -insetAmount, bottom: 0, right: insetAmount)
titleEdgeInsets = UIEdgeInsets(top: 0, left: insetAmount, bottom: 0, right: -insetAmount)
contentEdgeInsets = UIEdgeInsets(top: 0, left: insetAmount, bottom: 0, right: insetAmount)
configuration?.imagePlacement = .leading
}

self.configuration = configuration
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,30 +174,47 @@ private extension TextRelationDetailsViewController {
actionStackView.addArrangedSubview(UIKitAnytypeDivider())
}
for actionViewModel in viewModel.actionsViewModel {
let actionButton = UIButton(type: .custom)
let image = UIImage(asset: actionViewModel.iconAsset)
actionButton.setImage(image, for: .normal)
actionButton.tintColor = .Button.active
let text = NSAttributedString(
string: actionViewModel.title,
attributes: [
let text = AttributedString(
actionViewModel.title,
attributes: AttributeContainer([
.font: UIFont.bodyRegular,
.foregroundColor: UIColor.Text.primary
]
])
)

let disabledText = NSAttributedString(
string: actionViewModel.title,
attributes: [
let disabledText = AttributedString(
actionViewModel.title,
attributes: AttributeContainer([
.font: UIFont.bodyRegular,
.foregroundColor: UIColor.Text.tertiary
]
])
)
actionButton.setAttributedTitle(text, for: .normal)
actionButton.setAttributedTitle(disabledText, for: .disabled)

var configuration = UIButton.Configuration.plain()
configuration.attributedTitle = text
configuration.image = image
configuration.buttonSize = .large
configuration.titleAlignment = .leading
configuration.imagePlacement = .leading
configuration.contentInsets = .init(top: 14, leading: -8, bottom: 14, trailing: 0)
configuration.imagePadding = 10

let actionButton = UIButton(configuration: configuration)
actionButton.configurationUpdateHandler = { button in
var configuration = button.configuration
switch button.state {
case .disabled:
configuration?.attributedTitle = disabledText
default:
configuration?.attributedTitle = text
}

button.configuration = configuration
}

actionButton.tintColor = .Button.active
actionButton.contentHorizontalAlignment = .leading
actionButton.contentEdgeInsets = UIEdgeInsets(top: 14, left: 0, bottom: 14, right: 0)
actionButton.titleEdgeInsets = UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 0)

actionButton.addAction(
UIAction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,6 @@ final class HomeWidgetsCoordinator: HomeWidgetsCoordinatorProtocol, HomeWidgetsM
guard let shareView = shareView else {
return
}

let shareViewPopup = AnytypePopup(
contentView: shareView,
floatingPanelStyle: true,
configuration: .init(isGrabberVisible: false, dismissOnBackdropView: true)
)

navigationContext.present(shareView)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,32 @@ private final class ChangeButton: UIButton {
}

private func setup() {
setTitle(Loc.changeType, for: .normal)
setImage(UIImage(asset: .TextEditor.turnIntoArrow), for: .normal)
titleLabel?.font = .bodyRegular
setTitleColor(.Button.active, for: .normal)
setTitleColor(.Text.primary, for: .highlighted)

imageEdgeInsets = .init(top: 0, left: -9, bottom: 0, right: 0)
var configuration = UIButton.Configuration.plain()
configuration.attributedTitle = attributedString(for: .normal)
configuration.image = UIImage(asset: .TextEditor.turnIntoArrow)
configuration.buttonSize = .mini
configuration.titleAlignment = .leading
configuration.imagePlacement = .leading
configuration.contentInsets = .init(top: 0, leading: -5, bottom: 0, trailing: 0)
configuration.imagePadding = 5
self.configuration = configuration

configurationUpdateHandler = { [weak self] button in
guard let self = self else { return }

var configuration = button.configuration
configuration?.attributedTitle = attributedString(for: button.state)
self.configuration = configuration
}
}

private func attributedString(for state: UIButton.State) -> AttributedString {
.init(
Loc.changeType,
attributes: AttributeContainer([
NSAttributedString.Key.font: UIFont.bodyRegular,
NSAttributedString.Key.foregroundColor: state == .highlighted ? UIColor.Text.primary : UIColor.Button.active
])
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,13 @@ final class SlashMenuActionHandler {
case let .other(other):
switch other {
case .table(let rowsCount, let columnsCount):
Task { @MainActor [textView] in
let safeSendableAttributedText = SafeSendable(value: textView?.attributedText)
Task { @MainActor in
guard let blockId = try? await actionHandler.createTable(
blockId: blockId,
rowsCount: rowsCount,
columnsCount: columnsCount,
blockText: textView?.attributedText
blockText: safeSendableAttributedText
) else { return }

cursorManager.blockFocus = .init(id: blockId, position: .beginning)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,15 @@ struct TextBlockActionHandler: TextBlockActionHandlerProtocol {
let position: BlockPosition = textView.text == trimmedText ?
.replace : .bottom

let safeSendableAttributedString = SafeSendable(value: originalAttributedString)
Task {
try await actionHandler.createAndFetchBookmark(
targetID: self.info.id,
position: position,
url: url
)

originalAttributedString.map {
safeSendableAttributedString.value.map {
actionHandler.changeTextForced($0, blockId: self.info.id)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,10 @@ final class SpreadsheetLayout: UICollectionViewLayout {
override func layoutAttributesForElements(
in rect: CGRect
) -> [UICollectionViewLayoutAttributes]? {

guard let collectionView = collectionView,
dataSource?.allModels.count ?? 0 > 0,
let visibleRect = relativePositionProvider?.visibleRect(to: collectionView) else {
guard dataSource?.allModels.count ?? 0 > 0 else {
return nil
}

let height: CGFloat
let y: CGFloat
if visibleRect.origin.y < 0 {
y = 0
height = visibleRect.size.height + visibleRect.origin.y
} else {
y = visibleRect.origin.y
height = visibleRect.size.height
}

let newRect = CGRect(x: rect.origin.x, y: y, width: rect.width, height: height)
let attributes = (attributes + [selectionAttributes])

return attributes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ final class EditorPageController: UIViewController {
let bottomNavigationManager: EditorBottomNavigationManagerProtocol
private(set) weak var browserViewInput: EditorBrowserViewInputProtocol?
private(set) lazy var dataSource = makeCollectionViewDataSource()

private lazy var deletedScreen = EditorPageDeletedScreen(
onBackTap: viewModel.router.closeEditor
)
private weak var firstResponderView: UIView?

let collectionView: EditorCollectionView = {
Expand Down Expand Up @@ -396,12 +392,6 @@ extension EditorPageController: EditorPageViewInput {
// For future changes
}

func showDeletedScreen(_ show: Bool) {
navigationController?.setNavigationBarHidden(show, animated: false)
deletedScreen.isHidden = !show
if show { UIApplication.shared.hideKeyboard() }
}

func blockDidFinishEditing(blockId: BlockId) {
self.selectingRangeTextView = nil
self.selectingRangeEditorItem = nil
Expand Down Expand Up @@ -485,10 +475,6 @@ private extension EditorPageController {
view.addSubview(collectionView) {
$0.pinToSuperviewPreservingReadability()
}

view.addSubview(deletedScreen) {
$0.pinToSuperviewPreservingReadability()
}

navigationBarHelper.addFakeNavigationBarBackgroundView(to: view)

Expand All @@ -497,8 +483,6 @@ private extension EditorPageController {
}

blocksSelectionOverlayView.isHidden = true

deletedScreen.isHidden = true
}

func reloadCell(for item: EditorItem) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ protocol EditorPageViewInput: RelativePositionProvider {
)
func update(syncStatus: SyncStatus)

func showDeletedScreen(_ show: Bool)

/// Tells the delegate when editing of the text block begins
func textBlockDidBeginEditing(firstResponderView: UIView)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ final class EditorPageViewModel: EditorPageViewModelProtocol {
guard let headerModel = value else { return }
self?.updateHeaderIfNeeded(headerModel: headerModel)
}.store(in: &subscriptions)

document.detailsPublisher
.sink { [weak self] in self?.handleDeletionState(details: $0) }
.store(in: &subscriptions)
}

private func setupLoadingState() {
Expand Down Expand Up @@ -158,10 +154,6 @@ final class EditorPageViewModel: EditorPageViewModelProtocol {
handleTemplatesPopupShowing()
}
}

private func handleDeletionState(details: ObjectDetails) {
viewInput?.showDeletedScreen(details.isDeleted)
}

private func difference(
with blockIds: Set<BlockId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ final class EditorMainItemModelsHolder {
guard case let .block(blockViewModel) = pair else { return }

if let viewModel = result[blockViewModel.blockId] {
anytypeAssertionFailure("There are duplicates with block type: \(blockViewModel.content.type)")
anytypeAssertionFailure("There are duplicates with block type: \(viewModel.content.type)")
}

result[blockViewModel.blockId] = blockViewModel
Expand Down
Loading

0 comments on commit a30fdd5

Please sign in to comment.