Разработка мобильного приложения LMS "Practicum"
Применение системы класса Learning Management System (LMS) для проектирования образовательной траектории малых групп и подгрупп. Создание мобильного приложения LMS "Practicum" для организации эмоционально-смыслового подхода в изучении иностранных языков.
Рубрика | Программирование, компьютеры и кибернетика |
Вид | дипломная работа |
Язык | русский |
Дата добавления | 19.09.2016 |
Размер файла | 3,7 M |
Отправить свою хорошую работу в базу знаний просто. Используйте форму, расположенную ниже
Студенты, аспиранты, молодые ученые, использующие базу знаний в своей учебе и работе, будут вам очень благодарны.
@IBOutlet var mainIcon: UIImageView!
@IBOutlet var nameLabel: UILabel!
@IBOutlet var genreLabel: UILabel!
@IBOutlet var descriptionLabel: UILabel!
@IBOutlet var coinsButton: UIButton!
@IBOutlet var cloudIcon: UIButton!
override func awakeFromNib () {
super. awakeFromNib ()
// Initialization code
self. mainIcon. layer. masksToBounds = true
self. mainIcon. layer. cornerRadius = 5;
self. typeIcon. layer. masksToBounds = true
self. typeIcon. layer. cornerRadius = 3;
}
@IBAction func coinsButtonPressed (sender: UIButton) {
if let viewController = sender. parentViewController as? TaskController{
let row = viewController. tableView. indexPathForCell (self)!. row;
viewController. tableView. selectRowAtIndexPath (viewController. tableView. indexPathForCell (self), animated: false, scrollPosition: UITableViewScrollPosition. None);
viewController. quest = viewController. quests [row];
viewController. performSegueWithIdentifier ("showItemForPurchase", sender: viewController);
}
else{
print ("Implement");
}
}
@IBAction func cloudIconPressed (sender: UIButton) {
if let viewController = sender. parentViewController as? ChooseExcursion{
let row = viewController. tableView. indexPathForCell (self)!. row;
viewController. tableView. selectRowAtIndexPath (viewController. tableView. indexPathForCell (self), animated: false, scrollPosition: UITableViewScrollPosition. None);
viewController. quest = viewController. questsPurchasedButUnloaded [row];
let manager = UnzipArchiveFromUrl ();
manager. downloadWithURL (NSURL (string: viewController. quest. downloadUrl)!, productId: viewController. quest. bundleId);
}
else{
print ("Implement");
}
}
override func setSelected (selected: Bool, animated: Bool) {
super. setSelected (selected, animated: animated)
// Configure the view for the selected state
}
func setButton () {
switch type{
case "Unstarted":
self. progressAndPrice. layer. borderColor = UIColor (red: 1, green: 1, blue: 1, alpha:
1). CGColor;
self. progressAndPrice. setTitleColor (UIColor (red: 161/255, green: 161/255, blue: 161/255, alpha:
1), forState: UIControlState. Normal)
break;
default:
self. progressAndPrice. setTitleColor (UIColor (red: 0, green: 126/255, blue: 197/255, alpha:
1), forState: UIControlState. Normal)
self. progressAndPrice. layer. borderColor = UIColor (red: 0, green: 126/255, blue: 197/255, alpha:
1). CGColor;
self. progressAndPrice. layer. cornerRadius = 5;
self. progressAndPrice. layer. borderWidth = 1;
break;
}
}
func setTitle (progress: Int, price: Int) {
// print (progress);
if self. cloudIcon! = nil {
self. cloudIcon. hidden = true;
}
self. progressAndPrice. hidden = false;
switch progress{
case 0:
self. type = "Unstarted";
if price == 0 {
self. progressAndPrice. setTitle ("\ (progress) %", forState: UIControlState. Normal);
}
else{
self. type = "Started";
self. progressAndPrice. setTitle ("\ (price) р.", forState: UIControlState. Normal);
}
break;
default:
self. type = "Unstarted"
self. progressAndPrice. setTitle ("\ (progress) %", forState: UIControlState. Normal);
break;
}
}
func setCloudTitle () {
self. cloudIcon. hidden = false;
self. progressAndPrice. hidden = true;
}
func setCoinsTitle (coins: Int) {
self. coinsButton. layer. borderColor = UIColor (red: 0, green: 126/255, blue: 197/255, alpha:
1). CGColor;
self. coinsButton. setTitle ("\ (coins) c", forState: UIControlState. Normal);
self. coinsButton. layer. cornerRadius = 5;
self. coinsButton. layer. borderWidth = 1;
}
@IBAction func ProgresOrBuyButtonPressed (sender: UIButton) {
if let viewController = sender. parentViewController as? ChooseExcursion{
let row = viewController. tableView. indexPathForCell (self)!. row;
viewController. tableView. selectRowAtIndexPath (viewController. tableView. indexPathForCell (self), animated: false, scrollPosition: UITableViewScrollPosition. None);
viewController. quest = viewController. quests [row];
if viewController. quest is Excursion
{
viewController. performSegueWithIdentifier ("showDetailedItem", sender: self);
}
else if viewController. quest is Book
{
viewController. performSegueWithIdentifier ("showChapters", sender: self);
}
}
else if let viewController = sender. parentViewController as? TaskController{
let row = viewController. tableView. indexPathForCell (self)!. row;
viewController. tableView. selectRowAtIndexPath (viewController. tableView. indexPathForCell (self), animated: false, scrollPosition: UITableViewScrollPosition. None);
viewController. quest = viewController. quests [row];
viewController. performSegueWithIdentifier ("showItemForPurchase", sender: viewController);
}
else if let viewController = sender. parentViewController as? ChapterExcursions{
let row = viewController. tableView. indexPathForCell (self)!. row;
viewController. tableView. selectRowAtIndexPath (viewController. tableView. indexPathForCell (self), animated: false, scrollPosition: UITableViewScrollPosition. None);
viewController. excursion = viewController. chapter. excursions [row];
viewController. performSegueWithIdentifier ("showDetailedItem", sender: viewController);
}
else if let viewController = sender. parentViewController as? CoinsController{
let row = viewController. tableView. indexPathForCell (self)!. row;
viewController. tableView. selectRowAtIndexPath (viewController. tableView. indexPathForCell (self), animated: false, scrollPosition: UITableViewScrollPosition. None);
viewController. product = productsArray [row] as! SKProduct
viewController. performSegueWithIdentifier ("goAndPurchase", sender: viewController);
}
else{
print ("Implement");
}
}
}
//
// ChooseVariantCell. swift
// Owley_quest
//
// Created by Патутинский Федор on 29.09.15.
// Copyright © 2015 Fedor Patutinski. All rights reserved.
//
import UIKit
class ChooseVariantCell: UITableViewCell {
var label: UILabel! {
didSet{
self. backgroundColor = UIColor (red: 255/255, green: 255/255, blue: 255/255, alpha:
1);
self. label. translatesAutoresizingMaskIntoConstraints = false
// self. translatesAutoresizingMaskIntoConstraints = false
self. contentView. translatesAutoresizingMaskIntoConstraints = false
label. font = UIFont (name: "HelveticaNeue-Light", size: 14);
self. contentView. addSubview (label);
self. accessoryType = UITableViewCellAccessoryType. DisclosureIndicator;
let namec1 = NSLayoutConstraint (item: label, attribute: NSLayoutAttribute. Leading, relatedBy: NSLayoutRelation. Equal, toItem: self, attribute: NSLayoutAttribute. Leading, multiplier: 1, constant: 17);
let namec2 = NSLayoutConstraint (item: label, attribute: NSLayoutAttribute. Trailing, relatedBy: NSLayoutRelation. Equal, toItem: self, attribute: NSLayoutAttribute. Trailing, multiplier: 1, constant: 0);
let namec3 = NSLayoutConstraint (item: label, attribute: NSLayoutAttribute. CenterY, relatedBy: NSLayoutRelation. Equal, toItem: self, attribute: NSLayoutAttribute. CenterY, multiplier: 1, constant: 0);
// let namec5 = NSLayoutConstraint (item: self, attribute: NSLayoutAttribute. Height, relatedBy: NSLayoutRelation. Equal, toItem: nil, attribute: NSLayoutAttribute. NotAnAttribute, multiplier: 1, constant: 30);
self. addConstraints ([namec1, namec2, namec3]);
let c = NSLayoutConstraint (item: self. contentView, attribute: NSLayoutAttribute. Height, relatedBy: NSLayoutRelation. Equal, toItem: nil, attribute: NSLayoutAttribute. NotAnAttribute, multiplier: 1, constant: 35);
// let c2 = NSLayoutConstraint (item: label, attribute: NSLayoutAttribute. Top, relatedBy: NSLayoutRelation. Equal, toItem: self. contentView, attribute: NSLayoutAttribute. Top, multiplier: 1, constant: 15);
// let c3 = NSLayoutConstraint (item: label, attribute: NSLayoutAttribute. Bottom, relatedBy: NSLayoutRelation. Equal, toItem: self. contentView, attribute: NSLayoutAttribute. Bottom, multiplier: 1, constant: - 15);
self. contentView. addConstraints ([c]);
}
}
override func awakeFromNib () {
super. awakeFromNib ()
// Initialization code
}
override func setSelected (selected: Bool, animated: Bool) {
super. setSelected (selected, animated: animated)
// Configure the view for the selected state
}
}
//
// CoinsCell. swift
// Practica
//
// Created by Патутинский Федор on 20.12.15.
// Copyright © 2015 Fedor Patutinski. All rights reserved.
//
import UIKit
import StoreKit;
class CoinsCell: UITableViewCell {
@IBOutlet var progressAndPrice: UIButton!
var type = ""{
didSet{
self. setButton ();
}
}
@IBOutlet var nameLabel: UILabel!
@IBOutlet var numberOfLineLabel: UILabel!
override func awakeFromNib () {
super. awakeFromNib ()
// Initialization code
// self. mainIcon. layer. masksToBounds = true
// self. mainIcon. layer. cornerRadius = 5;
// self. typeIcon. layer. masksToBounds = true
// self. typeIcon. layer. cornerRadius = 3;
}
override func setSelected (selected: Bool, animated: Bool) {
super. setSelected (selected, animated: animated)
// Configure the view for the selected state
}
func setButton () {
switch type{
case "Unstarted":
self. progressAndPrice. layer. borderColor = UIColor (red: 1, green: 1, blue: 1, alpha:
1). CGColor;
self. progressAndPrice. setTitleColor (UIColor (red: 161/255, green: 161/255, blue: 161/255, alpha:
1), forState: UIControlState. Normal)
break;
default:
self. progressAndPrice. layer. borderColor = UIColor (red: 0, green: 126/255, blue: 197/255, alpha:
1). CGColor;
self. progressAndPrice. layer. cornerRadius = 5;
self. progressAndPrice. layer. borderWidth = 1;
break;
}
}
func setTitle (price: Int) {
// print (progress);
self. type = "Started";
self. progressAndPrice. setTitle ("\ (price) р.", forState: UIControlState. Normal);
}
@IBAction func ProgresOrBuyButtonPressed (sender: UIButton) {
if let viewController = sender. parentViewController as? CoinsController{
let row = viewController. tableView. indexPathForCell (self)!. row;
viewController. product = productsArray [row] as! SKProduct
let payment = SKPayment (product: viewController. product)
SKPaymentQueue. defaultQueue (). addPayment (payment)
}
else{
print ("Implement");
}
}
}
//
// ActionView. swift
// Practica
//
// Created by Патутинский Федор on 05.12.15.
// Copyright © 2015 Fedor Patutinski. All rights reserved.
//
import UIKit
import MediaPlayer;
import GoogleMaps;
class ActionView: UIView, UITableViewDelegate, UITableViewDataSource, AVAudioPlayerDelegate {
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
override func drawRect (rect: CGRect) {
// Drawing code
}
*/
// func loadViewFromNib () - > UIView {
//
// let bundle = NSBundle (forClass: self. dynamicType)
// let nib = UINib (nibName: nibName, bundle: bundle)
// let view = nib. instantiateWithOwner (self, options: nil) [0] as! UIView
//
// return view
// }
@IBOutlet var contentView: UIView!
@IBOutlet var descriptionLabel: UILabel!
@IBOutlet var chooseOrEnterTaskLabel: UILabel!
@IBOutlet var descriptionView: UIView!
@IBOutlet var taskView: UIView!
@IBOutlet var taskText: UILabel!
@IBOutlet var taskTextBackground: UIView!
@IBOutlet var continueAndBackButtonsView: UIView!
@IBOutlet var imageOrMapView: UIView!
var mapView: GMSMapView = GMSMapView ();
var tableView: UITableView?;
var excursionPoint: ExcursionPoint!;
var answerId = 0;
var textField: UITextField?;
var moviePlayer: MPMoviePlayerController = MPMoviePlayerController ();
var youTubePlayer: YouTubePlayerView = YouTubePlayerView ();
func numberOfSectionsInTableView (tableView: UITableView) - > Int {
return 1;
}
func tableView (tableView: UITableView, numberOfRowsInSection section: Int) - > Int {
let task: MultipleChoiceTask = self. excursionPoint. task as! MultipleChoiceTask;
return task. answers. count;
}
func tableView (tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let task: MultipleChoiceTask = self. excursionPoint. task as! MultipleChoiceTask;
let answer = task. answers [indexPath. row];
self. answerId = answer. id;
}
func tableView (tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) - > UITableViewCell {
let task: MultipleChoiceTask = excursionPoint. task as! MultipleChoiceTask;
let cell = ChooseVariantCell ();
cell. label = UILabel ();
cell. label. text = task. answers [indexPath. row]. text;
cell. backgroundColor = UIColor. whiteColor ();
return cell;
}
}
//
// UIElementsTuner. swift
// Owley_quest
//
// Created by Патутинский Федор on 26.09.15.
// Copyright © 2015 Fedor Patutinski. All rights reserved.
//
import Foundation
import MediaPlayer;
import GoogleMaps;
class UIElementsTuner {
// var DetailPurhaseDelegate: DetailPurchaseViewController!;
var elementsArray: [UIView]!;
func setScreenElements (viewController: UIViewController) {
switch viewController{
case is DetailExcursionViewController:
self. setDeatailexcurViewController ( (viewController as? DetailExcursionViewController)!)
break;
case is ActionViewController:
self. setActionViewControllers ( (viewController as? ActionViewController)!);
break;
case is PopulatedActionViewController:
self. setActionViewControllers ( (viewController as? PopulatedActionViewController)!)
break;
default:
break;
}
}
func setDeatailexcurViewController (viewController: DetailExcursionViewController) {
for element in self. elementsArray as [UIView] {
switch element{
case viewController. authorButton:
self. setButtonWithIcon (viewController. authorButton, iconName: "fa-chevron-right", text: (viewController. quest. author), iconAfterText: true);
break;
case viewController. titleLabel:
viewController. titleLabel. text = viewController. quest. name;
break;
case viewController. mainImage:
self. setRoundedImage (5, image: viewController. mainImage)
UIElementsTuner. setMainIconImageView (viewController. quest. picture, image: viewController. mainImage);
break;
case viewController. categoryImage:
self. setRoundedImage (3, image: viewController. categoryImage)
break;
case viewController. ageLabel:
viewController. ageLabel. text = "\ (viewController. quest. maxAge) +";
self. setLabelRectangled (viewController. ageLabel, borderWidth:
1);
break;
case viewController. startButton:
self. chooseSuitingTitle (viewController);
self. setButtonRounded (viewController. startButton, borderWidth: 2, cornerRadius: 5);
break;
case viewController. languageButton:
self. setButtonRounded (viewController. languageButton, borderWidth: 2, cornerRadius: 5);
break;
case viewController. talentsList:
self. setTalentsList (viewController);
break;
case viewController. categoryLabel:
viewController. categoryLabel. text = viewController. quest. category;
case viewController. authorButton:
viewController. authorButton. setTitle (viewController. quest. author, forState:. Normal);
break;
case viewController. durationLabel:
viewController. durationLabel. text = "Длительность: " + getDurationLabel (viewController. quest. duration);
break;
case viewController. progressLabel:
if viewController. quest is Excursion{
let ex = viewController. quest as! Excursion
viewController. progressLabel. text = "\ (Int (Float (ex. currentProgress) /Float (ex. points. count) *100)) %"
}
else{
viewController. progressLabel. text = "-";
}
break;
case viewController. taskLabel:
if viewController. quest is Excursion{
let ex = viewController. quest as! Excursion
viewController. taskLabel. text = ex. mainTask;
}
else{
viewController. taskLabel. text = "-"
}
break;
case viewController. scriptWriterLabel:
viewController. scriptWriterLabel. text = viewController. quest. author;
break;
case viewController. typeOfSoundLabel:
if viewController. quest is Excursion{
let ex = viewController. quest as! Excursion
viewController. typeOfSoundLabel. text = ex. sound. description;
}
else{
viewController. typeOfSoundLabel. text = "-"
}
break
case viewController. genreLabel:
viewController. genreLabel. text = viewController. quest. genre;
break;
case viewController. fileSizeLabel:
viewController. fileSizeLabel. text = viewController. quest. size;
break;
case viewController. gameplayDurationLabel:
viewController. gameplayDurationLabel. text = getDurationLabel (viewController. quest. duration);
break;
case viewController. numberOfTasksLabel:
if viewController. quest is Excursion{
let ex = viewController. quest as! Excursion
viewController. numberOfTasksLabel. text = "\ (ex. numberOfTasks)";
}
else{
viewController. numberOfTasksLabel. text = "-"
}
break;
case viewController. placeLabel:
if viewController. quest is Excursion{
let ex = viewController. quest as! Excursion
viewController. placeLabel. text = ex. place;
}
else{
viewController. placeLabel. text = "-"
}
break;
case viewController. languagesLabel:
viewController. languagesLabel. text = self. getLanguagesToLabel (viewController. quest. languages);
break;
case viewController. descriptionLabel:
viewController. descriptionLabel. text = viewController. quest. description;
break;
default:
break;
}
}
}
func setButtonWithIcon (button: UIButton, iconName: String, text: String, iconAfterText: Bool) {
var position = 0;
var buttonText = "";
let color = button. titleLabel?. textColor;
if iconAfterText{
position = text. characters. count+1;
buttonText = text + " " + String. fontAwesomeString (iconName);
}
else {
position = 0
buttonText = String. fontAwesomeString (iconName) + " " + text;
}
let font = button. titleLabel?. font;
let lA = NSMutableAttributedString (string: buttonText, attributes: [NSFontAttributeName: UIFont (name: (font?. fontName)!, size: (font?. pointSize)!)!])
lA. addAttribute (NSFontAttributeName, value: UIFont. iconFontOfSize ("FontAwesome", fontSize: (font?. pointSize)!), range: NSRange (location: position, length:
1));
lA. addAttribute (NSForegroundColorAttributeName, value: color!, range: NSRange (location: 0, length: position));
button. setAttributedTitle (lA, forState:. Normal);
}
func chooseSuitingTitle (viewConrtoller: DetailExcursionViewController) {
print (viewConrtoller. isItemPurchased)
switch viewConrtoller. isItemPurchased{
case false:
viewConrtoller. startButton. setTitle ("КУПИТЬ", forState:. Normal)
break
default:
if viewConrtoller. quest is Excursion{
let quest = viewConrtoller. quest as! Excursion;
if quest. currentProgress == 0{
viewConrtoller. startButton. setTitle ("НАЧАТЬ", forState:. Normal);
}
else{
viewConrtoller. startButton. setTitle ("ПРОДОЛЖИТЬ", forState:. Normal);
}
}
else{
viewConrtoller. startButton. setTitle ("НАЧАТЬ", forState:. Normal);
}
break;
}
}
func setRoundedImage (radius: Int, image: UIImageView) {
image. layer. masksToBounds = true
image. layer. cornerRadius = 5;
}
func setLabelRectangled (label: UILabel, borderWidth: CGFloat) {
let color = label. textColor;
label. layer. borderColor = color. CGColor
label. layer. borderWidth = borderWidth;
}
func setButtonRounded (button: UIButton, borderWidth: CGFloat, cornerRadius: CGFloat) {
let color = button. titleLabel?. textColor;
button. layer. masksToBounds = true;
button. layer. borderColor = color?. CGColor;
button. layer. borderWidth = borderWidth;
button. layer. cornerRadius = cornerRadius;
}
func getDurationLabel (minutes: Int) - >String{
let hours = Int (floor (Float (minutes/60)));
let rest = (Float (minutes) /60) %1;
let min = Int (rest*60.0);
return "\ (hours) h \ (min) m";
}
func getLanguagesToLabel (languages: [String]) - >String{
var returnString="";
for l in languages{
if l! = languages [languages. count-1] {
returnString = returnString + l +", ";
}
else{
returnString = returnString + l;
}
}
return returnString;
}
func setTalentsList (viewController: DetailExcursionViewController) {
viewController. talentsList. translatesAutoresizingMaskIntoConstraints = false
formReportsView (viewController. leftTalentsView, reports: viewController. quest. reportItems. filter{$0. type == Options. ReportItemType. Round});
formReportsView (viewController. centerTalentsView, reports: viewController. quest. reportItems. filter{$0. type == Options. ReportItemType. Scale});
formReportsView (viewController. rightTalentsView, reports: viewController. quest. reportItems. filter{$0. type == Options. ReportItemType. ScaleWithOpposite});
}
func formReportsView (container: UIView, reports: [ReportItem]) {
print (reports);
var viewsArray: [UIView] = [];
container. translatesAutoresizingMaskIntoConstraints = false
for (index,report) in reports. enumerate () {
var previousView: UIView!
var alignTopConst: NSLayoutAttribute!;
if index == 0{
previousView = container;
alignTopConst =. Top;
}
else{
previousView = viewsArray [index-1];
alignTopConst =. Bottom;
}
let talentLabel = UILabel ();
talentLabel. translatesAutoresizingMaskIntoConstraints = false
talentLabel. text = report. name;
talentLabel. font = UIFont (name: "HelveticaNeue-Light", size: 12);
container. addSubview (talentLabel);
let namec1 = NSLayoutConstraint (item: talentLabel, attribute: NSLayoutAttribute. Leading, relatedBy: NSLayoutRelation. Equal, toItem: previousView, attribute: NSLayoutAttribute. Leading, multiplier: 1, constant: 0);
let namec2 = NSLayoutConstraint (item: talentLabel, attribute: NSLayoutAttribute. Top, relatedBy: NSLayoutRelation. Equal, toItem: previousView, attribute: alignTopConst, multiplier: 1, constant: 0);
container. addConstraints ([namec1, namec2]);
viewsArray. append (talentLabel);
}
if viewsArray. count! = 0{
let lastView = viewsArray [viewsArray. count-1];
let c = NSLayoutConstraint (item: lastView, attribute: NSLayoutAttribute. Bottom, relatedBy: NSLayoutRelation. Equal, toItem: container, attribute: NSLayoutAttribute. Bottom, multiplier: 1, constant: 0);
container. addConstraint (c);
}
}
func setActionViewControllers (vc: ActionParentController) {
self. cleanDescriptionAndtViews (vc);
for ui in elementsArray{
switch ui{
case vc. aSlider:
self. setAudioSlider (vc. aSlider,viewController: vc);
break;
case vc. mView:
self. setMapView (vc);
break;
case vc. tView!:
self. setTaskText (vc);
self. setTask (vc);
break;
case vc. descripView!:
self. setDescriptionView (vc);
break;
case vc. iView:
self. setImageView (vc);
break;
case vc. imageOrMapVContainer:
self. setimageOrMapVContainer (vc);
break;
default:
break;
}
}
}
func setAudioSlider (slider: UISlider, viewController: ActionParentController) {
if ( (viewController. hideAudioPlayer! = nil) && (viewController. hideAudioPlayer == true)) {
viewController. playPauseButton?. hidden = true;
viewController. lineContinuation?. hidden = true;
viewController. time1Label?. hidden = true;
viewController. time2Label?. hidden = true;
viewController. aSlider. hidden = true;
return;
}
let iv = UIImage (named: "SliderThumb");
slider. setThumbImage (iv, forState:. Normal)
slider. setThumbImage (iv, forState:. Selected)
slider. setThumbImage (iv, forState:. Highlighted)
slider. userInteractionEnabled = true;
}
func setTaskText (viewController: ActionParentController) {
let task = viewController. excur!. points [viewController. pIndex!]. task;
viewController. tText!. text = task. task;
if task. style ==. subtask{
viewController. tText!. textColor = UIColor (colorLiteralRed: 91/255, green: 91/255, blue: 91/255, alpha: 1.0);
}
}
func setTask (vc: ActionParentController) {
switch vc. excur!. points [vc. pIndex!]. task. type{
case. Multiple:
setMultipleChoiceTask (vc);
break;
case. Text:
setTexttViewController (vc);
break;
case. Empty:
if vc is PopulatedActionViewController == false{
self. setEmptyTask (vc);
}
break;
default:
setEmptyTask (vc);
break;
}
}
func setMultipleChoiceTask (viewController: ActionParentController) {
let height: CGFloat = CGFloat ( (viewController. excur!. points [viewController. pIndex!]. task as! MultipleChoiceTask). answers. count) *40;
// print (height);
viewController. chTaskLabel!. text = "Выберите вариант";
let tableView = UITableView ();
viewController. tableV = tableView;
viewController. tableV!. translatesAutoresizingMaskIntoConstraints = false;
// viewController. tView. addSubview (viewController. chTaskLabel);
viewController. tView!. addSubview (viewController. tableV!);
viewController. tableV!. rowHeight = UITableViewAutomaticDimension;
viewController. tableV!. estimatedRowHeight = 100.0;
if viewController is ActionViewController{
viewController. tableV!. delegate = viewController as! ActionViewController;
viewController. tableV!. dataSource = viewController as! ActionViewController;
}
else if viewController is PopulatedActionViewController{
viewController. tableV!. delegate = (viewController as! PopulatedActionViewController). viewsArray [ (viewController as! PopulatedActionViewController). pointIndex];
viewController. tableV!. dataSource = (viewController as! PopulatedActionViewController). viewsArray [ (viewController as! PopulatedActionViewController). pointIndex];
}
else{
print ("implement");
}
let c = NSLayoutConstraint (item: viewController. tableV!, attribute: NSLayoutAttribute. Top, relatedBy: NSLayoutRelation. Equal, toItem: viewController. chTaskLabel, attribute: NSLayoutAttribute. Bottom, multiplier: 1, constant: 10);
let c2 = NSLayoutConstraint (item: viewController. tableV!, attribute: NSLayoutAttribute. Height, relatedBy: NSLayoutRelation. Equal, toItem: nil, attribute: NSLayoutAttribute. NotAnAttribute, multiplier: 1, constant: height);
let c3 = NSLayoutConstraint (item: viewController. tableV!, attribute: NSLayoutAttribute. Width, relatedBy: NSLayoutRelation. Equal, toItem: viewController. tView, attribute: NSLayoutAttribute. Width, multiplier: 1, constant: 0);
let c4 = NSLayoutConstraint (item: viewController. tableV!, attribute: NSLayoutAttribute. Trailing, relatedBy: NSLayoutRelation. Equal, toItem: viewController. tView, attribute: NSLayoutAttribute. Trailing, multiplier: 1, constant: 0);
let c5 = NSLayoutConstraint (item: viewController. tableV!, attribute: NSLayoutAttribute. Leading, relatedBy: NSLayoutRelation. Equal, toItem: viewController. tView, attribute: NSLayoutAttribute. Leading, multiplier: 1, constant: 0);
let c6 = NSLayoutConstraint (item: viewController. tView!, attribute: NSLayoutAttribute. Bottom, relatedBy: NSLayoutRelation. Equal, toItem: viewController. tableV!, attribute: NSLayoutAttribute. Bottom, multiplier: 1, constant: 10);
viewController. tView!. addConstraints ([c,c2,c3,c4,c5,c6]);
viewController. tableV!. reloadData ();
}
func setTexttViewController (viewController: ActionParentController) {
viewController. chTaskLabel!. text = "Введите слово";
let textField = UITextField ();
textField. backgroundColor = UIColor. whiteColor ();
textField. font = UIFont (name: "HelveticaNeue-Light", size: 14);
let paddingView = UIView (frame: CGRectMake (0, 0, 7, textField. frame. height))
textField. leftView = paddingView
textField. leftViewMode = UITextFieldViewMode. Always
textField. layer. cornerRadius = 5;
textField. layer. borderWidth = 2;
textField. layer. borderColor = UIColor (colorLiteralRed: 235/255, green: 235/255, blue: 235/255, alpha:
1). CGColor;
textField. userInteractionEnabled = true;
if viewController is ActionViewController{
textField. delegate = viewController as! ActionViewController;
(viewController as! ActionViewController). textField = textField;
}
else if viewController is PopulatedActionViewController{
textField. delegate = viewController as! PopulatedActionViewController;
(viewController as! PopulatedActionViewController). viewsArray [ (viewController as! PopulatedActionViewController). pointIndex]. textField = textField;
}
else{
print ("implement");
}
textField. translatesAutoresizingMaskIntoConstraints = false
viewController. tView!. addSubview (textField);
viewController. textFd = textField;
let c = NSLayoutConstraint (item: textField, attribute: NSLayoutAttribute. Height, relatedBy: NSLayoutRelation. Equal, toItem: nil, attribute: NSLayoutAttribute. NotAnAttribute, multiplier: 1, constant: 20);
let c1 = NSLayoutConstraint (item: textField, attribute: NSLayoutAttribute. Left, relatedBy: NSLayoutRelation. Equal, toItem: viewController. chTaskLabel, attribute: NSLayoutAttribute. Left, multiplier: 1, constant: 0);
let c2 = NSLayoutConstraint (item: textField, attribute: NSLayoutAttribute. Top, relatedBy: NSLayoutRelation. Equal, toItem: viewController. chTaskLabel, attribute: NSLayoutAttribute. Bottom, multiplier: 1, constant: 5);
let c3 = NSLayoutConstraint (item: textField, attribute: NSLayoutAttribute. Width, relatedBy: NSLayoutRelation. Equal, toItem: nil, attribute: NSLayoutAttribute. NotAnAttribute, multiplier: 1, constant: 160);
let c4 = NSLayoutConstraint (item: textField, attribute: NSLayoutAttribute. Bottom, relatedBy: NSLayoutRelation. Equal, toItem: viewController. tView, attribute: NSLayoutAttribute. Bottom, multiplier: 1, constant: - 10)
viewController. tView!. addConstraints ([c, c1, c2, c3, c4]);
let button = UIButton ();
button. setTitle ("Далее", forState:. Normal);
button. titleLabel!. font = UIFont (name: "HelveticaNeue", size: 14)!;
button. backgroundColor = UIColor (colorLiteralRed: 54/255, green: 175/255, blue: 16/255, alpha:
1);
button. setTitleColor (UIColor. whiteColor (), forState:. Normal);
button. userInteractionEnabled = true;
button. addTarget (viewController, action: (#selector (viewController. submitTextButtonPressed)), forControlEvents:. TouchUpInside);
button. addTarget (viewController, action: (#selector (viewController. submitTextButtonPressed)), forControlEvents:. TouchUpInside);
button. translatesAutoresizingMaskIntoConstraints = false
viewController. tView!. addSubview (button);
let c6 = NSLayoutConstraint (item: button, attribute: NSLayoutAttribute. Right, relatedBy: NSLayoutRelation. Equal, toItem: viewController. tView!, attribute: NSLayoutAttribute. Right, multiplier: 1, constant: - 17);
let c7 = NSLayoutConstraint (item: button, attribute: NSLayoutAttribute. CenterY, relatedBy: NSLayoutRelation. Equal, toItem: textField, attribute: NSLayoutAttribute. CenterY, multiplier: 1, constant: 0);
let c8 = NSLayoutConstraint (item: button, attribute: NSLayoutAttribute. Width, relatedBy: NSLayoutRelation. Equal, toItem: nil, attribute: NSLayoutAttribute. NotAnAttribute, multiplier: 1, constant: 65);
viewController. tView!. addConstraints ([c6, c7, c8]);
}
func setDescriptionView (viewController: ActionParentController) {
let dialogs = viewController. excur!. points [viewController. pIndex!]. dialogs;
var label: UILabel = viewController. descripLabel!
for dialog in dialogs{
switch dialog. mainCharacter{
case true:
label = self. setRightDialog (dialog, previousLabel: label, contentView: viewController. descripView!);
break;
default:
label = self. setLeftDialog (dialog, previousLabel: label, contentView: viewController. descripView!, decriptionLabel: viewController. descripLabel!);
break;
}
}
let c = NSLayoutConstraint (item: label, attribute: NSLayoutAttribute. Bottom, relatedBy: NSLayoutRelation. Equal, toItem: viewController. descripView!, attribute: NSLayoutAttribute. Bottom, multiplier: 1, constant: - 10)
c. identifier = "Delete";
viewController. descripView!. addConstraint (c);
}
func setLeftDialog (dialog: Dialog, previousLabel: UILabel, contentView: UIView, decriptionLabel: UILabel) - >UILabel{
var nameLabel = UILabel ();
var trailingValue: CGFloat = - 60
if dialog. isNameEmpty () == false{
nameLabel. text = dialog. name;
nameLabel. font = UIFont (name: "HelveticaNeue-Italic", size: 14);
nameLabel. translatesAutoresizingMaskIntoConstraints = false;
contentView. addSubview (nameLabel);
let c1 = NSLayoutConstraint (item: nameLabel, attribute: NSLayoutAttribute. Top, relatedBy: NSLayoutRelation. Equal, toItem: previousLabel, attribute: NSLayoutAttribute. Bottom, multiplier: 1, constant: 10);
let c2 = NSLayoutConstraint (item: nameLabel, attribute: NSLayoutAttribute. Leading, relatedBy: NSLayoutRelation. Equal, toItem: decriptionLabel, attribute: NSLayoutAttribute. Leading, multiplier: 1, constant: 0);
contentView. addConstraints ([c1,c2]);
}
else{
nameLabel = previousLabel;
trailingValue = - 17;
}
let textLabel = UILabel ();
textLabel. text = dialog. text;
textLabel. font = UIFont (name: "HelveticaNeue-Light", size: 14);
textLabel. translatesAutoresizingMaskIntoConstraints = false;
textLabel. numberOfLines = 0;
contentView. addSubview (textLabel);
let c3 = NSLayoutConstraint (item: textLabel, attribute: NSLayoutAttribute. Top, relatedBy: NSLayoutRelation. Equal, toItem: nameLabel, attribute: NSLayoutAttribute. Bottom, multiplier: 1, constant: 5);
let c4 = NSLayoutConstraint (item: textLabel, attribute: NSLayoutAttribute. Leading, relatedBy: NSLayoutRelation. Equal, toItem: nameLabel, attribute: NSLayoutAttribute. Leading, multiplier: 1, constant: 0);
let c5 = NSLayoutConstraint (item: textLabel, attribute: NSLayoutAttribute. Trailing, relatedBy: NSLayoutRelation. Equal, toItem: contentView, attribute: NSLayoutAttribute. Trailing, multiplier: 1, constant: trailingValue);
contentView. addConstraints ([c3,c4,c5]);
return textLabel;
}
func setRightDialog (dialog: Dialog, previousLabel: UILabel, contentView: UIView) - >UILabel{
var nameLabel = UILabel ();
var textAlignment: NSTextAlignment =. Right;
var leadingValue: CGFloat = - 60
if dialog. isNameEmpty () == false{
nameLabel. text = dialog. name;
nameLabel. font = UIFont (name: "HelveticaNeue-Italic", size: 14);
nameLabel. translatesAutoresizingMaskIntoConstraints = false;
contentView. addSubview (nameLabel);
let c1 = NSLayoutConstraint (item: nameLabel, attribute: NSLayoutAttribute. Top, relatedBy: NSLayoutRelation. Equal, toItem: previousLabel, attribute: NSLayoutAttribute. Bottom, multiplier: 1, constant: 10);
let c2 = NSLayoutConstraint (item: nameLabel, attribute: NSLayoutAttribute. Trailing, relatedBy: NSLayoutRelation. Equal, toItem: contentView, attribute: NSLayoutAttribute. Trailing, multiplier: 1, constant: - 17);
contentView. addConstraints ([c1,c2]);
}
else{
nameLabel = previousLabel
textAlignment =. Left
leadingValue = - 17;
}
let textLabel = UILabel ();
textLabel. text = dialog. text;
textLabel. font = UIFont (name: "HelveticaNeue-Light", size: 14);
textLabel. translatesAutoresizingMaskIntoConstraints = false;
textLabel. numberOfLines = 0;
textLabel. textAlignment = textAlignment;
contentView. addSubview (textLabel);
let c3 = NSLayoutConstraint (item: textLabel, attribute: NSLayoutAttribute. Top, relatedBy: NSLayoutRelation. Equal, toItem: nameLabel, attribute: NSLayoutAttribute. Bottom, multiplier: 1, constant: 5);
let c4 = NSLayoutConstraint (item: textLabel, attribute: NSLayoutAttribute. Trailing, relatedBy: NSLayoutRelation. Equal, toItem: nameLabel, attribute: NSLayoutAttribute. Trailing, multiplier: 1, constant: 0);
let c5 = NSLayoutConstraint (item: contentView, attribute: NSLayoutAttribute. Leading, relatedBy: NSLayoutRelation. Equal, toItem: textLabel, attribute: NSLayoutAttribute. Leading, multiplier: 1, constant: leadingValue);
contentView. addConstraints ([c3,c4,c5]);
return textLabel;
}
func setEmptyTask (viewController: ActionParentController) {
viewController. chTaskLabel!. text = "";
if viewController. excur!. points [viewController. pIndex!]. task. type == Options. TypesOfTask. None{
for t in viewController. excur!. points [viewController. pIndex!]. description{
viewController. chTaskLabel!. text = viewController. chTaskLabel!. text! + t;
}
}
let button = UIButton (type:. Custom);
if viewController. pIndex == viewController. excur?. points. count{
button. hidden = true;
}
button. setBackgroundImage (UIImage (named: "arrow_next. png"), forState:. Normal);
button. userInteractionEnabled = true;
button. addTarget (viewController, action: #selector (viewController. continueButtonPressed), forControlEvents:. TouchUpInside);
button. translatesAutoresizingMaskIntoConstraints = false
viewController. continueAndBButtonsView!. addSubview (button);
let c2 = NSLayoutConstraint (item: button, attribute: NSLayoutAttribute. CenterX, relatedBy: NSLayoutRelation. Equal, toItem: viewController. continueAndBButtonsView, attribute: NSLayoutAttribute. CenterX, multiplier: 1, constant: 38);
let c3 = NSLayoutConstraint (item: button, attribute: NSLayoutAttribute. Top, relatedBy: NSLayoutRelation. Equal, toItem: viewController. continueAndBButtonsView, attribute: NSLayoutAttribute. Top, multiplier: 1, constant: 10);
let c4 = NSLayoutConstraint (item: button, attribute: NSLayoutAttribute. Bottom, relatedBy: NSLayoutRelation. Equal, toItem: viewController. continueAndBButtonsView, attribute: NSLayoutAttribute. Bottom, multiplier: 1, constant: - 10)
let c5 = NSLayoutConstraint (item: button, attribute: NSLayoutAttribute. Width, relatedBy: NSLayoutRelation. Equal, toItem: nil, attribute: NSLayoutAttribute. NotAnAttribute, multiplier: 1, constant: 40)
let c6 = NSLayoutConstraint (item: button, attribute: NSLayoutAttribute. Height, relatedBy: NSLayoutRelation. Equal, toItem: nil, attribute: NSLayoutAttribute. NotAnAttribute, multiplier: 1, constant: 25)
viewController. continueAndBButtonsView!. addConstraints ([c2, c3, c4, c5, c6]);
let button2 = UIButton (type:. Custom);
if (viewController. prevPIndex == 0 && viewController. pIndex == 0) {
button2. hidden = true;
}
button2. setBackgroundImage (UIImage (named: "arrow_prev. png"), forState:. Normal);
button2. userInteractionEnabled = true;
button2. addTarget (viewController, action: #selector (viewController. returnButtonPressed), forControlEvents:. TouchUpInside);
button2. translatesAutoresizingMaskIntoConstraints = false
viewController. continueAndBButtonsView!. addSubview (button2);
button2. hidden = true;
let c7 = NSLayoutConstraint (item: button2, attribute: NSLayoutAttribute. CenterX, relatedBy: NSLayoutRelation. Equal, toItem: viewController. continueAndBButtonsView, attribute: NSLayoutAttribute. CenterX, multiplier: 1, constant: - 38);
let c8 = NSLayoutConstraint (item: button2, attribute: NSLayoutAttribute. Top, relatedBy: NSLayoutRelation. Equal, toItem: viewController. continueAndBButtonsView, attribute: NSLayoutAttribute. Top, multiplier: 1, constant: 10);
let c9 = NSLayoutConstraint (item: button2, attribute: NSLayoutAttribute. Bottom, relatedBy: NSLayoutRelation. Equal, toItem: viewController. continueAndBButtonsView, attribute: NSLayoutAttribute. Bottom, multiplier: 1, constant: - 10)
let c10 = NSLayoutConstraint (item: button2, attribute: NSLayoutAttribute. Width, relatedBy: NSLayoutRelation. Equal, toItem: nil, attribute: NSLayoutAttribute. NotAnAttribute, multiplier: 1, constant: 40)
let c11 = NSLayoutConstraint (item: button2, attribute: NSLayoutAttribute. Height, relatedBy: NSLayoutRelation. Equal, toItem: nil, attribute: NSLayoutAttribute. NotAnAttribute, multiplier: 1, constant: 25)
viewController. continueAndBButtonsView!. addConstraints ([c7, c8, c9, c10, c11]);
}
func cleanDescriptionAndtViews (vc: ActionParentController) {
for view in vc. continueAndBButtonsView!. subviews{
view. removeFromSuperview ();
}
for view in vc. tView!. subviews{
if view! = vc. chTaskLabel{
view. removeFromSuperview ();
}
}
for view in vc. descripView!. subviews{
if view! = vc. descripLabel{
view. removeFromSuperview ();
}
}
for c in vc. descripView!. constraints{
if c. identifier == "Delete"{
vc. descripView!. removeConstraint (c);
}
}
if vc. imageOrMapVContainer. subviews. count! = 0{
for sub in vc. imageOrMapVContainer. subviews{
sub. removeFromSuperview ();
}
}
vc. chTaskLabel!. text = "";
vc. tText!. text = "";
// self. addTrailingConstraint (viewController);
}
func setImageView (vc: ActionParentController) {
for sub in vc. cView!. subviews{
if let mv = sub as? GMSMapView{
mv. hidden = true;
}
if let mv = sub as? UIImageView{
mv. hidden = false;
mv. image = vc. excur!. points [vc. pIndex!]. image
for cons in mv. constraints{
mv. removeConstraint (cons);
}
let c = NSLayoutConstraint (item: mv, attribute: NSLayoutAttribute. Height, relatedBy: NSLayoutRelation. Equal, toItem: nil, attribute: NSLayoutAttribute. NotAnAttribute, multiplier: 1, constant: self. getProportionalHeight (mv));
mv. addConstraint (c);
}
}
}
func setMapView (vc: ActionParentController) {
for sub in vc. cView!. subviews{
if let iv = sub as? UIImageView{
iv. hidden = true;
}
if let mv = sub as? GMSMapView{
mv. hidden = false;
}
}
}
func setimageOrMapVContainer (vc: ActionParentController) {
if vc. excur!. points [vc. pIndex!]. image! = nil{
let imageView = UIImageView (image: vc. excur!. points [vc. pIndex!]. image);
imageView. translatesAutoresizingMaskIntoConstraints = false
vc. imageOrMapVContainer. addSubview (imageView);
let c2 = NSLayoutConstraint (item: imageView, attribute: NSLayoutAttribute. Height, relatedBy: NSLayoutRelation. Equal, toItem: nil, attribute: NSLayoutAttribute. NotAnAttribute, multiplier: 1, constant: self. getProportionalHeight (imageView));
let c3 = NSLayoutConstraint (item: imageView, attribute: NSLayoutAttribute. Top, relatedBy: NSLayoutRelation. Equal, toItem: vc. imageOrMapVContainer, attribute: NSLayoutAttribute. Top, multiplier: 1, constant: 0);
let c4 = NSLayoutConstraint (item: vc. imageOrMapVContainer, attribute: NSLayoutAttribute. Bottom, relatedBy: NSLayoutRelation. Equal, toItem: imageView, attribute: NSLayoutAttribute. Bottom, multiplier: 1, constant: 0)
let c5 = NSLayoutConstraint (item: imageView, attribute: NSLayoutAttribute. Leading, relatedBy: NSLayoutRelation. Equal, toItem: vc. imageOrMapVContainer, attribute: NSLayoutAttribute. Leading, multiplier: 1, constant: 0);
let c6 = NSLayoutConstraint (item: imageView, attribute: NSLayoutAttribute. Trailing, relatedBy: NSLayoutRelation. Equal, toItem: vc. imageOrMapVContainer, attribute: NSLayoutAttribute. Trailing, multiplier: 1, constant: 0)
imageView. addConstraint (c2);
vc. imageOrMapVContainer. addConstraints ([c3,c4,c5,c6]);
}
else if vc. excur!. points [vc. pIndex!]. coordinate. coordinate. latitude! = 0 || vc. excur!. points [vc. pIndex!]. coordinate. coordinate. longitude! = 0{
let mapView = GMSMapView ();
mapView. translatesAutoresizingMaskIntoConstraints = false
vc. imageOrMapVContainer. addSubview (mapView);
let c2 = NSLayoutConstraint (item: mapView, attribute: NSLayoutAttribute. Height, relatedBy: NSLayoutRelation. Equal, toItem: nil, attribute: NSLayoutAttribute. NotAnAttribute, multiplier: 1, constant: 400);
let c3 = NSLayoutConstraint (item: mapView, attribute: NSLayoutAttribute. Top, relatedBy: NSLayoutRelation. Equal, toItem: vc. imageOrMapVContainer, attribute: NSLayoutAttribute. Top, multiplier: 1, constant: 0);
let c4 = NSLayoutConstraint (item: vc. imageOrMapVContainer, attribute: NSLayoutAttribute. Bottom, relatedBy: NSLayoutRelation. Equal, toItem: mapView, attribute: NSLayoutAttribute. Bottom, multiplier: 1, constant: 0)
let c5 = NSLayoutConstraint (item: mapView, attribute: NSLayoutAttribute. Leading, relatedBy: NSLayoutRelation. Equal, toItem: vc. imageOrMapVContainer, attribute: NSLayoutAttribute. Leading, multiplier: 1, constant: 0);
let c6 = NSLayoutConstraint (item: mapView, attribute: NSLayoutAttribute. Trailing, relatedBy: NSLayoutRelation. Equal, toItem: vc. imageOrMapVContainer, attribute: NSLayoutAttribute. Trailing, multiplier: 1, constant: 0)
mapView. addConstraint (c2);
vc. imageOrMapVContainer. addConstraints ([c3,c4,c5,c6]);
let dc = DirectionsChecker (stepLocation: vc. excur!. points [vc. pIndex!]. coordinate);
dc. mapView = mapView;
dc. mapView. delegate = dc;
}
else if vc. excur!. points [vc. pIndex!]. videoPath! = nil{
if vc. excur!. points [vc. pIndex!]. isYouTubeVideo {
self. createYouTubePlayer (vc);
}
else{
self. createStandartPlayer (vc);
}
}
}
func createYouTubePlayer (vc: ActionParentController) {
let player = vc. youTubePlayer
player. delegate = vc;
player. loadVideoByHTMLpath (vc. excur!. points [vc. pIndex!]. videoPath!)
vc. imageOrMapVContainer. addSubview (player);
player. translatesAutoresizingMaskIntoConstraints = false
let c2 = NSLayoutConstraint (item: player, attribute: NSLayoutAttribute. Height, relatedBy: NSLayoutRelation. Equal, toItem: nil, attribute: NSLayoutAttribute. NotAnAttribute, multiplier: 1, constant: 200);
let c3 = NSLayoutConstraint (item: player, attribute: NSLayoutAttribute. Top, relatedBy: NSLayoutRelation. Equal, toItem: vc. imageOrMapVContainer, attribute: NSLayoutAttribute. Top, multiplier: 1, constant: 0);
let c4 = NSLayoutConstraint (item: vc. imageOrMapVContainer, attribute: NSLayoutAttribute. Bottom, relatedBy: NSLayoutRelation. Equal, toItem: player, attribute: NSLayoutAttribute. Bottom, multiplier: 1, constant: 0)
let c5 = NSLayoutConstraint (item: player, attribute: NSLayoutAttribute. Leading, relatedBy: NSLayoutRelation. Equal, toItem: vc. imageOrMapVContainer, attribute: NSLayoutAttribute. Leading, multiplier: 1, constant: 0);
let c6 = NSLayoutConstraint (item: player, attribute: NSLayoutAttribute. Trailing, relatedBy: NSLayoutRelation. Equal, toItem: vc. imageOrMapVContainer, attribute: NSLayoutAttribute. Trailing, multiplier: 1, constant: 0)
player. addConstraints ([c2]);
vc. imageOrMapVContainer. addConstraints ([c3,c4,c5,c6]);
}
func createStandartPlayer (vc: ActionParentController) {
let mas = vc. excur!. points [vc. pIndex!]. videoPath!.componentsSeparatedByString (". ");
let path = NSBundle. mainBundle (). pathForResource (mas [0], ofType: mas [1])
let url = NSURL. fileURLWithPath (path!)
vc. moviePlayer = MPMoviePlayerController (contentURL: url)
let player = vc. moviePlayer
player. fullscreen = true;
player. scalingMode =. AspectFill;
player. controlStyle = MPMovieControlStyle. Embedded;
player. movieSourceType = MPMovieSourceType. File
player. repeatMode = MPMovieRepeatMode. One
vc. imageOrMapVContainer. addSubview (player. view);
player. view. translatesAutoresizingMaskIntoConstraints = false
let c2 = NSLayoutConstraint (item: player. view, attribute: NSLayoutAttribute. Height, relatedBy: NSLayoutRelation. Equal, toItem: nil, attribute: NSLayoutAttribute. NotAnAttribute, multiplier: 1, constant: 200);
let c3 = NSLayoutConstraint (item: player. view, attribute: NSLayoutAttribute. Top, relatedBy: NSLayoutRelation. Equal, toItem: vc. imageOrMapVContainer, attribute: NSLayoutAttribute. Top, multiplier: 1, constant: 0);
let c4 = NSLayoutConstraint (item: vc. imageOrMapVContainer, attribute: NSLayoutAttribute. Bottom, relatedBy: NSLayoutRelation. Equal, toItem: player. view, attribute: NSLayoutAttribute. Bottom, multiplier: 1, constant: 0)
let c5 = NSLayoutConstraint (item: player. view, attribute: NSLayoutAttribute. Leading, relatedBy: NSLayoutRelation. Equal, toItem: vc. imageOrMapVContainer, attribute: NSLayoutAttribute. Leading, multiplier: 1, constant: 0);
let c6 = NSLayoutConstraint (item: player. view, attribute: NSLayoutAttribute. Trailing, relatedBy: NSLayoutRelation. Equal, toItem: vc. imageOrMapVContainer, attribute: NSLayoutAttribute. Trailing, multiplier: 1, constant: 0)
player. view. addConstraint (c2);
vc. imageOrMapVContainer. addConstraints ([c3,c4,c5,c6]);
let session: AVAudioSession = AVAudioSession. sharedInstance ()
do {try session. setCategory ("AVAudioSessionCategoryPlayback", withOptions: AVAudioSessionCategoryOptions. DefaultToSpeaker) }
catch{
print (error)
}
player. prepareToPlay ()
player. pause ();
}
class func setRightNavigationBarButtons (navItem: UINavigationItem, viewController: UIViewController) {
var coinsLocal = 0;
if userId! = nil {
if coins == nil{
coins = 0;
let sh = ServerHelper ();
sh. saveCoins (coinsLocal, handler: { (success) in});
}
else{
coinsLocal = coins;
}
}
else{
var path = NSSearchPathForDirectoriesInDomains (NSSearchPathDirectory. DocumentDirectory, NSSearchPathDomainMask. UserDomainMask, true) [0];
path = path + "/Transactions. json";
let jsonData = try? NSData (contentsOfFile: path, options:. DataReadingMappedIfSafe);
let jsonResult: AnyObject = (try! NSJSONSerialization. JSONObjectWithData (jsonData!, options: NSJSONReadingOptions. MutableContainers))
coins = jsonResult ["coins"] as! Int;
}
rightBarButtons = [];
UIElementsTuner. setNavigationBar (coins, viewController: viewController);
navItem. rightBarButtonItems = [];
if ( (navItem. rightBarButtonItems?. count == 0) && (rightBarButtons. count == 2)) {
// rightBarButtons [0]. customView as! UIButton
var value = "\ (coins)"
if coins > 1000{
value = "\ (Int (round (Double (coins/1000)))) K";
}
(rightBarButtons [1]. customView as! UIButton). setTitle (value, forState:. Normal)
navItem. rightBarButtonItems!. append (rightBarButtons [0])
navItem. rightBarButtonItems!. append (rightBarButtons [1])
}
}
class func setNavigationBar (coins: Int, viewController: UIViewController) {
let button2: UIButton = UIButton (type: UIButtonType. Custom)
button2. titleLabel?. font = UIFont (name: "HelveticaNeue", size: 12);
var value = "\ (coins)"
if coins > 1000{
value = "\ (Int (round (Double (coins/1000)))) K";
}
button2. setTitle (value, forState:. Normal);
button2. addTarget (viewController, action: #selector (viewController. buyCoinsPressed (_:)), forControlEvents: UIControlEvents. TouchUpInside)
button2. setTitleColor (UIColor (red: 0, green: 115/255, blue: 185/255, alpha:
1), forState:. Normal);
button2. setTitleColor (UIColor (red: 0, green: 115/255, blue: 185/255, alpha:
1), forState:. Disabled);
button2. frame = CGRectMake (0, 0, 30, 20)
button2. enabled = false;
let barButton2 = UIBarButtonItem (customView: button2);
let button: UIButton = UIButton (type: UIButtonType. Custom)
button. setImage (UIImage (named: "coins"), forState: UIControlState. Normal);
button. frame = CGRectMake (0, 0, 25, 25)
button. enabled = false;
// button. addTarget (viewController, action: "buyCoinsPressed:", forControlEvents: UIControlEvents. TouchUpInside)
button. addTarget (viewController, action: #selector (viewController. buyCoinsPressed (_:)), forControlEvents: UIControlEvents. TouchUpInside)
let barButton = UIBarButtonItem (customView: button)
rightBarButtons. append (barButton)
rightBarButtons. append (barButton2)
}
func getProportionalHeight (view: UIImageView) - >CGFloat{
let imheight = view. image!. size. height;
let imwidth = view. image!. size. width;
return UIScreen. mainScreen (). bounds. width*imheight/imwidth;
}
class func setMainIconImageView (imageName: String, image: UIImageView) {
let nameArray = imageName.componentsSeparatedByString (". ");
if nameArray. count <= 1{
return;
}
if let _ = NSBundle. mainBundle (). pathForResource (nameArray [0], ofType: nameArray [1]) {
image. image = UIImage (named: imageName)
}
}
}
Размещено на Allbest.ru
...Подобные документы
Современное состояние рынка мобильных приложений. Основные подходы к разработке мобильных приложений. Обоснование выбора целевой группы потребителей приложения. Этапы проектирования и разработки мобильного приложения для операционной системы Android.
курсовая работа [987,1 K], добавлен 27.06.2019Разработка приложения для проверки использования времен глаголов в английском языке. Создание базы данных. Анализ используемых средств для реализации автоматического разбора текста. Проектирование мобильного приложения с помощью диаграмм деятельности.
дипломная работа [2,6 M], добавлен 13.09.2017Анализ российского рынка мобильных приложений. Мобильное приложение как новый канал коммуникации с целевой аудиторией. Этапы создания мобильного приложения. План продвижения мобильного приложения в сети Интернет. Бесплатные инструменты продвижения.
дипломная работа [1,6 M], добавлен 23.06.2016Изучение языков программирования PHP, SQL, C++, HTML. Рассмотрение правил запуска и использования локального сервера Denwer. Составление технического задания по разработке программного продукта. Описание создаваемого мобильного и веб-приложения.
курсовая работа [212,4 K], добавлен 07.04.2015Разработка программного решения по созданию мобильного приложения. Изучение технологий для разработки приложений. Анализ работы торговых агентов. Обоснование выбора языка программирования. Проектирование интерфейса структуры и верстка, листинг программы.
дипломная работа [2,2 M], добавлен 08.06.2017Разработка приложений для смартфонов на ОС Android для сети аптек "Фармация". Архитектура операционной системы Android. Архитектура и реализация приложения. Его функциональность. Описание работы мобильного приложения. Расчет затрат на создание продукта.
дипломная работа [1,6 M], добавлен 17.06.2017Создание, изучение и разработка приложение на Android. Среда разработки приложения DelphiXE5. Установка и настройка среды программирования. Этапы разработки приложения. Инструменты для упрощения конструирования графического интерфейса пользователя.
курсовая работа [1,6 M], добавлен 19.04.2017Мобильное приложение и его предназначение для организации информационного обмена между мобильными сотрудниками компании (водитель эвакуатора, мастер техпомощи) и CRM системой. Синхронизация данных о заказах. Пользовательский интерфейс приложения.
дипломная работа [594,5 K], добавлен 12.08.2017История возникновения и развития современной робототехники, применение технологий искусственного интеллекта. Разработка структурной схемы системы навигации мобильного робота, коррекция траектории его движения, методы управления локальными перемещениями.
дипломная работа [1,1 M], добавлен 18.05.2011Обзор мобильной операционной системы ios: Архитектура ОС iOS; уровень библиотек; среды разработки приложения (Xcode, Xamarin). Доступ к информации колледжа "Угреша". Требования к мобильному приложению. Подготовка среды разработки. Тестирование приложения.
дипломная работа [5,6 M], добавлен 10.07.2014Разработка приложения "Калькулятор" для подсчитывания количества символов или букв в арабском тексте. Проектирование программной системы, определение функциональных требований к приложению. Алгоритм разработки модульной структуры мобильного приложения.
презентация [853,9 K], добавлен 08.04.2019Разработка и формализация эффективного подхода к оценке качества каналов трафика мобильного приложения. Преимущества работы с социальными сетями. Тестирование возможных типов каналов по привлечению установок приложения. Расчёт средней стоимости лидов.
дипломная работа [2,6 M], добавлен 09.02.2017Проектирование удобного приложения для комфортной навигации по файлам облачного хранилища в одном файловом менеджере. Выбор интегрированной среды разработки. Выбор инструментов для визуализации приложения. Выбор средств отслеживания HTTPзапросов.
курсовая работа [3,6 M], добавлен 16.07.2016Обзор подходов к разработке музейных приложений с элементами дополненной реальности, формирование требований к ним. Выбор методов разработки приложения, разработка пользовательского интерфейса. Принципы тестирования. Реализация раздела "Распознавание".
дипломная работа [2,8 M], добавлен 03.07.2017Электронные носители и их преимущества. Создание приложения электронного журнала для учета посещаемости и выполнения студентами лабораторных работ для мобильных устройств на базе Android. Автоматизация заполнения журнала, упрощение ведения учета.
курсовая работа [681,5 K], добавлен 13.06.2017Анализ хозяйственной деятельности организации и ее состояния. Особенности работы мобильной платформы. Реквизитный состав документов. Программная реализация и оценка эффективности приложения. Безопасность работы с приложением и безопасность данных.
дипломная работа [1,0 M], добавлен 13.06.2014Обоснование выбора средств разработки. Анализ предметной области. Сущность структурного подхода к разработке информационных систем. Требования к информационной и программной совместимости. Запросы к базе данных. Инфологическое проектирование системы.
дипломная работа [1,6 M], добавлен 22.08.2016Управление электронным обучением. Технологии электронного обучения e-Learning. Программное обеспечение для создания e-Learning решений. Компоненты LMS на примере IBM Lotus Learning Management System и Moodle. Разработка учебных курсов в системе Moodle.
курсовая работа [146,6 K], добавлен 11.06.2009Общая характеристика и анализ требований к разрабатываемому приложению, функциональные особенности и сферы практического применения. Проектирование базы данных и выбор системы управления ею. Тестирование приложения и выбор языка программирования.
дипломная работа [791,8 K], добавлен 10.07.2017Общая характеристика и структурная схема приложения, требования к нему и функциональные особенности, сферы практического применения. Обоснование выбора языка программирования. Описание интерфейса и инструкция пользователя. Проведение листинга программы.
дипломная работа [1,0 M], добавлен 10.07.2017