Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.

Commit fb51242

Browse files
committed
UI Patches & Image share issue fix
1 parent 27e67ff commit fb51242

File tree

13 files changed

+224
-134
lines changed

13 files changed

+224
-134
lines changed

android/app/src/main/AndroidManifest.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
55
<uses-permission android:name="android.permission.INTERNET" />
66
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
7+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
78

89
<uses-permission android:name="android.permission.WAKE_LOCK" />
910

@@ -13,6 +14,15 @@
1314
android:icon="@mipmap/ic_launcher_round"
1415
android:allowBackup="false"
1516
android:theme="@style/AppTheme">
17+
<provider
18+
android:name="androidx.core.content.FileProvider"
19+
android:authorities="${applicationId}.provider"
20+
android:grantUriPermissions="true"
21+
android:exported="false">
22+
<meta-data
23+
android:name="android.support.FILE_PROVIDER_PATHS"
24+
android:resource="@xml/filepaths" />
25+
</provider>
1626
<activity
1727
android:name=".MainActivity"
1828
android:label="@string/app_name"

android/app/src/main/java/com/onemdev/rnloop/MainApplication.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@
99
import com.facebook.soloader.SoLoader;
1010
import java.lang.reflect.InvocationTargetException;
1111
import java.util.List;
12+
import cl.json.ShareApplication;
1213

13-
public class MainApplication extends Application implements ReactApplication {
14+
public class MainApplication extends Application implements ReactApplication, ShareApplication {
15+
16+
@Override
17+
public String getFileProviderAuthority() {
18+
return BuildConfig.APPLICATION_ID + ".provider";
19+
}
1420

1521
private final ReactNativeHost mReactNativeHost =
1622
new ReactNativeHost(this) {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<paths xmlns:android="http://schemas.android.com/apk/res/android">
3+
<external-path name="myexternalimages" path="Download/" />
4+
</paths>

app/components/PageView/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ function PageView({
2727
noKeyBoard,
2828
navigation,
2929
afterRender,
30+
disableMaxContainer,
3031
...props
3132
}) {
3233
let Comp = View;
@@ -42,7 +43,12 @@ function PageView({
4243
<SafeAreaView {...baseProps} style={[styles.base].concat([baseStyle])}>
4344
{afterRender}
4445
{header ? <Header {...header} /> : null}
45-
<Comp style={[styles.container].concat(style)} {...compProps} {...props} ref={innerRef}>
46+
<Comp
47+
style={[styles.container, disableMaxContainer ? {} : styles.maxContainer].concat(style)}
48+
{...compProps}
49+
{...props}
50+
ref={innerRef}
51+
>
4652
{children}
4753
</Comp>
4854
{footer}
@@ -58,6 +64,7 @@ PageView.propTypes = {
5864
gradient: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
5965
navigation: PropTypes.object.isRequired,
6066
children: PropTypes.node.isRequired,
67+
disableMaxContainer: PropTypes.bool,
6168
afterRender: PropTypes.node,
6269
baseProps: PropTypes.object,
6370
noKeyBoard: PropTypes.bool,
@@ -70,6 +77,7 @@ PageView.propTypes = {
7077
};
7178

7279
PageView.defaultProps = {
80+
disableMaxContainer: false,
7381
innerRef: () => {},
7482
afterRender: null,
7583
noKeyBoard: false,

app/components/PageView/styles.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { dimensions, platform } from 'rn-hgl';
99

1010
import { colors } from 'configs';
1111

12+
export const MAX_WIDTH = dimensions.width > 650 ? 650 : dimensions.width;
13+
1214
const styles = StyleSheet.create({
1315
base: {
1416
flex: 1,
@@ -18,6 +20,10 @@ const styles = StyleSheet.create({
1820
flex: 1,
1921
paddingTop: platform.isAndroid ? dimensions.statusBarHeight : 0,
2022
},
23+
maxContainer: {
24+
maxWidth: MAX_WIDTH,
25+
marginLeft: dimensions.width / 2 - MAX_WIDTH / 2,
26+
},
2127
gradientBackground: {
2228
backgroundColor: colors.dark.alpha(0.01),
2329
},

app/engine/index.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
import { Animated, Easing } from 'react-native';
22
import { useState, useEffect, useMemo } from 'react';
33
import { captureRef } from 'react-native-view-shot';
4+
import performance from '@react-native-firebase/perf';
45
import share from 'react-native-share';
56

67
import { rotateBox, calculateSuccess, data2Grid } from './utils';
78
import * as UI from './utils/ui';
89

910
import levels from './levels';
1011

11-
export default function useEngine(forceLevel) {
12+
/**
13+
* I had to pass player refrence becuase when we share screenshot
14+
* it calls a native library to share image & I kind of put app in background state
15+
* react-native-audio-toolkit is configured only play music when app is on screen
16+
*/
17+
18+
export default function useEngine(forceLevel, player) {
1219
const [level, setLevel] = useState(forceLevel);
1320
const { data, theme } = levels[level];
1421
const [grid, setGrid] = useState(data2Grid(data));
@@ -50,16 +57,25 @@ export default function useEngine(forceLevel) {
5057

5158
async function capture(ref) {
5259
try {
60+
const trace = await performance().startTrace('capture_screenshot');
61+
5362
const base64 = await captureRef(ref, {
5463
format: 'jpg',
5564
quality: 1.0,
5665
result: 'base64',
5766
});
67+
await trace.stop();
5868
await share.open({
59-
url: `data:image/jpg;base64,${base64}`,
69+
url: `data:image/jpeg;base64,${base64}`,
6070
filename: `rn-loop-game-${new Date().getTime()}`,
6171
});
72+
73+
// await sleep(4000);
74+
player.play();
6275
} catch (e) {
76+
console.log(e);
77+
78+
player.play();
6379
// e
6480
}
6581
}

app/screens/AboutDeveloper/index.js

Lines changed: 62 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -8,69 +8,82 @@ import avatarImage from 'assets/hamza.jpg';
88
import * as utils from 'utils';
99

1010
import PageView from 'components/PageView';
11+
import pageViewStyles from 'components/PageView/styles';
1112
import Icon from 'components/Icon';
1213

1314
import * as data from './data';
1415
import styles from './styles';
1516

1617
function AboutDeveloperScreen({ navigation }) {
1718
return (
18-
<PageView type="scroll" navigation={navigation} baseStyle={styles.page}>
19-
<View style={styles.redSection}>
19+
<PageView
20+
disableMaxContainer
21+
type="scroll"
22+
navigation={navigation}
23+
baseStyle={styles.page}
24+
baseProps={{
25+
forceInset: { bottom: false },
26+
}}
27+
>
28+
<View style={styles.header}>
2029
<TouchNative style={styles.backButtonBase} onPress={() => navigation.pop()}>
2130
<Icon name="chevron-left" style={styles.backButtonIcon} />
2231
</TouchNative>
2332
</View>
2433
<View style={styles.body}>
25-
<Text style={styles.heading}>Full stack web & app developer</Text>
26-
<Text style={styles.description}>
27-
Hi, I am full stack developer who has been developing end to end smart solutions for more
28-
than three years. I am a committed individual who is highly efficient and has excellent
29-
organisational skills to develop applications. I help throughout the life cycle of an
30-
assigned project with my experience and ensure quality solutions that meet objectives.
31-
With all that being said, I am very proud of the work I do, and will stop at nothing to
32-
make sure the job is done to 100% satisfaction.
33-
</Text>
34-
<Text style={styles.heading}>My skill set</Text>
35-
<View style={styles.skillsHolder}>
36-
{data.skills.map((skill) => (
37-
<Text key={skill} style={styles.skill}>
38-
{skill}
39-
</Text>
40-
))}
34+
<View style={pageViewStyles.maxContainer}>
35+
<Text style={styles.heading}>Full stack web & app developer</Text>
36+
<Text style={styles.description}>
37+
Hi, I am full stack developer who has been developing end to end smart solutions for
38+
more than three years. I am a committed individual who is highly efficient and has
39+
excellent organisational skills to develop applications. I help throughout the life
40+
cycle of an assigned project with my experience and ensure quality solutions that meet
41+
objectives. With all that being said, I am very proud of the work I do, and will stop at
42+
nothing to make sure the job is done to 100% satisfaction.
43+
</Text>
44+
<Text style={styles.heading}>My skill set</Text>
45+
<View style={styles.skillsHolder}>
46+
{data.skills.map((skill) => (
47+
<Text key={skill} style={styles.skill}>
48+
{skill}
49+
</Text>
50+
))}
51+
</View>
52+
<Text style={styles.heading}>Let&apos;s Chat!</Text>
53+
<View style={styles.contactsHolder}>
54+
{data.contacts.map((contact) => (
55+
<TouchNative
56+
key={contact.icon}
57+
style={styles.contactBase}
58+
onPress={() =>
59+
Linking.openURL(utils.socialLink(contact.username, contact.platform))
60+
}
61+
>
62+
<Icon style={styles.contactIcon} name={contact.icon} />
63+
<Text style={styles.contactText}>{contact.username}</Text>
64+
</TouchNative>
65+
))}
66+
</View>
67+
<Text style={styles.heading}>Show support</Text>
68+
<Text style={styles.subDescription}>
69+
If you like the project and want to appreciate my effort. Then please click any of these
70+
links and perform any action you may like.
71+
</Text>
72+
<View style={styles.supportHolder}>
73+
{data.showSupport.map((support) => (
74+
<TouchNative
75+
key={support.link}
76+
style={styles.supportBase}
77+
onPress={() => Linking.openURL(support.link)}
78+
>
79+
<Text style={styles.supportText}>* {support.text}</Text>
80+
</TouchNative>
81+
))}
82+
</View>
4183
</View>
42-
<Text style={styles.heading}>Let&apos;s Chat!</Text>
43-
<View style={styles.contactsHolder}>
44-
{data.contacts.map((contact) => (
45-
<TouchNative
46-
key={contact.icon}
47-
style={styles.contactBase}
48-
onPress={() => Linking.openURL(utils.socialLink(contact.username, contact.platform))}
49-
>
50-
<Icon style={styles.contactIcon} name={contact.icon} />
51-
<Text style={styles.contactText}>{contact.username}</Text>
52-
</TouchNative>
53-
))}
84+
<View style={styles.avatarBase}>
85+
<Image source={avatarImage} style={styles.avatarImage} resizeMode="cover" />
5486
</View>
55-
<Text style={styles.heading}>Show support</Text>
56-
<Text style={styles.subDescription}>
57-
If you like the project and want to appreciate my effort. Then please click any of these
58-
links and perform any action you may like.
59-
</Text>
60-
<View style={styles.supportHolder}>
61-
{data.showSupport.map((support) => (
62-
<TouchNative
63-
key={support.link}
64-
style={styles.supportBase}
65-
onPress={() => Linking.openURL(support.link)}
66-
>
67-
<Text style={styles.supportText}>* {support.text}</Text>
68-
</TouchNative>
69-
))}
70-
</View>
71-
</View>
72-
<View style={styles.avatarBase}>
73-
<Image source={avatarImage} style={styles.avatarImage} resizeMode="cover" />
7487
</View>
7588
</PageView>
7689
);

app/screens/AboutDeveloper/styles.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@ const AVATAR_TOP_OFFSET = RED_SECTION_HEIGHT - AVATAR_BORDER_WIDTH - AVATAR_SIZE
1111
const AVATAR_LEFT_OFFSET = dimensions.width / 2 - AVATAR_SIZE / 2;
1212

1313
const styles = StyleSheet.create({
14+
background: {
15+
flex: 1,
16+
backgroundColor: colors.primary,
17+
},
1418
page: {
1519
backgroundColor: colors.primary,
1620
},
17-
redSection: {
21+
header: {
1822
height: RED_SECTION_HEIGHT,
1923
},
2024
backButtonBase: {

0 commit comments

Comments
 (0)