From 05d2d7d6810f58b14a804128562c844293982548 Mon Sep 17 00:00:00 2001 From: guipasmoi Date: Thu, 26 Oct 2017 18:27:36 +0200 Subject: [PATCH] Fix/cleaning (#68) * feat: progress + hoc withValidEntities * fix: eslint * fix: remove what can be * fix progress circle positioning. * temporary rollback - android settings! --- android/app/build.gradle | 30 +++++++------- app/components/common/card/styles.js | 4 -- .../common/progress}/styles.js | 0 .../layout/scrollableList/ScrollableList.js | 41 +++++++++++++++++++ .../layout/scrollableList/styles.js | 21 ++++++++++ app/components/specific/map/RaceMap.js | 4 +- .../main/athleteDetails/AthleteDetails.js | 7 ++-- app/routes/main/athleteDetails/styles.js | 10 ----- .../AthletePerformanceLevel.js | 7 ++-- app/routes/main/clubEvents/ClubEvents.js | 35 ++++++++++------ app/routes/main/clubEvents/styles.js | 15 ------- app/routes/main/clubFeed/ClubFeed.js | 8 ++-- app/routes/main/clubFeed/helper.js | 26 ++++++------ app/routes/main/clubFeed/styles.js | 10 ----- 14 files changed, 123 insertions(+), 95 deletions(-) rename app/{routes/main/athletePerformanceLevel => components/common/progress}/styles.js (100%) create mode 100644 app/components/layout/scrollableList/ScrollableList.js create mode 100644 app/components/layout/scrollableList/styles.js delete mode 100644 app/routes/main/athleteDetails/styles.js delete mode 100644 app/routes/main/clubFeed/styles.js diff --git a/android/app/build.gradle b/android/app/build.gradle index b9e87cf8..95df3671 100755 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -93,10 +93,10 @@ def enableSeparateBuildPerCPUArchitecture = false /** * Run Proguard to shrink the Java bytecode in release builds. */ -def enableProguardInReleaseBuilds = false -def keystorePropertiesFile = rootProject.file("keystore.properties") -def keystoreProperties = new Properties() -keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) + def enableProguardInReleaseBuilds = false + def keystorePropertiesFile = rootProject.file("keystore.properties") + def keystoreProperties = new Properties() + keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) android { compileSdkVersion 23 @@ -113,12 +113,12 @@ android { } } signingConfigs { - release { - keyAlias keystoreProperties['keyAlias'] - keyPassword keystoreProperties['keyPassword'] - storeFile file(keystoreProperties['storeFile']) - storePassword keystoreProperties['storePassword'] - } + release { + keyAlias keystoreProperties['keyAlias'] + keyPassword keystoreProperties['keyPassword'] + storeFile file(keystoreProperties['storeFile']) + storePassword keystoreProperties['storePassword'] + } } splits { abi { @@ -129,11 +129,11 @@ android { } } buildTypes { - release { - minifyEnabled enableProguardInReleaseBuilds - proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" - signingConfig signingConfigs.release - } + release { + minifyEnabled enableProguardInReleaseBuilds + proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" + signingConfig signingConfigs.release + } } // applicationVariants are e.g. debug, release applicationVariants.all { variant -> diff --git a/app/components/common/card/styles.js b/app/components/common/card/styles.js index af897351..037d8918 100644 --- a/app/components/common/card/styles.js +++ b/app/components/common/card/styles.js @@ -4,10 +4,6 @@ import theme from "../../../theme/theme"; export default StyleSheet.create({ containerCardStyle: { - padding: 15, - marginTop: 15, - marginLeft: 0, - marginRight: 0, borderWidth: 0 }, dividerStyle: { diff --git a/app/routes/main/athletePerformanceLevel/styles.js b/app/components/common/progress/styles.js similarity index 100% rename from app/routes/main/athletePerformanceLevel/styles.js rename to app/components/common/progress/styles.js diff --git a/app/components/layout/scrollableList/ScrollableList.js b/app/components/layout/scrollableList/ScrollableList.js new file mode 100644 index 00000000..6e1f8ab5 --- /dev/null +++ b/app/components/layout/scrollableList/ScrollableList.js @@ -0,0 +1,41 @@ +import React, { Component } from "react"; +import PropTypes from "prop-types"; +import { ScrollView, View } from "react-native"; + +import styles from "./styles"; + +// https://pawelgrzybek.com/return-multiple-elements-from-a-component-with-react-16/ +const Aux = props => props.children; + +const Separator = () => ; + +export default class ScrollableList extends Component { + static propTypes = { + children: PropTypes.node, + alignItems: PropTypes.oneOf(["center", "top", "full"]) + }; + + static defaultProps = { + children: [], + alignItems: "top" + }; + + render() { + return ( + + {this.props.children.length > 0 + ? this.props.children.map((item, index) => ( + + {item} + {this.props.children.length - 1 !== index && } + + )) + : this.props.children} + + ); + } +} diff --git a/app/components/layout/scrollableList/styles.js b/app/components/layout/scrollableList/styles.js new file mode 100644 index 00000000..d284e1e8 --- /dev/null +++ b/app/components/layout/scrollableList/styles.js @@ -0,0 +1,21 @@ +import { StyleSheet } from "react-native"; + +export default StyleSheet.create({ + container: { + flex: 1 + }, + separator: { + height: 10, + flex: 1 + }, + center: { + flex: 1, + justifyContent: "center", + alignItems: "center" + }, + top: {}, + full: { + flex: 1, + alignItems: "stretch" + } +}); diff --git a/app/components/specific/map/RaceMap.js b/app/components/specific/map/RaceMap.js index 1d8d4e66..956bb7cb 100644 --- a/app/components/specific/map/RaceMap.js +++ b/app/components/specific/map/RaceMap.js @@ -75,7 +75,7 @@ export default class RaceMap extends Component { fillColor={theme.PrimaryColor} strokeWidth={3} /> - {race.checkPoints.map(marker => + {race.checkPoints.map(marker => ( - )} + ))} {race.locations && Object.entries(race.locations).map(([id, location]) => { const coordinate = { diff --git a/app/routes/main/athleteDetails/AthleteDetails.js b/app/routes/main/athleteDetails/AthleteDetails.js index 0ed33a31..c896df65 100644 --- a/app/routes/main/athleteDetails/AthleteDetails.js +++ b/app/routes/main/athleteDetails/AthleteDetails.js @@ -1,14 +1,13 @@ import React, { Component } from "react"; import PropTypes from "prop-types"; -import { ScrollView } from "react-native"; import { connect } from "react-redux"; import { compose } from "redux"; import enhanceWithValidEntities from "../../../hocs/enhanceWithValidEntities"; import selector from "./selector"; -import styles from "./styles"; import AthleteCard from "../../../components/specific/cards/AthleteCard"; import AthletePerformancesCard from "../../../components/specific/cards/AthletePerformancesCard"; +import ScrollableList from "../../../components/layout/scrollableList/ScrollableList"; class AthleteDetails extends Component { static propTypes = { @@ -30,13 +29,13 @@ class AthleteDetails extends Component { render() { const { athlete, performances } = this.props; return ( - + 0} performances={performances} /> - + ); } } diff --git a/app/routes/main/athleteDetails/styles.js b/app/routes/main/athleteDetails/styles.js deleted file mode 100644 index 018d8f9a..00000000 --- a/app/routes/main/athleteDetails/styles.js +++ /dev/null @@ -1,10 +0,0 @@ -import { StyleSheet } from "react-native"; - -export default StyleSheet.create({ - scroll: { - marginTop: 0, - marginBottom: 0, - marginLeft: 0, - marginRight: 0 - } -}); diff --git a/app/routes/main/athletePerformanceLevel/AthletePerformanceLevel.js b/app/routes/main/athletePerformanceLevel/AthletePerformanceLevel.js index 97929722..c5e3986b 100644 --- a/app/routes/main/athletePerformanceLevel/AthletePerformanceLevel.js +++ b/app/routes/main/athletePerformanceLevel/AthletePerformanceLevel.js @@ -1,13 +1,12 @@ import React, { Component } from "react"; import PropTypes from "prop-types"; import { connect } from "react-redux"; -import { View } from "react-native"; import { compose } from "redux"; import enhanceWithValidEntities from "../../../hocs/enhanceWithValidEntities"; import selector from "./selector"; -import styles from "./styles"; import Progress from "../../../components/common/progress/Progress"; +import ScrollableList from "../../../components/layout/scrollableList/ScrollableList"; class AthletePerformanceLevel extends Component { static propTypes = { @@ -26,9 +25,9 @@ class AthletePerformanceLevel extends Component { render() { return ( - + - + ); } } diff --git a/app/routes/main/clubEvents/ClubEvents.js b/app/routes/main/clubEvents/ClubEvents.js index fc9b97fe..0c180a25 100644 --- a/app/routes/main/clubEvents/ClubEvents.js +++ b/app/routes/main/clubEvents/ClubEvents.js @@ -1,18 +1,31 @@ +/* eslint-disable react-native/no-color-literals */ import React, { Component } from "react"; import PropTypes from "prop-types"; -import { View } from "react-native"; +import { View, StyleSheet } from "react-native"; import { connect } from "react-redux"; import { compose } from "redux"; import enhanceWithValidEntities from "../../../hocs/enhanceWithValidEntities"; import CountDown from "../../../components/specific/countdown/Countdown"; -import styles from "./styles"; import selector from "./selector"; import mapDispatchToProps from "./mapDispatchToProps"; import Link from "../../../components/typography/link/Link"; import RaceMap from "../../../components/specific/map/RaceMap"; import CollapsableDrawer from "../../../components/specific/collapsableDrawer/CollapsableDrawer"; +// fix me -> remove +const styles = StyleSheet.create({ + bubble: { + // todo handle transparency theme + backgroundColor: "rgba(255,255,255,0.7)", + paddingHorizontal: 18, + paddingVertical: 12, + position: "absolute", + bottom: 20, + alignSelf: "center" + } +}); + class ClubEvents extends Component { static propTypes = { race: PropTypes.shape({ @@ -52,17 +65,15 @@ class ClubEvents extends Component { render() { const { race, clubMembers, shareLocation } = this.props; - return ( - - - - - - - Spot me! - + return [ + , + + + , + + Spot me! - ); + ]; } } diff --git a/app/routes/main/clubEvents/styles.js b/app/routes/main/clubEvents/styles.js index f126fe2a..e69de29b 100644 --- a/app/routes/main/clubEvents/styles.js +++ b/app/routes/main/clubEvents/styles.js @@ -1,15 +0,0 @@ -import { StyleSheet } from "react-native"; - -export default StyleSheet.create({ - container: { - ...StyleSheet.absoluteFillObject, - justifyContent: "flex-end", - alignItems: "center" - }, - bubble: { - // todo handle transparency theme - backgroundColor: "rgba(255,255,255,0.7)", - paddingHorizontal: 18, - paddingVertical: 12 - } -}); diff --git a/app/routes/main/clubFeed/ClubFeed.js b/app/routes/main/clubFeed/ClubFeed.js index f46b6e01..3bd466d8 100644 --- a/app/routes/main/clubFeed/ClubFeed.js +++ b/app/routes/main/clubFeed/ClubFeed.js @@ -1,18 +1,16 @@ import React, { Component } from "react"; import PropTypes from "prop-types"; import { connect } from "react-redux"; -import { ScrollView } from "react-native"; import { compose } from "redux"; import enhanceWithValidEntities from "../../../hocs/enhanceWithValidEntities"; import selector from "./selector"; -import styles from "./styles"; import ClubCard from "../../../components/specific/cards/ClubCard"; import ClubAwardsCard from "../../../components/specific/cards/ClubAwardsCard"; import ClubMembersCard from "../../../components/specific/cards/ClubMembersCard"; import ClubActivitiesCard from "../../../components/specific/cards/ClubActivitiesCard"; +import ScrollableList from "../../../components/layout/scrollableList/ScrollableList"; -// styles class ClubFeed extends Component { static propTypes = { club: PropTypes.shape({ @@ -42,12 +40,12 @@ class ClubFeed extends Component { const { club, clubMembers, activities } = this.props; return ( - + - + ); } } diff --git a/app/routes/main/clubFeed/helper.js b/app/routes/main/clubFeed/helper.js index 75390f21..67c557a5 100644 --- a/app/routes/main/clubFeed/helper.js +++ b/app/routes/main/clubFeed/helper.js @@ -1,15 +1,13 @@ -export const getIconName = (value = "") => { - const mapping = { - distance: "drive-eta", - total_elevation_gain: "landscape", - elapsed_time: "timer", - max_speed: "motorcycle", - achievement_count: "star", - elevation: "landscape", - duration: "timer", - pace: "flash-on", - "runs count": "plus-one" - }; - - return mapping[value] || "error"; +const mapping = { + distance: "drive-eta", + total_elevation_gain: "landscape", + elapsed_time: "timer", + max_speed: "motorcycle", + achievement_count: "star", + elevation: "landscape", + duration: "timer", + pace: "flash-on", + "runs count": "plus-one" }; + +export const getIconName = (value = "") => mapping[value] || "error"; diff --git a/app/routes/main/clubFeed/styles.js b/app/routes/main/clubFeed/styles.js deleted file mode 100644 index 018d8f9a..00000000 --- a/app/routes/main/clubFeed/styles.js +++ /dev/null @@ -1,10 +0,0 @@ -import { StyleSheet } from "react-native"; - -export default StyleSheet.create({ - scroll: { - marginTop: 0, - marginBottom: 0, - marginLeft: 0, - marginRight: 0 - } -});