Sha256: 307beed17b3ba9675ae4ae08832cb72d90df5338ea7afe36597ff38eb85795a7

Contents?: true

Size: 902 Bytes

Versions: 1

Compression:

Stored size: 902 Bytes

Contents

class LoginController < Formotion::FormController
	attr_accessor :meteor

  def viewDidLoad
    super

    self.view.backgroundColor = UIColor.whiteColor
    self.title = "Login"

    self.form.on_submit do |form|
    	data = form.render
    	self.view.endEditing(true)

    	@meteor.login_with_username( data[:user], data[:pass], self.method(:login_handler) )
    end

  end

  def login_handler action, details
  	if action == :success
  		controller = BookListController.alloc.initWithNibName(nil, bundle: nil)
			controller.meteor = @meteor
			navigationController = UINavigationController.alloc.initWithRootViewController(controller)

			self.presentViewController(navigationController , animated: true, completion: nil)

  	elsif action == :error
  		alert = UIAlertView.new
  		alert.message = "Error: #{details['reason'].to_s}"
  		alert.addButtonWithTitle "OK"
  		alert.show
  	end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
meteor-motion-0.1.0 app/controllers/login_controller.rb