From 9051e69ca83104aae4c5293773178d922b85cff3 Mon Sep 17 00:00:00 2001 From: jihf Date: Mon, 24 Dec 2018 13:31:34 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9SegmentedControl=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E9=A2=9C=E8=89=B2=E4=B8=BA=E4=B8=BB=E9=A2=98=E9=A2=9C?= =?UTF-8?q?=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../segmented-control/segmented.android.tsx | 12 ++++++------ .../segmented-control/segmented.ios.tsx | 19 +++++++++++-------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/components/segmented-control/segmented.android.tsx b/components/segmented-control/segmented.android.tsx index 51fad9345..7d44be3a7 100644 --- a/components/segmented-control/segmented.android.tsx +++ b/components/segmented-control/segmented.android.tsx @@ -46,7 +46,6 @@ export default class SegmentedControl extends React.Component< values: [], onChange() {}, onValueChange() {}, - tintColor: '#108ee9', style: {}, }; @@ -83,12 +82,13 @@ export default class SegmentedControl extends React.Component< } render() { - const { style, disabled, values = [], tintColor } = this.props; - + const { style, disabled, values = [] } = this.props; + let { tintColor } = this.props; return ( - {styles => { + {(styles, theme) => { const selectedIndex = this.state.selectedIndex; + tintColor = tintColor || theme.brand_primary; const items = values.map((value, idx) => { let itemRadius: any = null; if (idx === 0) { @@ -110,10 +110,10 @@ export default class SegmentedControl extends React.Component< const underlayColor = idx === selectedIndex ? tintColor - : setNormalizedColorAlpha( + : '#'+setNormalizedColorAlpha( normalizeColor(tintColor), 0.3, - ).toString(); + ).toString(16); return ( ; @@ -11,20 +12,22 @@ export default class SegmentedControl extends React.Component< any > { static defaultProps = { - tintColor: '#108ee9', selectedIndex: 0, }; render() { const { tintColor, disabled, selectedIndex, ...restProps } = this.props; - return ( - + + {(_, theme) => ( + + )} + ); } } From bef557a5610648808156023f91b84a59bdac54a8 Mon Sep 17 00:00:00 2001 From: jihf Date: Mon, 24 Dec 2018 15:59:30 +0800 Subject: [PATCH 2/2] =?UTF-8?q?SegmentedControl=E4=B8=BB=E9=A2=98=E9=A2=9C?= =?UTF-8?q?=E8=89=B2=E5=8F=98=E9=87=8F=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/segmented-control/segmented.android.tsx | 2 +- components/segmented-control/segmented.ios.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/segmented-control/segmented.android.tsx b/components/segmented-control/segmented.android.tsx index 7d44be3a7..7e3517187 100644 --- a/components/segmented-control/segmented.android.tsx +++ b/components/segmented-control/segmented.android.tsx @@ -88,7 +88,7 @@ export default class SegmentedControl extends React.Component< {(styles, theme) => { const selectedIndex = this.state.selectedIndex; - tintColor = tintColor || theme.brand_primary; + tintColor = tintColor || theme.segmented_control_color; const items = values.map((value, idx) => { let itemRadius: any = null; if (idx === 0) { diff --git a/components/segmented-control/segmented.ios.tsx b/components/segmented-control/segmented.ios.tsx index ceb1fe000..6422ba8a0 100644 --- a/components/segmented-control/segmented.ios.tsx +++ b/components/segmented-control/segmented.ios.tsx @@ -21,7 +21,7 @@ export default class SegmentedControl extends React.Component< {(_, theme) => (