Skip to content

Instantly share code, notes, and snippets.

@aqua30
aqua30 / background_curved_corners.xml
Created March 6, 2022 18:26
Curved rectangle background shape
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/white" />
<corners android:topLeftRadius="25dp" android:topRightRadius="25dp" />
</shape>
@aqua30
aqua30 / dialog_curved_corners.xml
Created March 6, 2022 18:28
Layout for bottom sheet dialog
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/curvedContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/button_selector"
android:orientation="horizontal">
</LinearLayout>
@aqua30
aqua30 / BottomSheetContainer.kt
Created March 6, 2022 18:30
Bottom sheet dialog
package com.aqua30.testingproject.curved_background
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import androidx.appcompat.app.AppCompatActivity
import com.aqua30.testingproject.R
import com.aqua30.testingproject.databinding.BottomCurvedBinding
@aqua30
aqua30 / CurvedContainer.kt
Last active March 6, 2022 18:54
Custom Layout
class CurvedContainer @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
): LinearLayout(context, attrs, defStyleAttr) {
/* paint object for coloring the canvas */
private val mPaint = Paint()
/* path that will be drawn to achieve the shape */
private val path = Path()
@aqua30
aqua30 / onSizeChanged.kt
Created March 6, 2022 19:15
Function of view class
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
super.onSizeChanged(w, h, oldw, oldh)
/* curve from P1 to P2 */
leftArc.set(
0f,
0f,
xAxisOffset,
yAxisOffset
)
path.addArc(leftArc, 180f, 90f)
override fun onDraw(canvas: Canvas?) {
super.onDraw(canvas)
canvas?.drawPath(path, mPaint)
}
<style name="TransparentBackgroundDialog" parent="Theme.Design.Light.BottomSheetDialog">
<item name="android:colorBackground">@android:color/transparent</item>
</style>
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(STYLE_NORMAL, R.style.TransparentBackgroundDialog)
}
@aqua30
aqua30 / settings.gradle
Created May 21, 2022 15:11
Version Catalog
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
versionCatalogs {
libs {
version('compose','1.4.0')
version('composeui','1.1.1')
@aqua30
aqua30 / TimerScreen.kt
Created May 27, 2022 18:22
Animation section for selection screen.
AnimatedContent(
targetState = timerContent,
transitionSpec = {
if(targetState == TimerContent.SELECTION) {
slideInVertically { height -> height } + fadeIn() with
slideOutVertically { height -> -height } + fadeOut()
} else {
slideInVertically { height -> -height } + fadeIn() with
slideOutVertically { height -> height } + fadeOut()
}