Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

GtechGovind/SmartDialog

Repository files navigation

Smart Dialog

An Android library that solves all Dialog Needs

Importing

The library may be found on Maven Central repository. Add it to your project by adding the following dependency:

implementation 'com.github.GtechGovind:SmartDialog:1.0'

Also uh need to add following in settings.gradle

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }
}

Usage

This lib offers two types of dialogs Loading Dialog & Aleart Dailog

Loading Dialog

This functions can only be called in Activity or Fragment

startLoader("Pass your message")
              or
startLoader() // default message : Please wait loading 

Aleart Dialog

This functions can only be called in Activity or Fragment

Function Defination

enum class DialogType {
    SUCCESS,
    INFO,
    ERROR
}

showAlert(message: String, type: DialogType, dialogListeners: DialogListeners? = null)

You can extend your Activity & Fragment with "DialogListeners" in order to recive button click event

Example (With DialogListeners)

If you use "DialogListeners" then dont forget to call dialog?.dismiss()

class ChatFragment : Fragment(), DialogListeners {

    private var _binding: FragmentChatBinding? = null
    private val binding get() = _binding!!

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
        _binding = FragmentChatBinding.inflate(inflater, container, false)
        return binding.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        showAlert("hello", DialogType.SUCCESS, this)
    }

    override fun onDialogClick(dialog: Dialog?, type: DialogType) {
        // Do user stuff
        dialog?.dismiss()
    }

    override fun onDestroy() {
        super.onDestroy()
        _binding = null
    }
    
}

Example (Without DialogListeners)

class ChatFragment : Fragment() {

    private var _binding: FragmentChatBinding? = null
    private val binding get() = _binding!!

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
        _binding = FragmentChatBinding.inflate(inflater, container, false)
        return binding.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        showAlert("hello", DialogType.SUCCESS)
    }

    override fun onDestroy() {
        super.onDestroy()
        _binding = null
    }
    
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages