2020-11-22 13:41:33 +03:00
|
|
|
//
|
|
|
|
// AppDelegate.swift
|
|
|
|
// TabsSupport
|
|
|
|
//
|
|
|
|
// Created by Tae Won Ha on 22.11.20.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Cocoa
|
2020-11-22 17:03:37 +03:00
|
|
|
import PureLayout
|
2020-11-22 13:41:33 +03:00
|
|
|
import Tabs
|
|
|
|
|
|
|
|
@main
|
|
|
|
class AppDelegate: NSObject, NSApplicationDelegate {
|
|
|
|
@IBOutlet var window: NSWindow!
|
|
|
|
|
2020-11-22 17:03:37 +03:00
|
|
|
override init() {
|
2020-11-28 17:58:12 +03:00
|
|
|
self.tabBar = TabBar(withTheme: .default)
|
2020-11-22 17:03:37 +03:00
|
|
|
super.init()
|
|
|
|
}
|
|
|
|
|
2020-11-22 13:41:33 +03:00
|
|
|
func applicationDidFinishLaunching(_: Notification) {
|
2020-11-22 17:03:37 +03:00
|
|
|
let contentView = self.window.contentView!
|
|
|
|
contentView.addSubview(self.tabBar)
|
|
|
|
self.tabBar.autoPinEdge(toSuperviewEdge: .top)
|
|
|
|
self.tabBar.autoPinEdge(toSuperviewEdge: .left)
|
|
|
|
self.tabBar.autoPinEdge(toSuperviewEdge: .right)
|
2020-11-28 17:58:12 +03:00
|
|
|
self.tabBar.autoSetDimension(.height, toSize: Theme().tabBarHeight)
|
2020-12-06 22:28:33 +03:00
|
|
|
self.tabBar.selectHandler = { _, entry in Swift.print("selected \(entry)") }
|
2020-12-06 18:50:49 +03:00
|
|
|
|
|
|
|
self.tabBar.update(tabRepresentatives: [
|
|
|
|
DummyTabEntry(title: "Test 1"),
|
|
|
|
DummyTabEntry(title: "Test 2"),
|
|
|
|
DummyTabEntry(title: "Test 3"),
|
|
|
|
DummyTabEntry(title: "Very long long long title, and some more text!"),
|
|
|
|
])
|
2020-11-22 13:41:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func applicationWillTerminate(_: Notification) {
|
|
|
|
// Insert code here to tear down your application
|
|
|
|
}
|
2020-11-22 17:03:37 +03:00
|
|
|
|
2020-12-06 18:08:12 +03:00
|
|
|
private let tabBar: TabBar<DummyTabEntry>
|
|
|
|
}
|
|
|
|
|
2020-12-06 18:50:49 +03:00
|
|
|
struct DummyTabEntry: Hashable, TabRepresentative {
|
2020-12-06 18:08:12 +03:00
|
|
|
var title: String
|
2020-12-06 18:50:49 +03:00
|
|
|
var isSelected = false
|
2020-11-22 13:41:33 +03:00
|
|
|
}
|