Mobile: login/sync stuff
This commit is contained in:
parent
17cb8676b1
commit
53e853439d
|
@ -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
|
|
@ -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";
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
buildConfiguration = "Release"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<key>MastoSearchMobile.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>2</integer>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>SuppressBuildableAutocreation</key>
|
||||
|
|
|
@ -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<Section, Item>!
|
||||
|
||||
private var searchQuerySubject = PassthroughSubject<String, Never>()
|
||||
private var searchQuerySubject = CurrentValueSubject<String, Never>("")
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
|
||||
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!
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue