|
|
|
|
@ -42,6 +42,23 @@ open class BottomSheetFragment : BottomSheetDialogFragment() { |
|
|
|
|
|
|
|
|
|
const val REQUEST_CODE_ADD_NEW_OBJECT = 100 |
|
|
|
|
|
|
|
|
|
private fun newInstance(bottomSheetType: BottomSheetType): BottomSheetFragment { |
|
|
|
|
return when (bottomSheetType) { |
|
|
|
|
BottomSheetType.NONE -> BottomSheetFragment() |
|
|
|
|
BottomSheetType.LIST -> BottomSheetListFragment() |
|
|
|
|
BottomSheetType.LIST_STATIC -> BottomSheetStaticListFragment() |
|
|
|
|
BottomSheetType.LIST_GAME -> BottomSheetListGameFragment() |
|
|
|
|
BottomSheetType.DOUBLE_LIST -> BottomSheetListGameFragment() |
|
|
|
|
BottomSheetType.MULTI_SELECTION -> BottomSheetMultiSelectionFragment() |
|
|
|
|
BottomSheetType.GRID -> BottomSheetTableSizeGridFragment() |
|
|
|
|
BottomSheetType.EDIT_TEXT -> BottomSheetEditTextFragment() |
|
|
|
|
BottomSheetType.EDIT_TEXT_MULTI_LINES -> BottomSheetEditTextMultiLinesFragment() |
|
|
|
|
BottomSheetType.DOUBLE_EDIT_TEXT -> BottomSheetDoubleEditTextFragment() |
|
|
|
|
BottomSheetType.NUMERIC_TEXT -> BottomSheetNumericTextFragment() |
|
|
|
|
BottomSheetType.SUM -> BottomSheetSumFragment() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun create( |
|
|
|
|
fragmentManager: FragmentManager?, |
|
|
|
|
row: RowRepresentable, |
|
|
|
|
@ -52,7 +69,7 @@ open class BottomSheetFragment : BottomSheetDialogFragment() { |
|
|
|
|
isDeletable: Boolean? = false, |
|
|
|
|
valueHasPlaceholder: Boolean? = null |
|
|
|
|
): BottomSheetFragment { |
|
|
|
|
val bottomSheetFragment = row.bottomSheetType.newInstance() |
|
|
|
|
val bottomSheetFragment = newInstance(row.bottomSheetType) |
|
|
|
|
bottomSheetFragment.show(fragmentManager, "bottomSheet") |
|
|
|
|
bottomSheetFragment.row = row |
|
|
|
|
bottomSheetFragment.delegate = delegate |
|
|
|
|
@ -76,7 +93,6 @@ open class BottomSheetFragment : BottomSheetDialogFragment() { |
|
|
|
|
initUI() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { |
|
|
|
|
super.onActivityResult(requestCode, resultCode, data) |
|
|
|
|
|
|
|
|
|
@ -103,7 +119,7 @@ open class BottomSheetFragment : BottomSheetDialogFragment() { |
|
|
|
|
* Init UI |
|
|
|
|
*/ |
|
|
|
|
private fun initUI() { |
|
|
|
|
row.let { |
|
|
|
|
|
|
|
|
|
bottomSheetToolbar.title = row.localizedTitle(requireContext()) |
|
|
|
|
bottomSheetToolbar.inflateMenu(R.menu.toolbar_bottom_sheet) |
|
|
|
|
bottomSheetToolbar.setOnMenuItemClickListener { |
|
|
|
|
@ -153,7 +169,7 @@ open class BottomSheetFragment : BottomSheetDialogFragment() { |
|
|
|
|
|
|
|
|
|
bottomSheetToolbar.menu.findItem(R.id.actionClear).isVisible = isClearable |
|
|
|
|
bottomSheetToolbar.menu.findItem(R.id.actionDelete).isVisible = isDeletable |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|