Polls in compose

This commit is contained in:
Grishka
2022-02-13 00:29:15 +03:00
parent dc63d054dc
commit ce258f1b54
9 changed files with 374 additions and 5 deletions

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/gray_800" android:alpha="0.3" android:state_enabled="false"/>
<item android:color="@color/gray_800"/>
</selector>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/gray_100"/>
<corners android:radius="10dp"/>
</shape>

View File

@@ -0,0 +1,3 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
<path android:pathData="M12 3.5c-4.694 0-8.5 3.806-8.5 8.5s3.806 8.5 8.5 8.5 8.5-3.806 8.5-8.5-3.806-8.5-8.5-8.5zM2 12C2 6.477 6.477 2 12 2s10 4.477 10 10-4.477 10-10 10S2 17.523 2 12z" android:fillColor="@color/fluent_default_icon_tint"/>
</vector>

View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="8dp"
android:paddingStart="16dp"
android:clipToPadding="false">
<LinearLayout
android:layout_width="0dp"
android:layout_height="56dp"
android:layout_weight="1"
android:background="@drawable/bg_poll_option"
android:outlineProvider="background"
android:elevation="2dp">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_margin="16dp"
android:src="@drawable/ic_fluent_circle_24_regular"/>
<EditText
android:id="@+id/edit"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@null"
android:paddingStart="0dp"
android:paddingEnd="16dp"
android:textAppearance="@style/m3_title_medium"
android:inputType="textCapSentences"
android:singleLine="true"/>
</LinearLayout>
<ImageView
android:id="@+id/dragger_thingy"
android:layout_width="56dp"
android:layout_height="56dp"
android:scaleType="center"
android:src="@drawable/ic_fluent_re_order_dots_vertical_24_regular"/>
</LinearLayout>

View File

@@ -81,6 +81,46 @@
android:background="@null"
android:inputType="textMultiLine|textCapSentences"/>
<LinearLayout
android:id="@+id/poll_wrap"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone"
tools:visibility="visible">
<org.joinmastodon.android.ui.views.ReorderableLinearLayout
android:id="@+id/poll_options"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"/>
<LinearLayout
android:id="@+id/add_poll_option"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="56dp"
android:layout_marginBottom="8dp"
android:background="@drawable/bg_poll_option"
android:outlineProvider="background"
android:elevation="2dp">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_margin="16dp"
android:src="@drawable/ic_fluent_add_circle_24_regular"/>
</LinearLayout>
<TextView
android:id="@+id/poll_duration"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="8dp"
android:textAppearance="@style/m3_label_large"
android:textColor="@color/gray_800"
tools:text="Duration: 7 days"/>
</LinearLayout>
<LinearLayout
android:id="@+id/attachments"
android:layout_width="match_parent"
@@ -109,6 +149,8 @@
android:layout_marginEnd="24dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:padding="0px"
android:tint="@color/compose_button"
android:tintMode="src_in"
android:src="@drawable/ic_fluent_image_24_regular"/>
<ImageButton
@@ -118,6 +160,8 @@
android:layout_marginEnd="24dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:padding="0px"
android:tint="@color/compose_button"
android:tintMode="src_in"
android:src="@drawable/ic_fluent_poll_24_selector"/>
<ImageButton
@@ -127,6 +171,8 @@
android:layout_marginEnd="24dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:padding="0px"
android:tint="@color/compose_button"
android:tintMode="src_in"
android:src="@drawable/ic_fluent_emoji_24_selector"/>
<ImageButton
@@ -136,6 +182,8 @@
android:layout_marginEnd="24dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:padding="0px"
android:tint="@color/compose_button"
android:tintMode="src_in"
android:src="@drawable/ic_fluent_chat_warning_24_selector"/>
<ImageButton
@@ -145,6 +193,8 @@
android:layout_marginEnd="24dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:padding="0px"
android:tint="@color/compose_button"
android:tintMode="src_in"
android:src="@drawable/ic_fluent_people_community_24_regular"/>
<Space

View File

@@ -73,4 +73,18 @@
<string name="field_content">Content</string>
<string name="saving">Saving…</string>
<string name="post_from_user">Post from %s</string>
<string name="poll_option_hint">Option %d</string>
<plurals name="x_minutes">
<item quantity="one">%d minute</item>
<item quantity="other">%d minutes</item>
</plurals>
<plurals name="x_hours">
<item quantity="one">%d hour</item>
<item quantity="other">%d hours</item>
</plurals>
<plurals name="x_days">
<item quantity="one">%d day</item>
<item quantity="other">%d days</item>
</plurals>
<string name="compose_poll_duration">Duration: %s</string>
</resources>

View File

@@ -16,6 +16,7 @@
<item name="android:buttonStyle">@style/Widget.Mastodon.Button</item>
<item name="android:alertDialogTheme">@style/Theme.Mastodon.Dialog.Alert</item>
<item name="appkitBackDrawable">@drawable/ic_fluent_arrow_left_24_regular</item>
<item name="android:splitMotionEvents">false</item>
</style>
<style name="Theme.Mastodon.Toolbar" parent="android:ThemeOverlay.Material.ActionBar">