-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathindex.widget.js
More file actions
49 lines (44 loc) · 1.08 KB
/
Copy pathindex.widget.js
File metadata and controls
49 lines (44 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import React, { Component } from "react";
import { AppRegistry, StyleSheet, Text, View } from "react-native";
import { setExpandable } from "react-native-today-widget";
class ExpandableTodayWidget extends Component {
constructor() {
super();
const isExpandable = true;
const maxHeight = 500;
setExpandable(isExpandable, maxHeight);
this.onLayout = event => {
const height = event.nativeEvent.layout.height;
if (height <= 110) {
console.log("widget is in compact mode");
} else if (height > 110) {
console.log("widget is in expanded mode");
}
};
}
render() {
return (
<View onLayout={this.onLayout} style={styles.widget}>
<Text style={styles.welcome}>
Hello expandable world!
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
welcome: {
fontSize: 20,
textAlign: "center",
margin: 10
},
widget: {
flex: 1,
justifyContent: "center",
alignItems: "center"
}
});
AppRegistry.registerComponent(
"TodayWidgetExtension",
() => ExpandableTodayWidget
);