From 2d39f0b1048b3ca488f9dd0823b6be18f8280080 Mon Sep 17 00:00:00 2001 From: Vladimir Pouzanov Date: Mon, 21 May 2012 16:27:24 +0300 Subject: [PATCH] Stylesheet proposals are moved to wiki --- proposals/styles/README.md | 23 ---- proposals/styles/beakr_improved.rb | 16 --- proposals/styles/beakr_stylesheet.rb | 60 ---------- proposals/styles/styles_by_spllr.rb | 89 -------------- proposals/styles/stylesheet_by_conradirwin.rb | 75 ------------ proposals/styles/teacup_by_colinta.rb | 109 ------------------ 6 files changed, 372 deletions(-) delete mode 100644 proposals/styles/README.md delete mode 100644 proposals/styles/beakr_improved.rb delete mode 100644 proposals/styles/beakr_stylesheet.rb delete mode 100644 proposals/styles/styles_by_spllr.rb delete mode 100644 proposals/styles/stylesheet_by_conradirwin.rb delete mode 100644 proposals/styles/teacup_by_colinta.rb diff --git a/proposals/styles/README.md b/proposals/styles/README.md deleted file mode 100644 index 52bc104..0000000 --- a/proposals/styles/README.md +++ /dev/null @@ -1,23 +0,0 @@ -## Put stylesheet examples here. - -What should teacup actually do? - -(features that most proposals contain) - -1. Provide a clean API to make views pretty. - -2. Provide a way to share design configuration throughout the app. - -What could teacup also do? - -(features that some proposals include) - -3. Provide assistance for automatically laying out sub-views (farcaller_layout) - -4. Provide assistance for automatically instantiating sub-views (stylesheet_by_conradirwin) - -5. Provide a clean API around animations (teacup_by_colinta) - - -I suggest we build something that implements 1. and 2. in such a way that 3., 4., and 5. can -easily be added (either to teacup itself, or using an external library). diff --git a/proposals/styles/beakr_improved.rb b/proposals/styles/beakr_improved.rb deleted file mode 100644 index aa3cb0e..0000000 --- a/proposals/styles/beakr_improved.rb +++ /dev/null @@ -1,16 +0,0 @@ -module Mystyle < ImageCaption - include Teacup::Stylesheet - - layout do - font = :'Proxima Nova' - end - - images do - # Size down images, add borders, etc. - end - - type :caption do - color = :gray - font_size = 12 - end -end diff --git a/proposals/styles/beakr_stylesheet.rb b/proposals/styles/beakr_stylesheet.rb deleted file mode 100644 index 596cbdc..0000000 --- a/proposals/styles/beakr_stylesheet.rb +++ /dev/null @@ -1,60 +0,0 @@ -# - - - - - - - - - - - - - - - - - - - -# Proposal by Beakr -# Created at: 15 May, 2012 -# -# May be improved later on through the -# applications development -# - - - - - - - - - - - - - - - - - - - - - -# - - - - - - - - - - - - - - - - - - - -# Style -# - - - - - - - - - - - - - - - - - - - - -class UIStyle < Teacup::Style # or Teacup::Stylesheet - - # All blocks are prefixed with UI, so - Label { ... } - # Will affect UILabel, while - TextField { ... } - # Will affect UITextField - - # Sample styles - Label do - color = :black - font = 'Proxima Nova' - - # Made into `types` so we're not using the class keyword - # Affects all UILabels with the type 'header' - type :header do - font_size = 20 - color = :blue - end - - end - - # Affect the whole layout of the app with - Layout do - background = :white - end - -end - -# - - - - - - - - - - - - - - - - - - - -# Controller -# - - - - - - - - - - - - - - - - - - - - -class SomeController < UIViewController - def viewDidLoad - # include Stylesheet - Teacup::include(UIStyle) - - # create an object - @label = Teacup::Label.type(:header).new - @label.text = "I used a Teacup stylesheet!" # Inherits from both Label {...} and - # header type. - - @standard = Teacup::Label.new # Just normal label not of the header type - @standard.text = "A normal label." - end -end diff --git a/proposals/styles/styles_by_spllr.rb b/proposals/styles/styles_by_spllr.rb deleted file mode 100644 index 28c8fc0..0000000 --- a/proposals/styles/styles_by_spllr.rb +++ /dev/null @@ -1,89 +0,0 @@ -## -# Styling is based on the UIAppearance Protocol and friends. -# http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIAppearance_Protocol/Reference/Reference.html -# -# Styles should be small components which can be defined and reused outside the controller and view scope. -# Taking a non intrusive approach allows the styling to have the same benifits css has for html. -# It keeps implementation of Bussiness Logic and styling seperated. -# -# All methods and namings are up for debate -# - -# Small style components -Teacup::Style.define :rounded do |s| - s.borderRadius = 10 -end - -# Style componets are extendable -Teacup::Style.define :dark, :extends => :rounded do |s| - s.backgroundColor = rgba(50, 50, 50, 0.5) - s.textColor = rgb(255, 255, 255) -end - -Teacup::Style.define :green_text do |s| - s.textColor = "#0000FF" -end - -# Styles can be applies globaly -UIView.adopt_style :dark -UIButton.adopt_style :rounded - -# Styles can applied per instance -button = UIButton.alloc.init -button.adopt_style :dark, :green_text - -# Styles can be refined -button.style do |s| - s.backgroundColor = "#FF0099" -end - -# Styles can be applied within a style scope -Teacup::Style.style_scope :dark do |s| - # All view instances will have :dark style applied - button = UIButton.alloc.init - cell = UITableCell.alloc.init -end - - -# Styles can define nested styles. -# Nested will attempt to apply the nested styles a the getter with the corresponding name -Teacup::Style.define_style :my_cell_style do |s| - s.backgroundColor = rgb(0, 0, 0) - - # apply styles the view in the #imageView - s.style :imageView do |s| - s.frame = [[10, 10], [50, 50]] - end - - # styles can be adopted - s.style :textLabel, :adopt => :green_text - - # styles can be adopted and overwritten - s.style :detailTextLabel, :adopt => :dark do |s| - s.textColor = UIColor.blueColor - end -end - -my_styled_cell = UITableViewCell.alloc.initWithStyle(UITableViewCellStyleDefault, reuseIdentifier:"MyCell") -my_styled_cell.adopt_style :my_cell_style - - -# Style costraints settings -# Constraints conform to CALayer constraints -# http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/CoreAnimation_guide/Articles/Layout.html#//apple_ref/doc/uid/TP40006084-SW5 -# -Teacup::Style.define_constraint :vertical_list do |c, rel| - c.width rel - c.minY rel, :offset => -20 - c.maxY rel, :offset => 20 -end - -super_button = UIButton.alloc.initWithFrame [[10, 10], [100, 30]] - -button_a = UIButton.alloc.init -button_a.adopt_constaint :vertical_list, super_button - -button_b = UIButton.alloc.init -button_b.adopt_constaint :vertical_list, button_a - - diff --git a/proposals/styles/stylesheet_by_conradirwin.rb b/proposals/styles/stylesheet_by_conradirwin.rb deleted file mode 100644 index a525f55..0000000 --- a/proposals/styles/stylesheet_by_conradirwin.rb +++ /dev/null @@ -1,75 +0,0 @@ -class StyleSheet - class IPad < StyleSheet - nom :left_label, - is_a: UILabel, - left: 100, - width: 200, - height: 50 - - nom :how_much, like: :left_label, - top: 100, - text: 'How Much?' - - nom :what_for, like: :left_label, - top: 175, - text: 'What for?' - - nom :who_paid, like: :left_label, - top: 300, - text: 'Who Paid?' - - nom :who_participated, like: :left_label, - top: 500, - text: 'Who Participated?' - - nom :text_box, - is_a: UITextField, - left: 300, - width: 200, - height: 50 - - nom :amount, like: :text_box, - top: 115, - placeholder: "$ 0.00", - keyboardType: UIKeyboardTypeNumberPad - - nom :event, like: :text_box, - top: 190, - placeholder: "Parada 22" - - nom :commune_it, - is_a: lambda{ UIButton.buttonWithType(UIButtonTypeRoundedRect) }, - type: UIButtonTypeRoundedRect, - frame: [[300, 600], [400, 100]] do - setTitle("Commune it!", forState: UIControlStateNormal) - end - - nom :commune_view, - backgroundColor: UIColor.whiteColor - end -end - - -class CommuneViewController < UIViewController - include DomNomery - - DOM = { - commune_view: self, - how_much: UILabel, - what_for: UILabel, - who_paid: UILabel, - who_participated: UILabel, - amount: UITextField, - event: UITextField, - commune_it: UIButton, - } - - def domDidNom - amount.delegate = self - event.delegate = self - commune_it.addTarget(self, action: :click, forControlEvents:UIControlEventTouchUpInside) - - createImages - end - -end diff --git a/proposals/styles/teacup_by_colinta.rb b/proposals/styles/teacup_by_colinta.rb deleted file mode 100644 index 9072e2c..0000000 --- a/proposals/styles/teacup_by_colinta.rb +++ /dev/null @@ -1,109 +0,0 @@ -# -# see http://colinta.com/thoughts/toolbar_teacup_and_me.html -# -# #colinta - -##| -##| APP DELEGATOR -##| -def ipad? - UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad -end - -Teacup::App do |application, options, window| - if ipad? - MyIpadController - else - MyIphoneController - end -end - -##| -##| CREATE A TOOLBAR AND ADD IT TO YOUR VIEW -##| -toolbar = Teacup::Toolbar( - frame: [[0, 416], [320, 44]], - tint: [21, 78, 118].color, - ) do - # self refers to the newly created UIToolbar, so self.BarButtonItem will - # know where to add the button - toolbar_button = self.BarButtonItem(:refresh) { target.flipp } -end - -self.view << toolbar - - -##| -##| CoreGraphics ANIMATION -##| -def flipp - # left_view_controller and right_view_controller are two views, this method - # toggles between them. @current points to one or the other. - - remove = @current - - if @current == left_view_controller - current = right_view_controller - transition = :curl_up - else - current = left_view_controller - transition = :curl_down - end - - @current = current - - Teacup::Animate( - duration: 1.25, - ease: :ease_in_out, - transition: transition, - view: self.view - ) do - # hmmm, not sure how I feel about THIS: - hide remove - show current, index: 0 - # replaces: - # remove.viewWillDisappear(true) - # current.viewWillAppear(true) - # remove.view.removeFromSuperview - # self.view.insertSubview(current.view, atIndex:0) - # remove.viewDidDisappear(true) - # current.viewDidAppear(true) - end -end - - -##| -##| STYLES / STYLESHEETS -##| -framed_view = Teacup::Style do - frame = [[0, 0], [320, 460]] -end - -##| inherit from another style -colored_view = Teacup::Style(framed_view) do - status_bar = :black - opacity = 0.5 -end - -class LeftViewController < UIViewController - - def viewDidLoad - # include styles, and add some of our own - Teacup::style(self.view) do - import colored_view - background_color = [0, 136, 14].color - end - end - -end - -class RightViewController < UIViewController - - def viewDidLoad - Teacup::style(self.view) do - import colored_view - background_color = [0, 136, 14].color - end - end - -end