Skip to content

Commit

Permalink
Merge 8b50f20 into 86e7714
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamMc331 committed Apr 27, 2022
2 parents 86e7714 + 8b50f20 commit 6277f47
Show file tree
Hide file tree
Showing 29 changed files with 270 additions and 194 deletions.
1 change: 0 additions & 1 deletion android-design-system/.gitignore

This file was deleted.

54 changes: 0 additions & 54 deletions android-design-system/build.gradle.kts

This file was deleted.

Empty file.
21 changes: 0 additions & 21 deletions android-design-system/proguard-rules.pro

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions android-design-system/src/main/AndroidManifest.xml

This file was deleted.

This file was deleted.

4 changes: 0 additions & 4 deletions android-design-system/src/main/res/values/dimens.xml

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ android {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
namespace = "com.adammcneilly.pocketleague"
}

dependencies {

implementation(project(":android-design-system"))
implementation(project(":shared"))
implementation("org.jetbrains.kotlinx:kotlinx-datetime:${Versions.kotlinxDatetime}")
implementation("androidx.core:core-ktx:${Versions.ktxCore}")
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.adammcneilly.pocketleague">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.graphics.Color
import androidx.core.view.WindowCompat
import com.adammcneilly.pocketleague.android.design.theme.PocketLeagueTheme
import com.adammcneilly.pocketleague.ui.MainComposable
import com.adammcneilly.pocketleague.ui.theme.PocketLeagueTheme
import com.google.accompanist.insets.ProvideWindowInsets
import com.google.accompanist.systemuicontroller.rememberSystemUiController
import dagger.hilt.android.AndroidEntryPoint
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
package com.adammcneilly.pocketleague.ui

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import com.adammcneilly.pocketleague.shared.models.CoreStats
import com.adammcneilly.pocketleague.ui.theme.rlcsBlue
import com.adammcneilly.pocketleague.ui.theme.rlcsOrange

/**
* A composable to compare the [CoreStats] between two teams.
*/
@Composable
fun CoreStatsComparison(
blueTeamStats: CoreStats,
orangeTeamStats: CoreStats,
modifier: Modifier = Modifier,
) {
Column(
modifier = modifier
.fillMaxWidth(),
verticalArrangement = Arrangement.spacedBy(8.dp),
) {
StatComparisonRow(
title = "Goals",
blueValue = blueTeamStats.goals.toFloat(),
orangeValue = orangeTeamStats.goals.toFloat(),
)

StatComparisonRow(
title = "Saves",
blueValue = blueTeamStats.saves.toFloat(),
orangeValue = orangeTeamStats.saves.toFloat(),
)

StatComparisonRow(
title = "Shots",
blueValue = blueTeamStats.shots.toFloat(),
orangeValue = orangeTeamStats.shots.toFloat(),
)
}
}

@Composable
private fun StatComparisonRow(
title: String,
blueValue: Float,
orangeValue: Float,
) {
Column(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(8.dp),
) {
Text(
text = title,
)

BoxWithConstraints {
val total = blueValue + orangeValue
val blueWeight = blueValue / total
val orangeWeight = orangeValue / total

val statBarHeight = 4.dp
val dividerHeight = 12.dp
val dividerWidth = 4.dp

val availableWidth = this.maxWidth - dividerWidth
val blueWidth = availableWidth * blueWeight
val orangeWidth = availableWidth * orangeWeight

Row(
verticalAlignment = Alignment.CenterVertically,
) {
Box(
modifier = Modifier
.background(
color = rlcsBlue,
shape = RoundedCornerShape(
topStartPercent = 50,
bottomStartPercent = 50,
),
)
.size(
width = blueWidth,
height = statBarHeight,
)
)

Box(
modifier = Modifier
.background(color = Color.White)
.size(
width = dividerWidth,
height = dividerHeight,
),
)

Box(
modifier = Modifier
.background(
color = rlcsOrange,
shape = RoundedCornerShape(
topEndPercent = 50,
bottomEndPercent = 50,
),
)
.height(statBarHeight)
.width(orangeWidth)
)
}
}
}
}
Loading

0 comments on commit 6277f47

Please sign in to comment.