• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import {Callback} from './basic';
17
18/**
19 * Used to do mediaquery operations.
20 * @import import mediaquery from '@ohos.mediaquery'
21 * @syscap SystemCapability.ArkUI.ArkUI.Full
22 * @since 7
23 */
24declare namespace mediaquery {
25
26  interface MediaQueryResult {
27
28    /**
29     * Whether the match condition is met.
30     * This parameter is read-only.
31     * @since 7
32     */
33    readonly matches: boolean;
34
35    /**
36     * Matching condition of a media event.
37     * This parameter is read-only.
38     * @since 7
39     */
40    readonly media: string;
41  }
42
43  interface MediaQueryListener extends MediaQueryResult {
44
45    /**
46     * Registers a callback with the corresponding query condition by using the handle.
47     * This callback is triggered when the media attributes change.
48     * @since 7
49     */
50    on(type: 'change', callback: Callback<MediaQueryResult>): void;
51
52    /**
53     * Deregisters a callback with the corresponding query condition by using the handle.
54     * This callback is not triggered when the media attributes chang.
55     * @since 7
56     */
57    off(type: 'change', callback?: Callback<MediaQueryResult>): void;
58  }
59
60  /**
61   * Sets the media query criteria and returns the corresponding listening handle
62   * @since 7
63   */
64  function matchMediaSync(condition: string): MediaQueryListener;
65}
66
67export default mediaquery;
68