@@ -3,6 +3,8 @@ import script from '@/system/script';
33import { MyFloaty } from './MyFloaty' ;
44import { IScheme } from '@/interface/IScheme' ;
55import { GroupSchemeName } from '@/common/schemeList' ;
6+ import { getHeightPixels , getWidthPixels } from '@auto.pro/core' ;
7+
68
79export default {
810 show : ( myfloaty : MyFloaty , schemeList ?: IScheme [ ] ) => {
@@ -16,7 +18,11 @@ export default {
1618 </androidx.core.widget.NestedScrollView>`
1719 ) ;
1820 const title = '选择方案' ;
21+ const screenWidth = getWidthPixels ( ) ;
22+ const screenHeight = getHeightPixels ( ) ;
1923 const schemeDialog = dialogs . build ( { title, customView } ) . show ( ) ;
24+ schemeDialog . getWindow ( ) . setLayout ( Math . max ( screenWidth * 0.6 , Math . min ( 576 , screenWidth ) ) , screenHeight * 0.8 ) ;
25+
2026 let groupSchemeNames : GroupSchemeName [ ] = store . get ( 'groupSchemeNames' ) ;
2127 if ( ! schemeList ) {
2228 schemeList = store . get ( 'schemeList' ) ;
@@ -34,8 +40,13 @@ export default {
3440 customView . groupList . on ( 'item_bind' , function ( itemView , _itemHolder ) {
3541 const schemeListView = ui . inflate (
3642 `<list id="groupSchemeList">
37- <horizontal padding="10 10 10 10" bg="?selectableItemBackground" w="*">
38- <text textColor="black" textSize="14" text="{{this}}" layout_gravity="center" />
43+ <horizontal w="*">
44+ <vertical w="0dp" layout_weight="1">
45+ <text padding="10 5 10 5" textColor="black" textSize="14" id="leftText" text="{{left}}" layout_gravity="center" />
46+ </vertical>
47+ <vertical w="0dp" layout_weight="1">
48+ <text padding="10 5 10 5" textColor="black" textSize="14" id="rightText" text="{{right}}" layout_gravity="center" />
49+ </vertical>
3950 </horizontal>
4051 </list>` ,
4152 itemView ,
@@ -44,25 +55,61 @@ export default {
4455 } ) ;
4556
4657 customView . groupList . on ( 'item_data_bind' , function ( itemView , itemHolder ) {
47- itemView . groupSchemeList . setDataSource ( itemHolder . item . schemeNames ) ;
48- itemView . groupSchemeList . on ( 'item_click' , function ( item , _i , _itemView , _listView ) {
49- const schemeName = item ;
50- script . setCurrentScheme ( schemeName ) ;
51- const storeSettings = storeCommon . get ( 'settings' , { } ) ;
52- if ( storeSettings . floaty_scheme_direct_run ) {
53- // myfloaty.fy.start();
54- setTimeout ( ( ) => {
55- const storeSettings = storeCommon . get ( 'settings' , { } ) ;
56- if ( storeSettings . floaty_scheme_openApp ) {
57- script . launchRelatedApp ( ) ;
58- }
59- myfloaty . thisRun ( ) ;
60- } , 1000 ) ;
61- } else {
62- toast ( '设置方案[' + schemeName + ']' ) ;
58+
59+ const data : { left : string , right ?: string } [ ] = [ ] ;
60+ for ( let i = 0 ; i < itemHolder . item . schemeNames . length ; i += 2 ) {
61+ data . push ( {
62+ left : itemHolder . item . schemeNames [ i ] ,
63+ right : i + 1 < itemHolder . item . schemeNames . length ? itemHolder . item . schemeNames [ i + 1 ] : ''
64+ } ) ;
65+ }
66+ itemView . groupSchemeList . setDataSource ( data ) ;
67+ itemView . groupSchemeList . on ( 'item_data_bind' , ( itemView , itemHolder ) => {
68+ const textClick = ( schemeName ) => {
69+ if ( ! schemeName ) return ;
70+ script . setCurrentScheme ( schemeName ) ;
71+ const storeSettings = storeCommon . get ( 'settings' , { } ) ;
72+ if ( storeSettings . floaty_scheme_direct_run ) {
73+ // myfloaty.fy.start();
74+ setTimeout ( ( ) => {
75+ const storeSettings = storeCommon . get ( 'settings' , { } ) ;
76+ if ( storeSettings . floaty_scheme_openApp ) {
77+ script . launchRelatedApp ( ) ;
78+ }
79+ myfloaty . thisRun ( ) ;
80+ } , 1000 ) ;
81+ } else {
82+ toast ( '设置方案[' + schemeName + ']' ) ;
83+ }
84+ schemeDialog . dismiss ( ) ;
6385 }
64- schemeDialog . dismiss ( ) ;
65- } )
86+ itemView . leftText . attr ( 'foreground' , '?selectableItemBackground' ) ;
87+ itemView . leftText . click ( ( ) => {
88+ textClick ( itemHolder . item . left ) ;
89+ } ) ;
90+ itemHolder . item . right && itemView . rightText . attr ( 'foreground' , '?selectableItemBackground' ) ;
91+ itemHolder . item . right && itemView . rightText . click ( ( ) => {
92+ textClick ( itemHolder . item . right ) ;
93+ } ) ;
94+ } ) ;
95+ // itemView.groupSchemeList.on('item_click', function (item, _i, _itemView, _listView) {
96+ // const schemeName = item;
97+ // script.setCurrentScheme(schemeName);
98+ // const storeSettings = storeCommon.get('settings', {});
99+ // if (storeSettings.floaty_scheme_direct_run) {
100+ // // myfloaty.fy.start();
101+ // setTimeout(() => {
102+ // const storeSettings = storeCommon.get('settings', {});
103+ // if (storeSettings.floaty_scheme_openApp) {
104+ // script.launchRelatedApp();
105+ // }
106+ // myfloaty.thisRun();
107+ // }, 1000);
108+ // } else {
109+ // toast('设置方案[' + schemeName + ']');
110+ // }
111+ // schemeDialog.dismiss();
112+ // })
66113 } ) ;
67114 } ,
68115}
0 commit comments