Commit b1c8e830 by Olzhas Aldabergenov

bugs fixed

parent d0bd26e8
......@@ -9,44 +9,46 @@
import Foundation
class ActiveSession {
var startTime: NSDate?
var framedIpAddress: String?
var inputOctets: Int?
var outputOctets: Int?
var serviceInfo: String?
init(json: JSON) {
if let startTime = json["start_time"].string {
let dateFormatter = NSDateFormatter()
dateFormatter.locale = NSLocale(localeIdentifier: "en_US_POSIX")
dateFormatter.dateFormat = "dd-MM-yy"
self.startTime = dateFormatter.dateFromString(startTime)
if self.startTime == nil {
dateFormatter.dateFormat = "yy-MM-dd HH:mm:ss"
var startTime: NSDate?
var framedIpAddress: String?
//var inputOctets: Int?
//var outputOctets: Int?
var serviceInfo: String?
var inputOctetNew : Int64?
var outputOctetNew : Int64?
init(json: JSON) {
if let startTime = json["start_time"].string {
let dateFormatter = NSDateFormatter()
dateFormatter.locale = NSLocale(localeIdentifier: "en_US_POSIX")
dateFormatter.dateFormat = "dd-MM-yy"
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
self.outputOctets = json["output_octets"].int
self.serviceInfo = json["service_info"].string
}
func dateAndMonthFormat() -> String? {
guard let systemDate = startTime else {
return nil
}
let components = systemDate.getComponents()
let year = components.year
let month = components.month
let dateFormatter = NSDateFormatter()
dateFormatter.locale = AppLocalization.language().locale
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)"
func dateAndMonthFormat() -> String? {
guard let systemDate = startTime else {
return nil
}
let components = systemDate.getComponents()
let year = components.year
let month = components.month
let dateFormatter = NSDateFormatter()
dateFormatter.locale = AppLocalization.language().locale
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 {
var rates: [Rate] = []
var service : Service?
var isShowConnectButton : Bool?
var imageUrl : String?
var description : String?
var tariffs: [Tariff]!
......@@ -49,12 +51,14 @@ class ServiceItem {
// "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.name = name
self.type = type
self.data = data
self.key = key
self.imageUrl = imageUrlStr
self.description = description
}
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 {
}
private func configureSubviews() {
bottomView.backgroundColor = Color.PromoBlueColor
//bottomView.backgroundColor = Color.PromoBlueColor
bottomScrollView.backgroundColor = UIColor.clearColor()
bottomScrollView.tintColor = UIColor.clearColor()
}
private func configurePageControl() {
......@@ -69,10 +71,10 @@ class PromoViewController: UIViewController, UIScrollViewDelegate {
imageWrapperView.addSubview(imageView)
imageView.translatesAutoresizingMaskIntoConstraints = false
let views = ["image": imageView]
imageWrapperView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-40-[image]-40-|", options: [], metrics: nil, views: views))
imageWrapperView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|-40-[image]|", options: [], metrics: nil, views: views))
imageWrapperView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|[image]|", options: [], metrics: nil, views: views))
imageWrapperView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[image]|", options: [], metrics: nil, views: views))
imageView.image = UIImage(named: "promo_\(index)")
imageView.contentMode = .ScaleAspectFit
imageView.contentMode = .ScaleAspectFill
self.scrollView.addSubview(imageWrapperView)
// bottom ScrollView
......
......@@ -52,16 +52,38 @@ class ServiceListController: UIViewController, UITableViewDataSource, UITableVie
updateServicesList()
}
// func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
// return 250
// }
// func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
// return 250
// }
func configureTableView() {
servicesTableView.estimatedRowHeight = 100
servicesTableView.estimatedRowHeight = 280
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() {
servicesList = []
for subItem in self.data! {
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)
serviceItem.service = service;
} else {
......@@ -109,6 +131,20 @@ class ServiceListController: UIViewController, UITableViewDataSource, UITableVie
// 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 {
return servicesList.count
}
......
......@@ -35,8 +35,8 @@ class ActiveSessionsCell: UITableViewCell {
dateLabel.text = activeSession.dateAndMonthFormat()
infoLabel.text = activeSession.serviceInfo
firstRightLabel.text = activeSession.framedIpAddress
secondRightLabel.text = "\(activeSession.inputOctets! / 1048576)"
thirdRightLabel.text = "\(activeSession.outputOctets! / 1048576)"
secondRightLabel.text = "\(activeSession.inputOctetNew! / 1048576)"
thirdRightLabel.text = "\(activeSession.outputOctetNew! / 1048576)"
}
}
......
......@@ -18,6 +18,6 @@ class PromoDescriptionView: UIView {
override func awakeFromNib() {
super.awakeFromNib()
backgroundColor = Color.PromoBlueColor
backgroundColor = UIColor.clearColor()// Color.PromoBlueColor
}
}
......@@ -11,18 +11,36 @@ import UIKit
class ServiceCell: UITableViewCell {
@IBOutlet private weak var iconView: UIImageView!
@IBOutlet private weak var nameLabel: UILabel!
@IBOutlet weak var backgroundImage: UIImageView!
@IBOutlet weak var extraLabel: UILabel!
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)
iconView.image = UIImage(named: servicesItem.service!.imageName)
nameLabel.setTextAndSizeToFit(servicesItem.name)
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!.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) {
......
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