Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

+ [ios] picker support custom title title color background color and etc #233

Merged
merged 3 commits into from
Apr 11, 2017

Conversation

kfeagle
Copy link
Contributor

@kfeagle kfeagle commented Apr 7, 2017

  • [ios] picker support custom

title
titleColor
cancelTitle
confirmTitle
cancelTitleColor
confirmTitleColor
titleBackgroundColor
height
textColor
selectionColor

demo

<template>
  <scroller>
    <wxc-panel title="picker module" type="primary">
      <text style="margin-bottom: 20px;">pick value: {{value}}</text>
      <wxc-button type="primary" onclick="{{pick}}" value="single pick" style="margin-bottom: 20px;"></wxc-button>
      <wxc-button type="primary" onclick="{{pickDate}}" value="pickDate" style="margin-bottom: 20px;"></wxc-button>
      <wxc-button type="primary" onclick="{{pickTime}}" value="pickTime"></wxc-button>
    </wxc-panel>

    <wxc-panel title="input component" type="primary">
      <text>onchange: {{txtChange}}</text>
      <input
              type="date"
              placeholder="select date"
              class="input"
              autofocus="false"
              value=""
              onchange="onchange"
              max = "2029-11-28"
              min = "2015-11-28"
      />
      <input
              type="time"
              placeholder="select time"
              class="input"
              autofocus="false"
              value=""
              onchange="onchange"
      />
    </wxc-panel>
  </scroller>
</template>

<style>
  .input {
    font-size: 60px;
    height: 80px;
    width: 400px;
  }
</style>

<script>
  require('weex-components');
  module.exports = {
    data: {
      value: '',
      index: 0,
      txtChange: ''
    },
    methods: {
      pick: function() {
        var picker = require('@weex-module/picker');
        var items = new Array("Saab","Volvo","BMW");
        var self = this;
        picker.pick({
          'items':items,
          'index':self.index,
          'title':'test',
          'titleColor':'blue',
          'cancelTitle':'cccc',
          'confirmTitle':'dddd',
          'cancelTitleColor':'black',
          'confirmTitleColor':'yellow',
          'titleBackgroundColor':'green',
          'height':600,
          'textColor':'red',
          'selectionColor':'gray'
        },function (ret) {
          var result = ret.result;
          if(result == 'success')
          {
            self.value = items[ret.data];
            self.index = ret.data;
          }
        });

      },
      pickDate: function() {
        var picker = require('@weex-module/picker');
        var self = this;
        picker.pickDate({
          'value':'2016-11-28',
          'max':'2029-11-28',
          'min':'2015-11-28'
        },function (ret) {
          var result = ret.result;
          if(result == 'success')
          {
            self.value = ret.data;
          }
        });
      },
      pickTime: function() {
        var picker = require('@weex-module/picker');
        var self = this;
        picker.pickTime({
          'value':'19:24'
        },function (ret) {
          var result = ret.result;
          if(result == 'success')
          {
            self.value = ret.data;
          }
        });
      },
      onchange: function(event) {
        this.txtChange = event.value;
        console.log('onchange', event.value);
      }
    }
  }
</script>

if(self.selectionColor) {
UILabel *labelSelected = (UILabel*)[pickerView viewForRow:row forComponent:component];
[labelSelected setBackgroundColor:self.selectionColor?self.selectionColor:[UIColor whiteColor]];
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the background color of labelSelected? when self.selectionColor is nil.

doneBtn = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(done:)];
}
if(self.confirmTitleColor){
doneBtn.tintColor = self.confirmTitleColor;
Copy link
Contributor

@bluebird78999 bluebird78999 Apr 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

confirmTitleColor is a text's color or a tintColor?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

confirmTitleColor is a text's color

@asfgit asfgit merged commit cddebfb into apache:0.12-dev Apr 11, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants