1
0
Fork 0
mirror of https://github.com/anyproto/anytype-kotlin.git synced 2025-06-08 05:47:05 +09:00

DROID-201 Editor | Style background menu, default color line (#2502)

* DROID-201 add slanted style settings to style

* DROID-201 show slanted line for default background color

* DROID-201 show slanted line in markup menu

Co-authored-by: konstantiniiv <ki@anytype.io>
This commit is contained in:
Konstantin Ivanov 2022-08-10 23:31:29 +02:00 committed by GitHub
parent 1cb82f4c64
commit 283a19835a
Signed by: github
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 3 deletions

View file

@ -15,9 +15,11 @@ class ColorCircleWidget : View {
var innerColor: Int = 0
private var innerStrokeColor: Int = 0
private var innerRadius : Float = 0f
private var innerRadius: Float = 0f
private var outerStrokeWidth: Float = 0f
private var outerStrokeColor: Int = 0
private var showSlantedLine: Boolean = false
private var slantedLineHeight: Int = 0
private val paint = Paint(ANTI_ALIAS_FLAG)
@ -57,6 +59,11 @@ class ColorCircleWidget : View {
R.styleable.ColorCircleWidget_outerStrokeColor,
ContextCompat.getColor(context, R.color.default_style_color_circle_outer_stroke_color)
)
showSlantedLine = attrs.getBoolean(R.styleable.ColorCircleWidget_showSlantedLine, false)
slantedLineHeight = attrs.getDimensionPixelSize(
R.styleable.ColorCircleWidget_slantedLineWidth,
resources.getDimension(R.dimen.default_style_color_slanted_line_height).toInt()
)
attrs.recycle()
}
@ -89,7 +96,7 @@ class ColorCircleWidget : View {
color = innerStrokeColor
}
canvas.apply {
drawCircle(cx, cy, innerRadius - outerStrokeWidth / 4 , paint)
drawCircle(cx, cy, innerRadius - outerStrokeWidth / 4, paint)
}
}
@ -102,7 +109,33 @@ class ColorCircleWidget : View {
color = outerStrokeColor
}
canvas.apply {
drawCircle(cx, cy, radius - outerStrokeWidth / 2 , paint)
drawCircle(cx, cy, radius - outerStrokeWidth / 2, paint)
}
}
if (showSlantedLine) {
paint.apply {
style = Paint.Style.STROKE
strokeWidth = outerStrokeWidth / 2
color = outerStrokeColor
}
val dx = slantedLineHeight / 2
val dy = slantedLineHeight / 2
canvas.apply {
drawLine(
width / 2f,
height / 2f,
width / 2f + dx,
height / 2f - dy,
paint
)
drawLine(
width / 2f,
height / 2f,
width / 2f - dx,
height / 2f + dy,
paint
)
}
}
}

View file

@ -9,6 +9,7 @@
android:id="@+id/backgroundColorDefault"
style="@style/DefaultCircleColorStyle"
app:innerColor="@color/background_primary"
app:showSlantedLine="true"
tools:ignore="MissingConstraints" />
<com.anytypeio.anytype.core_ui.widgets.ColorCircleWidget

View file

@ -9,6 +9,7 @@
android:layout_width="44dp"
android:layout_height="44dp"
android:layout_gravity="center"
app:showSlantedLine="true"
app:outerStrokeColor="@color/shape_primary"
app:innerRadius="18dp" />
</FrameLayout>

View file

@ -30,6 +30,8 @@
<attr name="innerRadius" format="dimension" />
<attr name="outerStrokeWidth" format="dimension" />
<attr name="outerStrokeColor" format="color" />
<attr name="showSlantedLine" format="boolean" />
<attr name="slantedLineWidth" format="dimension"/>
</declare-styleable>
<declare-styleable name="HighlightDrawer">
<attr name="roundedTextHorizontalPadding" format="dimension" />

View file

@ -121,6 +121,7 @@
<dimen name="popup_context_menu_bottom_allowance">40dp</dimen>
<dimen name="default_style_color_circle_inner_radius">22dp</dimen>
<dimen name="default_style_color_outer_stroke_width">2dp</dimen>
<dimen name="default_style_color_slanted_line_height">16dp</dimen>
<dimen name="default_page_links_bottom_offset">64dp</dimen>