Skip to content

Commit

Permalink
Added an ability to specify the Bottom Sheet Configuration in the cor…
Browse files Browse the repository at this point in the history
…responding extensions methods.
  • Loading branch information
arthur3486 committed Mar 9, 2019
1 parent bce7c85 commit a5565f1
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 27 deletions.
Binary file modified app/release/app-release.apk
Binary file not shown.
2 changes: 1 addition & 1 deletion app/release/output.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":8,"versionName":"1.0.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":9,"versionName":"1.0.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
5 changes: 4 additions & 1 deletion app/src/main/java/com/arthurivanets/demo/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import com.arthurivanets.bottomsheets.BaseBottomSheet
import com.arthurivanets.bottomsheets.BottomSheet
import com.arthurivanets.bottomsheets.ktx.showActionPickerBottomSheet
import com.arthurivanets.bottomsheets.ktx.showCustomActionPickerBottomSheet
import com.arthurivanets.bottomsheets.sheets.config.Config
import com.arthurivanets.bottomsheets.sheets.listeners.OnItemSelectedListener
import com.arthurivanets.demo.R
import com.arthurivanets.demo.adapters.persons.PersonItem
Expand Down Expand Up @@ -75,8 +76,10 @@ class MainActivity : AppCompatActivity() {
dismissBottomSheet()

bottomSheet = showActionPickerBottomSheet(
title = getString(R.string.confirmation_title_item_deletion),
options = ConfirmationActionsProvider.getGeneralDeletionConfirmationActionOptions(this),
config = Config.Builder(this)
.title(getString(R.string.confirmation_title_item_deletion))
.build(),
onItemSelectedListener = OnItemSelectedListener {
shortToast(it.title.toString())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

@file:JvmName("BottomSheetsExtensions")
@file:JvmName("BottomSheetsUtils")

package com.arthurivanets.bottomsheets.ktx

Expand All @@ -24,6 +24,7 @@ import com.arthurivanets.bottomsheets.sheets.ActionPickerBottomSheet
import com.arthurivanets.bottomsheets.sheets.CustomActionPickerBottomSheet
import com.arthurivanets.bottomsheets.sheets.adapters.actionpicker.ActionItem
import com.arthurivanets.bottomsheets.sheets.adapters.actionpicker.BaseActionItem
import com.arthurivanets.bottomsheets.sheets.config.ActionPickerConfig
import com.arthurivanets.bottomsheets.sheets.config.Config
import com.arthurivanets.bottomsheets.sheets.listeners.OnItemSelectedListener
import com.arthurivanets.bottomsheets.sheets.model.Option
Expand All @@ -32,19 +33,36 @@ import com.arthurivanets.bottomsheets.sheets.model.Option
/**
* Initializes and shows the [Option] Action Picker Bottom Sheet.
*
* @param title bottom sheet header title (optional)
* @param options bottom sheet action options
* @param onItemSelectedListener item selection listener
*/
@JvmOverloads
fun Fragment.showActionPickerBottomSheet(title : CharSequence = "",
options : List<Option>,
fun Fragment.showActionPickerBottomSheet(options : List<Option>,
onItemSelectedListener : OnItemSelectedListener<Option>) : ActionPickerBottomSheet {
assertAttachedToActivity()

return showActionPickerBottomSheet(
options = options,
config = Config.Builder(this.activity!!).build(),
onItemSelectedListener = onItemSelectedListener
)
}


/**
* Initializes and shows the [Option] Action Picker Bottom Sheet.
*
* @param options bottom sheet action options
* @param config bottom sheet configuration (optional)
* @param onItemSelectedListener item selection listener
*/
fun Fragment.showActionPickerBottomSheet(options : List<Option>,
config : ActionPickerConfig,
onItemSelectedListener : OnItemSelectedListener<Option>) : ActionPickerBottomSheet {
assertAttachedToActivity()

return activity!!.showActionPickerBottomSheet(
title = title,
options = options,
config = config,
onItemSelectedListener = onItemSelectedListener
)
}
Expand All @@ -53,20 +71,18 @@ fun Fragment.showActionPickerBottomSheet(title : CharSequence = "",
/**
* Initializes and shows the [Option] Action Picker Bottom Sheet.
*
* @param title bottom sheet header title (optional)
* @param options bottom sheet action options
* @param config bottom sheet configuration (optional)
* @param onItemSelectedListener item selection listener
*/
@JvmOverloads
fun Activity.showActionPickerBottomSheet(title : CharSequence = "",
options : List<Option>,
fun Activity.showActionPickerBottomSheet(options : List<Option>,
config : ActionPickerConfig = Config.Builder(this).build(),
onItemSelectedListener : OnItemSelectedListener<Option>) : ActionPickerBottomSheet {
return ActionPickerBottomSheet.init(
this,
options.map(::ActionItem),
Config.Builder(this)
.title(title)
.build()
config
).also {
it.setOnItemSelectedListener { onItemSelectedListener.onItemSelected(it.itemModel) }
it.show()
Expand All @@ -78,19 +94,37 @@ fun Activity.showActionPickerBottomSheet(title : CharSequence = "",
* Initializes and shows the Custom Action Picker Bottom Sheet.
* Your custom action items of type [T] will be utilized.
*
* @param title bottom sheet header title (optional)
* @param items your custom bottom sheet action items
* @param onItemSelectedListener item selection listener
*/
@JvmOverloads
fun <T : BaseActionItem<*, *, *>> Fragment.showCustomActionPickerBottomSheet(title : CharSequence = "",
items : List<T>,
fun <T : BaseActionItem<*, *, *>> Fragment.showCustomActionPickerBottomSheet(items : List<T>,
onItemSelectedListener : OnItemSelectedListener<T>) : CustomActionPickerBottomSheet<T> {
assertAttachedToActivity()

return showCustomActionPickerBottomSheet(
items = items,
config = Config.Builder(this.activity!!).build(),
onItemSelectedListener = onItemSelectedListener
)
}


/**
* Initializes and shows the Custom Action Picker Bottom Sheet.
* Your custom action items of type [T] will be utilized.
*
* @param items your custom bottom sheet action items
* @param config bottom sheet configuration (optional)
* @param onItemSelectedListener item selection listener
*/
fun <T : BaseActionItem<*, *, *>> Fragment.showCustomActionPickerBottomSheet(items : List<T>,
config : ActionPickerConfig,
onItemSelectedListener : OnItemSelectedListener<T>) : CustomActionPickerBottomSheet<T> {
assertAttachedToActivity()

return activity!!.showCustomActionPickerBottomSheet(
title = title,
items = items,
config = config,
onItemSelectedListener = onItemSelectedListener
)
}
Expand All @@ -100,20 +134,18 @@ fun <T : BaseActionItem<*, *, *>> Fragment.showCustomActionPickerBottomSheet(tit
* Initializes and shows the Custom Action Picker Bottom Sheet.
* Your custom action items of type [T] will be utilized.
*
* @param title bottom sheet header title (optional)
* @param items your custom bottom sheet action items
* @param config bottom sheet configuration (optional)
* @param onItemSelectedListener item selection listener
*/
@JvmOverloads
fun <T : BaseActionItem<*, *, *>> Activity.showCustomActionPickerBottomSheet(title : CharSequence = "",
items : List<T>,
fun <T : BaseActionItem<*, *, *>> Activity.showCustomActionPickerBottomSheet(items : List<T>,
config : ActionPickerConfig = Config.Builder(this).build(),
onItemSelectedListener : OnItemSelectedListener<T>) : CustomActionPickerBottomSheet<T> {
return CustomActionPickerBottomSheet.init(
this,
items,
Config.Builder(this)
.title(title)
.build()
config
).also {
it.setOnItemSelectedListener(onItemSelectedListener)
it.show()
Expand Down
4 changes: 2 additions & 2 deletions common/constants.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ project.ext {
releaseRepoName = "maven"
releaseUserOrg = "arthurlabs"
releaseGroupId = "com.arthurivanets.bottomsheet"
releaseVersion = "1.0.0"
releaseVersionCode = 8
releaseVersion = "1.0.1"
releaseVersionCode = 10
releaseWebsite = "https://github.com/arthur3486/bottomsheet"
releaseLicense = ["Apache-2.0"]

Expand Down

0 comments on commit a5565f1

Please sign in to comment.