@@ -18,10 +18,13 @@ export default {
1818 </androidx.core.widget.NestedScrollView>`
1919 ) ;
2020 const title = '选择方案' ;
21+ const schemeDialog = dialogs . build ( { title, customView } ) . show ( ) ;
2122 const screenWidth = getWidthPixels ( ) ;
2223 const screenHeight = getHeightPixels ( ) ;
23- const schemeDialog = dialogs . build ( { title, customView } ) . show ( ) ;
24- schemeDialog . getWindow ( ) . setLayout ( Math . max ( screenWidth * 0.6 , Math . min ( 576 , screenWidth ) ) , screenHeight * 0.8 ) ;
24+ if ( screenWidth > screenHeight ) {
25+ schemeDialog . getWindow ( ) . setLayout ( Math . max ( screenWidth * 0.6 , Math . min ( 576 , screenWidth ) ) , android . view . WindowManager . LayoutParams . WRAP_CONTENT ) ;
26+ // schemeDialog.getWindow().setLayout(android.view.WindowManager.LayoutParams.MATCH_PARENT, android.view.WindowManager.LayoutParams.WRAP_CONTENT);
27+ }
2528
2629 let groupSchemeNames : GroupSchemeName [ ] = store . get ( 'groupSchemeNames' ) ;
2730 if ( ! schemeList ) {
@@ -38,8 +41,7 @@ export default {
3841 customView . groupList . setDataSource ( groupSchemeNames ) ;
3942
4043 customView . groupList . on ( 'item_bind' , function ( itemView , _itemHolder ) {
41- const schemeListView = ui . inflate (
42- `<list id="groupSchemeList">
44+ let itemStr = `<list id="groupSchemeList">
4345 <horizontal w="*">
4446 <vertical w="0dp" layout_weight="1">
4547 <text padding="10 5 10 5" textColor="black" textSize="14" id="leftText" text="{{left}}" layout_gravity="center" />
@@ -48,20 +50,37 @@ export default {
4850 <text padding="10 5 10 5" textColor="black" textSize="14" id="rightText" text="{{right}}" layout_gravity="center" />
4951 </vertical>
5052 </horizontal>
51- </list>` ,
52- itemView ,
53- ) ;
53+ </list>` ;
54+ if ( screenWidth <= screenHeight ) {
55+ itemStr = `<list id="groupSchemeList">
56+ <horizontal w="*">
57+ <vertical w="*">
58+ <text padding="10 5 10 5" textColor="black" textSize="14" id="leftText" text="{{left}}" layout_gravity="center" />
59+ </vertical>
60+ </horizontal>
61+ </list>` ;
62+ }
63+ const schemeListView = ui . inflate ( itemStr , itemView ) ;
5464 itemView . addView ( schemeListView ) ;
5565 } ) ;
5666
5767 customView . groupList . on ( 'item_data_bind' , function ( itemView , itemHolder ) {
5868
5969 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- } ) ;
70+ if ( screenWidth > screenHeight ) {
71+ for ( let i = 0 ; i < itemHolder . item . schemeNames . length ; i += 2 ) {
72+ data . push ( {
73+ left : itemHolder . item . schemeNames [ i ] ,
74+ right : i + 1 < itemHolder . item . schemeNames . length ? itemHolder . item . schemeNames [ i + 1 ] : ''
75+ } ) ;
76+ }
77+ } else {
78+ for ( let i = 0 ; i < itemHolder . item . schemeNames . length ; i ++ ) {
79+ data . push ( {
80+ left : itemHolder . item . schemeNames [ i ] ,
81+ right : ''
82+ } ) ;
83+ }
6584 }
6685 itemView . groupSchemeList . setDataSource ( data ) ;
6786 itemView . groupSchemeList . on ( 'item_data_bind' , ( itemView , itemHolder ) => {
@@ -87,10 +106,12 @@ export default {
87106 itemView . leftText . click ( ( ) => {
88107 textClick ( itemHolder . item . left ) ;
89108 } ) ;
90- itemHolder . item . right && itemView . rightText . attr ( 'foreground' , '?selectableItemBackground' ) ;
91- itemHolder . item . right && itemView . rightText . click ( ( ) => {
92- textClick ( itemHolder . item . right ) ;
93- } ) ;
109+ if ( screenWidth > screenHeight ) {
110+ itemHolder . item . right && itemView . rightText . attr ( 'foreground' , '?selectableItemBackground' ) ;
111+ itemHolder . item . right && itemView . rightText . click ( ( ) => {
112+ textClick ( itemHolder . item . right ) ;
113+ } ) ;
114+ }
94115 } ) ;
95116 // itemView.groupSchemeList.on('item_click', function (item, _i, _itemView, _listView) {
96117 // const schemeName = item;
0 commit comments