Create colorToolbarDark and colorStatusBar to color the toolbar and the status bar in the night mode theme and add the necessary methods to use them in the app accordingly.
This commit is contained in:
parent
5cde97f1e7
commit
2db74516bb
4 changed files with 21 additions and 11 deletions
|
@ -23,20 +23,21 @@ class HomeFragment : Fragment() {
|
||||||
|
|
||||||
private lateinit var mUserAccountViewModel: UserAccountViewModel
|
private lateinit var mUserAccountViewModel: UserAccountViewModel
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
inflater: LayoutInflater, container: ViewGroup?,
|
|
||||||
savedInstanceState: Bundle?
|
|
||||||
): View? {
|
|
||||||
setHasOptionsMenu(true)
|
setHasOptionsMenu(true)
|
||||||
|
|
||||||
|
val nightMode = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
|
.getBoolean(Constants.KEY_NIGHT_MODE_ACTIVATED, false)
|
||||||
|
|
||||||
// Sets the toolbar background color to primaryColor and forces shows the Bitsy icon to the left
|
// Sets the toolbar background color to primaryColor and forces shows the Bitsy icon to the left
|
||||||
val toolbar: Toolbar? = activity?.findViewById(R.id.toolbar)
|
val toolbar: Toolbar? = activity?.findViewById(R.id.toolbar)
|
||||||
toolbar?.navigationIcon = resources.getDrawable(R.drawable.ic_bitsy_logo_2, null)
|
toolbar?.navigationIcon = resources.getDrawable(R.drawable.ic_bitsy_logo_2, null)
|
||||||
toolbar?.setBackgroundResource(R.color.colorPrimary)
|
toolbar?.setBackgroundResource(if (!nightMode) R.color.colorPrimary else R.color.colorToolbarDark)
|
||||||
|
|
||||||
// Sets the status bar background color to a primaryColorDark
|
// Sets the status bar background color to a primaryColorDark
|
||||||
val window = activity?.window
|
val window = activity?.window
|
||||||
window?.statusBarColor = ContextCompat.getColor(context!!, R.color.colorPrimaryDark)
|
window?.statusBarColor = ContextCompat.getColor(context!!,
|
||||||
|
if (!nightMode) R.color.colorPrimaryDark else R.color.colorStatusBarDark)
|
||||||
|
|
||||||
return inflater.inflate(R.layout.fragment_home, container, false)
|
return inflater.inflate(R.layout.fragment_home, container, false)
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,13 +95,17 @@ class ReceiveTransactionFragment : Fragment(), ServiceConnection {
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
setHasOptionsMenu(true)
|
setHasOptionsMenu(true)
|
||||||
|
|
||||||
|
val nightMode = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
|
.getBoolean(Constants.KEY_NIGHT_MODE_ACTIVATED, false)
|
||||||
|
|
||||||
// Sets the toolbar background color to green
|
// Sets the toolbar background color to green
|
||||||
val toolbar: Toolbar? = activity?.findViewById(R.id.toolbar)
|
val toolbar: Toolbar? = activity?.findViewById(R.id.toolbar)
|
||||||
toolbar?.setBackgroundResource(R.color.colorReceive)
|
toolbar?.setBackgroundResource(if (!nightMode) R.color.colorReceive else R.color.colorToolbarDark)
|
||||||
|
|
||||||
// Sets the status bar background color to a dark green
|
// Sets the status bar background color to a dark green
|
||||||
val window = activity?.window
|
val window = activity?.window
|
||||||
window?.statusBarColor = ContextCompat.getColor(context!!, R.color.colorReceiveDark)
|
window?.statusBarColor = ContextCompat.getColor(context!!,
|
||||||
|
if (!nightMode) R.color.colorReceiveDark else R.color.colorStatusBarDark)
|
||||||
|
|
||||||
return inflater.inflate(R.layout.fragment_receive_transaction, container, false)
|
return inflater.inflate(R.layout.fragment_receive_transaction, container, false)
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,13 +111,17 @@ class SendTransactionFragment : Fragment(), ZXingScannerView.ResultHandler, Serv
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
setHasOptionsMenu(true)
|
setHasOptionsMenu(true)
|
||||||
|
|
||||||
|
val nightMode = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
|
.getBoolean(Constants.KEY_NIGHT_MODE_ACTIVATED, false)
|
||||||
|
|
||||||
// Sets the toolbar background color to red
|
// Sets the toolbar background color to red
|
||||||
val toolbar: Toolbar? = activity?.findViewById(R.id.toolbar)
|
val toolbar: Toolbar? = activity?.findViewById(R.id.toolbar)
|
||||||
toolbar?.setBackgroundResource(R.color.colorSend)
|
toolbar?.setBackgroundResource(if (!nightMode) R.color.colorSend else R.color.colorToolbarDark)
|
||||||
|
|
||||||
// Sets the status bar background color to a dark red
|
// Sets the status bar background color to a dark red
|
||||||
val window = activity?.window
|
val window = activity?.window
|
||||||
window?.statusBarColor = ContextCompat.getColor(context!!, R.color.colorSendDark)
|
window?.statusBarColor = ContextCompat.getColor(context!!,
|
||||||
|
if (!nightMode) R.color.colorSendDark else R.color.colorStatusBarDark)
|
||||||
|
|
||||||
return inflater.inflate(R.layout.fragment_send_transaction, container, false)
|
return inflater.inflate(R.layout.fragment_send_transaction, container, false)
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
<!-- Dark theme -->
|
<!-- Dark theme -->
|
||||||
<color name="colorBackgroundFloating">#424242</color>
|
<color name="colorBackgroundFloating">#424242</color>
|
||||||
|
<color name="colorToolbarDark">#424242</color>
|
||||||
|
<color name="colorStatusBarDark">#212121</color>
|
||||||
|
|
||||||
<color name="black">#000</color>
|
<color name="black">#000</color>
|
||||||
<color name="gray">#888</color>
|
<color name="gray">#888</color>
|
||||||
|
@ -17,6 +19,5 @@
|
||||||
<color name="colorReceiveDark">#1B5E20</color>
|
<color name="colorReceiveDark">#1B5E20</color>
|
||||||
<color name="colorSend">#D32F2F</color>
|
<color name="colorSend">#D32F2F</color>
|
||||||
<color name="colorSendDark">#B71C1C</color>
|
<color name="colorSendDark">#B71C1C</color>
|
||||||
<color name="errorRed">#F44336</color>
|
|
||||||
<color name="semiTransparent">#2888</color>
|
<color name="semiTransparent">#2888</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue