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

Commit b9121e7

Browse files
committed
Merge branch 'beta'
2 parents e6a3a54 + 90452ee commit b9121e7

29 files changed

+916
-712
lines changed

Notes.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Version 1.0.8 Notes
2+
3+
## What's new?
4+
5+
- Now you can add/remove games from MyGames from GameInfo.
6+
- Moved MyGames to an unique file `MyGames.js` and changed from .map to Flatlist.
7+
- Added Notification Bar messages when API-Key is missing and Notifications are empty.
8+
9+
## Fixes
10+
11+
- Fixed: App not reloading when logging in.
12+
- Fixed: Notifications issue when API-Key was not provided.
13+
- Fixed: Login screen buttons.
14+
- Fixed: Profiles with no country not displaying properly.
15+
- Fixed: Login `SKIP` button not working.
16+
17+
## Performance
18+
19+
- Optimized notifications load.
20+
- Removed unused packages.
21+
- Removed unused code.
22+
- Game search, user search and home now use hooks instead of React Components.
23+
- Small optimizations.
24+
- Profile
25+
26+
## Known issues
27+
28+
- App not reloading when logging out.
29+
- MyGames not reloading when adding/removing games.
30+
- Runs with multiple runners not displaying properly.
31+
- Japanese users not displaying.
32+
- OS forced darkmode breaks `UserHeader.js` colors.

Source/App.js

Lines changed: 51 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,59 @@
1-
import React, { Component } from "react";
1+
import React, { useState, useEffect } from "react";
22
import AsyncStorage from "@react-native-community/async-storage";
3+
import { ActivityIndicator } from "react-native";
4+
5+
//Screens
36
import Navigation from "./app/screens/Navigation";
47
import Login from "./app/screens/Login";
58

6-
export default class App extends Component {
7-
_isMounted = false;
8-
constructor(props) {
9-
super();
10-
this.state = {
11-
Loggedin: true,
12-
};
13-
}
14-
async componentDidMount() {
15-
this._isMounted = true;
16-
if (this._isMounted) {
17-
const Loggedin = await AsyncStorage.getItem("@Loggedin");
9+
//Themes
10+
import { Provider } from "react-redux";
11+
import { createStore, applyMiddleware, combineReducers } from "redux";
12+
import thunk from "redux-thunk";
13+
import themeReducer from "./app/redux/themeReducer";
1814

19-
if (Loggedin == "true") {
20-
this.setState({ Loggedin: true });
21-
} else if (Loggedin == "false") {
22-
this.setState({ Loggedin: false });
23-
} else {
24-
null;
25-
}
26-
}
27-
}
28-
componentWillUnmount() {
29-
this._isMounted = false;
30-
}
31-
render() {
32-
if (this.state.Loggedin) {
33-
return <Navigation />;
34-
} else {
35-
return <Login />;
15+
const store = createStore(
16+
combineReducers({ themeReducer }),
17+
applyMiddleware(thunk)
18+
);
19+
20+
export default function App() {
21+
const [loading, setLoading] = useState(true);
22+
const [Loggedin, setLoggedin] = useState(false);
23+
24+
useEffect(() => {
25+
let mounted = true;
26+
if (mounted) {
27+
(async () => {
28+
const LOGGEDIN = await AsyncStorage.getItem("@Loggedin");
29+
if (LOGGEDIN == "true") {
30+
setLoggedin(true);
31+
setLoading(false);
32+
} else if (LOGGEDIN == "false") {
33+
setLoggedin(false);
34+
setLoading(false);
35+
} else {
36+
setLoading(false);
37+
}
38+
})();
3639
}
40+
41+
return function cleanup() {
42+
mounted = false;
43+
};
44+
}, [Loggedin]);
45+
46+
if (loading) {
47+
return <ActivityIndicator />;
48+
} else {
49+
return (
50+
<Provider store={store}>
51+
{Loggedin == true ? (
52+
<Navigation function={() => setLoggedin()} />
53+
) : (
54+
<Login function={() => setLoggedin()} />
55+
)}
56+
</Provider>
57+
);
3758
}
3859
}

Source/app.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "SpeedrunHub",
44
"slug": "speedruncomapp",
55
"platforms": ["ios", "android", "web"],
6-
"version": "1.0.7",
6+
"version": "1.0.8",
77
"orientation": "portrait",
88
"icon": "./app/assets/trophy.png",
99
"splash": {
@@ -22,7 +22,7 @@
2222
"githubUrl": "https://github.com/Asiern/SpeedrunHub",
2323
"android": {
2424
"package": "com.asiern.speedrun",
25-
"versionCode": 7
25+
"versionCode": 8
2626
}
2727
}
2828
}

Source/app/components/Game.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import React from "react";
2+
import { Text, View, StyleSheet } from "react-native";
3+
4+
import colors from "../config/colors";
5+
const Game = (props) => {
6+
return (
7+
<View style={styles.container}>
8+
<Text style={styles.text}>{props.title}</Text>
9+
</View>
10+
);
11+
};
12+
13+
const styles = StyleSheet.create({
14+
container: {
15+
paddingVertical: 15,
16+
flexDirection: "row",
17+
alignItems: "center",
18+
backgroundColor: colors.white,
19+
marginTop: 10,
20+
borderRadius: 10,
21+
shadowColor: "gold",
22+
shadowOffset: { width: 5, height: 5 },
23+
shadowOpacity: 0.9,
24+
elevation: 5,
25+
margin: 10,
26+
},
27+
text: {
28+
paddingHorizontal: 10,
29+
paddingVertical: 10,
30+
fontSize: 15,
31+
},
32+
});
33+
export default Game;

Source/app/components/GameCard.js

Lines changed: 28 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,36 @@
1-
import React, { Component } from "react";
1+
import React from "react";
22
import { StyleSheet, ImageBackground, View } from "react-native";
33
import { TouchableOpacity } from "react-native-gesture-handler";
44

5-
class GameCard extends Component {
6-
constructor(props) {
7-
super(props);
8-
this.state = {
9-
id: this.props.id,
10-
abbreviation: this.props.abbreviation,
11-
cover:
12-
"https://www.speedrun.com/themes/" +
13-
this.props.abbreviation +
14-
"/cover-256.png",
15-
};
16-
}
17-
18-
render() {
19-
const shadow = {
20-
width: 110,
21-
height: 153,
22-
color: "#000000",
23-
radius: 10,
24-
opacity: 0.6,
25-
x: 5,
26-
y: 5,
27-
style: { marginVertical: 5 },
28-
};
29-
return (
30-
<View style={{ padding: 2 }}>
31-
<TouchableOpacity
32-
onPress={() =>
33-
this.props.navigation.navigate("Game Info", {
34-
id: this.state.id,
35-
name: "name",
36-
abbreviation: this.state.abbreviation,
37-
})
38-
}
39-
style={styles.container}
40-
>
41-
<ImageBackground
42-
source={{ uri: this.state.cover }}
43-
style={styles.image}
44-
imageStyle={{ borderRadius: 10 }}
45-
></ImageBackground>
46-
</TouchableOpacity>
47-
</View>
48-
);
49-
}
5+
export default function GameCard(props) {
6+
return (
7+
<View style={{ padding: 2 }}>
8+
<TouchableOpacity
9+
onPress={() =>
10+
props.navigation.navigate("Game Info", {
11+
id: props.id,
12+
name: "name",
13+
abbreviation: props.abbreviation,
14+
})
15+
}
16+
style={styles.container}
17+
>
18+
<ImageBackground
19+
source={{
20+
uri:
21+
"https://www.speedrun.com/themes/" +
22+
props.abbreviation +
23+
"/cover-256.png",
24+
}}
25+
style={styles.image}
26+
imageStyle={{ borderRadius: 10 }}
27+
></ImageBackground>
28+
</TouchableOpacity>
29+
</View>
30+
);
5031
}
51-
const styles = StyleSheet.create({
52-
shadow: {
53-
backgroundColor: "white",
54-
shadowColor: "gold",
55-
shadowOffset: { width: 5, height: 5 },
56-
shadowOpacity: 0.9,
5732

58-
// add shadows for Android only
59-
// No options for shadow color, shadow offset, shadow opacity like iOS
60-
elevation: 5,
61-
},
33+
const styles = StyleSheet.create({
6234
container: {
6335
width: 113,
6436
height: 160,
@@ -77,5 +49,3 @@ const styles = StyleSheet.create({
7749
flexDirection: "row",
7850
},
7951
});
80-
81-
export default GameCard;

Source/app/components/Games.js

Lines changed: 34 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,56 @@
1-
import React, { Component } from "react";
1+
import React, { useState } from "react";
22
import { View, StyleSheet } from "react-native";
33
import { FlatList } from "react-native-gesture-handler";
44
import GameCard from "./GameCard";
55
import colors from "../config/colors";
66
import { SearchBar } from "react-native-elements";
77

8-
class Games extends Component {
9-
constructor(props) {
10-
super(props);
11-
this.state = {
12-
games: [],
13-
search: "",
14-
loading: true,
15-
};
16-
}
17-
updateSearch = (input) => {
18-
this.setState({ search: input });
8+
export default function Games(props) {
9+
const [games, setGames] = useState([]);
10+
const [search, setSearch] = useState("");
11+
12+
function updateSearch(input) {
13+
setSearch(input);
1914
const gameeurl = "https://www.speedrun.com/api/v1/games?name=" + input;
2015
//Fetch url for users
21-
this.Fetch(gameeurl);
22-
};
23-
async Fetch(gameurl) {
16+
Fetch(gameeurl);
17+
}
18+
async function Fetch(gameurl) {
2419
//Users
2520
const gameresponse = await fetch(gameurl);
2621
const gamedata = await gameresponse.json();
2722

2823
//Load data to state
29-
this.setState({
30-
loading: false,
31-
games: gamedata.data,
32-
});
33-
}
34-
35-
render() {
36-
const { search } = this.state;
37-
return (
38-
<View style={styles.container}>
39-
<SearchBar
40-
placeholder="Search for games"
41-
onChangeText={this.updateSearch}
42-
value={search}
43-
platform="ios"
44-
/>
45-
<FlatList
46-
style={styles.flatList}
47-
numColumns={3}
48-
keyExtractor={(item) => item.id}
49-
data={this.state.games}
50-
renderItem={({ item }) => (
51-
<GameCard
52-
navigation={this.props.navigation}
53-
id={item.id}
54-
abbreviation={item.abbreviation}
55-
/>
56-
)}
57-
></FlatList>
58-
</View>
59-
);
24+
setGames(gamedata.data);
6025
}
26+
return (
27+
<View style={styles.container}>
28+
<SearchBar
29+
placeholder="Search for games"
30+
onChangeText={updateSearch}
31+
value={search}
32+
platform="ios"
33+
/>
34+
<FlatList
35+
style={styles.flatList}
36+
numColumns={3}
37+
keyExtractor={(item) => item.id}
38+
data={games}
39+
renderItem={({ item }) => (
40+
<GameCard
41+
navigation={props.navigation}
42+
id={item.id}
43+
abbreviation={item.abbreviation}
44+
/>
45+
)}
46+
></FlatList>
47+
</View>
48+
);
6149
}
6250

6351
const styles = StyleSheet.create({
6452
container: {
6553
flex: 1,
66-
//marginTop: Constants.statusBarHeight,
6754
backgroundColor: colors.light,
6855
},
6956
flatList: {
@@ -72,21 +59,4 @@ const styles = StyleSheet.create({
7259
flex: 1,
7360
alignSelf: "center",
7461
},
75-
gamecontainer: {
76-
flexDirection: "row",
77-
flexWrap: "wrap",
78-
flex: 2,
79-
justifyContent: "space-around",
80-
},
81-
headercontainer: {
82-
backgroundColor: colors.primary,
83-
},
84-
headertext: {
85-
color: colors.white,
86-
fontSize: 25,
87-
padding: 15,
88-
fontWeight: "bold",
89-
alignSelf: "center",
90-
},
9162
});
92-
export default Games;

0 commit comments

Comments
 (0)