From 607bb682792eb577c991082b2f26a5dab8dc7bb3 Mon Sep 17 00:00:00 2001 From: lts-po Date: Thu, 18 Apr 2024 15:52:02 +0200 Subject: [PATCH] [ui] swipeList for ios --- .../src/components/DNS/DNSOverrideList.ios.js | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 frontend/src/components/DNS/DNSOverrideList.ios.js diff --git a/frontend/src/components/DNS/DNSOverrideList.ios.js b/frontend/src/components/DNS/DNSOverrideList.ios.js new file mode 100644 index 000000000..0c407fcd0 --- /dev/null +++ b/frontend/src/components/DNS/DNSOverrideList.ios.js @@ -0,0 +1,79 @@ +import React from 'react' +import PropTypes from 'prop-types' + +import { + HStack, + Pressable, + VStack, + CloseIcon, + Text +} from '@gluestack-ui/themed' + +import ListHeader from 'components/List/ListHeader' +import { SwipeListView } from 'components/SwipeListView' +import DNSOverrideListItem from './DNSOverrideListItem' + +const DNSOverrideList = ({ title, list, deleteListItem, ...props }) => { + const closeRow = (rowMap, rowKey) => { + if (rowMap[rowKey]) { + rowMap[rowKey].closeRow() + } + } + + const deleteRow = (rowMap, rowKey) => { + closeRow(rowMap, rowKey) + let item = list.find((l) => l.Domain == rowKey) + deleteListItem(item) + } + + const renderHiddenItem = (data, rowMap) => ( + + deleteRow(rowMap, data.item.Domain)} + > + + + + Delete + + + + + ) + + return ( + <> + + {props.renderHeader ? props.renderHeader() : null} + + + ( + + )} + renderHiddenItem={renderHiddenItem} + keyExtractor={(item, index) => item.Domain} + rightOpenValue={-70} + /> + + {!list || !list.length ? ( + {`No ${title.split(' ')[0]} rules configured`} + ) : null} + + ) +} + +DNSOverrideList.propTypes = { + title: PropTypes.string.isRequired, + list: PropTypes.array, + notifyChange: PropTypes.func, + deleteListItem: PropTypes.func +} + +export default DNSOverrideList