Commit b1c8e830 by Olzhas Aldabergenov

bugs fixed

parent d0bd26e8
...@@ -9,44 +9,46 @@ ...@@ -9,44 +9,46 @@
import Foundation import Foundation
class ActiveSession { class ActiveSession {
var startTime: NSDate? var startTime: NSDate?
var framedIpAddress: String? var framedIpAddress: String?
var inputOctets: Int? //var inputOctets: Int?
var outputOctets: Int? //var outputOctets: Int?
var serviceInfo: String? var serviceInfo: String?
var inputOctetNew : Int64?
init(json: JSON) { var outputOctetNew : Int64?
if let startTime = json["start_time"].string {
let dateFormatter = NSDateFormatter() init(json: JSON) {
dateFormatter.locale = NSLocale(localeIdentifier: "en_US_POSIX") if let startTime = json["start_time"].string {
dateFormatter.dateFormat = "dd-MM-yy" let dateFormatter = NSDateFormatter()
self.startTime = dateFormatter.dateFromString(startTime) dateFormatter.locale = NSLocale(localeIdentifier: "en_US_POSIX")
if self.startTime == nil { dateFormatter.dateFormat = "dd-MM-yy"
dateFormatter.dateFormat = "yy-MM-dd HH:mm:ss"
self.startTime = dateFormatter.dateFromString(startTime) self.startTime = dateFormatter.dateFromString(startTime)
if self.startTime == nil {
dateFormatter.dateFormat = "yy-MM-dd HH:mm:ss"
self.startTime = dateFormatter.dateFromString(startTime)
}
} }
self.framedIpAddress = json["framed_ip_address"].string
self.inputOctetNew = json["input_octets"].int64
self.outputOctetNew = json["output_octets"].int64
self.serviceInfo = json["service_info"].string
} }
self.framedIpAddress = json["framed_ip_address"].string
self.inputOctets = json["input_octets"].int func dateAndMonthFormat() -> String? {
self.outputOctets = json["output_octets"].int guard let systemDate = startTime else {
self.serviceInfo = json["service_info"].string return nil
} }
let components = systemDate.getComponents()
func dateAndMonthFormat() -> String? { let year = components.year
guard let systemDate = startTime else { let month = components.month
return nil let dateFormatter = NSDateFormatter()
} dateFormatter.locale = AppLocalization.language().locale
let components = systemDate.getComponents() if #available(iOS 9.0, *) {
let year = components.year return "\(dateFormatter.standaloneMonthSymbols[month - 1].localizedCapitalizedString) \(year)"
let month = components.month } else {
let dateFormatter = NSDateFormatter() // Fallback on earlier versions
dateFormatter.locale = AppLocalization.language().locale return "\(dateFormatter.standaloneMonthSymbols[month - 1].capitalizedStringWithLocale(NSLocale.currentLocale())) \(year)"
if #available(iOS 9.0, *) { }
return "\(dateFormatter.standaloneMonthSymbols[month - 1].localizedCapitalizedString) \(year)"
} else {
// Fallback on earlier versions
return "\(dateFormatter.standaloneMonthSymbols[month - 1].capitalizedStringWithLocale(NSLocale.currentLocale())) \(year)"
} }
}
} }
...@@ -24,6 +24,8 @@ class ServiceItem { ...@@ -24,6 +24,8 @@ class ServiceItem {
var rates: [Rate] = [] var rates: [Rate] = []
var service : Service? var service : Service?
var isShowConnectButton : Bool? var isShowConnectButton : Bool?
var imageUrl : String?
var description : String?
var tariffs: [Tariff]! var tariffs: [Tariff]!
...@@ -49,12 +51,14 @@ class ServiceItem { ...@@ -49,12 +51,14 @@ class ServiceItem {
// "verbose_description_full": "<p>Оптимальная защита, для активных интернет пользователей.</p>\n<p><strong>Можно установить на 2 устройства.</strong> // "verbose_description_full": "<p>Оптимальная защита, для активных интернет пользователей.</p>\n<p><strong>Можно установить на 2 устройства.</strong>
init(id: Int? = nil, name: String, key: String? = nil, type: String? = nil, data: [[String: AnyObject]]? = nil) { init(id: Int? = nil, name: String, key: String? = nil, type: String? = nil, data: [[String: AnyObject]]? = nil, imageUrlStr: String? = nil, description: String? = nil) {
self.id = id self.id = id
self.name = name self.name = name
self.type = type self.type = type
self.data = data self.data = data
self.key = key self.key = key
self.imageUrl = imageUrlStr
self.description = description
} }
init(json: JSON) { init(json: JSON) {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -40,7 +40,9 @@ class PromoViewController: UIViewController, UIScrollViewDelegate { ...@@ -40,7 +40,9 @@ class PromoViewController: UIViewController, UIScrollViewDelegate {
} }
private func configureSubviews() { private func configureSubviews() {
bottomView.backgroundColor = Color.PromoBlueColor //bottomView.backgroundColor = Color.PromoBlueColor
bottomScrollView.backgroundColor = UIColor.clearColor()
bottomScrollView.tintColor = UIColor.clearColor()
} }
private func configurePageControl() { private func configurePageControl() {
...@@ -69,10 +71,10 @@ class PromoViewController: UIViewController, UIScrollViewDelegate { ...@@ -69,10 +71,10 @@ class PromoViewController: UIViewController, UIScrollViewDelegate {
imageWrapperView.addSubview(imageView) imageWrapperView.addSubview(imageView)
imageView.translatesAutoresizingMaskIntoConstraints = false imageView.translatesAutoresizingMaskIntoConstraints = false
let views = ["image": imageView] let views = ["image": imageView]
imageWrapperView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-40-[image]-40-|", options: [], metrics: nil, views: views)) imageWrapperView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|[image]|", options: [], metrics: nil, views: views))
imageWrapperView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|-40-[image]|", options: [], metrics: nil, views: views)) imageWrapperView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[image]|", options: [], metrics: nil, views: views))
imageView.image = UIImage(named: "promo_\(index)") imageView.image = UIImage(named: "promo_\(index)")
imageView.contentMode = .ScaleAspectFit imageView.contentMode = .ScaleAspectFill
self.scrollView.addSubview(imageWrapperView) self.scrollView.addSubview(imageWrapperView)
// bottom ScrollView // bottom ScrollView
......
...@@ -52,16 +52,38 @@ class ServiceListController: UIViewController, UITableViewDataSource, UITableVie ...@@ -52,16 +52,38 @@ class ServiceListController: UIViewController, UITableViewDataSource, UITableVie
updateServicesList() updateServicesList()
} }
// func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
// return 250
// }
// func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
// return 250
// }
func configureTableView() { func configureTableView() {
servicesTableView.estimatedRowHeight = 100 servicesTableView.estimatedRowHeight = 280
servicesTableView.rowHeight = UITableViewAutomaticDimension servicesTableView.rowHeight = UITableViewAutomaticDimension
} }
// func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
// return 40
// }
// func tableView(tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
// let headerView = UIView()
// headerView.backgroundColor = UIColor.whiteColor()
// return headerView
// }
private func updateServicesList() { private func updateServicesList() {
servicesList = [] servicesList = []
for subItem in self.data! { for subItem in self.data! {
if (subItem["data"] as? [[String: AnyObject]]) == nil { if (subItem["data"] as? [[String: AnyObject]]) == nil {
let serviceItem = ServiceItem(id: subItem["service_id"] as? Int, name: subItem["name"] as! String, key: subItem["key"] as? String, type: subItem["type"] as? String) var url : String? = nil
var description : String? = nil
if let full = subItem["full"] {
url = full["seo_image"] as! String?
description = full["seo_description"] as! String!
}
//let url = subItem["full"]?["seo_image"] as! String?
let serviceItem = ServiceItem(id: subItem["service_id"] as? Int, name: subItem["name"] as! String, key: subItem["key"] as? String, type: subItem["type"] as? String, imageUrlStr : url, description: description)
servicesList.append(serviceItem) servicesList.append(serviceItem)
serviceItem.service = service; serviceItem.service = service;
} else { } else {
...@@ -109,6 +131,20 @@ class ServiceListController: UIViewController, UITableViewDataSource, UITableVie ...@@ -109,6 +131,20 @@ class ServiceListController: UIViewController, UITableViewDataSource, UITableVie
// MARK: UITableViewDataSource // MARK: UITableViewDataSource
// func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
// return 30
// }
//
// func tableView(tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
// let view = UIView()
// view.backgroundColor = UIColor.whiteColor()
// return view
// }
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1//servicesList.count
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return servicesList.count return servicesList.count
} }
......
...@@ -35,8 +35,8 @@ class ActiveSessionsCell: UITableViewCell { ...@@ -35,8 +35,8 @@ class ActiveSessionsCell: UITableViewCell {
dateLabel.text = activeSession.dateAndMonthFormat() dateLabel.text = activeSession.dateAndMonthFormat()
infoLabel.text = activeSession.serviceInfo infoLabel.text = activeSession.serviceInfo
firstRightLabel.text = activeSession.framedIpAddress firstRightLabel.text = activeSession.framedIpAddress
secondRightLabel.text = "\(activeSession.inputOctets! / 1048576)" secondRightLabel.text = "\(activeSession.inputOctetNew! / 1048576)"
thirdRightLabel.text = "\(activeSession.outputOctets! / 1048576)" thirdRightLabel.text = "\(activeSession.outputOctetNew! / 1048576)"
} }
} }
......
...@@ -18,6 +18,6 @@ class PromoDescriptionView: UIView { ...@@ -18,6 +18,6 @@ class PromoDescriptionView: UIView {
override func awakeFromNib() { override func awakeFromNib() {
super.awakeFromNib() super.awakeFromNib()
backgroundColor = Color.PromoBlueColor backgroundColor = UIColor.clearColor()// Color.PromoBlueColor
} }
} }
...@@ -11,18 +11,36 @@ import UIKit ...@@ -11,18 +11,36 @@ import UIKit
class ServiceCell: UITableViewCell { class ServiceCell: UITableViewCell {
@IBOutlet private weak var iconView: UIImageView! @IBOutlet private weak var iconView: UIImageView!
@IBOutlet private weak var nameLabel: UILabel! @IBOutlet private weak var nameLabel: UILabel!
@IBOutlet weak var backgroundImage: UIImageView!
@IBOutlet weak var extraLabel: UILabel!
func setService(servicesItem : ServiceItem, withRow row: Int) { func setService(servicesItem : ServiceItem, withRow row: Int) {
contentView.backgroundColor = servicesItem.service!.colorForRow(row)
//contentView.backgroundColor = UIColor(red: 1.0, green: 0.44, blue: 0.18, alpha: 1.0) //contentView.backgroundColor = UIColor(red: 1.0, green: 0.44, blue: 0.18, alpha: 1.0)
iconView.image = UIImage(named: servicesItem.service!.imageName) iconView.image = UIImage(named: servicesItem.service!.imageName)
nameLabel.setTextAndSizeToFit(servicesItem.name) nameLabel.setTextAndSizeToFit(servicesItem.name)
selectedBackgroundView = UIView(frame: contentView.frame) selectedBackgroundView = UIView(frame: contentView.frame)
selectedBackgroundView!.backgroundColor = servicesItem.service!.colorForRow(row)
//selectedBackgroundView!.backgroundColor = UIColor(red: 0.0, green: 0.44, blue: 0.18, alpha: 1.0) //selectedBackgroundView!.backgroundColor = UIColor(red: 0.0, green: 0.44, blue: 0.18, alpha: 1.0)
//selectedBackgroundView!.alpha = 0.8 //selectedBackgroundView!.alpha = 0.8
if ( servicesItem.imageUrl != nil ) {
ImageLoader.sharedLoader.imageForUrl(servicesItem.imageUrl!) { (image, url) in
self.backgroundImage.image = image?.imageWithRenderingMode(.AlwaysOriginal)
}
self.iconView.alpha = 0.0
self.nameLabel.textColor = UIColor.blackColor()
// selectedBackgroundView!.backgroundColor = UIColor.clearColor()
} else {
self.iconView.alpha = 0.0
self.nameLabel.textColor = UIColor.whiteColor()
contentView.backgroundColor = servicesItem.service!.colorForRow(row)
selectedBackgroundView!.backgroundColor = servicesItem.service!.colorForRow(row)
self.backgroundImage.addConstraint(NSLayoutConstraint(item: self.backgroundImage, attribute: .Height, relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, multiplier: 1.0, constant: 0))
}
self.extraLabel.text = servicesItem.description
} }
override func setSelected(selected: Bool, animated: Bool) { override func setSelected(selected: Bool, animated: Bool) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment