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,7 +11,6 @@ export default function Card({ children, cardTopicText, cardBackgroundColor }) {
: cardBackgroundColor; : cardBackgroundColor;
return ( return (
<>
<View <View
style={{ style={{
paddingTop: 10, paddingTop: 10,
@ -44,6 +43,5 @@ export default function Card({ children, cardTopicText, cardBackgroundColor }) {
{children} {children}
</View> </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
); );
const DropdownCard = (style) => {
return ( return (
<> <Card style={style}>
<Card>
<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 === "" ? (
<>
<DropdownCard />
<MyResult <MyResult
text={t("screens.device.scenes.infoNoSceneSelected")} text={t("screens.device.scenes.infoNoSceneSelected")}
iconName={"selection-search"} 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>
); );
} }