-
-
Notifications
You must be signed in to change notification settings - Fork 445
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert channel group dialogs to bottom sheets
- Loading branch information
Showing
9 changed files
with
147 additions
and
82 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
47 changes: 0 additions & 47 deletions
47
app/src/main/java/com/github/libretube/ui/dialogs/ChannelGroupsDialog.kt
This file was deleted.
Oops, something went wrong.
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
51 changes: 51 additions & 0 deletions
51
app/src/main/java/com/github/libretube/ui/sheets/ChannelGroupsSheet.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,51 @@ | ||
package com.github.libretube.ui.sheets | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.LinearLayoutManager | ||
import com.github.libretube.databinding.DialogSubscriptionGroupsBinding | ||
import com.github.libretube.db.DatabaseHolder | ||
import com.github.libretube.db.obj.SubscriptionGroup | ||
import com.github.libretube.ui.adapters.SubscriptionGroupsAdapter | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.runBlocking | ||
|
||
class ChannelGroupsSheet( | ||
private val groups: MutableList<SubscriptionGroup>, | ||
private val onGroupsChanged: (List<SubscriptionGroup>) -> Unit | ||
) : ExpandedBottomSheet() { | ||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View { | ||
val binding = DialogSubscriptionGroupsBinding.inflate(layoutInflater) | ||
|
||
binding.groupsRV.layoutManager = LinearLayoutManager(context) | ||
val adapter = SubscriptionGroupsAdapter( | ||
groups.toMutableList(), | ||
parentFragmentManager, | ||
onGroupsChanged | ||
) | ||
binding.groupsRV.adapter = adapter | ||
|
||
binding.newGroup.setOnClickListener { | ||
EditChannelGroupSheet(SubscriptionGroup("", mutableListOf())) { | ||
runBlocking(Dispatchers.IO) { | ||
DatabaseHolder.Database.subscriptionGroupsDao().createGroup(it) | ||
} | ||
groups.add(it) | ||
adapter.insertItem(it) | ||
onGroupsChanged(groups) | ||
}.show(parentFragmentManager, null) | ||
} | ||
|
||
binding.confirm.setOnClickListener { | ||
dismiss() | ||
} | ||
|
||
return binding.root | ||
} | ||
} |
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
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
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 |
---|---|---|
@@ -1,12 +1,45 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical"> | ||
|
||
<TextView | ||
android:text="@string/channel_groups" | ||
android:textStyle="bold" | ||
android:textSize="24sp" | ||
android:layout_marginTop="18dp" | ||
android:layout_marginStart="18dp" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" /> | ||
|
||
<androidx.recyclerview.widget.RecyclerView | ||
android:id="@+id/groupsRV" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="20dp" /> | ||
android:layout_marginTop="20dp"/> | ||
|
||
<LinearLayout | ||
android:layout_width="wrap_content" | ||
android:layout_gravity="end" | ||
android:paddingVertical="10dp" | ||
android:layout_height="wrap_content"> | ||
|
||
<com.google.android.material.button.MaterialButton | ||
android:id="@+id/new_group" | ||
android:layout_width="wrap_content" | ||
android:text="@string/new_group" | ||
style="@style/Widget.Material3.Button.OutlinedButton" | ||
android:layout_height="wrap_content"/> | ||
|
||
<com.google.android.material.button.MaterialButton | ||
android:id="@+id/confirm" | ||
style="@style/Widget.Material3.Button.ElevatedButton" | ||
android:layout_width="wrap_content" | ||
android:text="@string/okay" | ||
android:layout_marginHorizontal="16dp" | ||
android:layout_height="wrap_content"/> | ||
|
||
</LinearLayout> | ||
|
||
</LinearLayout> |
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
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
8cf4f76
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, there is missing the OK button. Im not able to create groups in debug build.