mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary:
This adds support for `<Picker style={}/>` prop for text styling. It reuses most of conversion logic from BaseText. This means that it actually supports more styles than Paper Picker supported. (Paper picker only supported ~4 styles, this supports everything that Text supports, so 10+ styles).
The only tricky thing is that Picker supports multiple ways of setting text color. Both
<Picker
itemStyle={{color: '#008BD0'}} >
<Picker.Item label="Java" value="java" />
<Picker.Item label="JavaScript" value="js" />
</Picker>
and
<Picker>
<Picker.Item label="Java" value="java" color={'#008BD0'} />
<Picker.Item label="JavaScript" value="js" />
</Picker>
technically work in Paper. I've decided to maintain this behaviour (since there's lots of product code callsites to both options).
Changelog: [iOS][Fabric] Fabric Picker support
Reviewed By: sammy-SC
Differential Revision: D23980319
fbshipit-source-id: e469a837e28af0ad97cf0e171df26ee19adff3ab
37 lines
900 B
C++
37 lines
900 B
C++
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <react/renderer/components/iospicker/primitives.h>
|
|
#include <react/renderer/components/text/BaseTextProps.h>
|
|
#include <react/renderer/components/view/ViewProps.h>
|
|
|
|
#include <vector>
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
class PickerProps final : public ViewProps, public BaseTextProps {
|
|
public:
|
|
PickerProps() = default;
|
|
PickerProps(PickerProps const &sourceProps, RawProps const &rawProps);
|
|
|
|
#pragma mark - Props
|
|
|
|
std::vector<PickerItemsStruct> items{};
|
|
int selectedIndex{0};
|
|
std::string const testID{};
|
|
std::string const accessibilityLabel{};
|
|
|
|
#pragma mark - Accessors
|
|
TextAttributes getEffectiveTextAttributes() const;
|
|
};
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|