Archived
Transitioned from a fairly custom solution to using a colour palette generated by the Material Theme Builder to simplify colour management. Also began work on a bottom sheet for displaying allergens and additives in canteen offers.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package com.denizk0461.studip.sheet
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.LayoutRes
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
|
||||
/**
|
||||
* Bottom sheet super class providing common functionality. All bottom sheets should inherit from
|
||||
* this.
|
||||
*
|
||||
* @param layoutId ID of the layout of the bottom sheet
|
||||
*/
|
||||
open class AppSheet(@LayoutRes private val layoutId: Int) : BottomSheetDialogFragment() {
|
||||
|
||||
// Internal context object
|
||||
private lateinit var _context: Context
|
||||
|
||||
// Get non-null context. Only valid after onAttach()
|
||||
override fun getContext(): Context = _context
|
||||
|
||||
override fun onAttach(context: Context) {
|
||||
super.onAttach(context)
|
||||
_context = context
|
||||
}
|
||||
|
||||
// Inflate the given layout
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View =
|
||||
LayoutInflater.from(context).inflate(layoutId, container, false)
|
||||
}
|
||||
Reference in New Issue
Block a user