-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
위젯 다크 모드 추가 #384
위젯 다크 모드 추가 #384
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ import android.view.MotionEvent | |
import android.view.View | ||
import androidx.core.content.res.ResourcesCompat | ||
import com.wafflestudio.snutt2.R | ||
import com.wafflestudio.snutt2.data.SNUTTStorage | ||
import com.wafflestudio.snutt2.lib.contains | ||
import com.wafflestudio.snutt2.lib.getFittingTrimParam | ||
import com.wafflestudio.snutt2.lib.network.dto.core.ClassTimeDto | ||
|
@@ -18,12 +19,12 @@ import com.wafflestudio.snutt2.lib.rx.sp | |
import com.wafflestudio.snutt2.lib.toDayString | ||
import com.wafflestudio.snutt2.model.BuiltInTheme | ||
import com.wafflestudio.snutt2.model.TableTrimParam | ||
import com.wafflestudio.snutt2.ui.isSystemDarkMode | ||
import io.reactivex.rxjava3.core.Observable | ||
import kotlin.math.max | ||
import kotlin.math.min | ||
|
||
class TimetableView : View { | ||
|
||
private val hourLabelWidth = 24.5f.dp(context) | ||
private val dayLabelHeight = 28.5f.dp(context) | ||
private val cellPadding = 4.dp(context) | ||
|
@@ -132,7 +133,29 @@ class TimetableView : View { | |
} | ||
|
||
private fun init() { | ||
setBackgroundColor(Color.rgb(255, 255, 255)) | ||
val sharedPreferences = context.getSharedPreferences(SNUTTStorage.DOMAIN_SCOPE_CURRENT_VERSION, Context.MODE_PRIVATE) | ||
val themeMode = sharedPreferences.getString("theme_mode", null) ?: "" | ||
val isDarkMode = when (themeMode) { | ||
"\"DARK\"" -> true | ||
"\"LIGHT\"" -> false | ||
else -> isSystemDarkMode(context) | ||
} | ||
Comment on lines
+136
to
+142
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 생각보다 앱 내 화면 모드를 가져오는게 어렵지 않았어 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 어 isSystemDarkMode 이거 composable 함수인줄 알았는데 아니었구나 ㅋㅋㅋ 굳굳 |
||
|
||
setBackgroundColor( | ||
if (isDarkMode) Color.rgb(43, 43, 43) else Color.rgb(255, 255, 255), | ||
) | ||
linePaint.apply { | ||
color = if (isDarkMode) Color.rgb(60, 60, 60) else Color.rgb(235, 235, 235) | ||
} | ||
subLinePaint.apply { | ||
color = if (isDarkMode) Color.rgb(60, 60, 60) else Color.rgb(243, 243, 243) | ||
} | ||
hourLabelTextPaint.apply { | ||
color = if (isDarkMode) Color.rgb(119, 119, 119) else Color.rgb(0, 0, 0) | ||
} | ||
dayLabelTextPaint.apply { | ||
color = if (isDarkMode) Color.rgb(119, 119, 119) else Color.rgb(0, 0, 0) | ||
} | ||
Comment on lines
+144
to
+158
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Color... 좀 마음에 안들게 가져오는데 SNUTTColors꺼를 갖다 쓰는게 안되니 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 일단 싸게싸게 ㄱㄱ |
||
} | ||
|
||
override fun onDraw(canvas: Canvas) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 SharedPreference에 ThemeMode 저장할 때 큰따옴표도 같이 저장돼??
직렬화할 때
MoshiSerializer#serialize()
타는 거 같은데 moshi가 그렇게 동작하는건가There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
음 그러게 ThemeMode가 Enum이라 그런가
저장할 때 직렬화를 하는데, getSharedPreferences로 가져와서 그럴까..?
이유는 생각 안해보긴 했어.. ㅋㅋㅋㅋ