diff --git a/app/src/main/java/divyansh/tech/animeclassroom/settings/SettingsFragment.kt b/app/src/main/java/divyansh/tech/animeclassroom/settings/SettingsFragment.kt index 2997149..2fdb816 100644 --- a/app/src/main/java/divyansh/tech/animeclassroom/settings/SettingsFragment.kt +++ b/app/src/main/java/divyansh/tech/animeclassroom/settings/SettingsFragment.kt @@ -1,9 +1,63 @@ package divyansh.tech.animeclassroom.settings +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.appcompat.app.AlertDialog +import androidx.appcompat.app.AppCompatActivity +import androidx.appcompat.app.AppCompatDelegate import androidx.fragment.app.Fragment import dagger.hilt.android.AndroidEntryPoint import divyansh.tech.animeclassroom.R +import divyansh.tech.animeclassroom.databinding.FragmentHomeBinding +import divyansh.tech.animeclassroom.databinding.FragmentSearchBinding +import divyansh.tech.animeclassroom.generated.callback.OnClickListener +import kotlinx.android.synthetic.main.fragment_settings.* + +//Todo: Use FragmentSettingsBinding @AndroidEntryPoint -class SettingsFragment: Fragment(R.layout.fragment_settings) { +class SettingsFragment: Fragment(){ + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + return inflater.inflate(R.layout.fragment_settings, container, false) + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + setUpListeners() + } + + private fun setUpListeners() { + ui_mode.setOnClickListener{showUIDialog()} + } + + private fun showUIDialog() { + val uiModes = resources.getStringArray(R.array.ui_mode) + val checkedItem = 0 + + val alertDialogBuilder = AlertDialog.Builder(requireContext()) + alertDialogBuilder.setTitle("Choose ui Mode") + alertDialogBuilder.setSingleChoiceItems(uiModes, checkedItem){ dialog, checked -> + setUiMode(checked) + dialog.dismiss() + } + val alertDialog = alertDialogBuilder.create().apply { + setCancelable(true) + show() + } + } + + private fun setUiMode(checked: Int) { + when(checked){ + 0 -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO) + 1 -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES) + 2 -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM) + } + } } \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_baseline_arrow_forward_ios_24.xml b/app/src/main/res/drawable/ic_baseline_arrow_forward_ios_24.xml new file mode 100644 index 0000000..d7c08d9 --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_arrow_forward_ios_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/fragment_settings.xml b/app/src/main/res/layout/fragment_settings.xml index 465cedf..d3e2eaf 100644 --- a/app/src/main/res/layout/fragment_settings.xml +++ b/app/src/main/res/layout/fragment_settings.xml @@ -1,12 +1,72 @@ - + + + + android:layout_height="match_parent" + android:orientation="vertical" + android:background="@color/app_background" + android:paddingTop="20dp" + app:layout_constraintTop_toBottomOf="@+id/header" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintRight_toRightOf="parent"> + + + + + + + + + + + - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d443d11..2be335b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -35,4 +35,12 @@ Plot Summary No results for searched query + + Change Theme + + Light Mode + Night Mode + System + + \ No newline at end of file