diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..71c8374 --- /dev/null +++ b/.gitignore @@ -0,0 +1,77 @@ +.DS_Store + +### Swift ### +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## Build generated +build/ +DerivedData/ + +## Various settings +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata/ + +## Other +*.moved-aside +*.xccheckout +*.xcscmblueprint + +## Obj-C/Swift specific +*.hmap +*.ipa +*.dSYM.zip +*.dSYM + +## Playgrounds +timeline.xctimeline +playground.xcworkspace + +# Swift Package Manager +# +# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. +# Packages/ +# Package.pins +.build/ + +# CocoaPods - Refactored to standalone file + +# Carthage - Refactored to standalone file + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/#source-control + +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots +fastlane/test_output + +### Xcode ### +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## Build generated + +## Various settings + +## Other + +### Xcode Patch ### +*.xcodeproj/* +!*.xcodeproj/project.pbxproj +!*.xcodeproj/xcshareddata/ +!*.xcworkspace/contents.xcworkspacedata +/*.gcno diff --git a/MastoSearch.xcodeproj/project.pbxproj b/MastoSearch.xcodeproj/project.pbxproj index 2c1463c..1e0aff8 100644 --- a/MastoSearch.xcodeproj/project.pbxproj +++ b/MastoSearch.xcodeproj/project.pbxproj @@ -357,7 +357,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = HGYVAQA9FW; + DEVELOPMENT_TEAM = ZPBBSK8L8B; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = MastoSearchMobile/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = MastoSearch; @@ -372,7 +372,7 @@ "@executable_path/Frameworks", ); MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = net.shadowfacts.MastoSearchMobile; + PRODUCT_BUNDLE_IDENTIFIER = space.vaccor.MastoSearchMobile; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; @@ -391,7 +391,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = HGYVAQA9FW; + DEVELOPMENT_TEAM = ZPBBSK8L8B; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = MastoSearchMobile/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = MastoSearch; @@ -406,7 +406,7 @@ "@executable_path/Frameworks", ); MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = net.shadowfacts.MastoSearchMobile; + PRODUCT_BUNDLE_IDENTIFIER = space.vaccor.MastoSearchMobile; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; diff --git a/MastoSearch.xcodeproj/xcshareddata/xcschemes/MastoSearchMobile.xcscheme b/MastoSearch.xcodeproj/xcshareddata/xcschemes/MastoSearchMobile.xcscheme index 00c3066..7010cde 100644 --- a/MastoSearch.xcodeproj/xcshareddata/xcschemes/MastoSearchMobile.xcscheme +++ b/MastoSearch.xcodeproj/xcshareddata/xcschemes/MastoSearchMobile.xcscheme @@ -31,7 +31,7 @@ MastoSearchMobile.xcscheme_^#shared#^_ orderHint - 2 + 1 SuppressBuildableAutocreation diff --git a/MastoSearchMobile/ViewController.swift b/MastoSearchMobile/ViewController.swift index 7e7e5cb..4166680 100644 --- a/MastoSearchMobile/ViewController.swift +++ b/MastoSearchMobile/ViewController.swift @@ -9,6 +9,7 @@ import UIKit import MastoSearchCore import Combine import SafariServices +import AuthenticationServices class ViewController: UIViewController { @@ -17,7 +18,7 @@ class ViewController: UIViewController { private var collectionView: UICollectionView! private var dataSource: UICollectionViewDiffableDataSource! - private var searchQuerySubject = PassthroughSubject() + private var searchQuerySubject = CurrentValueSubject("") private var cancellables = Set() override func viewDidLoad() { @@ -85,6 +86,12 @@ class ViewController: UIViewController { .store(in: &cancellables) updateStatuses(query: "") + + SyncController.shared.onSync + .sink { [unowned self] _ in + self.updateStatuses(query: searchQuerySubject.value) + } + .store(in: &cancellables) } private func updateStatuses(query: String) { @@ -128,15 +135,30 @@ class ViewController: UIViewController { } private func login() { - + let alert = UIAlertController(title: "Instance URL", message: nil, preferredStyle: .alert) + alert.addTextField { textField in + textField.placeholder = "https://mastodon.social/" + } + alert.addAction(UIAlertAction(title: "Ok", style: .default, handler: { _ in + guard let text = alert.textFields!.first!.text, + let url = URL(string: text) else { + return + } + LoginController.shared.logIn(with: url, presentationContextProvider: self) { + self.navigationItem.leadingItemGroups.first!.barButtonItems.first!.menu = self.createAccountMenu() + (self.view.window!.windowScene!.delegate as! SceneDelegate).syncStatuses() + } + })) + alert.addAction(UIAlertAction(title: "Cancel", style: .cancel)) + present(alert, animated: true) } private func logout() { - + LocalData.account = nil + self.navigationItem.leadingItemGroups.first!.barButtonItems.first!.menu = self.createAccountMenu() } @objc private func importPressed() { - } } @@ -212,3 +234,9 @@ extension ViewController: UICollectionViewDelegate { } } } + +extension ViewController: ASWebAuthenticationPresentationContextProviding { + func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor { + return view.window! + } +}