-
-
Notifications
You must be signed in to change notification settings - Fork 385
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add intermediate dialog for initial settings
- Loading branch information
1 parent
522871a
commit 41c7652
Showing
4 changed files
with
183 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
app/src/main/java/com/hiddenramblings/tagmo/fragment/FittedSheets.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package com.hiddenramblings.tagmo.fragment | ||
|
||
import android.graphics.Color | ||
import android.os.Build | ||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.Button | ||
import android.widget.LinearLayout | ||
import android.widget.TextView | ||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment | ||
import com.hiddenramblings.tagmo.R | ||
|
||
|
||
class FittedSheets: BottomSheetDialogFragment() { | ||
|
||
private val viewList = mutableListOf<View>() | ||
fun addView(view: View) { | ||
viewList.add(view) | ||
} | ||
|
||
var title: String? = null | ||
fun setTitleText(string: String) { | ||
title = string | ||
} | ||
|
||
private var negativeText: String? = null | ||
private var negativeCallback: (() -> Unit)? = null | ||
fun setNegativeButton(text: String, callback: (() -> Unit)) { | ||
negativeText = text | ||
negativeCallback = callback | ||
} | ||
|
||
private var positiveText: String? = null | ||
private var positiveCallback: (() -> Unit)? = null | ||
fun setPositiveButton(text: String, callback: (() -> Unit)) { | ||
positiveText = text | ||
positiveCallback = callback | ||
} | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View { | ||
val view = inflater.inflate(R.layout.fitted_sheets, container, false) | ||
val window = dialog?.window | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | ||
window?.statusBarColor = Color.TRANSPARENT | ||
} | ||
return view | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
view.findViewById<TextView>(R.id.bottomSheetsTitle).text = title | ||
viewList.forEach { | ||
view.findViewById<LinearLayout>(R.id.bottomSheetsContainer).addView(it) | ||
} | ||
|
||
if (negativeText != null) view.findViewById<Button>(R.id.bottomSheetsNegative).apply { | ||
visibility = View.VISIBLE | ||
text = negativeText | ||
setOnClickListener { | ||
negativeCallback?.invoke() | ||
} | ||
} | ||
|
||
if (positiveText != null) view.findViewById<Button>(R.id.bottomSheetsPositive).apply { | ||
visibility = View.VISIBLE | ||
text = positiveText | ||
setOnClickListener { | ||
positiveCallback?.invoke() | ||
} | ||
} | ||
|
||
} | ||
|
||
override fun onDestroy() { | ||
super.onDestroy() | ||
} | ||
|
||
companion object { | ||
fun newInstance() = FittedSheets() | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:fillViewport="true"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical"> | ||
|
||
<TextView | ||
android:id="@+id/bottomSheetsTitle" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="16dp" | ||
android:textAlignment="center" | ||
android:textSize="20sp" /> | ||
|
||
<View | ||
android:layout_width="match_parent" | ||
android:layout_height="1dp" | ||
android:background="?android:attr/listDivider" /> | ||
|
||
|
||
<LinearLayout | ||
android:id="@+id/bottomSheetsContainer" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginHorizontal="32dp" | ||
android:orientation="vertical" /> | ||
|
||
<View | ||
android:layout_width="match_parent" | ||
android:layout_height="1dp" | ||
android:background="?android:attr/listDivider" /> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="8dp" | ||
android:orientation="horizontal"> | ||
|
||
<Button | ||
android:id="@+id/bottomSheetsNegative" | ||
style="@style/Widget.Material3.Button.OutlinedButton" | ||
android:layout_width="0dp" | ||
android:layout_height="@dimen/button_height_min" | ||
android:layout_margin="8dp" | ||
android:layout_weight="1" | ||
android:insetTop="0dp" | ||
android:insetBottom="0dp" | ||
android:padding="8dp" | ||
android:textSize="16sp" | ||
android:visibility="gone" | ||
app:cornerRadius="16dp" | ||
app:strokeColor="?attr/colorPrimaryContainer" | ||
tools:ignore="SpeakableTextPresentCheck" | ||
tools:visibility="visible" /> | ||
|
||
<Button | ||
android:id="@+id/bottomSheetsPositive" | ||
style="@style/Widget.Material3.Button.OutlinedButton" | ||
android:layout_width="0dp" | ||
android:layout_height="@dimen/button_height_min" | ||
android:layout_margin="8dp" | ||
android:layout_weight="1" | ||
android:insetTop="0dp" | ||
android:insetBottom="0dp" | ||
android:padding="8dp" | ||
android:textSize="16sp" | ||
android:visibility="gone" | ||
app:cornerRadius="16dp" | ||
app:strokeColor="?attr/colorPrimaryContainer" | ||
tools:ignore="SpeakableTextPresentCheck" | ||
tools:visibility="visible" /> | ||
</LinearLayout> | ||
</LinearLayout> | ||
</androidx.core.widget.NestedScrollView> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters