Skip to content

Commit

Permalink
Add New Features
Browse files Browse the repository at this point in the history
  • Loading branch information
abdullahalhakimi committed Aug 31, 2024
1 parent eaeea0f commit bb77f56
Show file tree
Hide file tree
Showing 14 changed files with 226 additions and 509 deletions.
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

247 changes: 91 additions & 156 deletions app/src/main/java/com/abdullahalhakimi/smoothmotion/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,195 +1,130 @@
package com.abdullahalhakimi.smoothmotion

import android.annotation.SuppressLint
import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Refresh
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.material3.MaterialTheme
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.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import com.abdullahalhakimi.smoothmotion.animations.AnimatedButton
import com.abdullahalhakimi.smoothmotion.animations.AppLoadingAnimation
import com.abdullahalhakimi.smoothmotion.animations.DroppingDotsProgress
import com.abdullahalhakimi.smoothmotion.animations.ExpandingCard
import com.abdullahalhakimi.smoothmotion.animations.PulsatingLoadingIndicator
import com.abdullahalhakimi.smoothmotion.animations.RotatingIcon
import com.abdullahalhakimi.smoothmotion.animations.ScatteredArcsProgress
import com.abdullahalhakimi.smoothmotion.animations.AnimatingArcsProgress
import com.abdullahalhakimi.smoothmotion.animations.AnimatingCircleWithArcsProgress
import com.abdullahalhakimi.smoothmotion.animations.SlideTransition
import com.abdullahalhakimi.smoothmotion.utils.ProgressTitle
import com.abdullahalhakimi.smoothmotion.animations.CircledDotsProgress
import com.abdullahalhakimi.smoothmotion.animations.DropCircleProgress
import com.abdullahalhakimi.smoothmotion.animations.LoadingDotsAnimation
import com.abdullahalhakimi.smoothmotion.animations.OutlinedLoadingDotsAnimation
import com.abdullahalhakimi.smoothmotion.animations.RotatingCircleProgress
import com.abdullahalhakimi.smoothmotion.animations.RotatingFilledCircleProgress
import com.abdullahalhakimi.smoothmotion.utils.Title

class MainActivity : ComponentActivity() {
@SuppressLint("UnusedMaterial3ScaffoldPaddingParameter")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent {
ExampleMainActivityContent()
ExampleMainActivityContent(modifier = Modifier)
}
}
}

@Composable
fun ExampleMainActivityContent() {
var isExpanded by remember { mutableStateOf(false) }
var showSlide by remember { mutableStateOf(true) }

fun ExampleMainActivityContent(modifier: Modifier = Modifier) {
Column(
modifier = Modifier
modifier
.fillMaxSize()
.padding(16.dp),
.verticalScroll(rememberScrollState()),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(16.dp)
verticalArrangement = Arrangement.Center,
) {
Spacer(modifier = Modifier.height(10.dp))
// AnimatedButton Example
AnimatedButton(
onClick = {
Log.d("A:","Ali")
},
modifier = Modifier,
Row(
horizontalArrangement = Arrangement.SpaceAround,
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.fillMaxWidth(),
) {
Text("Animated Button")
DropCircleProgress(
modifier = Modifier.size(90.dp),
backgroundColor = Color.Gray.copy(alpha = 0.2f),
color = MaterialTheme.colorScheme.primary
)
CircledDotsProgress(
modifier = Modifier.size(90.dp),
backgroundColor = Color.Gray.copy(alpha = 0.2f),
color = MaterialTheme.colorScheme.primary
)
}

// SlideTransition Example
SlideTransition(targetState = showSlide) {
Text("Slide In Content", modifier = Modifier.padding(16.dp))
Row(
horizontalArrangement = Arrangement.SpaceAround,
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.fillMaxWidth(),
) {
Title(title = "Drop Circle Progress")
Title(title = "Circled Dots Progress")
}
Button(onClick = { showSlide = !showSlide }) {
Text(if (showSlide) "Hide Slide" else "Show Slide")
Spacer(modifier = Modifier.height(100.dp))
Row(
horizontalArrangement = Arrangement.SpaceAround,
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.fillMaxWidth(),
) {
RotatingCircleProgress(
modifier = Modifier.size(90.dp),
color = MaterialTheme.colorScheme.primary
)
RotatingFilledCircleProgress(
modifier = Modifier.size(90.dp),
color = MaterialTheme.colorScheme.primary
)
}

// PulsatingLoadingIndicator Example
PulsatingLoadingIndicator()

// ExpandingCard Example
ExpandingCard(
headerContent = { Text("Expanding Card Header") },
expandedContent = { Text("This is the expanded content of the card.") },
isExpanded = isExpanded,
onClick = { isExpanded = !isExpanded }
)

// RotatingIcon Example
RotatingIcon(
modifier = Modifier.size(60.dp),
icon = { Icon(Icons.Default.Refresh, contentDescription = "Rotating Icon") },
color = Color.Blue
)

AppLoadingAnimation()
}
}

@Composable

fun AppLoadingExample() {
var isExpanded by remember { mutableStateOf(false) }
var showSlide by remember { mutableStateOf(true) }

Column(
modifier = Modifier
.fillMaxSize()
.padding(16.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(16.dp)
) {
Spacer(modifier = Modifier.height(10.dp))
// AnimatedButton Example
AnimatedButton(
onClick = {
Log.d("A:","Ali")
},
modifier = Modifier,
Row(
horizontalArrangement = Arrangement.SpaceAround,
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.fillMaxWidth(),
) {
Text("Animated Button")
Title(title = "Rotating Circle Progress")
Title(title = "Rotating Filled Circle Progress")
}

// SlideTransition Example
SlideTransition(targetState = showSlide) {
Text("Slide In Content", modifier = Modifier.padding(16.dp))
Spacer(modifier = Modifier.height(100.dp))
Row(
horizontalArrangement = Arrangement.SpaceAround,
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.fillMaxWidth(),
) {
LoadingDotsAnimation(
circleSize = 20.dp,
spaceBetween = 10.dp,
travelDistance = 15.dp,
circleColor = MaterialTheme.colorScheme.primary
)
OutlinedLoadingDotsAnimation(
circleSize = 20.dp,
spaceBetween = 10.dp,
travelDistance = 15.dp,
circleColor = MaterialTheme.colorScheme.primary
)
}
Button(onClick = { showSlide = !showSlide }) {
Text(if (showSlide) "Hide Slide" else "Show Slide")
Row(
horizontalArrangement = Arrangement.SpaceAround,
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.fillMaxWidth(),
) {
Title(title = "Loading Dots Animation")
Title(title = "Outlined Loading Dots Animation")
}

// PulsatingLoadingIndicator Example
PulsatingLoadingIndicator()

// ExpandingCard Example
ExpandingCard(
headerContent = { Text("Expanding Card Header") },
expandedContent = { Text("This is the expanded content of the card.") },
isExpanded = isExpanded,
onClick = { isExpanded = !isExpanded }
)

// RotatingIcon Example
RotatingIcon(
modifier = Modifier.size(60.dp),
icon = { Icon(Icons.Default.Refresh, contentDescription = "Rotating Icon") },
color = Color.Blue
)

AppLoadingAnimation()
}
}


@Composable
fun CircularProgressExample(modifier: Modifier = Modifier) {
Column(
modifier
.fillMaxSize()
.verticalScroll(rememberScrollState()),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {

ScatteredArcsProgress(
modifier = Modifier.size(100.dp),
backgroundColor = Color.Gray.copy(alpha = 0.2f),
activeColor = Color(0xFF0097ff)
)

ProgressTitle(title = "ScatteredArcsProgress")
Spacer(modifier = Modifier.height(32.dp))

DroppingDotsProgress(
modifier = Modifier.size(100.dp),
backgroundColor = Color.Gray.copy(alpha = 0.2f),
activeColor = Color(0xFF0097ff)
)

ProgressTitle(title = "DroppingDotsProgress")
Spacer(modifier = Modifier.height(32.dp))

AnimatingArcsProgress(
modifier = Modifier.size(100.dp),
activeColor = Color(0xFF0097ff)
)

ProgressTitle(title = "AnimatingArcsProgress")
Spacer(modifier = Modifier.height(32.dp))

AnimatingCircleWithArcsProgress(
modifier = Modifier.size(100.dp),
activeColor = Color(0xFF0097ff)
)
ProgressTitle(title = "AnimatingCircleWithArcsProgress.kt")
}
}

Expand Down

This file was deleted.

Loading

0 comments on commit bb77f56

Please sign in to comment.