-
-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: add inverseSecondary to theme color * chore: replace empty message text with pocketpal's icon * chore: add divider component * feat: group models by ready to use and available to download (when ungrouped by model type) * feat: add description to Available to download group in models screen * chore: update TextInput to support error messages * feat: add completion settings validation * chore: refactor completion settings * chore: remove n_probs from the ui * chore: update completion settings desc * fix: increase temp max value * chore: add inverseTextSecondary to the theme * chore: update background and surface for the dark mode
- Loading branch information
1 parent
a45fcb7
commit 416e1c5
Showing
57 changed files
with
2,343 additions
and
1,137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
93 changes: 51 additions & 42 deletions
93
src/components/AppleStyleSwipeableRow/AppleStyleSwipeableRow.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,89 @@ | ||
import {Animated, Text, View} from 'react-native'; | ||
import React, {Component, PropsWithChildren} from 'react'; | ||
import React, {useRef} from 'react'; | ||
import {Animated, View} from 'react-native'; | ||
|
||
import {Text} from 'react-native-paper'; | ||
import {RectButton, Swipeable} from 'react-native-gesture-handler'; | ||
import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; | ||
|
||
import {styles} from './styles'; | ||
import {useTheme} from '../../hooks'; | ||
|
||
import {createStyles, SWIPE_WIDTH} from './styles'; | ||
|
||
interface AppleStyleSwipeableRowProps { | ||
onDelete: () => void; | ||
onSwipeableOpen?: (direction: string) => void; | ||
onSwipeableClose?: (direction: string) => void; | ||
children: React.ReactNode; | ||
} | ||
|
||
export class AppleStyleSwipeableRow extends Component< | ||
PropsWithChildren<AppleStyleSwipeableRowProps> | ||
> { | ||
private renderLeftAction = ( | ||
export const AppleStyleSwipeableRow: React.FC<AppleStyleSwipeableRowProps> = ({ | ||
onDelete, | ||
onSwipeableOpen, | ||
onSwipeableClose, | ||
children, | ||
}) => { | ||
const theme = useTheme(); | ||
const styles = createStyles(theme); | ||
const swipeableRow = useRef<Swipeable>(null); | ||
|
||
const close = () => { | ||
swipeableRow.current?.close(); | ||
}; | ||
|
||
const renderLeftAction = ( | ||
text: string, | ||
color: string, | ||
x: number, | ||
progress: Animated.AnimatedInterpolation<number>, | ||
) => { | ||
const trans = progress.interpolate({ | ||
inputRange: [0, 1], | ||
outputRange: [-x, 0], // Start offscreen and move into view | ||
outputRange: [-x, 0], | ||
}); | ||
|
||
const pressHandler = () => { | ||
this.close(); | ||
this.props.onDelete(); | ||
close(); | ||
onDelete(); | ||
}; | ||
|
||
return ( | ||
<Animated.View | ||
style={[ | ||
styles.leftActionContainer, | ||
{transform: [{translateX: trans}]}, | ||
{ | ||
transform: [{translateX: trans}], | ||
backgroundColor: color, | ||
}, | ||
]}> | ||
<RectButton | ||
style={[styles.leftAction, {backgroundColor: color}]} | ||
onPress={pressHandler}> | ||
<Text style={styles.actionText}>{text}</Text> | ||
<RectButton style={styles.leftAction} onPress={pressHandler}> | ||
<Icon name="trash-can-outline" size={22} color="white" /> | ||
<Text variant="bodySmall" style={styles.actionText}> | ||
{text} | ||
</Text> | ||
</RectButton> | ||
</Animated.View> | ||
); | ||
}; | ||
|
||
private renderLeftActions = ( | ||
const renderLeftActions = ( | ||
progress: Animated.AnimatedInterpolation<number>, | ||
_dragAnimatedValue: Animated.AnimatedInterpolation<number>, | ||
) => ( | ||
<View style={styles.leftActionsContainer}> | ||
{this.renderLeftAction('Delete', '#dd2c00', 192, progress)} | ||
{renderLeftAction('Delete', theme.colors.error, SWIPE_WIDTH, progress)} | ||
</View> | ||
); | ||
|
||
private swipeableRow?: Swipeable; | ||
|
||
private updateRef = (ref: Swipeable) => { | ||
this.swipeableRow = ref; | ||
}; | ||
private close = () => { | ||
this.swipeableRow?.close(); | ||
}; | ||
|
||
render() { | ||
const {children} = this.props; | ||
return ( | ||
<Swipeable | ||
ref={this.updateRef} | ||
friction={2} | ||
enableTrackpadTwoFingerGesture | ||
leftThreshold={30} // Right swipe threshold | ||
renderLeftActions={this.renderLeftActions} // Swipe right to reveal left actions | ||
onSwipeableOpen={this.props.onSwipeableOpen} | ||
onSwipeableClose={this.props.onSwipeableClose}> | ||
{children} | ||
</Swipeable> | ||
); | ||
} | ||
} | ||
return ( | ||
<Swipeable | ||
ref={swipeableRow} | ||
friction={2} | ||
enableTrackpadTwoFingerGesture | ||
leftThreshold={30} | ||
renderLeftActions={renderLeftActions} | ||
onSwipeableOpen={onSwipeableOpen} | ||
onSwipeableClose={onSwipeableClose}> | ||
{children} | ||
</Swipeable> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,42 @@ | ||
import {I18nManager, StyleSheet} from 'react-native'; | ||
import {StyleSheet, Dimensions} from 'react-native'; | ||
import {Theme} from '../../utils/types'; | ||
|
||
export const styles = StyleSheet.create({ | ||
leftActionsContainer: { | ||
width: 192, | ||
flexDirection: I18nManager.isRTL ? 'row-reverse' : 'row', | ||
}, | ||
leftActionContainer: { | ||
flex: 1, | ||
}, | ||
actionText: { | ||
color: 'white', | ||
fontSize: 16, | ||
backgroundColor: 'transparent', | ||
padding: 10, | ||
}, | ||
leftAction: { | ||
alignItems: 'center', | ||
flex: 1, | ||
justifyContent: 'center', | ||
}, | ||
}); | ||
export const SWIPE_WIDTH = Dimensions.get('window').width * 0.3; // 30% of screen width | ||
|
||
export const createStyles = (theme: Theme) => | ||
StyleSheet.create({ | ||
leftActionContainer: { | ||
flex: 1, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
borderTopRightRadius: 24, | ||
borderBottomRightRadius: 24, | ||
shadowColor: theme.colors.shadow, | ||
shadowOffset: { | ||
width: 0, | ||
height: 1, | ||
}, | ||
shadowOpacity: 0.25, | ||
shadowRadius: 1.84, | ||
elevation: 5, | ||
marginVertical: 4, | ||
marginRight: 4, | ||
}, | ||
leftAction: { | ||
flex: 1, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
width: SWIPE_WIDTH, | ||
padding: 16, | ||
}, | ||
actionText: { | ||
color: theme.colors.onPrimary, | ||
marginTop: 4, | ||
textTransform: 'uppercase', | ||
letterSpacing: 0.5, | ||
}, | ||
leftActionsContainer: { | ||
width: SWIPE_WIDTH, | ||
flexDirection: 'row', | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.