RowHomePastActivities.swift 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. // Copyright (C) 2016 Inigo Valentin
  2. //
  3. // This file is part of the Gasteizko Margolariak IOS app.
  4. //
  5. // The Gasteizko Margolariak IOS app is free software: you can
  6. // redistribute it and/or modify it under the terms of the
  7. // GNU General Public License as published by the Free Software
  8. // Foundation, either version 3 of the License, or (at your
  9. // option) any later version.
  10. //
  11. // The Gasteizko Margolariak IOS app is distributed in the
  12. // hope that it will be useful, but WITHOUT ANY WARRANTY;
  13. // without even the implied warranty of MERCHANTABILITY or
  14. // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  15. // Public License for more details.
  16. //
  17. // You should have received a copy of the GNU General Public
  18. // License along with the Gasteizko Margolariak IOS app.
  19. // If not, see <http://www.gnu.org/licenses/>.
  20. import Foundation
  21. import UIKit
  22. /**
  23. Extension of UIView to be formatted as sections.
  24. */
  25. @IBDesignable class RowHomePastActivities: UIView {
  26. //This view
  27. var v: UIView!
  28. //The container.
  29. @IBOutlet weak var container: UIView!
  30. @IBOutlet weak var entry: UIView!
  31. //The activity title.
  32. @IBOutlet weak var title: UILabel!
  33. @IBOutlet weak var descrip: UILabel!
  34. //The acvtivity text.
  35. /**
  36. Run when the section is loaded.
  37. */
  38. required init?(coder aDecoder: NSCoder) {
  39. super.init(coder: aDecoder)
  40. }
  41. private func loadViewFromNib() -> UIView {
  42. let bundle = Bundle(for: type(of: self))
  43. let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
  44. let nibView = nib.instantiate(withOwner: self, options: nil).first as! UIView
  45. return nibView
  46. }
  47. init(s: String, i: Int) {
  48. //self.s = s
  49. //self.i = i
  50. super.init(frame: CGRect(x: 20, y: 100, width: 200, height: 450))
  51. print("Constructor: Custom")
  52. //self.bounds = CGRect(x: 00, y: 0, width: 200, height: 150)
  53. //v = loadViewFromNib()
  54. loadViewFromNib()
  55. v = self
  56. v.frame = bounds
  57. v.autoresizingMask = [.flexibleWidth, .flexibleHeight]
  58. v.translatesAutoresizingMaskIntoConstraints = true
  59. v.backgroundColor = UIColor.green
  60. //Bundle.main.loadNibNamed("RowHomePastActivities", owner: self, options: nil)
  61. //self.addSubview(container)
  62. //container.frame = CGRect(x: 20, y: 100, width: 100, height: 150)
  63. //container.frame = CGRect(x: 20, y: 0, width: 100, height: 150)
  64. container.backgroundColor = UIColor.green
  65. container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
  66. container.translatesAutoresizingMaskIntoConstraints = true
  67. self.backgroundColor = UIColor.red
  68. self.borderColor = UIColor.blue
  69. self.borderWidth = 3
  70. //container.bounds = self.bounds//CGRect(x: 20, y: 100, width: 10, height: 10)
  71. //title.frame = self.bounds
  72. print("bounds")
  73. //title.frame = container.bounds//CGRect(x: 30, y: 150, width: 80, height: 100)
  74. //title.frame = CGRect(x: 0, y: 0, width: 50, height: 15)
  75. //title.bounds = CGRect(x: 0, y: 0, width: 50, height: 15)
  76. //title.bounds = CGRec
  77. container.frame = v.frame
  78. //container.frame = CGRect(x: self.bounds.origin.x, y: self.bounds.origin.y, width: self.bounds.width, height: self.bounds.height)
  79. v.addSubview(container)
  80. title.frame = self.bounds
  81. container.addSubview(title)
  82. //container.autoresizingMask = [UIViewAutoresizing.flexibleWidth, UIViewAutoresizing.flexibleHeight]
  83. let lbl = UILabel()
  84. lbl.text = "ABBA2"
  85. lbl.frame = v.bounds
  86. //view.addEntry(view: row)
  87. v.addSubview(lbl)
  88. }
  89. override init(frame: CGRect){
  90. super.init(frame: frame)
  91. }
  92. func setBounds(rect: CGRect){
  93. container.bounds = rect
  94. }
  95. /**
  96. Changes the title of the activity.
  97. :param: text The new title.
  98. */
  99. func setTitle(text: String){
  100. print("Setting title: \(text)")
  101. //title.text = text
  102. //descrip.text = text
  103. }
  104. /**
  105. Changes the description of the activity.
  106. :param: text The new text.
  107. */
  108. func setText(text: String){
  109. descrip.text = text
  110. }
  111. /**
  112. Changes the image of the activity.
  113. If null or empty, the igage is hidden.
  114. :param: path The new text.
  115. */
  116. func setImage(path: String){
  117. //TODO
  118. }
  119. /*var view:UIView!
  120. func setup() {
  121. view = loadViewFromNib()
  122. view.frame = bounds
  123. view.autoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeightaddSubview(view)
  124. }
  125. func loadViewFromNib() -> UIView {
  126. let bundle = Bundle(for:type(of: self))
  127. let nib = UINib(nibName: "RowHomePastActivities", bundle: bundle)
  128. let view = nib.instantiate(withOwner: self, options: nil)[0] as! UIView
  129. return view
  130. }*/
  131. }