Skip to content

Commit

Permalink
适配深色模式
Browse files Browse the repository at this point in the history
  • Loading branch information
loper7 committed Sep 13, 2022
1 parent 1cb9664 commit 2d3007f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ class DatePickerExampleActivity : AppCompatActivity() {
var dialog = CardDatePickerDialog.builder(context)
.setTitle("DATE&TIME PICKER")
.setDisplayType(displayList)
// .setBackGroundModel(model)
.setBackGroundModel(R.drawable.shape_bg_dialog_dark)
.setBackGroundModel(model)
// .setBackGroundModel(R.drawable.shape_bg_dialog_dark)
.showBackNow(checkBackNow.isChecked)
.setMaxTime(maxDate)
.setPickerLayout(pickerLayout)
Expand All @@ -139,7 +139,8 @@ class DatePickerExampleActivity : AppCompatActivity() {
.setChooseDateModel(DateTimeConfig.DATE_LUNAR)
.setWrapSelectorWheel(false)
.setThemeColor(if (model == R.drawable.shape_bg_dialog_custom) Color.parseColor("#FF8000") else 0)
.setAssistColor(Color.parseColor("#ffffff"))
// .setAssistColor(Color.parseColor("#DDFFFFFF"))
// .setDividerColor(Color.parseColor("#222222"))
.showDateLabel(checkUnitLabel.isChecked)
.showFocusDateInfo(checkDateInfo.isChecked)
.setOnChoose("选择") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import com.loper7.date_time_picker.DateTimePicker
import com.loper7.date_time_picker.R
import com.loper7.date_time_picker.utils.StringUtils
import com.loper7.date_time_picker.utils.lunar.Lunar
import kotlinx.android.synthetic.main.dt_dialog_time_picker.*
import org.jetbrains.annotations.NotNull
import java.util.*

Expand Down Expand Up @@ -61,6 +60,9 @@ open class CardDatePickerDialog(context: Context) :
private var linear_now: LinearLayout? = null
private var linear_bg: LinearLayout? = null
private var mBehavior: BottomSheetBehavior<FrameLayout>? = null
private var divider_top:View?=null
private var divider_bottom:View?=null
private var divider_line:View?=null

private var millisecond: Long = 0

Expand Down Expand Up @@ -93,6 +95,9 @@ open class CardDatePickerDialog(context: Context) :
tv_go_back = findViewById(R.id.tv_go_back)
linear_now = findViewById(R.id.linear_now)
linear_bg = findViewById(R.id.linear_bg)
divider_top = findViewById(R.id.divider_top)
divider_bottom = findViewById(R.id.divider_bottom)
divider_line = findViewById(R.id.dialog_select_border)

mBehavior = BottomSheetBehavior.from(bottomSheet)

Expand Down Expand Up @@ -232,13 +237,13 @@ open class CardDatePickerDialog(context: Context) :
tv_cancel?.setTextColor(builder!!.assistColor)
datePicker!!.setTextColor(builder!!.assistColor)

var dividerColor = Color.parseColor("#FFFFFF") - builder!!.assistColor
if(builder!!.assistColor!=0 && dividerColor==0)
dividerColor = Color.parseColor("#40000000")
divider_top?.setBackgroundColor(dividerColor)
divider_bottom?.setBackgroundColor(dividerColor)
dialog_select_border?.setBackgroundColor(dividerColor)
datePicker!!.setDividerColor(dividerColor)

}
if (builder!!.dividerColor != 0) {
divider_top?.setBackgroundColor(builder!!.dividerColor)
divider_bottom?.setBackgroundColor(builder!!.dividerColor)
divider_line?.setBackgroundColor(builder!!.dividerColor)
datePicker!!.setDividerColor(builder!!.dividerColor)
}

tv_cancel!!.setOnClickListener(this)
Expand Down Expand Up @@ -331,6 +336,9 @@ open class CardDatePickerDialog(context: Context) :
@JvmField
var assistColor: Int = 0

@JvmField
var dividerColor: Int = 0

@JvmField
var pickerLayoutResId: Int = 0

Expand Down Expand Up @@ -591,6 +599,15 @@ open class CardDatePickerDialog(context: Context) :
return this
}

/**
* 这只dialog内分割线颜色
* @return Builder
*/
fun setDividerColor(@ColorInt value: Int): Builder {
this.dividerColor = value
return this
}

fun build(): CardDatePickerDialog {
return CardDatePickerDialog(context, this)
}
Expand Down

0 comments on commit 2d3007f

Please sign in to comment.