Skip to content

Commit c788585

Browse files
committed
适配深色模式
1 parent 2d3007f commit c788585

3 files changed

Lines changed: 45 additions & 1 deletion

File tree

app/src/main/java/com/loper7/datepicker/WeekPickerExampleActivity.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ class WeekPickerExampleActivity : AppCompatActivity() {
101101
.setStartMillisecond(minDate)
102102
.setEndMillisecond(maxDate)
103103
.setThemeColor(if (model == R.drawable.shape_bg_dialog_custom) Color.parseColor("#FF8000") else 0)
104+
// .setBackGroundModel(R.drawable.shape_bg_dialog_dark)
105+
// .setAssistColor(Color.parseColor("#DDFFFFFF"))
106+
// .setDividerColor(Color.parseColor("#222222"))
104107
.setFormatter {
105108
NumberPicker.Formatter { value: Int ->
106109
var weekData = it[value - 1].toFormatList("MM月dd日")

date_time_picker/src/main/java/com/loper7/date_time_picker/dialog/CardWeekPickerDialog.kt

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ import java.util.*
2626
/**
2727
* 卡片 周视图 选择器
2828
*/
29-
open class CardWeekPickerDialog(context: Context) : BottomSheetDialog(context), View.OnClickListener {
29+
open class CardWeekPickerDialog(context: Context) : BottomSheetDialog(context),
30+
View.OnClickListener {
3031
companion object {
3132
const val CARD = 0 //卡片
3233
const val CUBE = 1 //方形
@@ -44,6 +45,8 @@ open class CardWeekPickerDialog(context: Context) : BottomSheetDialog(context),
4445
private val tv_submit by lazy { delegate.findViewById<TextView>(R.id.dialog_submit) }
4546
private val tv_title by lazy { delegate.findViewById<TextView>(R.id.tv_title) }
4647
private val linear_bg by lazy { delegate.findViewById<LinearLayout>(R.id.linear_bg) }
48+
private val divider_bottom by lazy { delegate.findViewById<View>(R.id.divider_bottom) }
49+
private val divider_line by lazy { delegate.findViewById<View>(R.id.dialog_select_border) }
4750

4851
private var mBehavior: BottomSheetBehavior<FrameLayout>? = null
4952

@@ -128,6 +131,19 @@ open class CardWeekPickerDialog(context: Context) : BottomSheetDialog(context),
128131
np_week!!.selectedTextColor = themeColor
129132
}
130133

134+
if (builder!!.assistColor != 0) {
135+
tv_title?.setTextColor(builder!!.assistColor)
136+
tv_cancel?.setTextColor(builder!!.assistColor)
137+
np_week!!.textColor = builder!!.assistColor
138+
139+
140+
}
141+
if (builder!!.dividerColor != 0) {
142+
divider_bottom?.setBackgroundColor(builder!!.dividerColor)
143+
divider_line?.setBackgroundColor(builder!!.dividerColor)
144+
np_week!!.dividerColor = builder!!.dividerColor
145+
}
146+
131147
}
132148

133149
//视图周
@@ -194,6 +210,12 @@ open class CardWeekPickerDialog(context: Context) : BottomSheetDialog(context),
194210
@JvmField
195211
var themeColor: Int = 0
196212

213+
@JvmField
214+
var assistColor: Int = 0
215+
216+
@JvmField
217+
var dividerColor: Int = 0
218+
197219
@JvmField
198220
var wrapSelectorWheel: Boolean = true
199221

@@ -331,6 +353,24 @@ open class CardWeekPickerDialog(context: Context) : BottomSheetDialog(context),
331353
return this
332354
}
333355

356+
/**
357+
* 这只dialog内辅助文字的颜色
358+
* @return Builder
359+
*/
360+
fun setAssistColor(@ColorInt value: Int): Builder {
361+
this.assistColor = value
362+
return this
363+
}
364+
365+
/**
366+
* 这只dialog内分割线颜色
367+
* @return Builder
368+
*/
369+
fun setDividerColor(@ColorInt value: Int): Builder {
370+
this.dividerColor = value
371+
return this
372+
}
373+
334374
fun build(): CardWeekPickerDialog {
335375
return CardWeekPickerDialog(context, this)
336376
}

date_time_picker/src/main/res/layout/dt_dialog_week_picker.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
app:np_wheelItemCount="3" />
3838

3939
<View
40+
android:id="@+id/divider_bottom"
4041
android:layout_width="match_parent"
4142
android:layout_height="0.6dp"
4243
android:layout_marginTop="10dp"

0 commit comments

Comments
 (0)