Skip to content

Commit

Permalink
subletter xml updates (tablayout w/i subletter not working)
Browse files Browse the repository at this point in the history
  • Loading branch information
vavali08 committed Dec 3, 2023
1 parent 6883371 commit d134fd6
Show file tree
Hide file tree
Showing 11 changed files with 182 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.pennapps.labs.pennmobile

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment

class SubletterDraftListingsFragment : Fragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_subletter_draft_listings, container, false)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.viewpager2.widget.ViewPager2
import com.pennapps.labs.pennmobile.adapters.SubletterPagerAdapter

// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
Expand All @@ -17,10 +19,14 @@ private const val ARG_PARAM2 = "param2"
* create an instance of this fragment.
*/
class SubletterFragment : Fragment() {

lateinit var subletterPagerAdapter: SubletterPagerAdapter
private lateinit var mActivity: MainActivity
private lateinit var viewPager: ViewPager2

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
mActivity = activity as MainActivity
mActivity.closeKeyboard()
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
Expand All @@ -31,4 +37,6 @@ class SubletterFragment : Fragment() {





}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.pennapps.labs.pennmobile

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.fragment.app.Fragment
import androidx.viewpager2.widget.ViewPager2
import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayoutMediator
import com.pennapps.labs.pennmobile.adapters.SubletterPagerAdapter
import com.pennapps.labs.pennmobile.adapters.SublettingPagerAdapter
import com.pennapps.labs.pennmobile.components.collapsingtoolbar.ToolbarBehavior
import kotlinx.android.synthetic.main.fragment_dining_holder.view.appbar_home_holder

class SubletterHolderFragment : Fragment() {
lateinit var subletterPagerAdapter: SubletterPagerAdapter
private lateinit var mActivity: MainActivity
private lateinit var viewPager: ViewPager2


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
mActivity = activity as MainActivity
mActivity.closeKeyboard()
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_subletting, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
subletterPagerAdapter = SubletterPagerAdapter(this)
viewPager = view.findViewById(R.id.viewPager2)
viewPager.adapter = subletterPagerAdapter
val tabLayout : TabLayout = view.findViewById(R.id.subletting_tab_layout)
TabLayoutMediator(tabLayout, viewPager) { tab, position ->
tab.text = "OBJECT ${(position + 1)}"
}.attach()

}


private fun initAppBar(view: View) {
(view.appbar_home_holder.layoutParams as CoordinatorLayout.LayoutParams).behavior = ToolbarBehavior()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.pennapps.labs.pennmobile

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment

class SubletterPostedListingsFragment : Fragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_subletter_posted_listings, container, false)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.pennapps.labs.pennmobile.DiningHolderFragment
import com.pennapps.labs.pennmobile.GsrTabbedFragment
import com.pennapps.labs.pennmobile.HomeFragment
import com.pennapps.labs.pennmobile.LaundryFragment
import com.pennapps.labs.pennmobile.SublettingFragment
import com.pennapps.labs.pennmobile.more_fragments.MoreFragment

class MainPagerAdapter(fragmentManager: FragmentManager, lifecycle: Lifecycle?) : FragmentStateAdapter(fragmentManager, lifecycle!!) {
Expand All @@ -16,7 +17,7 @@ class MainPagerAdapter(fragmentManager: FragmentManager, lifecycle: Lifecycle?)
HOME_POSITION-> HomeFragment()
DINING_POSITION-> DiningHolderFragment()
GSR_POSITION-> GsrTabbedFragment()
LAUNDRY_POSITION-> LaundryFragment()
LAUNDRY_POSITION-> SublettingFragment()
MORE_POSITION-> MoreFragment()
else -> HomeFragment()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.pennapps.labs.pennmobile.adapters

import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.pennapps.labs.pennmobile.SubletterDraftListingsFragment
import com.pennapps.labs.pennmobile.SubletterPostedListingsFragment

class SubletterPagerAdapter(fragment: Fragment) : FragmentStateAdapter(fragment) {
override fun getItemCount(): Int = 2
override fun createFragment(position: Int): Fragment {
return if (position == 0) {
SubletterPostedListingsFragment()
} else {
SubletterDraftListingsFragment()
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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">

<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="drafts"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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">

<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="posted"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
33 changes: 31 additions & 2 deletions PennMobile/src/main/res/layout/fragment_subletter_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,48 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">

<TextView
android:id="@+id/listings_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="25sp"
android:fontFamily="@font/sf_pro_display_regular"
android:paddingTop="10dp"
android:text="Listings"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/my_listings_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="26sp"
android:layout_marginTop="50sp"
android:fontFamily="@font/sf_pro_display_bold"
android:text="@string/my_listings"
android:textSize="26sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/listings_text" />

<com.google.android.material.tabs.TabLayout
android:id="@+id/subletter_tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/my_listings_text"
/>

<androidx.viewpager2.widget.ViewPager2
android:id="@+id/subletter_view_pager"
android:layout_width="match_parent"
app:layout_constraintTop_toBottomOf="@id/subletter_tab_layout"
android:layout_height="wrap_content"/>


</androidx.constraintlayout.widget.ConstraintLayout>
5 changes: 3 additions & 2 deletions PennMobile/src/main/res/layout/fragment_subletting.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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:layout_height="wrap_content"
tools:context=".MainActivity">

<com.google.android.material.tabs.TabLayout
Expand All @@ -18,7 +18,8 @@
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/viewPager2"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
app:layout_constraintTop_toBottomOf="@id/subletting_tab_layout"
android:layout_height="wrap_content"/>


</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 1 addition & 0 deletions PennMobile/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,5 @@
<string name="room">Room</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="my_listings">My Listings</string>
</resources>

0 comments on commit d134fd6

Please sign in to comment.