Skip to content

Commit 645807b

Browse files
committed
Revert "feat: Change keyboard avoid mechanism"
This reverts commit de0cd7b.
1 parent 0f958f5 commit 645807b

16 files changed

Lines changed: 580 additions & 464 deletions

File tree

app/android/app/build.gradle

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,13 @@ android {
129129
if (project.hasProperty('ANDROID_UPLOAD_STORE_FILE')) {
130130
signingConfig signingConfigs.release
131131
} else {
132-
signingConfig signingConfigs.debug
133-
def enableShrinkResources = findProperty('android.enableShrinkResourcesInReleaseBuilds') ?: 'false'
134-
shrinkResources enableShrinkResources.toBoolean()
135-
minifyEnabled enableMinifyInReleaseBuilds
136-
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
137-
def enablePngCrunchInRelease = findProperty('android.enablePngCrunchInReleaseBuilds') ?: 'true'
138-
crunchPngs enablePngCrunchInRelease.toBoolean()
132+
signingConfig signingConfigs.debug
133+
def enableShrinkResources = findProperty('android.enableShrinkResourcesInReleaseBuilds') ?: 'false'
134+
shrinkResources enableShrinkResources.toBoolean()
135+
minifyEnabled enableMinifyInReleaseBuilds
136+
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
137+
def enablePngCrunchInRelease = findProperty('android.enablePngCrunchInReleaseBuilds') ?: 'true'
138+
crunchPngs enablePngCrunchInRelease.toBoolean()
139139
}
140140
}
141141
}

app/app.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@
6767
},
6868
"scheme": "liftlog",
6969
"android": {
70-
"softwareKeyboardLayoutMode": "pan",
7170
"package": "com.limajuice.liftlog",
71+
"softwareKeyboardLayoutMode": "pan",
7272
"permissions": [
7373
"com.android.vending.BILLING",
7474
"android.permission.health.WRITE_WEIGHT",

app/app/(tabs)/settings/ai/planner.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { T, useTranslate } from '@tolgee/react';
55
import { Stack, useRouter } from 'expo-router';
66
import { I18nManager, Platform, View } from 'react-native';
77
import { FlatList } from 'react-native-gesture-handler';
8+
import { KeyboardAvoidingView } from 'react-native-keyboard-controller';
89
import { useDispatch } from 'react-redux';
910
import IconButton from '@/components/presentation/foundation/gesture-wrappers/icon-button';
1011
import Button from '@/components/presentation/foundation/gesture-wrappers/button';
@@ -77,7 +78,10 @@ export default function AiPlanner() {
7778
const reset = () => dispatch(restartChat());
7879

7980
return (
80-
<View style={{ flex: 1 }}>
81+
<KeyboardAvoidingView
82+
behavior={'translate-with-padding'}
83+
style={{ flex: 1 }}
84+
>
8185
<Stack.Screen
8286
options={{
8387
title: t('ai.planner.title'),
@@ -156,7 +160,7 @@ export default function AiPlanner() {
156160
onPress={() => sendMessage(messageText)}
157161
/>
158162
</View>
159-
</View>
163+
</KeyboardAvoidingView>
160164
);
161165
}
162166

app/app/_layout.tsx

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { AppStateProvider } from '@/components/smart/app-state-provider';
88
import SnackbarProvider from '@/components/smart/snackbar-provider';
99
import { GestureHandlerRootView } from 'react-native-gesture-handler';
1010
import '@/utils/date-locale';
11+
import { KeyboardProvider } from 'react-native-keyboard-controller';
1112
import * as Sentry from '@sentry/react-native';
1213
import ServicesProvider from '@/components/smart/services-provider';
1314

@@ -30,30 +31,32 @@ export default Sentry.wrap(function RootLayout() {
3031

3132
return (
3233
<GestureHandlerRootView>
33-
<Provider store={store}>
34-
<SafeAreaProvider>
35-
<ServicesProvider>
36-
<AppThemeProvider>
37-
<AppStateProvider>
38-
<SnackbarProvider>
39-
<Stack
40-
screenOptions={{
41-
headerShown: false,
42-
statusBarStyle:
43-
Platform.OS === 'android'
44-
? colorScheme === 'dark'
45-
? 'light'
46-
: 'dark'
47-
: undefined,
48-
gestureEnabled: false,
49-
}}
50-
/>
51-
</SnackbarProvider>
52-
</AppStateProvider>
53-
</AppThemeProvider>
54-
</ServicesProvider>
55-
</SafeAreaProvider>
56-
</Provider>
34+
<KeyboardProvider>
35+
<Provider store={store}>
36+
<SafeAreaProvider>
37+
<ServicesProvider>
38+
<AppThemeProvider>
39+
<AppStateProvider>
40+
<SnackbarProvider>
41+
<Stack
42+
screenOptions={{
43+
headerShown: false,
44+
statusBarStyle:
45+
Platform.OS === 'android'
46+
? colorScheme === 'dark'
47+
? 'light'
48+
: 'dark'
49+
: undefined,
50+
gestureEnabled: false,
51+
}}
52+
/>
53+
</SnackbarProvider>
54+
</AppStateProvider>
55+
</AppThemeProvider>
56+
</ServicesProvider>
57+
</SafeAreaProvider>
58+
</Provider>
59+
</KeyboardProvider>
5760
</GestureHandlerRootView>
5861
);
5962
});

app/components/layout/full-height-scroll-view.tsx

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@ import { useScroll } from '@/hooks/useScrollListener';
33
import { useState } from 'react';
44
import { View, StyleProp, ViewStyle } from 'react-native';
55
import { ScrollView } from 'react-native-gesture-handler';
6+
import { KeyboardAwareScrollView } from 'react-native-keyboard-controller';
7+
import type { AnimatedScrollViewComponent } from 'react-native-keyboard-controller/lib/typescript/components/ScrollViewWithBottomPadding';
68

79
export default function FullHeightScrollView({
810
children,
911
floatingChildren,
1012
scrollStyle,
13+
ignoreKeyboard,
1114
contentContainerStyle,
1215
}: {
1316
children: React.ReactNode;
1417
floatingChildren?: React.ReactNode;
18+
ignoreKeyboard?: boolean;
1519
scrollStyle?: StyleProp<ViewStyle>;
1620
contentContainerStyle?: StyleProp<ViewStyle>;
1721
}) {
@@ -28,14 +32,26 @@ export default function FullHeightScrollView({
2832
},
2933
]}
3034
>
31-
<ScrollView
32-
onScroll={handleScroll}
33-
style={[scrollStyle]}
34-
contentContainerStyle={[contentContainerStyle]}
35-
>
36-
{children}
37-
<View style={{ height: floatingBottomSize }} />
38-
</ScrollView>
35+
{ignoreKeyboard ? (
36+
<ScrollView
37+
onScroll={handleScroll}
38+
style={[scrollStyle]}
39+
contentContainerStyle={[contentContainerStyle]}
40+
>
41+
{children}
42+
<View style={{ height: floatingBottomSize }} />
43+
</ScrollView>
44+
) : (
45+
<KeyboardAwareScrollView
46+
ScrollViewComponent={ScrollView as AnimatedScrollViewComponent}
47+
onScroll={handleScroll}
48+
style={[scrollStyle]}
49+
contentContainerStyle={[contentContainerStyle]}
50+
>
51+
{children}
52+
<View style={{ height: floatingBottomSize }} />
53+
</KeyboardAwareScrollView>
54+
)}
3955
{floatingChildren && (
4056
<View
4157
onLayout={(event) =>

app/components/presentation/foundation/editors/weight-dialog.tsx

Lines changed: 94 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { T, useTranslate } from '@tolgee/react';
77
import BigNumber from 'bignumber.js';
88
import { ReactNode, useEffect, useState } from 'react';
99
import { Keyboard, View } from 'react-native';
10+
import { KeyboardAvoidingView } from 'react-native-keyboard-controller';
1011
import IconButton from '@/components/presentation/foundation/gesture-wrappers/icon-button';
1112
import Button from '@/components/presentation/foundation/gesture-wrappers/button';
1213
import {
@@ -114,97 +115,104 @@ export default function WeightDialog(props: WeightDialogProps) {
114115

115116
return (
116117
<Portal>
117-
<Dialog visible={props.open} onDismiss={props.onClose}>
118-
<Dialog.Title>
119-
{props.label ?? <T keyName="weight.weight.label" />}
120-
</Dialog.Title>
121-
<Dialog.Content>
122-
<View style={{ gap: spacing[2] }}>
123-
<View
124-
style={{
125-
flexDirection: 'row',
126-
gap: spacing[2],
127-
justifyContent: 'center',
128-
alignItems: 'center',
129-
}}
130-
>
131-
<TextInput
132-
testID="weight-input"
133-
selectTextOnFocus
134-
mode="outlined"
135-
inputMode="decimal"
136-
keyboardType="decimal-pad"
137-
submitBehavior="blurAndSubmit"
138-
returnKeyType="done"
139-
autoFocus
140-
value={text}
141-
onChangeText={handleTextChange}
118+
<KeyboardAvoidingView
119+
behavior={'height'}
120+
style={{ flex: 1, pointerEvents: props.open ? 'box-none' : 'none' }}
121+
>
122+
<Dialog visible={props.open} onDismiss={props.onClose}>
123+
<Dialog.Title>
124+
{props.label ?? <T keyName="weight.weight.label" />}
125+
</Dialog.Title>
126+
<Dialog.Content>
127+
<View style={{ gap: spacing[2] }}>
128+
<View
142129
style={{
143-
backgroundColor: theme.colors.elevation.level3,
144-
flex: 1,
130+
flexDirection: 'row',
131+
gap: spacing[2],
132+
justifyContent: 'center',
133+
alignItems: 'center',
145134
}}
146-
/>
135+
>
136+
<TextInput
137+
testID="weight-input"
138+
selectTextOnFocus
139+
mode="outlined"
140+
inputMode="decimal"
141+
keyboardType="decimal-pad"
142+
submitBehavior="blurAndSubmit"
143+
returnKeyType="done"
144+
autoFocus
145+
value={text}
146+
onChangeText={handleTextChange}
147+
style={{
148+
backgroundColor: theme.colors.elevation.level3,
149+
flex: 1,
150+
}}
151+
/>
147152

148-
<SelectButton
149-
testID="weight-dialog-unit-selector"
150-
options={[
151-
{ label: 'kg', value: 'kilograms' },
152-
{ label: 'lbs', value: 'pounds' },
153-
{ label: 'Unit', value: 'nil', disabledAndHidden: true },
154-
]}
155-
value={editorWeightUnit}
156-
onMenuOpen={() => Keyboard.dismiss()}
157-
onChange={(unit) => setEditorWeightUnit(unit)}
158-
/>
159-
</View>
160-
<View
161-
style={{
162-
flexDirection: 'row',
163-
gap: spacing[2],
164-
alignItems: 'center',
165-
}}
166-
>
167-
{props.allowNegative && (
168-
<Tooltip title={t('exercise.toggle_negative.button')}>
169-
<IconButton
170-
mode="outlined"
171-
icon={'plusMinus'}
172-
onPress={() => {
173-
setEditorWeightValue(editorWeightValue?.multipliedBy(-1));
174-
setText(
175-
localeFormatBigNumber(
153+
<SelectButton
154+
testID="weight-dialog-unit-selector"
155+
options={[
156+
{ label: 'kg', value: 'kilograms' },
157+
{ label: 'lbs', value: 'pounds' },
158+
{ label: 'Unit', value: 'nil', disabledAndHidden: true },
159+
]}
160+
value={editorWeightUnit}
161+
onMenuOpen={() => Keyboard.dismiss()}
162+
onChange={(unit) => setEditorWeightUnit(unit)}
163+
/>
164+
</View>
165+
<View
166+
style={{
167+
flexDirection: 'row',
168+
gap: spacing[2],
169+
alignItems: 'center',
170+
}}
171+
>
172+
{props.allowNegative && (
173+
<Tooltip title={t('exercise.toggle_negative.button')}>
174+
<IconButton
175+
mode="outlined"
176+
icon={'plusMinus'}
177+
onPress={() => {
178+
setEditorWeightValue(
176179
editorWeightValue?.multipliedBy(-1),
177-
),
178-
);
179-
}}
180-
/>
181-
</Tooltip>
182-
)}
183-
<IconButton
184-
icon={'minus'}
185-
mode="outlined"
186-
testID="decrement-weight"
187-
onPress={decrementWeight}
188-
/>
189-
<IconButton
190-
icon={'plus'}
191-
mode="outlined"
192-
testID="increment-weight"
193-
onPress={incrementWeight}
194-
/>
180+
);
181+
setText(
182+
localeFormatBigNumber(
183+
editorWeightValue?.multipliedBy(-1),
184+
),
185+
);
186+
}}
187+
/>
188+
</Tooltip>
189+
)}
190+
<IconButton
191+
icon={'minus'}
192+
mode="outlined"
193+
testID="decrement-weight"
194+
onPress={decrementWeight}
195+
/>
196+
<IconButton
197+
icon={'plus'}
198+
mode="outlined"
199+
testID="increment-weight"
200+
onPress={incrementWeight}
201+
/>
202+
</View>
203+
{props.children}
195204
</View>
196-
{props.children}
197-
</View>
198-
</Dialog.Content>
199-
<Dialog.Actions>
200-
<Button onPress={props.onClose} testID="close">
201-
<T keyName="generic.close.button" />
202-
</Button>
203-
<Button onPress={onSaveClick} testID="save">
204-
<T keyName="generic.save.button" />
205-
</Button>
206-
</Dialog.Actions>
207-
</Dialog>
205+
</Dialog.Content>
206+
<Dialog.Actions>
207+
<Button onPress={props.onClose} testID="close">
208+
<T keyName="generic.close.button" />
209+
</Button>
210+
<Button onPress={onSaveClick} testID="save">
211+
<T keyName="generic.save.button" />
212+
</Button>
213+
</Dialog.Actions>
214+
</Dialog>
215+
</KeyboardAvoidingView>
208216
</Portal>
209217
);
210218
}

0 commit comments

Comments
 (0)