feat: Inbox WIP(#222)

This commit is contained in:
ibo 2024-03-06 16:06:56 +01:00 committed by GitHub
parent e50a65571f
commit 2855093f5f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 171 additions and 0 deletions

View file

@ -27,6 +27,7 @@ import ani.dantotsu.connections.anilist.AnilistHomeViewModel
import ani.dantotsu.connections.anilist.getUserId
import ani.dantotsu.currContext
import ani.dantotsu.databinding.FragmentHomeBinding
import ani.dantotsu.inbox.InboxActivity
import ani.dantotsu.loadImage
import ani.dantotsu.media.Media
import ani.dantotsu.media.MediaAdaptor
@ -77,6 +78,7 @@ class HomeFragment : Fragment() {
binding.homeUserChaptersRead.text = Anilist.chapterRead.toString()
binding.homeUserAvatar.loadImage(Anilist.avatar)
if (!(PrefManager.getVal(PrefName.BannerAnimations) as Boolean)) binding.homeUserBg.pause()
binding.imageButton.startAnimation(setSlideIn())
binding.homeUserBg.loadImage(Anilist.bg)
binding.homeUserDataProgressBar.visibility = View.GONE
@ -305,6 +307,13 @@ class HomeFragment : Fragment() {
}
}
binding.imageButton.setOnClickListener {
val intent = Intent(requireActivity(), InboxActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP
startActivity(intent)
}
val array = arrayOf(
"AnimeContinue",
"AnimeFav",

View file

@ -0,0 +1,8 @@
package ani.dantotsu.inbox
import androidx.fragment.app.Fragment
import ani.dantotsu.R
class FeedFragment : Fragment(R.layout.fragment_feed) {
// testing rn
}

View file

@ -0,0 +1,60 @@
package ani.dantotsu.inbox
import android.content.Intent
import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import android.widget.ImageButton
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.updateLayoutParams
import ani.dantotsu.databinding.ActivityInboxBinding
import ani.dantotsu.R
import ani.dantotsu.navBarHeight
import nl.joery.animatedbottombar.AnimatedBottomBar
class InboxActivity : AppCompatActivity() {
private lateinit var binding: ActivityInboxBinding
private lateinit var navBar: AnimatedBottomBar
private var selected: Int = 0
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityInboxBinding.inflate(layoutInflater)
setContentView(binding.root)
// Find the ImageButton from activity_inbox.xml
val imageButton = findViewById<ImageButton>(R.id.imageButton)
navBar = binding.inboxNavBar
navBar.updateLayoutParams<ViewGroup.MarginLayoutParams> { bottomMargin = navBarHeight }
val activityTab = navBar.createTab(R.drawable.inbox_filled, "Activity")
val notificationTab =
navBar.createTab(R.drawable.ic_round_notifications_active_24, "Notification")
navBar.addTab(activityTab)
navBar.addTab(notificationTab)
navBar.visibility = View.GONE
navBar.setOnTabSelectListener(object : AnimatedBottomBar.OnTabSelectListener {
override fun onTabSelected(
lastIndex: Int,
lastTab: AnimatedBottomBar.Tab?,
newIndex: Int,
newTab: AnimatedBottomBar.Tab
) {
selected = newIndex
val fragmentTransaction = supportFragmentManager.beginTransaction()
when (newIndex) {
0 -> fragmentTransaction.replace(R.id.container, FeedFragment())
1 -> fragmentTransaction.replace(R.id.container, NotifsFragment())
}
fragmentTransaction.commit()
}
})
navBar.selectTabAt(selected)
navBar.visibility = View.VISIBLE
}
}

View file

@ -0,0 +1,8 @@
package ani.dantotsu.inbox
import androidx.fragment.app.Fragment
import ani.dantotsu.R
class NotifsFragment : Fragment(R.layout.fragment_notifs) {
// testing rn
}