problem solve

Signed-off-by: z00513345 <zhuchengfeng1@huawei.com>
This commit is contained in:
z00513345 2022-08-08 11:39:24 +08:00
parent 009148b5ab
commit 897f27b902
10 changed files with 185 additions and 31 deletions

View File

@ -32,6 +32,7 @@ const appLogger: Logger = new Logger('app');
let isFromCard = false;
let isFromCamera = false;
let appBroadCast = BroadCastManager.getInstance().getBroadCast();
const pagePath: string = 'product/phone/view/index';
export default class MainAbility extends Ability {
private static readonly RETRY_MAX_TIMES = 100;
@ -183,7 +184,7 @@ export default class MainAbility extends Ability {
}, 50)
});
} else {
windowStage.setUIContent(this.context, 'product/pad/view/index', null);
windowStage.setUIContent(this.context, pagePath, null);
ScreenManager.getInstance().initWindowMode();
}
TraceControllerUtils.finishTrace('onWindowStageCreate');
@ -258,7 +259,7 @@ export default class MainAbility extends Ability {
}, 50)
} else if (entryFrom == Constants.ENTRY_FROM_FORM_ABILITY_NONE) {
let options = {
uri: 'product/phone/view/index'
uri: pagePath
}
router.replace(options);
} else if (entryFrom == Constants.ENTRY_FROM_FORM_FORM_EDITOR) {

View File

@ -19,7 +19,7 @@ import { BroadCastManager } from '../model/common/BroadCastManager'
import { BroadCast } from '../utils/BroadCast'
import { BroadCastConstants } from '../model/common/BroadCastConstants'
import { Constants } from '../model/common/Constants'
import { ScreenManager } from '../model/common/ScreenManager';
import { ScreenManager, ColumnSize } from '../model/common/ScreenManager'
export enum DEVICE_TYPE {
DEVICE_PHONE,
@ -31,7 +31,7 @@ export struct TabBar {
@Consume isSelectedMode: boolean;
@Consume isAlbumSetSelectedMode: boolean;
private currentIndex: number;
@StorageLink('isSidebar') isSidebar: boolean = ScreenManager.getInstance().isSidebar();
private isSidebar: boolean = false;
private tabs: TabItem[] = [];
private controller: TabsController;
private logger: Logger = new Logger('TabBar');
@ -147,6 +147,9 @@ export struct TabBarForAlbumSet {
private tabs: TabItemWithText[] = [];
private controller: TabsController;
private logger: Logger = new Logger('TabBarForAlbumSet');
@State tabWidth: string = '100%';
@State tabCol: Resource = $r('app.float.album_tab_col_4_gap');
@StorageLink('isSidebar') isSidebar: boolean = ScreenManager.getInstance().isSidebar();
aboutToAppear(): void {
this.onTabSelected = this.onTabSelected.bind(this);
@ -154,6 +157,16 @@ export struct TabBarForAlbumSet {
this.tabs.forEach((tab: TabItemWithText) => {
this.logger.info(`${JSON.stringify(tab.name)}, ${tab.isSelected}`);
});
let col = ScreenManager.getInstance().getScreenColumns();
if (col < ColumnSize.COLUMN_EIGHT) {
this.tabWidth = '100%';
this.tabCol = $r('app.float.album_tab_col_4_gap');
} else {
let sideWidth = this.isSidebar ? Constants.TAB_BAR_WIDTH : 0;
this.tabWidth = (ScreenManager.getInstance().getWinWidth() - sideWidth) / Constants.NUMBER_2 + 'vp';
this.tabCol = $r('app.float.album_tab_col_8_gap');
}
this.logger.info(`album tabs item width: ${this.tabWidth}, col: ${col}`);
}
private onTabSelected(index: number) {
@ -172,9 +185,20 @@ export struct TabBarForAlbumSet {
justifyContent: FlexAlign.Center,
alignItems: ItemAlign.Start
}) {
ForEach(this.tabs, (tab: TabItemWithText) => {
TabWithText({ tabItemWithText: tab, index: this.tabs.indexOf(tab), onTabSelected: this.onTabSelected })
}, tab => tab.name.id)
Grid() {
ForEach(this.tabs, (tab: TabItemWithText) => {
GridItem() {
TabWithText({
tabItemWithText: tab,
index: this.tabs.indexOf(tab),
onTabSelected: this.onTabSelected
})
}
}, tab => tab.name.id)
}
.width(this.tabWidth)
.columnsTemplate('1fr '.repeat(this.tabs.length))
.columnsGap(this.tabCol)
}
.width('100%')
.visibility(this.isTabBarShow ? Visibility.Visible : Visibility.None)
@ -228,6 +252,7 @@ struct TabWithText {
.visibility(this.tabItemWithText.isSelected ? Visibility.Visible : Visibility.Hidden)
}
.height('100%')
.width('100%')
.onClick(() => {
if (!this.isAlbumSetSelectedMode) {
this.onTabSelected && this.onTabSelected(this.index)

View File

@ -172,36 +172,45 @@ struct MediaOperationPage {
build() {
Column() {
MediaOperationActionBar({ onMenuClicked: this.onMenuClicked })
List({ scroller: this.scroller }) {
LazyForEach(this.albums, (item: AlbumInfo, index) => {
ListItem() {
if (!AlbumDefine.ALBUM_DISABLE_COPY_LIST.has(item.id) && item.id != this.sourceAlbumId) {
Column() {
AlbumListCard({ item: item })
if (!this.isLast(item)) {
Divider().vertical(false).strokeWidth(1)
.color($r('sys.color.ohos_id_color_list_separator'))
.margin({ left: $r('app.float.album_list_card_divider_margin_left') })
ListItem() {
List() {
LazyForEach(this.albums, (item: AlbumInfo, index) => {
ListItem() {
if (!AlbumDefine.ALBUM_DISABLE_COPY_LIST.has(item.id) && item.id != this.sourceAlbumId) {
Column() {
AlbumListCard({ item: item })
if (!this.isLast(item)) {
Divider().vertical(false).strokeWidth(1)
.color($r('sys.color.ohos_id_color_list_separator'))
.margin({ left: $r('app.float.album_list_card_divider_margin_left') })
}
}
}
}
}
}, item => item.id)
}
}, item => item.id)
.borderRadius($r('sys.float.ohos_id_corner_radius_default_l'))
.backgroundColor($r('sys.color.ohos_id_color_card_bg'))
.padding({
left: $r('app.float.list_card_margin'),
right: $r('app.float.list_card_margin')
})
}
}
.borderRadius($r('sys.float.ohos_id_corner_radius_default_l'))
.scrollBar(BarState.Auto)
.padding({
left: $r('app.float.list_card_margin'),
right: $r('app.float.list_card_margin')
})
.width(this.listCardWidth)
.margin({
top: $r('app.float.album_let_page_padding_top'),
left: $r('app.float.max_padding_start'),
right: $r('app.float.max_padding_end'),
bottom: this.leftBlank[3]
})
.padding({
left: $r('app.float.list_card_margin'),
right: $r('app.float.list_card_margin')
})
.width(this.listCardWidth)
.backgroundColor($r('sys.color.ohos_id_color_card_bg'))
CustomDialogView()
}

View File

@ -0,0 +1,55 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@Component
export struct AlbumScrollBar {
scroller: Scroller;
@State isClickScrollBar: boolean = false;
@Consume isHideScrollBar: boolean;
hasSideBar: boolean = true;
@Consume('tabBarShow') hasTabBarShow: boolean;
build() {
ScrollBar({ scroller: this.scroller, direction: ScrollBarDirection.Vertical,
state: this.isHideScrollBar ? BarState.Off : BarState.Auto }) {
Row() {
}
.width(this.isClickScrollBar ?
$r('app.float.album_scrollbar_select_size') : $r('app.float.album_scrollbar_normal_size'))
.height($r('app.float.album_scrollbar_height_size'))
.border({ radius: $r('app.float.album_scrollbar_radius') })
.backgroundColor($r('app.color.album_scrollbar_color'))
}
.height('100%')
.position({ x: '100%', y: 0 })
.markAnchor({
x: this.isClickScrollBar
? $r('app.float.album_scrollbar_select_size') : $r('app.float.album_scrollbar_normal_size'),
y: 0
})
.onTouch((event: TouchEvent) => {
if (event.type == TouchType.Down) {
this.isClickScrollBar = true;
} else if (event.type == TouchType.Up) {
this.isClickScrollBar = false;
}
})
.padding({
bottom: this.hasTabBarShow
? (this.hasSideBar ? $r('app.float.album_set_page_padding_end') : $r('app.float.album_set_page_padding_end_112'))
: (this.hasSideBar ? 0 : $r('app.float.album_set_tab_bar_height'))
})
}
}

View File

@ -46,6 +46,7 @@ import { AlbumGridItemNewStyle } from './AlbumGridItemNewStyle'
import { DistributedAlbumGriItem } from './DistributedAlbumGriItem'
import { AlbumSetDeleteMenuOperation } from '../operation/AlbumSetDeleteMenuOperation'
import { AlbumSetRenameMenuOperation } from '../operation/AlbumSetRenameMenuOperation'
import { AlbumScrollBar } from '../../../common/view/scrollBar/AlbumScrollBar'
// Album Set Page
@Component
@ -57,6 +58,7 @@ export struct AlbumSetPage {
@Consume @Watch('onModeChange') isAlbumSetSelectedMode: boolean;
@Provide('selectedCount') selectedAlbumsCount: number = 0;
@Provide isDisableDelete: boolean = false;
@Provide isHideScrollBar: boolean = true;
@Provide isDisableRename: boolean = false;
@State isEmpty: boolean = true;
@Provide gridColumnsCount: number = 0;
@ -76,7 +78,7 @@ export struct AlbumSetPage {
isDataFreeze: boolean = false;
// the switch of distributed page
@Provide isTabBarShow: boolean = false;
@Provide('tabBarShow') isTabBarShow: boolean = false;
@Provide moreMenuList: Action[] = new Array<Action>();
private tabsController: TabsController = new TabsController();
private currentIndex: number = Constants.LOCAL_TAB_INDEX;
@ -84,6 +86,7 @@ export struct AlbumSetPage {
private ignoreLocalNotify = false;
private barModel: AlbumBarModel = new AlbumBarModel()
private toPhotoGrid: boolean = false;
private isNewAlbum: boolean = false;
onMenuClicked(action: Action, arg: any[]) {
this.logger.info(`onMenuClicked, action: ${action.actionID}`);
@ -150,8 +153,8 @@ export struct AlbumSetPage {
this.ignoreLocalNotify = false;
this.albums.onChange(Constants.MEDIA_TYPE_IMAGE);
this.albums.unfreeze();
let newAlbum = AppStorage.Get<boolean>(Constants.APP_KEY_NEW_ALBUM);
if (newAlbum) {
if (this.isNewAlbum) {
this.toPhotoGrid = true;
AppStorage.Delete(Constants.APP_KEY_NEW_ALBUM_SELECTED);
}
@ -165,8 +168,9 @@ export struct AlbumSetPage {
this.appBroadCast.on(BroadCastConstants.RESET_STATE_EVENT, this.onStateReset.bind(this));
this.broadCast.on(Constants.ON_LOADING_FINISHED, (size: number) => {
this.isEmpty = (size == 0);
let newAlbum = AppStorage.Get<boolean>(Constants.APP_KEY_NEW_ALBUM);
if (!this.isEmpty && newAlbum && this.toPhotoGrid) {
this.isHideScrollBar = (size <= (this.gridColumnsCount * Constants.NUMBER_3 - Constants.NUMBER_1));
if (!this.isEmpty && this.isNewAlbum && this.toPhotoGrid) {
this.isNewAlbum = false;
this.toPhotoGrid = false;
let newAlbum = AppStorage.Get<AlbumInfo>(Constants.APP_KEY_NEW_ALBUM_TARGET);
for (let album of this.albums.mediaSetList) {
@ -253,6 +257,7 @@ export struct AlbumSetPage {
if (this.isShow && this.isInCurrentTab) {
this.onActive();
this.createAlbum();
this.isHideScrollBar = (this.albums.totalCount() <= (this.gridColumnsCount * Constants.NUMBER_3 - Constants.NUMBER_1));
} else if (!this.isShow && this.isInCurrentTab) {
this.onInActive();
} else {
@ -262,12 +267,14 @@ export struct AlbumSetPage {
createAlbum() {
let newAlbum = AppStorage.Get<boolean>(Constants.APP_KEY_NEW_ALBUM);
if (newAlbum) {
AppStorage.Delete(Constants.APP_KEY_NEW_ALBUM);
this.broadCast.emit(BroadCastConstants.SHOW_COPY_OR_MOVE_DIALOG,
[this.moveOperation.bind(this), this.copyOperation.bind(this)]);
}
}
private copyOperation() {
this.isNewAlbum = true;
let selectManager = AppStorage.Get<SelectManager>(Constants.APP_KEY_NEW_ALBUM_SELECTED);
let targetAlbum = AppStorage.Get<AlbumInfo>(Constants.APP_KEY_NEW_ALBUM_TARGET);
if (undefined == selectManager || undefined == targetAlbum) {
@ -285,6 +292,7 @@ export struct AlbumSetPage {
}
private moveOperation() {
this.isNewAlbum = true;
let selectManager = AppStorage.Get<SelectManager>(Constants.APP_KEY_NEW_ALBUM_SELECTED);
let targetAlbum = AppStorage.Get<AlbumInfo>(Constants.APP_KEY_NEW_ALBUM_TARGET);
if (undefined == selectManager || undefined == targetAlbum) {
@ -497,6 +505,8 @@ export struct AlbumSetPage {
})
.columnsGap($r('app.float.album_set_grid_column_gap'))
.rowsGap($r('app.float.album_set_grid_row_gap'))
AlbumScrollBar({ scroller: this.scroller, hasSideBar: this.isSidebar })
}
}
@ -519,6 +529,8 @@ export struct AlbumSetPage {
})
.columnsGap($r('app.float.album_set_grid_column_gap'))
.rowsGap($r('app.float.album_set_grid_row_gap'))
AlbumScrollBar({ scroller: this.scroller, hasSideBar: this.isSidebar })
}
build() {

View File

@ -32,6 +32,7 @@ import { AlbumInfo } from '../../../common/model/browser/album/AlbumInfo';
import { BroadCastManager } from '../../../common/model/common/BroadCastManager';
import { BroadCastConstants } from '../../../common/model/common/BroadCastConstants';
import { AlbumSelectBarModel } from '../model/AlbumSelectBarModel';
import { AlbumScrollBar } from '../../../common/view/scrollBar/AlbumScrollBar'
@Entry
@Component
@ -43,6 +44,8 @@ export struct AlbumSelect {
@StorageLink('leftBlank') leftBlank: [number, number, number, number]
= [0, ScreenManager.getInstance().getStatusBarHeight(), 0, ScreenManager.getInstance().getNaviBarHeight()];
@Provide moreMenuList: Action[] = new Array<Action>();
@Provide isHideScrollBar: boolean = true;
@Provide('tabBarShow') isTabBarShow: boolean = false;
private isActive = false;
private logger: Logger = new Logger('AlbumSelect');
private scroller: Scroller = new Scroller();
@ -57,6 +60,7 @@ export struct AlbumSelect {
this.broadCast.on(Constants.ON_LOADING_FINISHED, (size: number) => {
this.logger.info(`ON_LOADING_FINISHED size: ${size}`);
this.isEmpty = size == 0;
this.isHideScrollBar = (size <= (this.gridColumnsCount * Constants.NUMBER_3 - Constants.NUMBER_1));
});
this.albums = new AlbumSetDataSource(this.broadCast);
this.onActive();
@ -88,12 +92,20 @@ export struct AlbumSelect {
onPageShow() {
BroadCastManager.getInstance().getBroadCast().emit(BroadCastConstants.THIRD_ROUTE_PAGE, []);
this.onActive();
this.isHideScrollBar = (this.albums.totalCount() < (this.gridColumnsCount * Constants.NUMBER_3 - Constants.NUMBER_1));
}
onPageHide() {
this.onInActive();
}
onBackPress() {
AppStorage.Delete(Constants.APP_KEY_NEW_ALBUM);
AppStorage.Delete(Constants.APP_KEY_NEW_ALBUM_TARGET);
AppStorage.Delete(Constants.APP_KEY_NEW_ALBUM_SELECTED);
return false;
}
// Callback when the page is in the foreground
onActive() {
if (!this.isActive) {
@ -120,6 +132,8 @@ export struct AlbumSelect {
case Action.CANCEL:
this.logger.info('clear SelectManager data');
this.mSelectManager.onModeChange(false);
AppStorage.Delete(Constants.APP_KEY_NEW_ALBUM);
AppStorage.Delete(Constants.APP_KEY_NEW_ALBUM_TARGET);
AppStorage.Delete(Constants.APP_KEY_NEW_ALBUM_SELECTED);
router.back();
break;
@ -173,6 +187,8 @@ export struct AlbumSelect {
})
.columnsGap($r('app.float.album_set_grid_column_gap'))
.rowsGap($r('app.float.album_set_grid_row_gap'))
AlbumScrollBar({ scroller: this.scroller })
}
}
.backgroundColor($r('app.color.default_background_color'))

View File

@ -676,6 +676,7 @@ struct PhotoBrowser {
}
}
this.onPhotoChanged(newIndex);
this.dataSource.onDataChanged(newIndex);
}
} catch (e) {
this.logger.error(`ON_DATA_RELOADED_WITH_EDIT error ${e}`);

View File

@ -30,6 +30,7 @@ import { AlbumDefine } from '../../../common/model/browser/AlbumDefine'
import { BroadCastConstants } from '../../../common/model/common/BroadCastConstants'
import { BroadCastManager } from '../../../common/model/common/BroadCastManager'
import { ThirdSelectBarModel } from '../model/ThirdSelectBarModel'
import { AlbumScrollBar } from '../../../common/view/scrollBar/AlbumScrollBar'
// Third Select AlbumSet Page
@Entry
@ -58,6 +59,9 @@ export struct ThirdSelectAlbumSetPage {
private barModel: ThirdSelectBarModel = new ThirdSelectBarModel()
private leftAction: Action = Action.BACK
private title: string | Resource = ""
private scroller: Scroller = new Scroller();
@Provide isHideScrollBar: boolean = true;
@Provide('tabBarShow') isTabBarShow: boolean = false;
aboutToAppear(): void {
this.albums = new AlbumSetDataSource(this.broadCast);
@ -92,6 +96,7 @@ export struct ThirdSelectAlbumSetPage {
this.broadCast.on(Constants.ON_LOADING_FINISHED, (size: number) => {
this.logger.info(`ON_LOADING_FINISHED size: ${size}`);
this.isEmpty = size == 0;
this.isHideScrollBar = (size <= (this.gridRowCount * Constants.NUMBER_3 - Constants.NUMBER_1));
});
if (this.isMultiPick) {
this.selectManager.registerCallback('thirdSelectUpdateCount', (newState: number) => {
@ -189,7 +194,7 @@ export struct ThirdSelectAlbumSetPage {
if (this.isEmpty) {
NoPhotoComponent({ title: $r('app.string.title_no_albums') })
}
Grid() {
Grid(this.scroller) {
LazyForEach(this.albums, (item) => {
if (item.name != AlbumDefine.ALBUM_ID_RECYCLE) {
if (this.albums.mediaSetList.indexOf(item) == 0) {
@ -224,6 +229,8 @@ export struct ThirdSelectAlbumSetPage {
})
.columnsGap($r('app.float.album_set_grid_column_gap'))
.rowsGap($r('app.float.album_set_grid_row_gap'))
AlbumScrollBar({ scroller: this.scroller })
}
}
.backgroundColor($r('app.color.default_background_color'))

View File

@ -323,6 +323,10 @@
{
"name": "scroll_bar_side_text_shadow_color",
"value": "#1A000000"
},
{
"name": "album_scrollbar_color",
"value": "#ffb3b3b3"
}
]
}

View File

@ -100,6 +100,14 @@
"name":"album_set_grid_column_gap",
"value":"12vp"
},
{
"name":"album_tab_col_4_gap",
"value":"16vp"
},
{
"name":"album_tab_col_8_gap",
"value":"24vp"
},
{
"name":"album_set_grid_row_gap",
"value":"12vp"
@ -959,6 +967,22 @@
{
"name": "tip_popup_border_radius",
"value": "15vp"
},
{
"name": "album_scrollbar_normal_size",
"value": "6vp"
},
{
"name": "album_scrollbar_select_size",
"value": "12vp"
},
{
"name": "album_scrollbar_height_size",
"value": "80vp"
},
{
"name": "album_scrollbar_radius",
"value": "50vp"
}
]
}