diff --git a/README.md b/README.md index 2925434..bb52649 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,12 @@ Second terminal: npm run android ``` +## Build apk + +``` +./build-apk.sh +``` + ## Version release ``` diff --git a/build-apk.sh b/build-apk.sh new file mode 100755 index 0000000..ea7ac15 --- /dev/null +++ b/build-apk.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +cd android +./gradlew bundleRelease +cd .. + +bta='https://github.com/google/bundletool/releases/download/1.4.0/bundletool-all-1.4.0.jar' +btl='/tmp/bundletool-all-1.4.0.jar' + +if [ ! -f "$btl" ]; then + wget $bta -O $btl +fi + +apks='myapp.apks' + +java -jar "$btl" build-apks \ + --bundle="android/app/build/outputs/bundle/release/app-release.aab" \ + --output="$apks" \ + --ks="android/app/my-upload-key.keystore" \ + --ks-pass=pass:123456 \ + --ks-key-alias=my-key-alias \ + --key-pass=pass:123456 \ + --mode=universal + +apkname=$(cat package.json | jq -r '.name') +apkname="$apkname-$(cat package.json | jq -r '.version').apk" + +unzip -p $apks universal.apk > $apkname +rm $apks diff --git a/components/NewsItem.js b/components/NewsItem.js new file mode 100644 index 0000000..da7d5ff --- /dev/null +++ b/components/NewsItem.js @@ -0,0 +1,94 @@ +import {Linking, SafeAreaView, ScrollView, StyleSheet, Text, View} from "react-native"; +import React from "react"; +import Image from "react-native-scalable-image"; +import {Dev_Width, lpuColor, textColor, transparent} from "./Const"; +import HTMLView from "react-native-htmlview"; +import IoniIcons from "react-native-vector-icons/Ionicons"; + +export default function NewsItem(props) { + + const content = props.content; + const setContent = props.setContentFn; + + return ( + + + + {content.title} + + + + + + setContent({})} + backgroundColor={transparent} + underlayColor={transparent} + size={30} + borderRadius={0} + iconStyle={styles.noMargin} + color={lpuColor} + >Wróć do listy + + Linking.openURL(content.id)} + backgroundColor={transparent} + underlayColor={transparent} + size={30} + borderRadius={0} + iconStyle={styles.noMargin} + color={lpuColor} + >Zobacz na stronie + + + + ) +} + +const htmlStyles = StyleSheet.create({ + p: { + fontSize: 15, + color: textColor, + textAlign: 'justify', + }, + pre: { + fontSize: 15, + color: textColor, + textAlign: 'justify', + }, + marginBottom: 10, +}); + +const styles = StyleSheet.create({ + view: { + width: Dev_Width, + flex: 1, + flexDirection: 'column', + backgroundColor: transparent, + justifyContent: 'space-between', + }, + content: { + paddingLeft: 10, + paddingRight: 10, + }, + buttons: { + flexDirection: 'row', + justifyContent: 'space-between', + }, + title: { + color: textColor, + fontSize: 25, + fontWeight: '500', + marginTop: 10, + marginBottom: 10, + }, + news: { + marginTop: 15, + }, +}); diff --git a/components/RssReader.js b/components/RssReader.js index 08e6bd8..dd19bfe 100644 --- a/components/RssReader.js +++ b/components/RssReader.js @@ -1,19 +1,18 @@ import React, {useEffect, useState} from 'react'; import { BackHandler, - Linking, RefreshControl, SafeAreaView, ScrollView, StyleSheet, Text, TouchableHighlight, - View + View, } from "react-native"; -import {bgLighter, Dev_Height, Dev_Width, lpuColor, textColor, transparent} from "./Const"; +import {Dev_Height, Dev_Width, lpuColor, textColor, transparent} from "./Const"; import * as rssParser from 'react-native-rss-parser'; -import HTMLView from 'react-native-htmlview'; -import IoniIcons from "react-native-vector-icons/Ionicons"; +import Image from 'react-native-scalable-image'; +import NewsItem from "./NewsItem"; export default function RssReader(props) { @@ -21,13 +20,27 @@ export default function RssReader(props) { const [refreshing, setRefreshing] = useState(false); const [content, setContent] = useState({}); + const minRes = '-390x220' + async function fetchNews() { setRefreshing(true); await fetch('https://lpu24.pl/feed/') .then((response) => response.text()) .then((responseData) => rssParser.parse(responseData)) .then((rss) => { - setNews(rss.items); + const withImages = rss.items.map((it) => { + const url = it.enclosures[0].url; + const lastDot = url.lastIndexOf('.'); + const ext = url.substr(lastDot); + const file = url.substr(0, lastDot); + return { + ...it, + smallImg: {uri: file + minRes + ext}, + bigImg: {uri: url}, + } + }) + + setNews(withImages); return setRefreshing(false); }) } @@ -49,69 +62,40 @@ export default function RssReader(props) { return () => BackHandler.removeEventListener("hardwareBackPress", bh); }, [content]); + function Divider(props) { + if (props.idx === news.length - 1) { + return () + } else { + return () + } + } + + if (!!content.title) { return ( - - - - {content.title} - - - - - - setContent({})} - backgroundColor={transparent} - underlayColor={transparent} - size={30} - borderRadius={0} - iconStyle={styles.noMargin} - color={lpuColor} - >Wróć do listy - - Linking.openURL(content.id)} - backgroundColor={transparent} - underlayColor={transparent} - size={30} - borderRadius={0} - iconStyle={styles.noMargin} - color={lpuColor} - >Zobacz na stronie - - - + ) } else { return ( - }> { - news.map(el => ( - { - // console.log(el); - setContent(el); - }} - > - - - {el.title} - - - {el.description} - - + news.map((el, idx) => ( + setContent(el)}> + + + + + + {el.title} + + + + {el.description} + + + )) @@ -122,34 +106,7 @@ export default function RssReader(props) { } } - -const htmlStyles = StyleSheet.create({ - p: { - fontSize: 15, - color: textColor, - textAlign: 'justify', - }, - pre: { - fontSize: 15, - color: textColor, - textAlign: 'justify', - }, - marginBottom: 10, -}); - const styles = StyleSheet.create({ - contentContainer: { - height: Dev_Height, - width: Dev_Width, - flex: 1, - flexDirection: 'column', - backgroundColor: transparent, - paddingTop: 10, - paddingLeft: 10, - paddingRight: 10, - paddingBottom: 10, - justifyContent: 'space-between', - }, listContainer: { height: Dev_Height, width: Dev_Width, @@ -158,35 +115,33 @@ const styles = StyleSheet.create({ alignContent: 'space-between', justifyContent: 'space-between', backgroundColor: transparent, - paddingTop: 10, - paddingLeft: 10, - paddingRight: 10, - paddingBottom: 10, - }, - buttons: { - flexDirection: 'row', - justifyContent: 'space-between', }, title: { color: textColor, - fontSize: 25, + fontSize: 20, fontWeight: '500', - marginBottom: 5, + marginLeft: 10, + width: (Dev_Width - 30) * 0.7, }, desc: { + marginTop: 10, textAlign: 'justify', - fontSize: 15, color: textColor, - marginBottom: 10, }, news: { + paddingLeft: 10, + paddingRight: 10, + marginBottom: 15, marginTop: 15, }, + newsRow: { + flex: 1, + flexDirection: 'row', + }, hr: { - marginTop: 15, marginLeft: 50, marginRight: 50, - borderBottomColor: bgLighter, + borderBottomColor: lpuColor, borderBottomWidth: 1, } });