export default (configuration) => {
    return `
    package com.manaknight.app.ui.fragments.chatui

    import Manaknight.R
    import Manaknight.databinding.FragmentRoomListBinding
    import android.os.Bundle
    import android.view.Menu
    import android.view.MenuInflater
    import android.view.MenuItem
    import android.view.View
    import androidx.core.os.bundleOf
    import androidx.fragment.app.Fragment
    import androidx.lifecycle.LifecycleOwner
    import androidx.navigation.fragment.findNavController
    import androidx.recyclerview.widget.LinearLayoutManager
    import com.manaknight.app.adapters.ChatRoomAdapter
    import com.manaknight.app.adapters.FriendListAdapter
    import com.manaknight.app.data.loadAllUserData
    import com.manaknight.app.data.loadDataData
    import com.manaknight.app.data.local.AppPreferences
    import com.manaknight.app.extensions.viewBinding
    import com.manaknight.app.model.remote.ChatRoomListResponse
    import com.manaknight.app.network.Status
    import com.manaknight.app.viewmodels.BaasViewModel
    import org.koin.android.ext.android.inject
    import org.koin.androidx.viewmodel.ext.android.viewModel
    
    class RoomListFragment : Fragment(R.layout.fragment_room_list) {
    
        private val binding by viewBinding(FragmentRoomListBinding::bind)
        private val baasViewModel: BaasViewModel by viewModel()
        private val pref by inject<AppPreferences>()
        var userId = pref.userId
        lateinit var otherUserID:String
    
        private lateinit var adapterData: ChatRoomAdapter
    
        override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
            super.onViewCreated(view, savedInstanceState)
            // binding.icBack.setOnClickListener { findNavController().popBackStack() }
    
            otherUserID = arguments?.getString("otherUserID").toString()
    
            val recyclerview637093b5 = binding.recyclerview637093b5
            adapterData = ChatRoomAdapter(emptyList())
            recyclerview637093b5.layoutManager = LinearLayoutManager(requireContext())
    
    
            loadRoomData(viewLifecycleOwner, baasViewModel, userId!!, otherUserID.toInt(), adapterData)
            recyclerview637093b5.adapter = adapterData
    
    
            adapterData.onItemClick = { roomModel ->
    
                val args = Bundle()
                args.putString("roomid", ""+roomModel.id)
    
    
                findNavController().navigate(R.id.action_loginFragment_to_chatFragment, args)
            }
    
            //setHasOptionsMenu(true)
            binding.addRoom.setOnClickListener {
    
                createRoom(userId!!, otherUserID.toInt())
            }
        }
    
    
        override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
    
            val inflater = inflater
    
            //inflater.inflate(R.menu.add_menu, menu)
    
            //val searchItem: MenuItem = menu.findItem(R.id.alerts)
    
            /*val searchView: SearchView = searchItem.getActionView() as SearchView
    
            searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener,
                android.widget.SearchView.OnQueryTextListener {
                override fun onQueryTextSubmit(p0: String?): Boolean {
                    return false
                }
    
                override fun onQueryTextChange(msg: String): Boolean {
    
                    filter(msg)
                    return false
                }
            })*/
            //return true
        }
    
        fun loadRoomData(viewLifecycleOwner: LifecycleOwner, baasViewModel: BaasViewModel, userId: Int, otherUserId: Int, adapter: ChatRoomAdapter) {
    
            baasViewModel.getAllRoom(userId).observe(viewLifecycleOwner) {
                when (it.status) {
                    Status.ERROR -> println(it.message ?: "Something went wrong")
                    Status.LOADING -> {
    
                    }
    
                    Status.SUCCESS -> {
    
                        it.data?.let {
    
                            var roomList = mutableListOf<ChatRoomListResponse>()
                            for (list in it.list) {
                                if ((list.user_id == userId && list.other_user_id == otherUserId)
                                    || (list.user_id == otherUserId && list.other_user_id == userId)) {
    
                                    roomList.add(list)
                                }
                            }
                            adapter.updateData(roomList)
                            if(roomList.count() > 0) {
                                binding.addRoom.visibility = View.GONE
                            }
                        }
                    }
                }
            }
        }
    
    
        fun createRoom(userId: Int, otherUserId: Int) {
    
            baasViewModel.CreateRoomRequests(userId, otherUserId).observe(viewLifecycleOwner) {
                when (it.status) {
                    Status.ERROR -> println(it.message ?: "Something went wrong")
                    Status.LOADING -> {
    
                    }
    
                    Status.SUCCESS -> {
    
                        loadDataData(viewLifecycleOwner, baasViewModel, userId!!, otherUserID.toInt(), adapterData)
                    }
                }
            }
        }
    
    }
    
    
    

      `;
  };