Skip to content

Commit

Permalink
Merge pull request #4 from ImaginativeShohag/dev
Browse files Browse the repository at this point in the history
More sample
  • Loading branch information
ImaginativeShohag authored Dec 15, 2021
2 parents ffe5bc2 + 7e9a8d0 commit 6cd02bc
Show file tree
Hide file tree
Showing 31 changed files with 1,681 additions and 41 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,21 @@ Feel free to request features or suggestions for improvements.
- Counter with ViewModel (Beginner)
- AnimatedVisibility (Beginner)
- Lottie (Beginner)
- Select image and crop for upload (Intermediate)
- Capture image and crop for upload (Intermediate)
- Permission (Beginner)

| ![Preview](images/counter.gif) | ![Preview](images/animated-visibility.gif) | ![Preview](images/lottie.gif) |
| :------: | :------: | :------: |

# TODO

- [ ] Tutorial: Select image for upload
- [ ] Tutorial: Permission
- [x] Composition: Bottom Navigation
- [ ] Composition: Dialog
- [x] Composition: Text
- [x] Tutorial: Select image and crop for upload
- [x] Tutorial: Capture image and crop for upload
- [x] Tutorial: Permission
- [ ] Tutorial: ExoPlayer sample
- [ ] Tutorial: Data fetch and LazyColumn
- [ ] Tutorial: Navigation
Expand Down Expand Up @@ -88,6 +95,9 @@ MAPS_API_KEY=YOUR_API_KEY

## Other Interesting Repos

- [Compose Material Catalog](https://github.com/androidx/androidx/tree/androidx-main/compose/integration-tests/material-catalog)
- [Official Compose Samples](https://github.com/android/compose-samples)
- [ChrisBanes/Tivi](https://github.com/chrisbanes/tivi)
- [Gurupreet/ComposeCookBook](https://github.com/Gurupreet/ComposeCookBook)
- [spencergriffin/exoplayer-compose](https://github.com/spencergriffin/exoplayer-compose)
- [godaddy/compose-color-picker](https://github.com/godaddy/compose-color-picker)
Expand Down
8 changes: 7 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ dependencies {
androidTestImplementation(Libs.AndroidX.Test.Ext.junit)
androidTestImplementation(Libs.AndroidX.Test.espressoCore)
androidTestImplementation(Libs.AndroidX.Compose.uiTest)
androidTestImplementation(Libs.AndroidX.Compose.uiTestManifest)

// ----------------------------------------------------------------
// Compose
Expand Down Expand Up @@ -171,7 +172,8 @@ dependencies {
implementation(Libs.AndroidX.Room.ktx)

// Coil
implementation(Libs.coil)
implementation(Libs.Coil.compose)
implementation(Libs.Coil.svg)

// Paging
implementation(Libs.AndroidX.Paging.runtime)
Expand All @@ -192,7 +194,11 @@ dependencies {
implementation(Libs.Google.Maps.core)
implementation(Libs.Google.Maps.utils)

// Lottie
implementation(Libs.Airbnb.Lottie.compose)

// uCrop
implementation(Libs.Yalantis.uCrop)
}

kapt {
Expand Down
7 changes: 6 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile

# uCrop
-dontwarn com.yalantis.ucrop**
-keep class com.yalantis.ucrop** { *; }
-keep interface com.yalantis.ucrop** { *; }
24 changes: 20 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright 2021 Md. Mahmudul Hasan Shohag
~
~ Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -34,6 +33,15 @@
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

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

<queries>
<intent>
<action android:name="android.media.action.IMAGE_CAPTURE" />
</intent>
</queries>

<application
android:name=".App"
android:allowBackup="false"
Expand All @@ -47,9 +55,10 @@
tools:ignore="UnusedAttribute">
<activity
android:name=".ui.screens.MainActivity"
android:configChanges="screenSize"
android:configChanges="colorMode|density|fontScale|keyboard|keyboardHidden|layoutDirection|locale|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode"
android:exported="true"
android:label="@string/app_name"
android:launchMode="singleTask"
android:resizeableActivity="true"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand All @@ -58,6 +67,13 @@
</intent-filter>
</activity>

<!-- For uCrop -->
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
tools:ignore="LockedOrientationActivity" />

<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="${MAPS_API_KEY}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,13 @@ package org.imaginativeworld.whynotcompose.template

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Divider
import androidx.compose.material.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.google.accompanist.insets.navigationBarsWithImePadding
import com.google.accompanist.insets.statusBarsPadding
import org.imaginativeworld.whynotcompose.ui.screens.AppComponent
Expand Down Expand Up @@ -74,7 +72,6 @@ fun TemplateChildScreenSkeleton() {
Modifier
.fillMaxSize()
.verticalScroll(rememberScrollState())
.padding(start = 16.dp, end = 16.dp)
) {
AppComponent.Header("Title")

Expand All @@ -88,6 +85,7 @@ fun TemplateChildScreenSkeleton() {
// ----------------------------------------------------------------

// Content here...
// Use `padding(start = 16.dp, end = 16.dp)` for the elements.

// ----------------------------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ object AppComponent {

@Composable
fun Header(
text: String
text: String,
modifier: Modifier = Modifier,
) {
Text(
modifier = Modifier
modifier = modifier
.padding(
start = 16.dp,
top = 32.dp,
Expand All @@ -65,10 +66,11 @@ object AppComponent {

@Composable
fun SubHeader(
text: String
text: String,
modifier: Modifier = Modifier,
) {
Text(
modifier = Modifier
modifier = modifier
.padding(
start = 16.dp,
top = 16.dp,
Expand All @@ -83,29 +85,34 @@ object AppComponent {
}

@Composable
fun MediumSpacer() {
fun MediumSpacer(
modifier: Modifier = Modifier,
) {
Spacer(
modifier = Modifier
modifier = modifier
.fillMaxWidth()
.height(16.dp)
)
}

@Composable
fun BigSpacer() {
fun BigSpacer(
modifier: Modifier = Modifier,
) {
Spacer(
modifier = Modifier
modifier = modifier
.fillMaxWidth()
.height(32.dp)
)
}

@Composable
fun CustomListItem(
text: String
text: String,
modifier: Modifier = Modifier,
) {
Text(
modifier = Modifier
modifier = modifier
.fillMaxWidth()
.padding(16.dp, 4.dp)
.shadow(2.dp, RoundedCornerShape(4.dp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import org.imaginativeworld.whynotcompose.ui.screens.animation.runningcar.Runnin
import org.imaginativeworld.whynotcompose.ui.screens.animation.thestory.TheStoryScreen
import org.imaginativeworld.whynotcompose.ui.screens.composition.appbar.AppBarScreen
import org.imaginativeworld.whynotcompose.ui.screens.composition.badge.BadgeScreen
import org.imaginativeworld.whynotcompose.ui.screens.composition.bottomnavigation.BottomNavigationScreen
import org.imaginativeworld.whynotcompose.ui.screens.composition.button.ButtonScreen
import org.imaginativeworld.whynotcompose.ui.screens.composition.card.CardScreen
import org.imaginativeworld.whynotcompose.ui.screens.composition.checkbox.CheckBoxScreen
Expand Down Expand Up @@ -74,15 +75,21 @@ import org.imaginativeworld.whynotcompose.ui.screens.composition.snackbar.Snackb
import org.imaginativeworld.whynotcompose.ui.screens.composition.swiperefresh.SwipeRefreshScreen
import org.imaginativeworld.whynotcompose.ui.screens.composition.swipetodismiss.SwipeToDismissScreen
import org.imaginativeworld.whynotcompose.ui.screens.composition.switch.SwitchScreen
import org.imaginativeworld.whynotcompose.ui.screens.composition.text.TextScreen
import org.imaginativeworld.whynotcompose.ui.screens.composition.textfield.TextFieldScreen
import org.imaginativeworld.whynotcompose.ui.screens.home.index.HomeIndexScreen
import org.imaginativeworld.whynotcompose.ui.screens.home.splash.SplashScreen
import org.imaginativeworld.whynotcompose.ui.screens.tutorial.animatedvisibility.AnimatedVisibilityScreen
import org.imaginativeworld.whynotcompose.ui.screens.tutorial.captureimageandcrop.CaptureImageAndCropScreen
import org.imaginativeworld.whynotcompose.ui.screens.tutorial.captureimageandcrop.CaptureImageAndCropViewModel
import org.imaginativeworld.whynotcompose.ui.screens.tutorial.counter.CounterScreen
import org.imaginativeworld.whynotcompose.ui.screens.tutorial.counterwithviewmodel.CounterWithVMScreen
import org.imaginativeworld.whynotcompose.ui.screens.tutorial.counterwithviewmodel.CounterWithVMViewModel
import org.imaginativeworld.whynotcompose.ui.screens.tutorial.index.TutorialIndexScreen
import org.imaginativeworld.whynotcompose.ui.screens.tutorial.lottie.LottieScreen
import org.imaginativeworld.whynotcompose.ui.screens.tutorial.permission.PermissionScreen
import org.imaginativeworld.whynotcompose.ui.screens.tutorial.selectimageandcrop.SelectImageAndCropScreen
import org.imaginativeworld.whynotcompose.ui.screens.tutorial.selectimageandcrop.SelectImageAndCropViewModel
import org.imaginativeworld.whynotcompose.ui.screens.ui.index.UiIndexScreen
import org.imaginativeworld.whynotcompose.ui.screens.ui.mapview.MapScreen
import org.imaginativeworld.whynotcompose.ui.screens.ui.mapview.MapViewDetailsScreen
Expand Down Expand Up @@ -157,6 +164,8 @@ sealed class CompositionsScreen(val route: String) {
object CompositionBadge : CompositionsScreen("composition/badge")
object CompositionFloatingActionButton : CompositionsScreen("composition/fab")
object CompositionSlider : CompositionsScreen("composition/slider")
object CompositionText : CompositionsScreen("composition/text")
object CompositionBottomNavigation : CompositionsScreen("composition/bottomnavigation")
}

sealed class UIsScreen(val route: String) {
Expand All @@ -180,6 +189,9 @@ sealed class TutorialsScreen(val route: String) {
object TutorialCounterWithViewModel : TutorialsScreen("tutorial/counter-with-view-model")
object TutorialAnimatedVisibility : TutorialsScreen("tutorial/animated-visibility")
object TutorialLottie : TutorialsScreen("tutorial/lottie")
object TutorialSelectImageAndCrop : TutorialsScreen("tutorial/select-image-and-crop")
object TutorialCaptureImageAndCrop : TutorialsScreen("tutorial/capture-image-and-crop")
object TutorialPermission : TutorialsScreen("tutorial/permission")
}

// ================================================================
Expand Down Expand Up @@ -421,6 +433,14 @@ private fun NavGraphBuilder.addCompositionScreens(
composable(CompositionsScreen.CompositionSlider.route) {
SliderScreen()
}

composable(CompositionsScreen.CompositionText.route) {
TextScreen()
}

composable(CompositionsScreen.CompositionBottomNavigation.route) {
BottomNavigationScreen()
}
}
}

Expand Down Expand Up @@ -618,6 +638,26 @@ private fun NavGraphBuilder.addTutorialIndexScreen(
composable(TutorialsScreen.TutorialLottie.route) {
LottieScreen()
}

composable(TutorialsScreen.TutorialSelectImageAndCrop.route) {
val viewModel: SelectImageAndCropViewModel = hiltViewModel()

SelectImageAndCropScreen(
viewModel = viewModel
)
}

composable(TutorialsScreen.TutorialCaptureImageAndCrop.route) {
val viewModel: CaptureImageAndCropViewModel = hiltViewModel()

CaptureImageAndCropScreen(
viewModel = viewModel
)
}

composable(TutorialsScreen.TutorialPermission.route) {
PermissionScreen()
}
}

// ================================================================
Expand Down
Loading

0 comments on commit 6cd02bc

Please sign in to comment.