-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
209 additions
and
28 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
PennMobile/src/main/java/com/pennapps/labs/pennmobile/DynamicTabsFragment.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,40 @@ | ||
package com.pennapps.labs.pennmobile | ||
|
||
import android.os.Bundle | ||
import androidx.fragment.app.Fragment | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.ItemTouchHelper | ||
import androidx.recyclerview.widget.LinearLayoutManager | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.pennapps.labs.pennmobile.adapters.DynamicTabsAdapter | ||
import com.pennapps.labs.pennmobile.classes.Tab | ||
import kotlinx.android.synthetic.main.fragment_dynamic_tabs.view.* | ||
|
||
|
||
class DynamicTabsFragment : Fragment() { | ||
|
||
lateinit var dynamicTabsAdapter: DynamicTabsAdapter | ||
lateinit var tabs : List<Tab> | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
} | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { | ||
// Inflate the layout for this fragment | ||
val view = inflater.inflate(R.layout.fragment_dynamic_tabs, container, false) | ||
tabs = listOf(Tab("Dining"), Tab("GSR"), Tab("Laundry")) | ||
// val itemTouchHelper = object : ItemTouchHelper() { | ||
// } | ||
dynamicTabsAdapter = DynamicTabsAdapter(tabs) | ||
view.rvDynamicTabs.adapter = dynamicTabsAdapter | ||
view.rvDynamicTabs.layoutManager = LinearLayoutManager(context) | ||
return view | ||
} | ||
|
||
} |
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
36 changes: 36 additions & 0 deletions
36
PennMobile/src/main/java/com/pennapps/labs/pennmobile/adapters/DynamicTabsAdapter.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,36 @@ | ||
package com.pennapps.labs.pennmobile.adapters | ||
|
||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.pennapps.labs.pennmobile.R | ||
import com.pennapps.labs.pennmobile.classes.Tab | ||
import kotlinx.android.synthetic.main.dynamic_tab_item.view.* | ||
|
||
class DynamicTabsAdapter(private val tabs : List<Tab>) : RecyclerView.Adapter<DynamicTabsAdapter.ViewHolder>() { | ||
|
||
class ViewHolder(val view: View) : RecyclerView.ViewHolder(view) { | ||
|
||
init { | ||
// Define click listener for the ViewHolder's View | ||
} | ||
fun bindTab(tab: Tab) { | ||
view.tvDynamicTab.text = tab.name | ||
|
||
} | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { | ||
return ViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.dynamic_tab_item, parent, false)) | ||
} | ||
|
||
override fun getItemCount(): Int { | ||
return tabs.size | ||
} | ||
|
||
override fun onBindViewHolder(holder: ViewHolder, position: Int) { | ||
holder.itemView | ||
holder.bindTab(tabs[position]) | ||
} | ||
} |
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
5 changes: 5 additions & 0 deletions
5
PennMobile/src/main/java/com/pennapps/labs/pennmobile/classes/Tab.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,5 @@ | ||
package com.pennapps.labs.pennmobile.classes | ||
|
||
class Tab(val name: String) { | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="300dp" | ||
android:layout_height="60dp" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
|
||
<ImageView | ||
android:id="@+id/ivDynamicTab" | ||
android:layout_width="40dp" | ||
android:layout_height="40dp" | ||
android:layout_marginStart="20dp" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
android:background="@drawable/ic_home_grey"/> | ||
<TextView | ||
android:id="@+id/tvDynamicTab" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="20dp" | ||
app:layout_constraintStart_toEndOf="@id/ivDynamicTab" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
android:textSize="24sp" | ||
style="@style/tab_text" | ||
tools:text="Dining"/> | ||
<View | ||
android:layout_width="match_parent" | ||
android:layout_height="1dp" | ||
android:background="@color/black" | ||
app:layout_constraintBottom_toBottomOf="parent" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
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,25 @@ | ||
<?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" | ||
tools:context=".DynamicTabsFragment"> | ||
|
||
<androidx.cardview.widget.CardView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="100dp" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent"> | ||
<androidx.recyclerview.widget.RecyclerView | ||
android:id="@+id/rvDynamicTabs" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
|
||
tools:listitem="@layout/dynamic_tab_item" | ||
tools:itemCount="8"/> | ||
</androidx.cardview.widget.CardView> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
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