@@ -3,138 +3,109 @@ Calendar 日历
33
44展示日历
55
6- ![ ] ( https://user-images.githubusercontent.com/66067296/141939109-5fbd8b77-82fa-4eb4-bd6d-6670fd577878.gif ) <!-- rehype:style=zoom: 33%;float: right; margin-left: 15px;-->
7-
86### 基础示例
97
10- ``` jsx
11- import React from ' react' ;
12- import { Text , View } from ' react-native' ;
8+ ``` jsx mdx:preview
9+ import React ,{ Component } from ' react' ;
10+ import { View } from ' react-native' ;
1311import { Calendar } from ' @uiw/react-native' ;
14- import { ComProps } from ' ../../routes' ;
15- import Layout , { Container } from ' ../../Layout' ;
16-
17- const { Header , Body , Card , Footer } = Layout;
18-
19- export interface CalendarViewProps extends ComProps { }
12+ import Layout , { Container } from ' ../Layout' ;
13+ const { Header , Body , Footer } = Layout;
2014
21- export default class CalendarView extends React . Component < CalendarViewProps > {
15+ class CalendarView extends Component {
2216 render () {
23- const { route } = this .props ;
24- const description = route .params .description ;
25- const title = route .params .title ;
17+ const title = ' Calendar' ;
2618 return (
27- < Container>
28- < Layout>
29- < Header title= {title} description= {description} / >
30- < Body>
31- < Calendar / >
32- < / Body>
33- < Footer / >
34- < / Layout>
35- < / Container>
19+ < Container>
20+ < Layout>
21+ < Body>
22+ < Calendar / >
23+ < / Body>
24+ < Footer / >
25+ < / Layout>
26+ < / Container>
3627 );
3728 }
3829}
30+ export default CalendarView
3931```
4032
4133### 自定义日历颜色、农历及假日展示
4234
43- ``` jsx
44- import React from ' react' ;
45- import { Text , View } from ' react-native' ;
35+ ``` jsx mdx:preview
36+ import React ,{ Component } from ' react' ;
37+ import { View } from ' react-native' ;
4638import { Calendar } from ' @uiw/react-native' ;
47- import { ComProps } from ' ../../routes' ;
48- import Layout , { Container } from ' ../../Layout' ;
49-
50- const { Header , Body , Card , Footer } = Layout;
39+ import Layout , { Container } from ' ../Layout' ;
40+ const { Header , Body , Footer } = Layout;
5141
52- export interface CalendarViewProps extends ComProps { }
53-
54- export default class CalendarView extends React .Component < CalendarViewProps> {
42+ class CalendarView extends Component {
5543 render () {
56- const { route } = this .props ;
57- const description = route .params .description ;
58- const title = route .params .title ;
5944 return (
60- < Container>
61- < Layout>
62- < Header title= {title} description= {description} / >
63- < Body>
45+ < Container>
46+ < Layout>
47+ < Body>
6448 < Calendar color= " red" lunarHoliday= {true }/ >
65- < / Body>
66- < Footer / >
67- < / Layout>
68- < / Container>
49+ < / Body>
50+ < Footer / >
51+ < / Layout>
52+ < / Container>
6953 );
7054 }
7155}
56+ export default CalendarView
57+
7258```
7359
7460### 自定义日历头部及农历详情展示
7561
76- ``` jsx
77- import React from ' react' ;
62+ ``` jsx mdx:preview
63+ import React ,{ Component } from ' react' ;
7864import { Text , View } from ' react-native' ;
7965import { Calendar } from ' @uiw/react-native' ;
80- import { ComProps } from ' ../../routes ' ;
81- import Layout , { Container } from ' ../../ Layout' ;
66+ import Layout , { Container } from ' ../Layout ' ;
67+ const { Header , Body , Footer } = Layout;
8268
83- const { Header , Body , Card , Footer } = Layout;
84-
85- export interface CalendarViewProps extends ComProps { }
86-
87- export default class CalendarView extends React .Component < CalendarViewProps> {
69+ class CalendarView extends Component {
8870 render () {
89- const { route } = this .props ;
90- const description = route .params .description ;
91- const title = route .params .title ;
9271 const barProps = {
9372 barRightText: " 返回" ,
9473 title : " 日历" ,
9574 onPressBarLeft : () => navigation .goBack (),
9675 barLeftText: " 今天"
9776 }
9877 return (
99- < Container>
100- < Layout>
101- < Header title= {title} description= {description} / >
102- < Body>
103- < Calendar color= " red" bar= {barProps} lunarHoliday= {true } showLunar= {true }/ >
104- < / Body>
105- < Footer / >
106- < / Layout>
107- < / Container>
78+ < Container>
79+ < Layout>
80+ < Body>
81+ < Calendar color= " red" bar= {barProps} lunarHoliday= {true } showLunar= {true }/ >
82+ < / Body>
83+ < Footer / >
84+ < / Layout>
85+ < / Container>
10886 );
10987 }
11088}
89+ export default CalendarView
11190```
11291
113- ### props
114-
115- ``` ts
116-
117- interface barState {
118- // 导航栏标题
119- title? : string
120- // 是否显示农历及假日
121- lunarHoliday: Boolean
122- // 导航左侧文本
123- barRightText? : string ;
124- // 导航右侧文本
125- barLeftText? : string ;
126- // 导航左侧点击事件
127- onPressBarLeft? : () => void ;
128- // 自定义导航栏
129- render? : React .ReactNode
130- }
131- export interface CalendarProps extends ViewProps {
132- // 日历颜色
133- color? : string ;
134- // 是否显示农历及假日
135- lunarHoliday: boolean ;
136- bar: barState ;
137- // 农历详情
138- showLunar: boolean ;
139- }
140- ```
92+ ### Props
93+
94+ 集成继承 ` Button ` 组件自定义属性,外层包裹继承 [ ` Flex ` ] 组件。
95+
96+ | 参数 | 说明 | 类型 | 默认值 |
97+ | ------| ------| -----| ------|
98+ | ` color ` | 日历颜色 | string | - |
99+ | ` lunarHoliday ` | 是否显示农历及假日 | Boolean | ` false ` |
100+ | ` showLunar ` | 农历详情 | Boolean | ` false ` |
101+ | ` bar ` | 导航栏 | React.ReactNode | - |
102+
103+ ### bar 参数
104+ | 参数 | 说明 | 类型 | 默认值 |
105+ | ------| ------| -----| ------|
106+ | ` title ` | 导航栏标题 | string | - |
107+ | ` lunarHoliday ` | 是否显示农历及假日 | Boolean | ` false ` |
108+ | ` barLeftText ` | 导航左侧文本 | string | - |
109+ | ` barRightText ` | 导航右侧文本 | string | - |
110+ | ` onPressBarLeft ` | 是否显示农历及假日 | ` () => void ` | - |
111+ | ` render ` | 自定义导航栏 | React.ReactNode | - |
0 commit comments