Skip to content

Commit 77f67b0

Browse files
committed
feat: migrate channel fragment header to material 3 expressive
1 parent 0742f44 commit 77f67b0

2 files changed

Lines changed: 37 additions & 81 deletions

File tree

app/src/main/java/com/github/libretube/ui/fragments/ChannelFragment.kt

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,15 @@ import com.github.libretube.api.obj.ChannelTab
1818
import com.github.libretube.api.obj.StreamItem
1919
import com.github.libretube.constants.IntentData
2020
import com.github.libretube.databinding.FragmentChannelBinding
21-
import com.github.libretube.enums.ShareObjectType
2221
import com.github.libretube.extensions.TAG
2322
import com.github.libretube.extensions.formatShort
24-
import com.github.libretube.extensions.toID
2523
import com.github.libretube.helpers.ClipboardHelper
2624
import com.github.libretube.helpers.ImageHelper
2725
import com.github.libretube.helpers.NavigationHelper
28-
import com.github.libretube.obj.ShareData
2926
import com.github.libretube.ui.adapters.VideosAdapter
30-
import com.github.libretube.ui.dialogs.ShareDialog
3127
import com.github.libretube.ui.extensions.setupFragmentAnimation
3228
import com.github.libretube.ui.extensions.setupSubscriptionButton
33-
import com.github.libretube.ui.sheets.AddChannelToGroupSheet
29+
import com.github.libretube.ui.sheets.ChannelOptionsBottomSheet
3430
import com.github.libretube.util.deArrow
3531
import com.google.android.material.tabs.TabLayoutMediator
3632
import kotlinx.coroutines.Dispatchers
@@ -141,42 +137,30 @@ class ChannelFragment : Fragment(R.layout.fragment_channel) {
141137
// needed if the channel gets loaded by the ID
142138
channelId = response.id
143139
channelName = response.name
144-
val shareData = ShareData(currentChannel = response.name)
145140

146141
val channelId = channelId ?: return@launch
147142

143+
var isSubscribed = false
148144
binding.channelSubscribe.setupSubscriptionButton(
149145
channelId,
150146
response.name.orEmpty(),
151147
response.avatarUrl,
152148
response.verified,
153149
binding.notificationBell
154-
) { isSubscribed ->
155-
_binding?.addToGroup?.isVisible = isSubscribed
150+
) {
151+
isSubscribed = it
156152
}
157153

158-
binding.channelShare.setOnClickListener {
159-
val bundle = bundleOf(
160-
IntentData.id to channelId.toID(),
161-
IntentData.shareObjectType to ShareObjectType.CHANNEL,
162-
IntentData.shareData to shareData
163-
)
164-
val newShareDialog = ShareDialog()
165-
newShareDialog.arguments = bundle
166-
newShareDialog.show(childFragmentManager, ShareDialog::class.java.name)
167-
}
168-
169-
binding.addToGroup.setOnClickListener {
170-
AddChannelToGroupSheet().apply {
171-
arguments = bundleOf(IntentData.channelId to channelId)
172-
}.show(childFragmentManager)
173-
}
174-
175-
binding.playAll.setOnClickListener {
176-
val firstVideoId =
177-
response.relatedStreams.firstOrNull()?.url?.toID() ?: return@setOnClickListener
178-
179-
NavigationHelper.navigateVideo(requireContext(), firstVideoId, channelId = channelId)
154+
binding.showMore.setOnClickListener {
155+
ChannelOptionsBottomSheet()
156+
.apply {
157+
arguments = bundleOf(
158+
IntentData.channelId to channelId,
159+
IntentData.channelName to channelName,
160+
IntentData.isSubscribed to isSubscribed
161+
)
162+
}
163+
.show(childFragmentManager)
180164
}
181165

182166
nextPages[0] = response.nextpage

app/src/main/res/layout/fragment_channel.xml

Lines changed: 23 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
android:layout_height="match_parent"
4141
android:layout_gravity="center"
4242
android:layout_marginHorizontal="1dp"
43-
android:layout_marginVertical="10dp"
43+
android:layout_marginTop="10dp"
44+
android:layout_marginBottom="4dp"
4445
android:orientation="horizontal">
4546

4647
<com.google.android.material.imageview.ShapeableImageView
@@ -82,73 +83,44 @@
8283

8384
</LinearLayout>
8485

85-
<com.google.android.material.button.MaterialButton
86-
android:id="@+id/channel_subscribe"
87-
style="@style/PlayerActionsButton"
86+
<com.google.android.material.button.MaterialButtonGroup
87+
style="@style/Widget.Material3.MaterialButtonGroup.Connected"
8888
android:layout_width="wrap_content"
8989
android:layout_height="wrap_content"
90-
android:stateListAnimator="@null"
91-
android:text="@string/subscribe"
92-
android:textSize="12sp"
93-
tools:targetApi="m" />
94-
95-
</LinearLayout>
96-
97-
<HorizontalScrollView
98-
android:layout_width="match_parent"
99-
android:layout_height="wrap_content"
100-
android:scrollbars="none">
101-
102-
<LinearLayout
103-
android:layout_width="wrap_content"
104-
android:layout_height="wrap_content"
105-
android:orientation="horizontal">
90+
android:gravity="center_vertical">
10691

10792
<com.google.android.material.button.MaterialButton
108-
android:id="@+id/channel_share"
109-
style="@style/PlayerActionsButton"
110-
android:text="@string/share"
111-
android:textSize="12sp"
112-
android:tooltipText="@string/share"
113-
app:icon="@drawable/ic_share"
114-
tools:targetApi="m" />
93+
android:id="@+id/channel_subscribe"
94+
style="?materialButtonStyle"
95+
android:layout_width="wrap_content"
96+
android:layout_height="wrap_content"
97+
android:text="@string/subscribe"
98+
android:maxLines="1"/>
11599

116100
<com.google.android.material.button.MaterialButton
117101
android:id="@+id/notification_bell"
118-
style="@style/PlayerActionsButton"
119-
android:text="@string/notifications"
120-
android:textSize="12sp"
102+
style="?materialIconButtonFilledStyle"
103+
android:layout_width="wrap_content"
104+
android:layout_height="wrap_content"
121105
android:tooltipText="@string/notifications"
122-
app:icon="@drawable/ic_notification"
123-
tools:targetApi="m" />
124-
125-
<com.google.android.material.button.MaterialButton
126-
android:id="@+id/add_to_group"
127-
style="@style/PlayerActionsButton"
128-
android:text="@string/add_to_group"
129-
android:textSize="12sp"
130-
android:tooltipText="@string/add_to_group"
131-
app:icon="@drawable/ic_add"
132-
tools:targetApi="m" />
106+
app:icon="@drawable/ic_notification" />
133107

134108
<com.google.android.material.button.MaterialButton
135-
android:id="@+id/play_all"
136-
style="@style/PlayerActionsButton"
137-
android:text="@string/play_latest_videos"
138-
android:textSize="12sp"
139-
android:tooltipText="@string/play_latest_videos"
140-
app:icon="@drawable/ic_playlist"
141-
tools:targetApi="m" />
109+
android:id="@+id/show_more"
110+
style="?attr/materialIconButtonFilledStyle"
111+
android:layout_width="wrap_content"
112+
android:layout_height="wrap_content"
113+
android:tooltipText="@string/misc"
114+
app:icon="@drawable/ic_three_dots" />
142115

143-
</LinearLayout>
116+
</com.google.android.material.button.MaterialButtonGroup>
144117

145-
</HorizontalScrollView>
118+
</LinearLayout>
146119

147120
<com.github.libretube.ui.views.ExpandableTextView
148121
android:id="@+id/channel_description"
149122
android:layout_width="match_parent"
150123
android:layout_height="wrap_content"
151-
android:layout_marginHorizontal="5dp"
152124
android:padding="10dp" />
153125

154126
</LinearLayout>

0 commit comments

Comments
 (0)