Skip to content

Commit

Permalink
refactor(TestScreen): 重构 TestScreen 组件,移除本地身份验证逻辑,添加 Lottie 动画展示
Browse files Browse the repository at this point in the history
  • Loading branch information
thoulee21 committed Nov 15, 2024
1 parent bb2426d commit f945809
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 128 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ android {
applicationId 'com.thoulee.jointplayer'
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 5010000
versionName "5.10.0"
versionCode 5010001
versionName "5.10.1"
}
signingConfigs {
debug {
Expand Down
4 changes: 2 additions & 2 deletions ios/jointplayer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 5010000;
CURRENT_PROJECT_VERSION = 5010001;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = jointplayer/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -507,7 +507,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 5010000;
CURRENT_PROJECT_VERSION = 5010001;
INFOPLIST_FILE = jointplayer/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down
4 changes: 2 additions & 2 deletions ios/jointplayer/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>5.10.0</string>
<string>5.10.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>5010000</string>
<string>5010001</string>
<key>LSRequiresIPhoneOS</key>
<true />
<key>NSAppTransportSecurity</key>
Expand Down
4 changes: 2 additions & 2 deletions ios/jointplayerTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>5.10.0</string>
<string>5.10.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>5010000</string>
<string>5010001</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jointplayer",
"version": "5.10.0",
"version": "5.10.1",
"private": true,
"homepage": "https://github.com/thoulee21/joint-player",
"displayName": "Joint Player",
Expand Down
127 changes: 8 additions & 119 deletions src/pages/test.tsx
Original file line number Diff line number Diff line change
@@ -1,122 +1,11 @@
import {
Header,
LargeHeader,
ScalingView,
ScrollViewWithHeaders,
} from '@codeherence/react-native-header';
import type { LocalAuthenticationResult } from 'expo-local-authentication';
import * as LocalAuthentication from 'expo-local-authentication';
import React, { useEffect, useState } from 'react';
import { StyleSheet } from 'react-native';
import { Button, Card, Text } from 'react-native-paper';
import type { SharedValue } from 'react-native-reanimated';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { BlurBackground } from '../components/BlurBackground';
import { rootLog } from '../utils/logger';

const HeaderComponent = (
{ showNavBar }: { showNavBar: SharedValue<number> }
) => (
<Header
showNavBar={showNavBar}
headerCenter={
<Text style={styles.headerTitle}>
react-native-header
</Text>
}
/>
);

const LargeHeaderComponent = (
{ scrollY }: { scrollY: SharedValue<number> }
) => {
return (
<LargeHeader>
<ScalingView scrollY={scrollY}>
<Text variant="titleMedium">Welcome!</Text>
<Text variant="titleLarge">react-native-header</Text>
<Text variant="titleSmall">
This project displays some header examples using the package.
</Text>
</ScalingView>
</LargeHeader>
);
};
import React from 'react';
import { LottieAnimation } from '../components/LottieAnimation';

export const TestScreen = () => {
const { bottom } = useSafeAreaInsets();
const [isLoaded, setIsLoaded] = useState(false);
const [authResult, setAuthResult] = useState<LocalAuthenticationResult>();

useEffect(() => {
const init = async () => {
const hasHardware = await LocalAuthentication.hasHardwareAsync();
rootLog.debug('hasHardware', hasHardware);

const supported = await LocalAuthentication.supportedAuthenticationTypesAsync();
rootLog.debug('supported', supported);

const enrolled = await LocalAuthentication.isEnrolledAsync();
rootLog.info('enrolled', enrolled);

const result = await LocalAuthentication.authenticateAsync();
rootLog.info('result', result);
setAuthResult(result);

if (result.success) {
rootLog.info('Authenticated!');
} else {
rootLog.warn('Not authenticated!');
}
};

if (!isLoaded) {
init().then(() => {
setIsLoaded(true);
});
}
}, [isLoaded]);

return (
<BlurBackground>
<ScrollViewWithHeaders
HeaderComponent={HeaderComponent}
LargeHeaderComponent={LargeHeaderComponent}
contentContainerStyle={{ paddingBottom: bottom }}
>
<Card style={styles.main}>
<Card.Cover source={{ uri: 'https://picsum.photos/700' }} />
<Card.Title title="Result" />

<Card.Content>
<Text>
{JSON.stringify(
authResult, null, 2
)}
</Text>
</Card.Content>

<Card.Actions>
<Button
icon="reload"
onPress={() => setIsLoaded(false)}
>Reload</Button>
</Card.Actions>
</Card>
</ScrollViewWithHeaders>
</BlurBackground>
);
return (
<LottieAnimation
animation="teapot"
caption="Test Screen"
/>
);
};

const styles = StyleSheet.create({
main: {
flex: 1,
height: 1500,
marginTop: '10%',
marginHorizontal: '2.5%',
},
headerTitle: {
fontSize: 16,
fontWeight: 'bold',
}
});

0 comments on commit f945809

Please sign in to comment.