GriverBackButtonStyleExtension
IAPMiniProgram SDK provides the ability to customize the style of the back button in the title bar of the mini program, so that the Super App can use its own text or image to customize and render the back button of the mini programs accordingly. Follow this topic to realize this customization ability by implementing the specific interface of IAPMiniProgram SDK.
Procedures
Step 1. Implement the GriverBackButtonStyleExtension interface
Implement the GriverBackButtonStyleExtension interface and write code in the required methods according to your business logic.
Code sample as follows:
class CustomGriverBackButtonStyleExtensionImpl : GriverBackButtonStyleExtension {
override fun getType(): String {
return "icon"
}
override fun getContent(): String {
return ""
}
override fun getIconDrawable(): Drawable {
return context.getResources().getDrawable(R.drawable.custom_back)
}
}
Step 2: Register the CustomGriverBackButtonStyleExtensionImpl class
Refer to the following sample code and call the registerExtension interface to register the CustomGriverBackButtonStyleExtensionImpl class after initializing the SDK.
IAPConnect.init(application, initConfig, object : InitCallback() {
fun onSuccess() {
//ยทยทยท
Griver.registerExtension(
GriverExtensionManifest(
GriverBackButtonStyleExtension::class.java,
CustomGriverBackButtonStyleExtensionImpl()
)
)
}
})
Structures
GriverBackButtonStyleExtension interface
The definition of the GriverBackButtonStyleExtension interface is shown in the following codes:
interface GriverBackButtonStyleExtension : GriverButtonStyleExtension {
}
interface GriverButtonStyleExtension : GriverExtension {
fun type(): String
fun content(): String
fun iconDrawable(): Drawable
}
Methods
Based on this interface definition, it provides the following methods:
Method | Description |
type | This method returns the style of the back button that can be customized. The following types of style (return value) are supported:
Note: If other value is returned, this customization ability does not take effect. |
content | This method is called when the return value of the type method is This method returns the customized display text of the back button. Note: Because of the current width limitation of the back button component, the custom text may not be fully displayed. |
iconDrawable | This method is called when the return value of the type method is This method returns the customized image resource of the back button. |
Appendices
User experience
Configuration | Screenshot |
When the type method returns | |
When the type method returns Tip: The custom text may not be fully displayed. |