Skip to content
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

建议分离多个库,有些用不到 #22

Open
caobin821651400 opened this issue Sep 4, 2017 · 12 comments
Open

建议分离多个库,有些用不到 #22

caobin821651400 opened this issue Sep 4, 2017 · 12 comments

Comments

@caobin821651400
Copy link

caobin821651400 commented Sep 4, 2017

想提取其中一部分UI很麻烦

@chanthuang
Copy link
Collaborator

QMUI 是作为一个整体库存在,且很多组件都依赖于统一的 theme 和其他工具类。

请问你是想单独提取哪一部分?而作为一个整体库引入的话会给你带来什么不便吗?

@caobin821651400
Copy link
Author

caobin821651400 commented Sep 5, 2017

dialog效果很漂亮,我想单独拿出来,可是依赖于theme会报错,最后还是放弃了,有时间在仔细研究下

@chanthuang
Copy link
Collaborator

单独提取一部分控件,除了需要把依赖到的工具类都提取出来,还需要把依赖到的 attr、theme 也提取出来,才能单独使用。
建议还是将 QMUI 作为一个整体引入,会比较方便。

@ahhsfj1991
Copy link

必须要继承你们的主题,导致原先app有些地方写好的样式变了,能否绕过这个限制,不用继承你们的主题,仅仅使用控件的方案

@chanthuang
Copy link
Collaborator

目前不能绕过这个限制,因为许多组件都依赖主题里的样式,后续我们可能会优化这种使用方式。具体是哪些地方原先写好的样式变了?我们先查查

@ahhsfj1991
Copy link

colorPrimaryDark,actionMenuTextColor,其他没具体看,视觉上的一一检查太麻烦了,让我没办法放心使用

@chanthuang
Copy link
Collaborator

因为一些组件默认样式的需要,我们在 qmui_themes_compat.xml 文件里的 <style name="AppConfigTheme.Compat"><style name="AppBaseTheme.Compat"> 中,覆盖了系统默认主题的一些值。目前如果需要将这些值改为其他值,可以在项目自己的 theme 中覆盖。
后面将会优化,尽量减少对系统默认表现的修改。

@caobin821651400
Copy link
Author

我建议设置样式颜色字体大小那些在代码中setXX比较好,但是你们改动会很大。

@chanthuang
Copy link
Collaborator

组件本身提供 setXXX 是合理的,但使用 theme 的初衷是为了方便在一个项目中快速配置控件的默认样式,所以 theme 的方式也不应该被废弃,只是 theme 不应该影响到该控件以外的样式。如果做到这样,是否能解决你的担忧?

@ahhsfj1991
Copy link

能这样肯定是最好不过了

@JakeWoki
Copy link

JakeWoki commented Sep 18, 2017

只看了下dialog的按钮部分,说错请见谅。
更改按钮颜色,没必要像这个库这样做。以下做法即可:

    <style name="AlertDialogCustom" parent="Theme.AppCompat.Light.Dialog.Alert">
        <item name="buttonBarPositiveButtonStyle">@style/buttonBarPositive</item>
        <item name="buttonBarNegativeButtonStyle">@style/buttonBarNegative</item>
    </style>

    <style name="buttonBarPositive" parent="@style/Widget.AppCompat.Button.ButtonBar.AlertDialog">
        <item name="android:textColor">@color/positive</item>
    </style>

    <style name="buttonBarNegative" parent="@style/Widget.AppCompat.Button.ButtonBar.AlertDialog">
        <item name="android:textColor">@color/negative</item>
    </style>


new AlertDialog.Builder(getActivity(), R.style.AlertDialogCustom)
                    .setTitle("title")
                    .setMessage("message")
                    .setNegativeButton("canel", null)
                    .setPositiveButton("ok", null).create().show();

至于菜单类型、单选、多选和以下属性有关,如果全局统一使用同一个风格,改下面的属性即可。

     <style name="Base.AlertDialog.AppCompat" parent="android:Widget">
        <item name="android:layout">@layout/abc_alert_dialog_material</item>
        <item name="listLayout">@layout/abc_select_dialog_material</item>
        <item name="listItemLayout">@layout/select_dialog_item_material</item>
        <item name="multiChoiceItemLayout">@layout/select_dialog_multichoice_material</item>
        <item name="singleChoiceItemLayout">@layout/select_dialog_singlechoice_material</item>
    </style>

@chanthuang
Copy link
Collaborator

@JakeWoki 目前 QMUI 库里确实有不少冗余的属性,你提的这种做法也确实更合理,我们会考虑按这种方法进一步优化。感谢。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants