Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 2 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
View
40 examples/Styling/app/app_delegate.rb
@@ -44,21 +44,45 @@ def application(application, didFinishLaunchingWithOptions:launchOptions)
}, {
title: "Font Color",
rows: [{
- title: "White on Red",
+ title: "All Red",
type: :string,
+ value: "Red Everything",
style: {
- background_color: "red",
- font_color: "white"
+ font_color: "red"
+ }
+ }, {
+ title: "Red Title",
+ type: :text,
+ value: "Purple value",
+ style: {
+ font_color: {
+ title: "red",
+ value: "purple"
+ }
+ }
+ }, {
+ title: "Success!",
+ type: :string,
+ subtitle: "It worked",
+ value: "This is normal",
+ style: {
+ font_color: {
+ title: "09A41D",
+ subtitle: "09A41D"
+ }
}
}, {
title: "Blue on Gradient",
type: :string,
+ value: "I'm blue",
style: {
background_color: {
top: "ffffff",
bottom: "dddddd"
},
- font_color: "0088cc"
+ font_color: {
+ value: "0088cc"
+ }
}
}]
}, {
@@ -82,15 +106,18 @@ def application(application, didFinishLaunchingWithOptions:launchOptions)
}
}, {
title: "Green to Purple",
+ subtitle: "Tap me",
type: :string,
style: {
selection_color: {
top: "green",
- bottom: "purple"
+ bottom: "purple",
+ font_color: "red"
}
}
}, {
title: "Square",
+ subtitle: "A subtle touch",
type: :string,
style: {
background_color: {
@@ -99,7 +126,8 @@ def application(application, didFinishLaunchingWithOptions:launchOptions)
},
selection_color: {
top: "eeeeee",
- bottom: "dddddd"
+ bottom: "dddddd",
+ font_color: "none"
}
}
}]
View
22 lib/formotion/style/font_color_style.rb
@@ -1,7 +1,7 @@
module Formotion
module RowStyle
class FontColorStyle < Base
- PROPERTIES = [:color].each { |prop|
+ PROPERTIES = [:color, :title, :subtitle, :value].each { |prop|
attr_accessor prop
}
@@ -10,11 +10,25 @@ def self.default_object_key
end
def setup_cell(cell)
- cell.subviews_recursive_each do |subview|
- if subview.respond_to? "setTextColor:"
- subview.setTextColor(self.color.to_color)
+ if self.color
+ cell.subviews_recursive_each do |subview|
+ if subview.respond_to? "setTextColor:"
+ subview.setTextColor(self.color.to_color)
+ end
end
end
+
+ if self.title
+ cell.textLabel.setTextColor(self.title.to_color)
+ end
+
+ if self.subtitle
+ cell.detailTextLabel.setTextColor(self.subtitle.to_color)
+ end
+
+ if self.value
+ self.row.text_field.setTextColor(self.value.to_color)
+ end
end
end
end
View
11 lib/formotion/style/selection_color_style.rb
@@ -1,7 +1,7 @@
module Formotion
module RowStyle
class SelectionColorStyle < Base
- PROPERTIES = [:color, :top, :bottom].each { |prop|
+ PROPERTIES = [:color, :top, :bottom, :font_color].each { |prop|
attr_accessor prop
}
@@ -28,6 +28,15 @@ def setup_cell(cell)
cell.selectedBackgroundView.colors = [top_color, bottom_color]
end
+
+ if self.font_color
+ cell.subviews_recursive_each do |subview|
+ if subview.respond_to?("setHighlightedTextColor:")
+ using_color = (self.font_color == "none") ? subview.textColor : self.font_color.to_color
+ subview.setHighlightedTextColor(using_color)
+ end
+ end
+ end
end
def will_display(cell)
View
5 spec/styling/font_color_style_spec.rb
@@ -0,0 +1,5 @@
+describe "FontColorStyle" do
+ it "should be true" do
+ true.should == true
+ end
+end

No commit comments for this range

Something went wrong with that request. Please try again.