• 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 * @syscap SystemCapability.ArkUI.ArkUI.Full
21 * @since 7
22 */
23declare namespace mediaquery {
24
25  interface MediaQueryResult {
26
27    /**
28     * Whether the match condition is met.
29     * This parameter is read-only.
30     * @since 7
31     */
32    readonly matches: boolean;
33
34    /**
35     * Matching condition of a media event.
36     * This parameter is read-only.
37     * @since 7
38     */
39    readonly media: string;
40  }
41
42  interface MediaQueryListener extends MediaQueryResult {
43
44    /**
45     * Registers a callback with the corresponding query condition by using the handle.
46     * This callback is triggered when the media attributes change.
47     * @since 7
48     */
49    on(type: 'change', callback: Callback<MediaQueryResult>): void;
50
51    /**
52     * Deregisters a callback with the corresponding query condition by using the handle.
53     * This callback is not triggered when the media attributes chang.
54     * @since 7
55     */
56    off(type: 'change', callback?: Callback<MediaQueryResult>): void;
57  }
58
59  /**
60   * Sets the media query criteria and returns the corresponding listening handle
61   * @since 7
62   */
63  function matchMediaSync(condition: string): MediaQueryListener;
64}
65
66export default mediaquery;
67