Skip to content

Commit

Permalink
cleanup and reformatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Gurupreet committed Sep 17, 2021
1 parent d4f7b2f commit 2d11d4a
Show file tree
Hide file tree
Showing 15 changed files with 3,921 additions and 56 deletions.
3,867 changes: 3,866 additions & 1 deletion animations/lottie/src/main/assets/success.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
package com.guru.composecookbook.lottie

import android.animation.ValueAnimator
import android.content.Context
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.viewinterop.AndroidView
import com.airbnb.lottie.LottieAnimationView
import com.airbnb.lottie.compose.LottieCompositionSpec
import com.airbnb.lottie.compose.rememberLottieComposition
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.airbnb.lottie.compose.LottieAnimation
import com.airbnb.lottie.compose.LottieCompositionSpec
import com.airbnb.lottie.compose.rememberLottieComposition


@Composable
Expand All @@ -24,7 +19,11 @@ fun LottieLoadingView(
iterations: Int = 10
) {
val composition by rememberLottieComposition(LottieCompositionSpec.Asset(file))
LottieAnimation(composition, modifier = modifier.defaultMinSize(300.dp), iterations = iterations)
LottieAnimation(
composition,
modifier = modifier.defaultMinSize(300.dp),
iterations = iterations
)

// OLD ANDROID VIEW IMPLEMENTATION
// val lottieView = remember {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/guru/composecookbook/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.guru.composecookbook

import com.guru.composecookbook.ui.animation.AnimationScreen
import FaIcons
import android.os.Bundle
import androidx.activity.ComponentActivity
Expand All @@ -22,6 +21,7 @@ import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.tooling.preview.Preview
import com.google.android.gms.ads.MobileAds
import com.guru.composecookbook.theme.*
import com.guru.composecookbook.ui.animation.AnimationScreen
import com.guru.composecookbook.ui.demoapps.DemoUIList
import com.guru.composecookbook.ui.home.HomeScreen
import com.guru.composecookbook.ui.learnwidgets.WidgetScreen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,22 @@ package com.guru.composecookbook.ui.home.dialogs

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.FavoriteBorder
import androidx.compose.material.icons.filled.List
import androidx.compose.material.icons.filled.PlayArrow
import androidx.compose.runtime.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTag
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.guru.composecookbook.spotify.R
import com.guru.composecookbook.theme.graySurface
import com.guru.composecookbook.theme.typography
import com.guru.composecookbook.ui.home.lists.VerticalListView
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch

Expand All @@ -54,7 +45,7 @@ fun BottomSheetDrawer() {
PlayerBottomSheet()
},
drawerContent = {
DrawerContent()
DrawerContent()
},
scaffoldState = bottomSheetScaffoldState,
sheetPeekHeight = if (sheetState.isAnimationRunning || sheetState.isVisible) 0.dp else 65
Expand Down Expand Up @@ -125,26 +116,32 @@ fun BottomSheetContent() {

@Composable
fun DrawerContent() {
Row(modifier = Modifier
.fillMaxWidth()
.padding(16.dp), horizontalArrangement = Arrangement
.SpaceBetween) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp), horizontalArrangement = Arrangement
.SpaceBetween
) {
Text(text = "Item 1")
Icon(imageVector = Icons.Default.List, contentDescription = "List")
}

Row(modifier = Modifier
.fillMaxWidth()
.padding(16.dp), horizontalArrangement = Arrangement
.SpaceBetween) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp), horizontalArrangement = Arrangement
.SpaceBetween
) {
Text(text = "Item 2")
Icon(imageVector = Icons.Default.List, contentDescription = "List")
}

Row(modifier = Modifier
.fillMaxWidth()
.padding(16.dp), horizontalArrangement = Arrangement
.SpaceBetween) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp), horizontalArrangement = Arrangement
.SpaceBetween
) {
Text(text = "Item 3")
Icon(imageVector = Icons.Default.List, contentDescription = "List")
}
Expand Down Expand Up @@ -195,5 +192,5 @@ fun PlayerBottomSheet() {
"And that you'd be reminded that for me, it isn't over",
modifier = Modifier.padding(16.dp)
)

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import com.guru.composecookbook.theme.purple200
import com.guru.composecookbook.theme.typography
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import okhttp3.internal.wait

@ExperimentalMaterialApi
@ExperimentalAnimationApi
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.guru.composecookbook.ui.templates

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.os.Bundle
Expand Down Expand Up @@ -34,7 +33,7 @@ class TemplatesActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
// val prompt = createBiometricPrompt(this as FragmentActivity)
// val prompt = createBiometricPrompt(this as FragmentActivity)
setContent {
ComposeCookBookTheme(darkTheme = darkTheme) {
TemplateApp(templateType)
Expand Down Expand Up @@ -78,7 +77,7 @@ private fun createBiometricPrompt(activity: FragmentActivity): BiometricPrompt {
super.onAuthenticationError(errorCode, errString)
if (errorCode == BiometricPrompt.ERROR_NEGATIVE_BUTTON) {
//loginWithPassword() // Because in this app, the negative button allows the user
// to enter an account password. This is completely optional and your app doesn’t have to do it.
// to enter an account password. This is completely optional and your app doesn’t have to do it.
}
}

Expand All @@ -89,7 +88,7 @@ private fun createBiometricPrompt(activity: FragmentActivity): BiometricPrompt {
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
super.onAuthenticationSucceeded(result)
// Proceed with viewing the private encrypted message.
// showEncryptedMessage(result.cryptoObject)
// showEncryptedMessage(result.cryptoObject)
}
}
val biometricPrompt = BiometricPrompt(activity, executor, callback)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fun Pager(

Layout(
content = {
state.PrepareContent(offscreenLimit = offscreenLimit){
state.PrepareContent(offscreenLimit = offscreenLimit) {
content.invoke(this)
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class PagerState(
suspend fun fling(velocity: Float) {
if (velocity < 0 && currentPage == maxPage) {
currentPage = minPage
}else if (velocity > 0 && currentPage == minPage) return
} else if (velocity > 0 && currentPage == minPage) return

_currentPageOffset.animateTo(currentPageOffset.roundToInt().toFloat())
selectPage()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
package com.guru.composecookbook.charts

import androidx.compose.animation.core.*
import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.FastOutSlowInEasing
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.tween
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.*
import androidx.compose.runtime.*
import androidx.compose.material.Card
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Scaffold
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ sealed class HomeScreenItems {
object AndroidViews : HomeScreenItems()
object PullRefresh : HomeScreenItems()
object CustomFling : HomeScreenItems()
object MotionLayout: HomeScreenItems()
object MotionLayout : HomeScreenItems()

val name: String
get() = when (this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class DatingHomeViewModel : ViewModel() {
getAlbums()
}

private fun getAlbums(){
private fun getAlbums() {
_albumLiveData.value = AlbumsDataProvider.albums.take(15).toMutableList()
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.guru.pinlock

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.*
import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
Expand Down
2 changes: 1 addition & 1 deletion templates/pinlock/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<activity
android:name=".BiometricActivity"
android:exported="true"
android:theme="@style/Theme.Transparent"/>
android:theme="@style/Theme.Transparent" />
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ fun PinLockView() {
Column(
modifier = Modifier
.fillMaxSize()
.background(MaterialTheme.colors.primary), horizontalAlignment = Alignment.CenterHorizontally
.background(MaterialTheme.colors.primary),
horizontalAlignment = Alignment.CenterHorizontally
) {
Spacer(modifier = Modifier.height(100.dp))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.guru.pinlock

import org.junit.Test

import org.junit.Assert.*
import org.junit.Test

/**
* Example local unit test, which will execute on the development machine (host).
Expand Down

0 comments on commit 2d11d4a

Please sign in to comment.