Reorganize top level directory

This commit is contained in:
2021-01-03 14:43:49 -06:00
parent 9fd36d8d53
commit bebb356425
841 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
/*
* Copyright (C) 2016-2019 Álinson Santos Xavier <isoron@gmail.com>
*
* This file is part of Loop Habit Tracker.
*
* Loop Habit Tracker is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* Loop Habit Tracker is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import UIKit
@UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate, BackendListener {
var window: UIWindow?
var nav: UINavigationController?
let log = StandardLog()
var backend: Backend?
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
backend = Backend(databaseName: "uhabits.db",
databaseOpener: IosDatabaseOpener(),
fileOpener: IosFileOpener(),
localeHelper: IosLocaleHelper(log: log),
log: log,
scope: UIDispatcher())
backend?.observable.addListener(listener: self)
backend?.doInit()
window = UIWindow(frame: UIScreen.main.bounds)
nav = UINavigationController()
window?.backgroundColor = UIColor.white
window?.rootViewController = nav
window?.makeKeyAndVisible()
return true
}
func onReady() {
nav?.viewControllers = [MainScreenController(withBackend: backend!)]
}
}

View File

@@ -0,0 +1,100 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "loop-120.png",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "loop-180.png",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "baseline_more_horiz_black_24pt_1x.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "baseline_more_horiz_black_24pt_2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "baseline_more_horiz_black_24pt_3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 B

View File

@@ -0,0 +1,20 @@
/*
* Copyright (C) 2016-2019 Álinson Santos Xavier <isoron@gmail.com>
*
* This file is part of Loop Habit Tracker.
*
* Loop Habit Tracker is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* Loop Habit Tracker is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#import "LoopHabitTracker.h"

View File

@@ -0,0 +1,23 @@
/*
* Copyright (C) 2016-2019 Álinson Santos Xavier <isoron@gmail.com>
*
* This file is part of Loop Habit Tracker.
*
* Loop Habit Tracker is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* Loop Habit Tracker is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import UIKit
class AboutScreenController : UITableViewController {
}

View File

@@ -0,0 +1,115 @@
/*
* Copyright (C) 2016-2019 Álinson Santos Xavier <isoron@gmail.com>
*
* This file is part of Loop Habit Tracker.
*
* Loop Habit Tracker is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* Loop Habit Tracker is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import UIKit
class DetailScreenController : UITableViewController {
let theme: Theme
let habit: Habit
let color: Color
var cells = [UITableViewCell]()
required init?(coder aDecoder: NSCoder) {
fatalError()
}
init(habit: Habit, backend: Backend) {
self.theme = backend.theme
self.habit = habit
self.color = theme.color(paletteIndex: self.habit.color.index)
super.init(style: .grouped)
}
override func viewDidLoad() {
self.title = habit.name
self.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .edit,
target: self,
action: #selector(self.onEditHabitClicked))
cells.append(buildBarChartCell())
cells.append(buildHistoryChartCell())
}
func buildBarChartCell() -> UITableViewCell {
let today = LocalDate(year: 2019, month: 3, day: 15)
let axis = (0...365).map { today.minus(days: $0) }
let component = BarChart(theme: theme,
dateFormatter: IosLocalDateFormatter())
component.axis = axis
let cell = UITableViewCell()
let view = ComponentView(frame: cell.frame, component: component)
for k in 0...0 {
var series = [KotlinDouble]()
for _ in 1...365 {
series.append(KotlinDouble(value: Double.random(in: 0...5000)))
}
component.series.add(series)
let color = (self.habit.color.index + Int32(k * 3)) % 16
component.colors.add(theme.color(paletteIndex: color))
}
view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
cell.contentView.addSubview(view)
return cell
}
func buildHistoryChartCell() -> UITableViewCell {
let component = CalendarChart(today: LocalDate(year: 2019, month: 3, day: 15),
color: color,
theme: theme,
dateFormatter: IosLocalDateFormatter())
let cell = UITableViewCell()
let view = ComponentView(frame: cell.frame, component: component)
var series = [KotlinDouble]()
for _ in 1...365 {
series.append(KotlinDouble(value: Double.random(in: 0...1)))
}
component.series = series
view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
cell.contentView.addSubview(view)
return cell
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.navigationBar.barStyle = .blackOpaque
self.navigationController?.navigationBar.barTintColor = color.uicolor
self.navigationController?.navigationBar.tintColor = .white
self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
override func numberOfSections(in tableView: UITableView) -> Int {
return cells.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
return cells[indexPath.section]
}
@objc func onEditHabitClicked() {
self.navigationController?.pushViewController(EditHabitController(), animated: true)
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 200
}
}

View File

@@ -0,0 +1,87 @@
/*
* Copyright (C) 2016-2019 Álinson Santos Xavier <isoron@gmail.com>
*
* This file is part of Loop Habit Tracker.
*
* Loop Habit Tracker is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* Loop Habit Tracker is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import UIKit
class EditHabitTableViewController: NSObject, UITableViewDataSource, UITableViewDelegate {
func disclosure(title: String, subtitle: String) -> UITableViewCell {
let cell = UITableViewCell(style: .value1, reuseIdentifier: nil)
cell.textLabel?.text = title
cell.detailTextLabel?.text = subtitle
cell.accessoryType = .disclosureIndicator
return cell
}
func input(title: String) -> UITableViewCell {
let cell = UITableViewCell()
let field = UITextField(frame: cell.bounds.insetBy(dx: 20, dy: 0))
field.placeholder = title
field.autoresizingMask = [UIView.AutoresizingMask.flexibleWidth,
UIView.AutoresizingMask.flexibleHeight]
cell.contentView.addSubview(field)
return cell
}
var primary = [UITableViewCell]()
var secondary = [UITableViewCell]()
var parentController: EditHabitController
init(withParentController parentController: EditHabitController) {
self.parentController = parentController
super.init()
primary.append(input(title: "Name"))
primary.append(input(title: "Question (e.g. Did you wake up early today?)"))
secondary.append(disclosure(title: "Color", subtitle: "Blue"))
secondary.append(disclosure(title: "Repeat", subtitle: "Daily"))
secondary.append(disclosure(title: "Reminder", subtitle: "Disabled"))
}
func numberOfSections(in tableView: UITableView) -> Int {
return 2
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return section == 0 ? primary.count : secondary.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
return indexPath.section == 0 ? primary[indexPath.item] : secondary[indexPath.item]
}
// func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
// let alert = UIAlertController(title: "Hello", message: "You selected something", preferredStyle: .alert)
// parentController.present(alert, animated: true)
// }
}
class EditHabitController: UIViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
let bounds = UIScreen.main.bounds
let tableController = EditHabitTableViewController(withParentController: self)
let table = UITableView(frame: bounds, style: .grouped)
table.dataSource = tableController
table.delegate = tableController
self.view = table
}
override func viewDidLoad() {
self.title = "Edit Habit"
}
}

View File

@@ -0,0 +1,265 @@
/*
* Copyright (C) 2016-2019 Álinson Santos Xavier <isoron@gmail.com>
*
* This file is part of Loop Habit Tracker.
*
* Loop Habit Tracker is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* Loop Habit Tracker is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import UIKit
class MainScreenCell : UITableViewCell {
var ring = ComponentView(frame: CGRect(), component: nil)
var label = UILabel()
var buttons: [ComponentView] = []
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: .default, reuseIdentifier: reuseIdentifier)
}
required init?(coder aDecoder: NSCoder) {
fatalError()
}
func update(habit: Habit, checkmarks: [Checkmark], score: Score, theme: Theme, nButtons: Int) {
if buttons.count != nButtons {
buttons.removeAll()
for v in contentView.subviews { v.removeFromSuperview() }
let size = CGFloat(theme.checkmarkButtonSize)
let stack = UIStackView(frame: contentView.frame)
stack.autoresizingMask = [.flexibleWidth, .flexibleHeight]
stack.axis = .horizontal
stack.distribution = .fill
stack.alignment = .center
contentView.addSubview(stack)
ring.backgroundColor = .white
ring.widthAnchor.constraint(equalToConstant: size * 0.75).isActive = true
ring.heightAnchor.constraint(equalToConstant: size).isActive = true
stack.addArrangedSubview(ring)
label.backgroundColor = .white
label.heightAnchor.constraint(equalToConstant: size).isActive = true
stack.addArrangedSubview(label)
for _ in 1...nButtons {
let btn = ComponentView(frame: frame, component: nil)
btn.backgroundColor = .white
btn.widthAnchor.constraint(equalToConstant: size).isActive = true
btn.heightAnchor.constraint(equalToConstant: size).isActive = true
buttons.append(btn)
stack.addArrangedSubview(btn)
}
}
var color = theme.color(paletteIndex: habit.color.index)
if habit.isArchived { color = theme.mediumContrastTextColor }
label.text = habit.name
label.textColor = color.uicolor
ring.component = Ring(color: color,
percentage: score.value,
thickness: 2.5,
radius: 7,
theme: theme,
label: false)
ring.setNeedsDisplay()
for i in 0..<buttons.count {
if habit.type == HabitType.numericalHabit {
buttons[i].component = NumberButton(color: color,
value: Double(checkmarks[i].value) / 1000.0,
threshold: habit.target,
units: habit.unit,
theme: theme)
} else {
buttons[i].component = CheckmarkButton(value: checkmarks[i].value,
color: color,
theme: theme)
}
buttons[i].setNeedsDisplay()
}
}
}
class MainScreenController: UITableViewController, MainScreenDataSourceListener {
var backend: Backend
var dataSource: MainScreenDataSource
var data: MainScreenDataSource.Data?
var preferences: Preferences
var theme: Theme
var nButtons = 3
var strings = Strings()
required init?(coder aDecoder: NSCoder) {
fatalError()
}
init(withBackend backend:Backend) {
self.backend = backend
self.strings = backend.strings
self.dataSource = backend.mainScreenDataSource
self.theme = backend.theme
self.preferences = backend.preferences
super.init(nibName: nil, bundle: nil)
self.dataSource.observable.addListener(listener: self)
self.dataSource.requestData()
}
override func viewDidLoad() {
self.title = strings.main_activity_title
self.navigationItem.rightBarButtonItems = [
UIBarButtonItem(image: UIImage(named: "ic_more"),
style: .plain,
target: self,
action: #selector(self.onMoreActionsClicked)),
UIBarButtonItem(barButtonSystemItem: .add,
target: self,
action: #selector(self.onCreateHabitClicked)),
]
tableView.register(MainScreenCell.self, forCellReuseIdentifier: "cell")
tableView.backgroundColor = theme.headerBackgroundColor.uicolor
computeNumberOfButtons(Double(view.frame.width))
}
override func viewDidAppear(_ animated: Bool) {
self.navigationController?.navigationBar.barStyle = .default
self.navigationController?.navigationBar.tintColor = theme.highContrastTextColor.uicolor
self.navigationController?.navigationBar.barTintColor = .white
self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.black]
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return data?.habits.count ?? 0
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! MainScreenCell
let habit = data!.habits[indexPath.row]
cell.update(habit: habit,
checkmarks: data!.checkmarks[habit]!,
score: data!.scores[habit]!,
theme: theme,
nButtons: nButtons)
return cell
}
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let component = HabitListHeader(today: LocalDate(year: 2019, month: 3, day: 24),
nButtons: Int32(nButtons),
theme: theme,
fmt: IosLocalDateFormatter())
return ComponentView(frame: CGRect(x: 0, y: 0, width: 100, height: CGFloat(theme.checkmarkButtonSize)),
component: component)
}
override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return CGFloat(theme.checkmarkButtonSize)
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return CGFloat(theme.checkmarkButtonSize) + 3
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let habit = data!.habits[indexPath.row]
self.navigationController?.pushViewController(DetailScreenController(habit: habit, backend: backend), animated: true)
}
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
computeNumberOfButtons(Double(size.width))
reload()
}
@objc func onCreateHabitClicked() {
self.navigationController?.pushViewController(EditHabitController(), animated: true)
}
@objc func onMoreActionsClicked() {
let alert = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
if preferences.showArchived {
alert.addAction(UIAlertAction(title: strings.hide_archived, style: .default) {
(action: UIAlertAction) -> Void in
self.preferences.showArchived = false
self.dataSource.requestData()
})
} else {
alert.addAction(UIAlertAction(title: strings.show_archived, style: .default) {
(action: UIAlertAction) -> Void in
self.preferences.showArchived = true
self.dataSource.requestData()
})
}
if preferences.showCompleted {
alert.addAction(UIAlertAction(title: strings.hide_completed, style: .default) {
(action: UIAlertAction) -> Void in
self.preferences.showCompleted = false
self.dataSource.requestData()
})
} else {
alert.addAction(UIAlertAction(title: strings.show_completed, style: .default) {
(action: UIAlertAction) -> Void in
self.preferences.showCompleted = true
self.dataSource.requestData()
})
}
if preferences.nightMode {
alert.addAction(UIAlertAction(title: strings.day_mode, style: .default) {
(action: UIAlertAction) -> Void in
self.preferences.nightMode = false
})
} else {
alert.addAction(UIAlertAction(title: strings.night_mode, style: .default) {
(action: UIAlertAction) -> Void in
self.preferences.nightMode = true
})
}
alert.addAction(UIAlertAction(title: strings.help, style: .default) {
(action: UIAlertAction) -> Void in
if let link = URL(string: "http://loophabits.org/faq") {
UIApplication.shared.open(link)
}
})
alert.addAction(UIAlertAction(title: strings.about, style: .default) {
(action: UIAlertAction) -> Void in
self.navigationController?.pushViewController(AboutScreenController(), animated: true)
})
alert.addAction(UIAlertAction(title: strings.cancel, style: .cancel) {
(action: UIAlertAction) -> Void in
// Do nothing
})
present(alert, animated: true, completion: nil)
}
func onDataChanged(newData: MainScreenDataSource.Data) {
data = newData
reload()
}
func computeNumberOfButtons(_ width: Double) {
nButtons = Int((width - 220) / theme.checkmarkButtonSize)
nButtons = max(nButtons, 3)
nButtons = min(nButtons, Int(dataSource.maxNumberOfButtons))
}
func reload() {
let sections = NSIndexSet(indexesIn: NSMakeRange(0, self.tableView.numberOfSections))
tableView.reloadSections(sections as IndexSet, with: .automatic)
}
}

View File

@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>Loop</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIAppFonts</key>
<array>
<string>fonts/FontAwesome.ttf</string>
</array>
<key>UILaunchStoryboardName</key>
<string>Launch.storyboard</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13142" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12042"/>
</dependencies>
<scenes/>
</document>

View File

@@ -0,0 +1,44 @@
/*
* Copyright (C) 2016-2019 Álinson Santos Xavier <isoron@gmail.com>
*
* This file is part of Loop Habit Tracker.
*
* Loop Habit Tracker is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* Loop Habit Tracker is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import UIKit
class ComponentView : UIView {
var component: Component?
init(frame: CGRect, component: Component?) {
self.component = component
super.init(frame: frame)
}
required init?(coder aDecoder: NSCoder) {
fatalError()
}
override func draw(_ rect: CGRect) {
let canvas = IosCanvas(width: Double(rect.width),
height: Double(rect.height),
scale: 1.0)
component?.draw(canvas: canvas)
}
override func layoutSubviews() {
setNeedsDisplay()
}
}