mirror of
https://github.com/Finb/Bark.git
synced 2025-12-08 21:36:01 +00:00
调整UI
This commit is contained in:
parent
636d34bbb0
commit
b202e1e240
@ -33,6 +33,7 @@
|
||||
0661A54A204FDA4100965E4E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0661A549204FDA4100965E4E /* Assets.xcassets */; };
|
||||
0661A54D204FDA4100965E4E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0661A54B204FDA4100965E4E /* LaunchScreen.storyboard */; };
|
||||
06802E5320ECC40C00767047 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0661A549204FDA4100965E4E /* Assets.xcassets */; };
|
||||
068F66B3247BD84C00DAD25A /* MessageListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 068F66B2247BD84C00DAD25A /* MessageListViewController.swift */; };
|
||||
06B1158D247BA6D5006D91FB /* CloudKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 06B1158C247BA6D5006D91FB /* CloudKit.framework */; };
|
||||
06B1158F247BB1FB006D91FB /* Message.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B1158E247BB1FB006D91FB /* Message.swift */; };
|
||||
06B11591247BC132006D91FB /* Message.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B1158E247BB1FB006D91FB /* Message.swift */; };
|
||||
@ -104,6 +105,7 @@
|
||||
0683486A2050F1310024B6DA /* Bark.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Bark.entitlements; sourceTree = "<group>"; };
|
||||
0683487020510FB20024B6DA /* UserNotifications.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UserNotifications.framework; path = System/Library/Frameworks/UserNotifications.framework; sourceTree = SDKROOT; };
|
||||
0683487220510FB20024B6DA /* UserNotificationsUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UserNotificationsUI.framework; path = System/Library/Frameworks/UserNotificationsUI.framework; sourceTree = SDKROOT; };
|
||||
068F66B2247BD84C00DAD25A /* MessageListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageListViewController.swift; sourceTree = "<group>"; };
|
||||
06B1158C247BA6D5006D91FB /* CloudKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CloudKit.framework; path = System/Library/Frameworks/CloudKit.framework; sourceTree = SDKROOT; };
|
||||
06B1158E247BB1FB006D91FB /* Message.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Message.swift; sourceTree = "<group>"; };
|
||||
06B11590247BBC15006D91FB /* NotificationServiceExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = NotificationServiceExtension.entitlements; sourceTree = "<group>"; };
|
||||
@ -157,6 +159,7 @@
|
||||
0661A544204FDA4100965E4E /* HomeViewController.swift */,
|
||||
0637FA8920E0D58800E80174 /* NewServerViewController.swift */,
|
||||
0603706C20E23EC000F4CA05 /* BarkSFSafariViewController.swift */,
|
||||
068F66B2247BD84C00DAD25A /* MessageListViewController.swift */,
|
||||
);
|
||||
path = Controller;
|
||||
sourceTree = "<group>";
|
||||
@ -502,6 +505,7 @@
|
||||
0637FA7C20E0930E00E80174 /* BarkApi.swift in Sources */,
|
||||
0637FA8020E0981E00E80174 /* BarkSettings.swift in Sources */,
|
||||
0603706B20E20A7C00F4CA05 /* String+Extension.swift in Sources */,
|
||||
068F66B3247BD84C00DAD25A /* MessageListViewController.swift in Sources */,
|
||||
0661A543204FDA4100965E4E /* AppDelegate.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
||||
@ -39,6 +39,17 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//调整返回按钮样式
|
||||
let bar = UINavigationBar.appearance(whenContainedInInstancesOf: [BarkNavigationController.self])
|
||||
bar.backIndicatorImage = UIImage(named: "back")
|
||||
bar.backIndicatorTransitionMaskImage = UIImage(named: "back")
|
||||
bar.tintColor = Color.darkText.primary
|
||||
|
||||
let buttonItem = UIBarButtonItem.appearance(whenContainedInInstancesOf: [BarkNavigationController.self])
|
||||
buttonItem.setTitleTextAttributes([NSAttributedString.Key.font: RobotoFont.regular(with: 0)], for: .normal)
|
||||
buttonItem.setBackButtonTitlePositionAdjustment(UIOffset(horizontal: -1000, vertical: 0), for: .default)
|
||||
|
||||
let groupUrl = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.bark")
|
||||
let fileUrl = groupUrl?.appendingPathComponent("bark.realm")
|
||||
let config = Realm.Configuration(
|
||||
|
||||
22
Bark/Assets.xcassets/back.imageset/Contents.json
vendored
Normal file
22
Bark/Assets.xcassets/back.imageset/Contents.json
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "back@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "back@3x.png",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
BIN
Bark/Assets.xcassets/back.imageset/back@2x.png
vendored
Normal file
BIN
Bark/Assets.xcassets/back.imageset/back@2x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
BIN
Bark/Assets.xcassets/back.imageset/back@3x.png
vendored
Normal file
BIN
Bark/Assets.xcassets/back.imageset/back@3x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
@ -27,11 +27,6 @@
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>UIBackgroundModes</key>
|
||||
<array>
|
||||
<string>fetch</string>
|
||||
<string>remote-notification</string>
|
||||
</array>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
|
||||
@ -8,30 +8,12 @@
|
||||
|
||||
import UIKit
|
||||
import Material
|
||||
|
||||
class BarkNavigationController: NavigationController{
|
||||
override func prepare() {
|
||||
super.prepare()
|
||||
isMotionEnabled = true
|
||||
motionNavigationTransitionType = .autoReverse(presenting: .fade)
|
||||
|
||||
guard let v = navigationBar as? NavigationBar else {
|
||||
return
|
||||
}
|
||||
|
||||
v.depthPreset = .none
|
||||
v.dividerColor = Color.grey.lighten2
|
||||
|
||||
navigationBar.backgroundColor = Color.blue.darken2
|
||||
|
||||
statusBarStyle = .lightContent
|
||||
|
||||
}
|
||||
|
||||
override var childForStatusBarStyle: UIViewController?{
|
||||
get {
|
||||
return self.topViewController
|
||||
}
|
||||
import UINavigationItem_Margin
|
||||
class BarkNavigationController: UINavigationController{
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
self.navigationItem.leftMargin = 8
|
||||
self.navigationItem.rightMargin = 8
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -12,10 +12,9 @@ class BaseViewController: UIViewController {
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
self.navigationItem.backButton.tintColor = UIColor.white
|
||||
self.view.backgroundColor = Color.grey.lighten5
|
||||
navigationItem.titleLabel.textColor = .white
|
||||
navigationItem.titleLabel.font = UIFont.systemFont(ofSize: 16)
|
||||
self.navigationItem.leftMargin = 8
|
||||
self.navigationItem.rightMargin = 8
|
||||
}
|
||||
|
||||
override var preferredStatusBarStyle: UIStatusBarStyle{
|
||||
|
||||
@ -12,14 +12,13 @@ import Material
|
||||
class HomeViewController: BaseViewController {
|
||||
|
||||
let newButton: IconButton = {
|
||||
let btn = IconButton(image: Icon.add, tintColor: .white)
|
||||
btn.pulseColor = .white
|
||||
let btn = IconButton(image: Icon.add, tintColor: .black)
|
||||
btn.pulseColor = .black
|
||||
btn.frame = CGRect(x: 0, y: 0, width: 40, height: 40)
|
||||
return btn
|
||||
}()
|
||||
|
||||
let startButton = FABButton(title: NSLocalizedString("RegisterDevice"))
|
||||
|
||||
let statusButton = IconButton(image: UIImage(named: "baseline_https_black_24pt"), tintColor: .white)
|
||||
lazy var startButton = FABButton(title: NSLocalizedString("RegisterDevice"))
|
||||
|
||||
let tableView :UITableView = {
|
||||
let tableView = UITableView()
|
||||
@ -73,15 +72,13 @@ class HomeViewController: BaseViewController {
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
self.view.backgroundColor = Color.grey.lighten3
|
||||
|
||||
navigationItem.titleLabel.textColor = .white
|
||||
navigationItem.titleLabel.textAlignment = .left
|
||||
navigationItem.detailLabel.textAlignment = .left
|
||||
navigationItem.detailLabel.textColor = .white
|
||||
|
||||
|
||||
newButton.addTarget(self, action: #selector(new), for: .touchUpInside)
|
||||
navigationItem.rightViews = [newButton]
|
||||
navigationItem.leftViews = [statusButton]
|
||||
navigationItem.rightBarButtonItem = UIBarButtonItem(customView: newButton)
|
||||
|
||||
let messageBtn = IconButton(image: Icon.history, tintColor: .black)
|
||||
messageBtn.frame = CGRect(x: 0, y: 0, width: 40, height: 40)
|
||||
navigationItem.leftBarButtonItem = UIBarButtonItem(customView: messageBtn)
|
||||
|
||||
self.view.addSubview(self.tableView)
|
||||
self.tableView.snp.makeConstraints { (make ) in
|
||||
@ -93,6 +90,7 @@ class HomeViewController: BaseViewController {
|
||||
UNUserNotificationCenter.current().getNotificationSettings { (settings) in
|
||||
if settings.authorizationStatus != .authorized {
|
||||
dispatch_sync_safely_main_queue {
|
||||
self.startButton.backgroundColor = Color.white
|
||||
self.startButton.transition([ .scale(0.75) , .opacity(0)] )
|
||||
self.startButton.addTarget(self, action: #selector(self.start), for: .touchUpInside)
|
||||
self.view.addSubview(self.startButton)
|
||||
@ -110,7 +108,8 @@ class HomeViewController: BaseViewController {
|
||||
}
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
if let url = URL(string: ServerManager.shared.currentAddress) {
|
||||
navigationItem.titleLabel.text = url.host
|
||||
// navigationItem.titleLabel.text = url.host
|
||||
navigationItem.title = url.host
|
||||
refreshState()
|
||||
}
|
||||
}
|
||||
@ -187,20 +186,14 @@ extension HomeViewController {
|
||||
switch Client.shared.state {
|
||||
case .ok:
|
||||
if let url = URL(string: ServerManager.shared.currentAddress) {
|
||||
if url.scheme?.lowercased() == "https" {
|
||||
navigationItem.detailLabel.text = NSLocalizedString("SecureConnection")
|
||||
statusButton.image = UIImage(named: "baseline_https_black_24pt")
|
||||
}
|
||||
else {
|
||||
navigationItem.detailLabel.text = NSLocalizedString("InsecureConnection")
|
||||
statusButton.image = UIImage(named: "baseline_http_black_24pt")
|
||||
if url.scheme?.lowercased() != "https" {
|
||||
self.showSnackbar(text: NSLocalizedString("InsecureConnection"))
|
||||
}
|
||||
self.tableView.reloadData()
|
||||
}
|
||||
case .unRegister:
|
||||
navigationItem.detailLabel.text = NSLocalizedString("UnregisteredDevice")
|
||||
case .serverError:
|
||||
navigationItem.detailLabel.text = NSLocalizedString("ServerError")
|
||||
self.showSnackbar(text: NSLocalizedString("ServerError"))
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
30
Controller/MessageListViewController.swift
Normal file
30
Controller/MessageListViewController.swift
Normal file
@ -0,0 +1,30 @@
|
||||
//
|
||||
// MessageListViewController.swift
|
||||
// Bark
|
||||
//
|
||||
// Created by huangfeng on 2020/5/25.
|
||||
// Copyright © 2020 Fin. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class MessageListViewController: UIViewController {
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
// Do any additional setup after loading the view.
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
// MARK: - Navigation
|
||||
|
||||
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
||||
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
||||
// Get the new view controller using segue.destination.
|
||||
// Pass the selected object to the new view controller.
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
@ -31,16 +31,18 @@ class NewServerViewController: BaseViewController {
|
||||
return label
|
||||
}()
|
||||
|
||||
let doneButton = IconButton(image: Icon.check, tintColor: .white)
|
||||
let doneButton = IconButton(image: Icon.check, tintColor: .black)
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
navigationItem.titleLabel.text = NSLocalizedString("AddServer")
|
||||
|
||||
navigationItem.title = NSLocalizedString("AddServer")
|
||||
|
||||
doneButton.frame = CGRect(x: 0, y: 0, width: 40, height: 40)
|
||||
doneButton.addTarget(self, action: #selector(done), for: .touchUpInside)
|
||||
navigationItem.rightViews = [doneButton]
|
||||
navigationItem.rightBarButtonItem = UIBarButtonItem(customView: doneButton)
|
||||
|
||||
self.view.layout(addressTextField).top(40).left(10).right(10)
|
||||
self.view.layout(addressTextField).top(kNavigationHeight + 40).left(10).right(10)
|
||||
|
||||
self.view.addSubview(noticeLabel)
|
||||
noticeLabel.snp.makeConstraints { (make) in
|
||||
@ -52,8 +54,10 @@ class NewServerViewController: BaseViewController {
|
||||
}
|
||||
|
||||
override func viewDidAppear(_ animated: Bool) {
|
||||
_ = self.addressTextField.becomeFirstResponder()
|
||||
addressTextField.text = "https://"
|
||||
if (addressTextField.text?.count ?? 0) <= 0 {
|
||||
_ = self.addressTextField.becomeFirstResponder()
|
||||
addressTextField.text = "https://"
|
||||
}
|
||||
}
|
||||
|
||||
@objc func done(){
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Defines.swift
|
||||
// Bark
|
||||
//
|
||||
@ -30,3 +30,19 @@ extension UIViewController {
|
||||
func NSLocalizedString( _ key:String ) -> String {
|
||||
return NSLocalizedString(key, comment: "")
|
||||
}
|
||||
|
||||
let kNavigationHeight: CGFloat = {
|
||||
return kSafeAreaInsets.top + 44
|
||||
}()
|
||||
|
||||
let kSafeAreaInsets:UIEdgeInsets = {
|
||||
if #available(iOS 12.0, *){
|
||||
return UIWindow().safeAreaInsets
|
||||
}
|
||||
else if #available(iOS 11.0, *){
|
||||
let inset = UIWindow().safeAreaInsets
|
||||
if inset.top > 0 { return inset}
|
||||
//iOS 11下,不是全面屏的手机 safeAreaInsets.top 是 0,与iOS12 不一致,这里强行让他们保持一致,方便开发
|
||||
}
|
||||
return UIEdgeInsets(top: 20, left: 0, bottom: 0, right: 0)
|
||||
}()
|
||||
|
||||
2
Podfile
2
Podfile
@ -1,6 +1,7 @@
|
||||
platform:ios,'10.0'
|
||||
inhibit_all_warnings!
|
||||
use_modular_headers!
|
||||
source 'https://github.com/CocoaPods/Specs.git'
|
||||
|
||||
def pods
|
||||
pod 'SnapKit'
|
||||
@ -14,6 +15,7 @@ def pods
|
||||
pod 'DeviceKit'
|
||||
pod 'DefaultsKit', :git => 'https://github.com/nmdias/DefaultsKit'
|
||||
pod 'IceCream'
|
||||
pod 'UINavigationItem+Margin'
|
||||
end
|
||||
|
||||
target 'Bark' do
|
||||
|
||||
@ -28,6 +28,7 @@ PODS:
|
||||
- SnapKit (5.0.1)
|
||||
- SVProgressHUD (2.2.5)
|
||||
- SwiftyJSON (5.0.0)
|
||||
- "UINavigationItem+Margin (2.1.1)"
|
||||
|
||||
DEPENDENCIES:
|
||||
- DefaultsKit (from `https://github.com/nmdias/DefaultsKit`)
|
||||
@ -41,8 +42,11 @@ DEPENDENCIES:
|
||||
- SnapKit
|
||||
- SVProgressHUD
|
||||
- SwiftyJSON
|
||||
- "UINavigationItem+Margin"
|
||||
|
||||
SPEC REPOS:
|
||||
https://github.com/CocoaPods/Specs.git:
|
||||
- "UINavigationItem+Margin"
|
||||
trunk:
|
||||
- Alamofire
|
||||
- DeviceKit
|
||||
@ -86,7 +90,8 @@ SPEC CHECKSUMS:
|
||||
SnapKit: 97b92857e3df3a0c71833cce143274bf6ef8e5eb
|
||||
SVProgressHUD: 1428aafac632c1f86f62aa4243ec12008d7a51d6
|
||||
SwiftyJSON: 36413e04c44ee145039d332b4f4e2d3e8d6c4db7
|
||||
"UINavigationItem+Margin": 7368d506fb2f7daa0c0489846cc8c2384ab1ab6d
|
||||
|
||||
PODFILE CHECKSUM: 993d19d838d6d55da4b65c5a2e5e68bce37c8097
|
||||
PODFILE CHECKSUM: 179f10f903da643b7f8bb2079d8f88b0f8e32323
|
||||
|
||||
COCOAPODS: 1.8.4
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user