Browse Source

add banner component

feature/admob
dslak 2 years ago
parent
commit
80233c9447
  1. 40
      vds-app/App/components/Banner.js
  2. 18
      vds-app/App/screens/Dictionary.js
  3. 9
      vds-app/App/screens/Quiz.js
  4. 8
      vds-app/App/screens/Recap.js
  5. 8
      vds-app/App/screens/RecapTrueFalse.js
  6. 33
      vds-app/App/screens/Splash.js
  7. 9
      vds-app/App/screens/TrueFalse.js
  8. 18
      vds-app/app.json
  9. 1
      vds-app/babel.config.js
  10. 11
      vds-app/package.json

40
vds-app/App/components/Banner.js

@ -1,54 +1,26 @@
import React from "react" import React from "react"
import { View, StyleSheet, StatusBar, Text, Dimensions } from "react-native" import { View, StyleSheet, StatusBar, Text, Dimensions } from "react-native"
//import { AdMobBanner, AdMobInterstitial, PublisherBanner, AdMobRewarded } from "expo-ads-admob"
import { colors, texts, credentials } from "./Variables" import { colors, texts, credentials } from "./Variables"
import { BannerAd, BannerAdSize, TestIds } from 'react-native-google-mobile-ads';
import { BannerAd, BannerAdSize, TestIds } from 'react-native-google-mobile-ads'
const adUnitId = __DEV__ ? TestIds.INTERSTITIAL : 'ca-app-pub-4145771316565790~1876877627'
const adUnitId = __DEV__ ? TestIds.INTERSTITIAL : 'ca-app-pub-4145771316565790~1876877627';
/*
<BannerAd
unitId={adUnitId}
size={BannerAdSize.FULL_BANNER}
requestOptions={{
requestNonPersonalizedAdsOnly: true,
}}
/>
*/
const screen = Dimensions.get("window") const screen = Dimensions.get("window")
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: { container: {
backgroundColor: colors.yellow,
position: "absolute",
bottom: 0,
left: 0,
right: 0,
//backgroundColor: colors.yellow,
flex: 1, flex: 1,
alignItems: "center", alignItems: "center",
justifyContent: "center"
},
title: {
color: colors.white,
fontSize: 25,
textAlign: "center",
fontWeight: "600",
paddingVertical: 20
},
banner: {
width: "100%",
height: "100%",
justifyContent: "center",
marginVertical: 20 marginVertical: 20
},
}
}) })
export const Banner = () => { export const Banner = () => {
return ( return (
<View style={styles.container}> <View style={styles.container}>
<Text>BANNER...</Text>
<BannerAd size={BannerAdSize.ADAPTIVE_BANNER} unitId={adUnitId} />
</View> </View>
) )
} }

18
vds-app/App/screens/Dictionary.js

@ -3,6 +3,7 @@ import { View, ScrollView, StyleSheet, StatusBar, Text, Dimensions, ImageBackgro
import SafeAreaView from 'react-native-safe-area-view' import SafeAreaView from 'react-native-safe-area-view'
import { Button, ButtonContainer } from "../components/Button" import { Button, ButtonContainer } from "../components/Button"
import { Banner } from "../components/Banner"
import { colors, texts, credentials} from "../components/Variables" import { colors, texts, credentials} from "../components/Variables"
import { abbreviations, alphabeth, numbers} from "../data/dictionary" import { abbreviations, alphabeth, numbers} from "../data/dictionary"
@ -98,8 +99,6 @@ const styles = StyleSheet.create({
fontSize: 26, fontSize: 26,
fontWeight: "600" fontWeight: "600"
}, },
box: { box: {
width: screen.width-40, width: screen.width-40,
paddingHorizontal: 20, paddingHorizontal: 20,
@ -108,12 +107,10 @@ const styles = StyleSheet.create({
borderRadius: 10, borderRadius: 10,
overflow: "hidden" overflow: "hidden"
}, },
scrollView: { scrollView: {
margin: 10, margin: 10,
height: screen.height-400 height: screen.height-400
}, },
bg: { bg: {
width: "100%", width: "100%",
height: "100%" height: "100%"
@ -121,15 +118,7 @@ const styles = StyleSheet.create({
bannerContainer: { bannerContainer: {
flex: 1, flex: 1,
alignItems: "center", alignItems: "center",
justifyContent: "center",
height: 60
},
banner: {
flex: 1,
alignItems: "center",
justifyContent: "center",
width: 320,
height: 60
justifyContent: "center"
} }
}) })
@ -231,9 +220,8 @@ class Dictionary extends React.Component {
</ScrollView> </ScrollView>
</View> </View>
</View> </View>
<View style={styles.bannerContainer}> <View style={styles.bannerContainer}>
<Text>BANNER</Text>
<Banner />
</View> </View>
</SafeAreaView> </SafeAreaView>
</View> </View>

9
vds-app/App/screens/Quiz.js

@ -5,6 +5,7 @@ import SafeAreaView from 'react-native-safe-area-view'
import AsyncStorage from '@react-native-async-storage/async-storage' import AsyncStorage from '@react-native-async-storage/async-storage'
import { Button, ButtonContainer } from "../components/Button" import { Button, ButtonContainer } from "../components/Button"
import { Banner } from "../components/Banner"
import { texts, colors, credentials } from "../components/Variables" import { texts, colors, credentials } from "../components/Variables"
const bgImage = require("../assets/bg.jpg") const bgImage = require("../assets/bg.jpg")
@ -76,12 +77,6 @@ const styles = StyleSheet.create({
flex: 1, flex: 1,
alignItems: "center", alignItems: "center",
justifyContent: "center" justifyContent: "center"
},
banner: {
flex: 1,
alignItems: "center",
justifyContent: "center",
width: 320
} }
}) })
@ -268,7 +263,7 @@ class Quiz extends React.Component {
</View> </View>
<View style={styles.bannerContainer}> <View style={styles.bannerContainer}>
<Text>BANNER</Text>
<Banner />
</View> </View>
</ImageBackground> </ImageBackground>
) )

8
vds-app/App/screens/Recap.js

@ -4,6 +4,7 @@ import SafeAreaView from 'react-native-safe-area-view'
import AsyncStorage from '@react-native-async-storage/async-storage' import AsyncStorage from '@react-native-async-storage/async-storage'
import { Button, ButtonContainer } from "../components/Button" import { Button, ButtonContainer } from "../components/Button"
import { Banner } from "../components/Banner"
import { colors, texts, examScheme, credentials } from "../components/Variables" import { colors, texts, examScheme, credentials } from "../components/Variables"
import aerodynamicsQuestions from "../data/aerodynamics" import aerodynamicsQuestions from "../data/aerodynamics"
@ -96,11 +97,6 @@ const styles = StyleSheet.create({
flex: 1, flex: 1,
alignItems: "center", alignItems: "center",
justifyContent: "center" justifyContent: "center"
},
banner: {
width: 320,
height: 100,
marginVertical: 20
} }
}) })
@ -196,7 +192,7 @@ class Recap extends React.Component {
</SafeAreaView> </SafeAreaView>
<View style={styles.bannerContainer}> <View style={styles.bannerContainer}>
<Text>BANNER</Text>
<Banner />
</View> </View>
</ScrollView> </ScrollView>

8
vds-app/App/screens/RecapTrueFalse.js

@ -4,6 +4,7 @@ import SafeAreaView from 'react-native-safe-area-view'
import AsyncStorage from '@react-native-async-storage/async-storage' import AsyncStorage from '@react-native-async-storage/async-storage'
import { Button, ButtonContainer } from "../components/Button" import { Button, ButtonContainer } from "../components/Button"
import { Banner } from "../components/Banner"
import { colors, texts, examScheme, credentials } from "../components/Variables" import { colors, texts, examScheme, credentials } from "../components/Variables"
import aerodynamicsQuestions from "../data/aerodynamics" import aerodynamicsQuestions from "../data/aerodynamics"
@ -96,11 +97,6 @@ const styles = StyleSheet.create({
flex: 1, flex: 1,
alignItems: "center", alignItems: "center",
justifyContent: "center" justifyContent: "center"
},
banner: {
width: 320,
height: 100,
marginVertical: 20
} }
}) })
@ -190,7 +186,7 @@ class RecapTrueFalse extends React.Component {
</SafeAreaView> </SafeAreaView>
<View style={styles.bannerContainer}> <View style={styles.bannerContainer}>
<Text>BANNER</Text>
<Banner />
</View> </View>
</ScrollView> </ScrollView>

33
vds-app/App/screens/Splash.js

@ -20,25 +20,6 @@ const styles = StyleSheet.create({
backgroundColor: colors.dark_blue, backgroundColor: colors.dark_blue,
flex: 1 flex: 1
}, },
bannerContainer: {
backgroundColor: colors.dark_blue,
flex: 1,
alignItems: "center",
justifyContent: "center"
},
bannerExpanded: {
backgroundColor: colors.dark_blue,
height: screen.height-230
},
bannerCollapsed: {
backgroundColor: colors.dark_blue,
height: 300
},
banner: {
width: 300,
height: 250,
marginVertical: 20
},
title: { title: {
color: colors.white, color: colors.white,
fontSize: 25, fontSize: 25,
@ -77,6 +58,11 @@ const styles = StyleSheet.create({
}, },
header: { header: {
width: "100%" width: "100%"
},
bannerContainer: {
flex: 1,
alignItems: "center",
justifyContent: "center"
} }
}) })
@ -280,15 +266,10 @@ class Splash extends React.Component {
</View> </View>
</SafeAreaView> </SafeAreaView>
<View style={[styles.bannerContainer, !this.state.bannerExpanded ? styles.bannerCollapsed : {}]}>
<View style={styles.bannerContainer}>
<Banner /> <Banner />
{
this.state.bannerExpanded ? (
<Text style={styles.timer}>{this.state.timer}</Text>
) : null
}
</View> </View>
</ScrollView> </ScrollView>
) )
} }

9
vds-app/App/screens/TrueFalse.js

@ -3,6 +3,7 @@ import { View, ScrollView, StyleSheet, StatusBar, Text, Dimensions, ImageBackgro
import SafeAreaView from 'react-native-safe-area-view' import SafeAreaView from 'react-native-safe-area-view'
import { Button, ButtonContainer } from "../components/Button" import { Button, ButtonContainer } from "../components/Button"
import { Banner } from "../components/Banner"
import { texts, colors, examScheme, credentials } from "../components/Variables" import { texts, colors, examScheme, credentials } from "../components/Variables"
import aerodynamicsQuestions from "../data/aerodynamics" import aerodynamicsQuestions from "../data/aerodynamics"
@ -85,12 +86,6 @@ const styles = StyleSheet.create({
flex: 1, flex: 1,
alignItems: "center", alignItems: "center",
justifyContent: "center" justifyContent: "center"
},
banner: {
flex: 1,
alignItems: "center",
justifyContent: "center",
width: 320
} }
}) })
@ -256,7 +251,7 @@ class Quiz extends React.Component {
</View> </View>
</View> </View>
<View style={styles.bannerContainer}> <View style={styles.bannerContainer}>
<Text>BANNER</Text>
<Banner />
</View> </View>
</ImageBackground> </ImageBackground>
) )

18
vds-app/app.json

@ -1,4 +1,6 @@
{ {
"displayName": "VDS Quiz",
"name": "VDS Quiz",
"expo": { "expo": {
"name": "VDS Quiz", "name": "VDS Quiz",
"slug": "VDS-Quiz", "slug": "VDS-Quiz",
@ -8,7 +10,7 @@
"android", "android",
"web" "web"
], ],
"version": "3.7.0",
"version": "3.7.3",
"orientation": "portrait", "orientation": "portrait",
"icon": "./assets/icon.png", "icon": "./assets/icon.png",
"splash": { "splash": {
@ -27,7 +29,7 @@
"icon": "./assets/icon.png", "icon": "./assets/icon.png",
"package": "com.dslak.vdsquiz", "package": "com.dslak.vdsquiz",
"permissions": [], "permissions": [],
"versionCode": 22
"versionCode": 26
}, },
"ios": { "ios": {
"icon": "./assets/iconIOS.png", "icon": "./assets/iconIOS.png",
@ -59,8 +61,12 @@
] ]
}, },
"react-native-google-mobile-ads": { "react-native-google-mobile-ads": {
"android_app_id": "ca-app-pub-4145771316565790~1876877627"
},
"displayName": "VDS Quiz",
"name": "VDS Quiz"
"android_app_id": "ca-app-pub-3940256099942544~3347511713",
"ios_app_id": "ca-app-pub-3940256099942544~1458002511",
"delay_app_measurement_init": false,
"optimize_initialization": true,
"optimize_ad_loading": true,
"user_tracking_usage_description": "This identifier will be used to deliver personalized ads to you."
}
} }

1
vds-app/babel.config.js

@ -1,6 +1,7 @@
module.exports = function(api) { module.exports = function(api) {
api.cache(true) api.cache(true)
return { return {
plugins: ['react-native-reanimated/plugin'],
presets: ['babel-preset-expo'] presets: ['babel-preset-expo']
} }
} }

11
vds-app/package.json

@ -1,6 +1,6 @@
{ {
"name": "vds-quiz", "name": "vds-quiz",
"version": "3.7.0",
"version": "3.7.3",
"license": "MIT", "license": "MIT",
"main": "node_modules/expo/AppEntry.js", "main": "node_modules/expo/AppEntry.js",
"scripts": { "scripts": {
@ -9,6 +9,7 @@
"web": "expo start --web", "web": "expo start --web",
"build-android-old": "expo build:android -t app-bundle", "build-android-old": "expo build:android -t app-bundle",
"build-android": "eas build -p android", "build-android": "eas build -p android",
"build-android-local": "eas build -p android --profile preview",
"build-ios": "expo build:ios", "build-ios": "expo build:ios",
"ios": "expo start --ios", "ios": "expo start --ios",
"eject": "expo eject", "eject": "expo eject",
@ -16,9 +17,10 @@
}, },
"dependencies": { "dependencies": {
"@expo/config-plugins": "^6.0.1", "@expo/config-plugins": "^6.0.1",
"@react-native-async-storage/async-storage": "^1.17.11",
"@react-native-admob/admob": "^2.0.1",
"@react-native-async-storage/async-storage": "1.17.11",
"@react-native-masked-view/masked-view": "^0.2.8", "@react-native-masked-view/masked-view": "^0.2.8",
"@react-native-picker/picker": "^2.4.8",
"@react-native-picker/picker": "2.4.8",
"expo": "^48.0.8", "expo": "^48.0.8",
"expo-build-properties": "~0.5.1", "expo-build-properties": "~0.5.1",
"expo-dev-client": "~2.1.6", "expo-dev-client": "~2.1.6",
@ -38,11 +40,10 @@
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.20.0", "@babel/core": "^7.20.0",
"@react-native-community/masked-view": "^0.1.11",
"@babel/preset-env": "^7.20.2",
"babel-preset-expo": "^9.3.0", "babel-preset-expo": "^9.3.0",
"eslint": "^8.36.0", "eslint": "^8.36.0",
"eslint-config-handlebarlabs": "^0.0.6", "eslint-config-handlebarlabs": "^0.0.6",
"@babel/preset-env": "^7.20.2",
"prettier": "^2.8.6" "prettier": "^2.8.6"
}, },
"peerDependencies": { "peerDependencies": {

Loading…
Cancel
Save