Skip to content

Instantly share code, notes, and snippets.

Avatar

Saurabh Pant aqua30

View GitHub Profile
View settings.gradle
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
versionCatalogs {
libs {
version('compose','1.4.0')
version('composeui','1.1.1')
View onCreate.kt
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(STYLE_NORMAL, R.style.TransparentBackgroundDialog)
}
View transparent_style.xml
<style name="TransparentBackgroundDialog" parent="Theme.Design.Light.BottomSheetDialog">
<item name="android:colorBackground">@android:color/transparent</item>
</style>
View onDraw.kt
override fun onDraw(canvas: Canvas?) {
super.onDraw(canvas)
canvas?.drawPath(path, mPaint)
}
@aqua30
aqua30 / onSizeChanged.kt
Created Mar 6, 2022
Function of view class
View onSizeChanged.kt
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)
View CurvedContainer.kt
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()
View BottomSheetContainer.kt
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 / dialog_curved_corners.xml
Created Mar 6, 2022
Layout for bottom sheet dialog
View dialog_curved_corners.xml
<?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 / background_curved_corners.xml
Created Mar 6, 2022
Curved rectangle background shape
View background_curved_corners.xml
<?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 / application.conf
Created Oct 31, 2021
Application config
View application.conf
ktor {
deployment {
port = 8080
port = ${?PORT}
}
application {
modules = [ com.aqua30.ApplicationKt.module ]
}
}