Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove motion require #251

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Formotion.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@ Gem::Specification.new do |s|
s.license = 'MIT'

s.add_dependency "bubble-wrap", ">= 1.4.0"
s.add_dependency "motion-require", ">= 0.1.0"
s.add_development_dependency 'rake'
end
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org'

gem 'guard-motion'
gem 'guard-motion', github: 'satoyos/guard-motion', branch: 'inherit_Plugin'
gem 'rb-fsevent'

gem "motion-cocoapods"
Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
$:.unshift("/Library/RubyMotion/lib")
$:.unshift("~/.rubymotion/rubymotion-templates")
require 'motion/project/template/ios'
require "bundler/gem_tasks"
require "bundler/setup"
Expand Down
15 changes: 9 additions & 6 deletions lib/formotion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
require 'bubble-wrap/font'
require 'bubble-wrap/camera'

require 'motion-require'
Motion::Project::App.setup do |app|
core_lib = File.join(File.dirname(__FILE__), 'formotion')
insert_point = app.files.find_index { |file| file =~ /^(?:\.\/)?app\// } || 0

Motion::Require.all(Dir.glob(File.expand_path('../formotion/**/*.rb', __FILE__)))
Dir.glob(File.join(core_lib, '**/*.rb')).reverse.each do |file|
app.files.insert(insert_point, file)
end

app.frameworks << 'CoreLocation' unless app.frameworks.include?('CoreLocation')
app.frameworks << 'MapKit' unless app.frameworks.include?('MapKit')

Motion::Project::App.setup do |app|
app.frameworks<<'CoreLocation' unless app.frameworks.include?('CoreLocation')
app.frameworks<<'MapKit' unless app.frameworks.include?('MapKit')

app.resources_dirs << File.join(File.dirname(__FILE__), '../resources')
end
2 changes: 0 additions & 2 deletions lib/formotion/base.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
motion_require 'row_type/base'

module Formotion
class Base
def initialize(params = {})
Expand Down
2 changes: 0 additions & 2 deletions lib/formotion/controller/form_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
motion_require '../patch/ui_text_field'

#################
#
# Formotion::FormController
Expand Down
2 changes: 0 additions & 2 deletions lib/formotion/form/form.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
motion_require "../base"

module Formotion
class Form < Formotion::Base
extend BubbleWrap::KVO
Expand Down
2 changes: 0 additions & 2 deletions lib/formotion/form/form_delegate.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
motion_require "../base"

module Formotion
class Form < Formotion::Base
attr_reader :table
Expand Down
2 changes: 0 additions & 2 deletions lib/formotion/row/row.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
motion_require "../base"

module Formotion
class Row < Formotion::Base
PROPERTIES = [
Expand Down
2 changes: 0 additions & 2 deletions lib/formotion/row_type/activity_view_row.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
motion_require 'object_row'

module Formotion
module RowType
class ActivityRow < ObjectRow
Expand Down
2 changes: 0 additions & 2 deletions lib/formotion/row_type/back_row.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
motion_require 'button'

module Formotion
module RowType
class BackRow < ButtonRow
Expand Down
2 changes: 0 additions & 2 deletions lib/formotion/row_type/button.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
motion_require 'base'

module Formotion
module RowType
class ButtonRow < Base
Expand Down
2 changes: 0 additions & 2 deletions lib/formotion/row_type/check_row.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
motion_require 'base'

module Formotion
module RowType
class CheckRow < Base
Expand Down
2 changes: 0 additions & 2 deletions lib/formotion/row_type/currency_row.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
motion_require 'number_row'

module Formotion
module RowType
class CurrencyRow < NumberRow
Expand Down
7 changes: 2 additions & 5 deletions lib/formotion/row_type/date_row.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
motion_require 'string_row'
motion_require 'multi_choice_row'

module Formotion
module RowType
class DateRow < StringRow
Expand Down Expand Up @@ -54,8 +51,8 @@ def after_build(cell)
self.picker.setDate(self.picker.date, animated:true)
picker.countDownDuration = self.row.value.to_f
end
#ensure the UIDatePicker gets updated if we update the row value

#ensure the UIDatePicker gets updated if we update the row value
observe(self.row, "value") do |old_value, new_value|
self.picker.setDate(date_from_numeric(new_value), animated:true)
end
Expand Down
2 changes: 0 additions & 2 deletions lib/formotion/row_type/edit_row.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
motion_require 'button'

module Formotion
module RowType
class EditRow < ButtonRow
Expand Down
2 changes: 0 additions & 2 deletions lib/formotion/row_type/email_row.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
motion_require 'string_row'

module Formotion
module RowType
class EmailRow < StringRow
Expand Down
2 changes: 0 additions & 2 deletions lib/formotion/row_type/image_row.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
motion_require 'base'

module Formotion
module RowType
class ImageRow < Base
Expand Down
2 changes: 0 additions & 2 deletions lib/formotion/row_type/map_row.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
motion_require 'base'

module Formotion
module RowType
class MapRowData
Expand Down
2 changes: 0 additions & 2 deletions lib/formotion/row_type/number_row.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
motion_require 'string_row'

module Formotion
module RowType
class NumberRow < StringRow
Expand Down
2 changes: 0 additions & 2 deletions lib/formotion/row_type/object_row.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
motion_require 'string_row'

module Formotion
module RowType
class ObjectRow < StringRow
Expand Down
3 changes: 0 additions & 3 deletions lib/formotion/row_type/options_row.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
motion_require 'base'
motion_require 'items_mapper'

module Formotion
module RowType
class OptionsRow < Base
Expand Down
36 changes: 17 additions & 19 deletions lib/formotion/row_type/paged_image_row.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
motion_require 'base'

# ideas taken from:
# http://www.raywenderlich.com/10518/how-to-use-uiscrollview-to-scroll-and-zoom-content

Expand All @@ -19,9 +17,9 @@ class PagedImageRow < Base
def build_cell(cell)
# only show the "plus" when editable
add_plus_accessory(cell) if row.editable?

self.row.value = [] unless self.row.value.is_a?(Array)

@page_view = UIPageControl.alloc.init
@page_view.tag = PAGE_VIEW_TAG
@page_view.pageIndicatorTintColor = '#d0d0d0'.to_color
Expand All @@ -37,15 +35,15 @@ def build_cell(cell)
@scroll_view.contentOffset=point
end
cell.addSubview(@page_view)

@scroll_view = UIScrollView.alloc.init
@scroll_view.tag = SCROLL_VIEW_TAG
@scroll_view.delegate = self
@scroll_view.pagingEnabled = true
@scroll_view.delaysContentTouches = true
@scroll_view.showsHorizontalScrollIndicator=false
@scroll_view.showsVerticalScrollIndicator=false

pages_size = @scroll_view.frame.size
@scroll_view.contentSize = CGSizeMake(pages_size.width * self.row.value.size, pages_size.height)
@page_views = [nil]*self.row.value.size
Expand All @@ -57,7 +55,7 @@ def layoutSubviews
old_layoutSubviews

# viewWithTag is terrible, but I think it's ok to use here...

formotion_field = self.viewWithTag(SCROLL_VIEW_TAG)
field_frame = formotion_field.frame
field_frame.origin.y = 10
Expand All @@ -67,15 +65,15 @@ def layoutSubviews
field_frame.size.height = f_height
formotion_field.frame = field_frame
scroll_view=formotion_field

formotion_field = self.viewWithTag(PAGE_VIEW_TAG)
field_frame = formotion_field.frame
field_frame.origin.y = 20 + f_height
field_frame.origin.x = self.textLabel.frame.origin.x + self.textLabel.frame.size.width + Formotion::RowType::Base.field_buffer
field_frame.size.width = self.frame.size.width - field_frame.origin.x - Formotion::RowType::Base.field_buffer
field_frame.size.height = 10
formotion_field.frame = field_frame

scroll_view.delegate.resizePages
scroll_view.delegate.clearPages
end
Expand All @@ -98,7 +96,7 @@ def actionSheet(actionSheet, clickedButtonAtIndex: index)
self.clearPages
return
end

source = nil
case actionSheet.buttonTitleAtIndex(index)
when TAKE
Expand Down Expand Up @@ -141,7 +139,7 @@ def add_plus_accessory(cell)
end
cell.accessoryView = cell.editingAccessoryView = @add_button
end

#{{{Paged
def loadVisiblePages
# First, determine which page is currently visible
Expand All @@ -163,12 +161,12 @@ def loadVisiblePages
self.purgePage(i)
end
end

def get_active_page
page_width = @scroll_view.frame.size.width
((@scroll_view.contentOffset.x * 2.0 + page_width) / (page_width * 2.0)).floor
end

def pages_single_tap
page = get_active_page
if row.editable?
Expand All @@ -177,7 +175,7 @@ def pages_single_tap
_on_select(nil, nil)
end
end

def take_photo(_page=nil)
@photo_page=_page
@action_sheet = UIActionSheet.alloc.init
Expand All @@ -188,14 +186,14 @@ def take_photo(_page=nil)
@action_sheet.cancelButtonIndex = (@action_sheet.addButtonWithTitle CANCEL)
@action_sheet.showInView @scroll_view
end

def clearPages
0.upto(@page_views.size-1) do |i|
self.purgePage(i) unless @page_views[i].nil?
end
self.loadVisiblePages
end

def resizePages
pages_size = @scroll_view.frame.size
@scroll_view.contentSize = CGSizeMake(pages_size.width * self.row.value.size, pages_size.height)
Expand All @@ -208,7 +206,7 @@ def resizePages
@page_view.currentPage = 0
@page_view.numberOfPages = self.row.value.size
end

def loadPage(_page)
if _page < 0 || _page >= self.row.value.size
# If it's outside the range of what we have to display, then do nothing
Expand Down Expand Up @@ -248,13 +246,13 @@ def purgePage(_page)
@page_views[_page]=nil
end
end

def scrollViewDidScroll(_scroll_view)
# Load the pages which are now on screen
self.loadVisiblePages
end
#}}}

end
end
end
2 changes: 0 additions & 2 deletions lib/formotion/row_type/phone_row.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
motion_require 'string_row'

module Formotion
module RowType
class PhoneRow < StringRow
Expand Down
2 changes: 0 additions & 2 deletions lib/formotion/row_type/picker_row.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# currently supports only one component
motion_require 'string_row'
motion_require 'multi_choice_row'

module Formotion
module RowType
Expand Down
2 changes: 0 additions & 2 deletions lib/formotion/row_type/slider_row.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
motion_require 'base'

module Formotion
module RowType
class SliderRow < Base
Expand Down
2 changes: 0 additions & 2 deletions lib/formotion/row_type/static_row.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
motion_require 'string_row'

module Formotion
module RowType
class StaticRow < StringRow
Expand Down
2 changes: 0 additions & 2 deletions lib/formotion/row_type/string_row.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
motion_require 'base'

module Formotion
module RowType
class StringRow < Base
Expand Down
2 changes: 0 additions & 2 deletions lib/formotion/row_type/subform_row.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
motion_require 'base'

module Formotion
module RowType
class SubformRow < Base
Expand Down
2 changes: 0 additions & 2 deletions lib/formotion/row_type/submit_row.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
motion_require 'button'

module Formotion
module RowType
class SubmitRow < ButtonRow
Expand Down
2 changes: 0 additions & 2 deletions lib/formotion/row_type/switch_row.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
motion_require 'base'

module Formotion
module RowType
class SwitchRow < Base
Expand Down
Loading