fixed bug: can't scroll on draggable list

main
alex 2023-08-06 14:26:45 +00:00
parent 8412e960ec
commit d8b3f14658
4 changed files with 53 additions and 47 deletions

View File

@ -11,39 +11,37 @@ export default function Card({ children, cardTopicText, cardBackgroundColor }) {
: cardBackgroundColor; : cardBackgroundColor;
return ( return (
<> <View
<View style={{
style={{ paddingTop: 10,
paddingTop: 10, paddingLeft: 10,
paddingLeft: 10, paddingRight: 10,
paddingRight: 10, paddingBottom: 10,
paddingBottom: 10, }}
}} >
> {cardTopicText !== undefined && (
{cardTopicText !== undefined && ( <Text
<Text style={{
style={{ paddingLeft: 10,
paddingLeft: 10, color: appContext.appTheme.colors.gray,
color: appContext.appTheme.colors.gray, paddingBottom: 6,
paddingBottom: 6, }}
}}
>
{cardTopicText}
</Text>
)}
<View
style={[
{
borderRadius: 20,
backgroundColor: backgroundColor,
padding: 20,
},
AppStyles.Shadow,
]}
> >
{children} {cardTopicText}
</View> </Text>
)}
<View
style={[
{
borderRadius: 20,
backgroundColor: backgroundColor,
padding: 20,
},
AppStyles.Shadow,
]}
>
{children}
</View> </View>
</> </View>
); );
} }

View File

@ -77,9 +77,9 @@ export default function DeviceScreen({ navigation }) {
onPress={() => setSelectedView(2)} onPress={() => setSelectedView(2)}
/> />
<ScrollView style={{ height: "100%" }}> <View style={{ flex: 1 }}>
<SelectedView /> <SelectedView />
</ScrollView> </View>
</View> </View>
); );
} }

View File

@ -19,6 +19,8 @@ import { Divider } from "../../Components/Divider";
import { MyColorSwatch } from "../../Components/ColorPicker"; import { MyColorSwatch } from "../../Components/ColorPicker";
import { MyDotsModal } from "../../Components/Modal"; import { MyDotsModal } from "../../Components/Modal";
import DraggableFlatList, { import DraggableFlatList, {
NestableDraggableFlatList,
NestableScrollContainer,
ScaleDecorator, ScaleDecorator,
} from "react-native-draggable-flatlist"; } from "react-native-draggable-flatlist";
@ -69,9 +71,9 @@ export default function SceneView({ navigation }) {
(a) => a.sceneId === device.selectedScene (a) => a.sceneId === device.selectedScene
); );
return ( const DropdownCard = (style) => {
<> return (
<Card> <Card style={style}>
<MyDropdown <MyDropdown
label={t("screens.device.scenes.dropdownSceneSelection.label")} label={t("screens.device.scenes.dropdownSceneSelection.label")}
onPress={() => onPress={() =>
@ -82,18 +84,23 @@ export default function SceneView({ navigation }) {
selectedItemLabel={getSelectedDeviceSceneName()} selectedItemLabel={getSelectedDeviceSceneName()}
/> />
</Card> </Card>
);
};
return (
<>
{device.selectedScene === "" ? ( {device.selectedScene === "" ? (
<MyResult <>
text={t("screens.device.scenes.infoNoSceneSelected")} <DropdownCard />
iconName={"selection-search"}
/> <MyResult
text={t("screens.device.scenes.infoNoSceneSelected")}
iconName={"selection-search"}
/>
</>
) : ( ) : (
<DraggableFlatList <DraggableFlatList
style={{ marginTop: 10 }}
scrollEnabled={false}
data={deviceSceneActions} data={deviceSceneActions}
simultaneousHandlers
onDragEnd={({ data }) => onDragEnd={({ data }) =>
// TODO: api: save sorting new order // TODO: api: save sorting new order
appContext.setDeviceSceneActions((arr) => { appContext.setDeviceSceneActions((arr) => {
@ -109,6 +116,7 @@ export default function SceneView({ navigation }) {
}) })
} }
keyExtractor={(item) => item.actionId} keyExtractor={(item) => item.actionId}
ListHeaderComponent={<DropdownCard style={{ marginBottom: 10 }} />}
ListEmptyComponent={ ListEmptyComponent={
<MyResult <MyResult
text={t("screens.device.scenes.infoNoActionsAvailableInScene")} text={t("screens.device.scenes.infoNoActionsAvailableInScene")}

View File

@ -1,4 +1,4 @@
import { Text, View } from "react-native"; import { ScrollView, Text, View } from "react-native";
import Card from "../../Components/Card"; import Card from "../../Components/Card";
import { useContext, useEffect, useState } from "react"; import { useContext, useEffect, useState } from "react";
import { AppContext, AppSelectedUserDevice, AppStyles } from "../../utils"; import { AppContext, AppSelectedUserDevice, AppStyles } from "../../utils";
@ -23,7 +23,7 @@ export default function SettingsView({ navigation }) {
}, []); }, []);
return ( return (
<> <ScrollView>
<Card cardTopicText={t("screens.device.settings.settingsTitle")}> <Card cardTopicText={t("screens.device.settings.settingsTitle")}>
<View <View
style={{ style={{
@ -149,6 +149,6 @@ export default function SettingsView({ navigation }) {
{device.firmware.lastUpdated} {device.firmware.lastUpdated}
</Text> </Text>
</Card> </Card>
</> </ScrollView>
); );
} }