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:

copy
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.

copy
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:

copy
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:

  • text: the customized text is displayed for the back button.
  • icon: the customized image is displayed for the back button.

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 text.

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 icon.

This method returns the customized image resource of the back button.

Appendices

User experience

Configuration

Screenshot

When the type method returns icon

image.png

When the type method returns text, and the customized content is Back.

Tip: The custom text may not be fully displayed.

image.png