Full Code of icerockdev/moko-permissions for AI

master d6d94f77a722 cached
106 files
153.9 KB
41.7k tokens
1 requests
Download .txt
Repository: icerockdev/moko-permissions
Branch: master
Commit: d6d94f77a722
Files: 106
Total size: 153.9 KB

Directory structure:
gitextract_m0_vw0yi/

├── .github/
│   └── workflows/
│       ├── compilation-check.yml
│       └── publish.yml
├── .gitignore
├── CONTRIBUTING.md
├── LICENSE.md
├── README.md
├── build.gradle.kts
├── gradle/
│   ├── libs.versions.toml
│   └── wrapper/
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── permissions/
│   ├── build.gradle.kts
│   └── src/
│       ├── androidMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       ├── PermissionDelegate.android.kt
│       │                       ├── PermissionsController.kt
│       │                       └── PermissionsControllerImpl.kt
│       ├── commonMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       ├── DeniedExceptions.kt
│       │                       ├── Permission.kt
│       │                       ├── PermissionDelegate.kt
│       │                       ├── PermissionState.kt
│       │                       ├── PermissionsController.kt
│       │                       └── RequestCanceledException.kt
│       └── iosMain/
│           └── kotlin/
│               └── dev/
│                   └── icerock/
│                       └── moko/
│                           └── permissions/
│                               ├── Async.kt
│                               ├── MainRunDispatcher.kt
│                               ├── PermissionDelegate.ios.kt
│                               ├── PermissionsController.kt
│                               └── ios/
│                                   ├── PermissionsController.kt
│                                   └── PermissionsControllerProtocol.kt
├── permissions-avfoundation/
│   ├── build.gradle.kts
│   └── src/
│       └── iosMain/
│           └── kotlin/
│               └── dev/
│                   └── icerock/
│                       └── moko/
│                           └── permissions/
│                               └── avfoundation/
│                                   └── AVCaptureDelegate.kt
├── permissions-bluetooth/
│   ├── build.gradle.kts
│   └── src/
│       ├── androidMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── bluetooth/
│       │                           └── BluetoothPermissions.android.kt
│       ├── commonMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── bluetooth/
│       │                           └── BluetoothPermissions.kt
│       └── iosMain/
│           └── kotlin/
│               └── dev/
│                   └── icerock/
│                       └── moko/
│                           └── permissions/
│                               └── bluetooth/
│                                   └── BluetoothPermissionDelegate.kt
├── permissions-camera/
│   ├── build.gradle.kts
│   └── src/
│       ├── androidMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── camera/
│       │                           └── CameraPermission.android.kt
│       ├── commonMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── camera/
│       │                           └── CameraPermission.kt
│       └── iosMain/
│           └── kotlin/
│               └── dev/
│                   └── icerock/
│                       └── moko/
│                           └── permissions/
│                               └── camera/
│                                   └── CameraPermission.ios.kt
├── permissions-compose/
│   ├── build.gradle.kts
│   └── src/
│       ├── androidMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── compose/
│       │                           ├── BindEffect.android.kt
│       │                           └── PermissionsControllerFactory.android.kt
│       ├── commonMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── compose/
│       │                           ├── BindEffect.kt
│       │                           └── PermissionsControllerFactory.kt
│       └── iosMain/
│           └── kotlin/
│               └── dev/
│                   └── icerock/
│                       └── moko/
│                           └── permissions/
│                               └── compose/
│                                   ├── BindEffect.ios.kt
│                                   └── PermissionsControllerFactory.ios.kt
├── permissions-contacts/
│   ├── build.gradle.kts
│   └── src/
│       ├── androidMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── contacts/
│       │                           └── ContactsPermission.android.kt
│       ├── commonMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── contacts/
│       │                           └── ContactPermission.kt
│       └── iosMain/
│           └── kotlin/
│               └── dev/
│                   └── icerock/
│                       └── moko/
│                           └── permissions/
│                               └── contacts/
│                                   └── ContactsPermission.ios.kt
├── permissions-gallery/
│   ├── build.gradle.kts
│   └── src/
│       ├── androidMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── gallery/
│       │                           └── GalleryPermission.android.kt
│       ├── commonMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── gallery/
│       │                           └── GalleryPermission.kt
│       └── iosMain/
│           └── kotlin/
│               └── dev/
│                   └── icerock/
│                       └── moko/
│                           └── permissions/
│                               └── gallery/
│                                   └── GalleryPermissionDelegate.kt
├── permissions-location/
│   ├── build.gradle.kts
│   └── src/
│       ├── androidMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── location/
│       │                           └── LocationPermission.android.kt
│       ├── commonMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── location/
│       │                           └── LocationPermission.kt
│       └── iosMain/
│           └── kotlin/
│               └── dev/
│                   └── icerock/
│                       └── moko/
│                           └── permissions/
│                               └── location/
│                                   ├── LocationManagerDelegate.kt
│                                   └── LocationPermission.ios.kt
├── permissions-microphone/
│   ├── build.gradle.kts
│   └── src/
│       ├── androidMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── microphone/
│       │                           └── MicrophonePermission.android.kt
│       ├── commonMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── microphone/
│       │                           └── MicrophonePermission.kt
│       └── iosMain/
│           └── kotlin/
│               └── dev/
│                   └── icerock/
│                       └── moko/
│                           └── permissions/
│                               └── microphone/
│                                   └── MicrophonePermission.ios.kt
├── permissions-motion/
│   ├── build.gradle.kts
│   └── src/
│       ├── androidMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── motion/
│       │                           └── MotionPermission.android.kt
│       ├── commonMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── motion/
│       │                           └── MotionPermission.kt
│       └── iosMain/
│           └── kotlin/
│               └── dev/
│                   └── icerock/
│                       └── moko/
│                           └── permissions/
│                               └── motion/
│                                   └── MotionPermission.ios.kt
├── permissions-notifications/
│   ├── build.gradle.kts
│   └── src/
│       ├── androidMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── notifications/
│       │                           └── NotificationPermission.android.kt
│       ├── commonMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── notifications/
│       │                           └── NotificationPermission.kt
│       └── iosMain/
│           └── kotlin/
│               └── dev/
│                   └── icerock/
│                       └── moko/
│                           └── permissions/
│                               └── notifications/
│                                   └── RemoteNotificationPermissionDelegate.kt
├── permissions-storage/
│   ├── build.gradle.kts
│   └── src/
│       ├── androidMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── storage/
│       │                           └── StoragePermissions.android.kt
│       ├── commonMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── storage/
│       │                           └── StoragePermissions.kt
│       └── iosMain/
│           └── kotlin/
│               └── dev/
│                   └── icerock/
│                       └── moko/
│                           └── permissions/
│                               └── storage/
│                                   ├── AlwaysGrantedDelegate.kt
│                                   └── StoragePermissions.ios.kt
├── permissions-test/
│   ├── build.gradle.kts
│   └── src/
│       ├── androidMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── test/
│       │                           └── PermissionsControllerMock.kt
│       ├── commonMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── test/
│       │                           └── PermissionsControllerMock.kt
│       └── iosMain/
│           └── kotlin/
│               └── dev/
│                   └── icerock/
│                       └── moko/
│                           └── permissions/
│                               └── test/
│                                   └── PermissionsControllerMock.kt
├── sample/
│   ├── android-app/
│   │   ├── build.gradle.kts
│   │   ├── proguard-rules.pro
│   │   └── src/
│   │       └── main/
│   │           ├── AndroidManifest.xml
│   │           ├── java/
│   │           │   └── com/
│   │           │       └── icerockdev/
│   │           │           └── MainActivity.kt
│   │           └── res/
│   │               └── layout/
│   │                   └── activity_main.xml
│   ├── compose-android-app/
│   │   ├── build.gradle.kts
│   │   └── src/
│   │       └── main/
│   │           ├── AndroidManifest.xml
│   │           └── java/
│   │               └── com/
│   │                   └── icerockdev/
│   │                       └── MainActivity.kt
│   ├── ios-app/
│   │   ├── Podfile
│   │   ├── TestProj.xcodeproj/
│   │   │   ├── project.pbxproj
│   │   │   └── project.xcworkspace/
│   │   │       └── contents.xcworkspacedata
│   │   ├── TestProj.xcworkspace/
│   │   │   ├── contents.xcworkspacedata
│   │   │   └── xcshareddata/
│   │   │       └── IDEWorkspaceChecks.plist
│   │   └── src/
│   │       ├── AppDelegate.swift
│   │       ├── Assets.xcassets/
│   │       │   ├── AppIcon.appiconset/
│   │       │   │   └── Contents.json
│   │       │   └── Contents.json
│   │       ├── Info.plist
│   │       ├── Resources/
│   │       │   └── Base.lproj/
│   │       │       ├── LaunchScreen.storyboard
│   │       │       └── Main.storyboard
│   │       └── TestViewController.swift
│   └── mpp-library/
│       ├── MultiPlatformLibrary.podspec
│       ├── build.gradle.kts
│       └── src/
│           ├── androidMain/
│           │   └── AndroidManifest.xml
│           ├── commonMain/
│           │   └── kotlin/
│           │       └── com/
│           │           └── icerockdev/
│           │               └── library/
│           │                   └── SampleViewModel.kt
│           └── commonTest/
│               └── kotlin/
│                   └── com/
│                       └── icerockdev/
│                           └── library/
│                               └── SampleViewModelTest.kt
└── settings.gradle.kts

================================================
FILE CONTENTS
================================================

================================================
FILE: .github/workflows/compilation-check.yml
================================================
name: KMP library compilation check

on:
  pull_request:
    branches:
      - master
      - develop

jobs:
  build:
    runs-on: macOS-latest

    steps:
      - uses: actions/checkout@v1
      - name: Set up JDK 17
        uses: actions/setup-java@v1
        with:
          java-version: 17
      - name: Build and publish local
        run: ./gradlew build publishToMavenLocal syncMultiPlatformLibraryDebugFrameworkIosX64
      - name: Install pods
        run: cd sample/ios-app && pod install
      - name: Check iOS
        run: cd sample/ios-app && set -o pipefail && xcodebuild -scheme TestProj -workspace TestProj.xcworkspace -configuration Debug -sdk iphonesimulator -arch x86_64 build CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO | xcpretty

================================================
FILE: .github/workflows/publish.yml
================================================
name: Create release

on:
  workflow_dispatch:
    inputs:
      version:
        description: 'Version'
        default: '0.1.0'
        required: true

jobs:
  publish:
    name: Publish library at mavenCentral
    runs-on: macOS-latest
    env:
      OSSRH_USER: ${{ secrets.OSSRH_USER }}
      OSSRH_KEY: ${{ secrets.OSSRH_KEY }}
      SIGNING_KEY_ID: ${{ secrets.SIGNING_KEYID }}
      SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
      SIGNING_KEY: ${{ secrets.GPG_KEY_CONTENTS }}

    steps:
      - uses: actions/checkout@v1
      - name: Set up JDK 17
        uses: actions/setup-java@v1
        with:
          java-version: 17
      - name: Prebuild library
        run: ./gradlew publishToMavenLocal
      - name: Publish
        run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository

  release:
    name: Create release
    needs: publish
    runs-on: ubuntu-latest
    steps:
      - name: Create Release
        id: create_release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          commitish: ${{ github.ref }}
          tag_name: release/${{ github.event.inputs.version }}
          release_name: ${{ github.event.inputs.version }}
          body: "Will be filled later"
          draft: true


================================================
FILE: .gitignore
================================================
.gradle
.settings
.project
.classpath
.vscode
.idea
build
*.iml
Pods
xcuserdata
local.properties
local.gradle

================================================
FILE: CONTRIBUTING.md
================================================
# Do’s and Don’ts

* **Search tickets before you file a new one.** Add to tickets if you have new information about the issue.
* **Keep tickets short but sweet.** Make sure you include all the context needed to solve the issue. Don't overdo it. Great tickets allow us to focus on solving problems instead of discussing them.
* **Take care of your ticket.** When you spend time to report a ticket with care we'll enjoy fixing it for you.
* **Use [GitHub-flavored Markdown](https://help.github.com/articles/markdown-basics/).** Especially put code blocks and console outputs in backticks (```` ``` ````). That increases the readability. Bonus points for applying the appropriate syntax highlighting.

## Bug Reports

In short, since you are most likely a developer, provide a ticket that you _yourself_ would _like_ to receive.

First check if you are using the latest library version and Kotlin version before filing a ticket.

Please include steps to reproduce and _all_ other relevant information, including any other relevant dependency and version information.

## Feature Requests

Please try to be precise about the proposed outcome of the feature and how it
would related to existing features.


## Pull Requests

We **love** pull requests!

All contributions _will_ be licensed under the Apache 2 license.

Code/comments should adhere to the following rules:

* Names should be descriptive and concise.
* Use four spaces and no tabs.
* Remember that source code usually gets written once and read often: ensure
  the reader doesn't have to make guesses. Make sure that the purpose and inner
  logic are either obvious to a reasonably skilled professional, or add a
  comment that explains it.
* Please add a detailed description.

If you consistently contribute improvements and/or bug fixes, we're happy to make you a maintainer.

================================================
FILE: LICENSE.md
================================================
                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "{}"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright {yyyy} {name of copyright owner}

   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.

================================================
FILE: README.md
================================================
![moko-permissions](img/logo.png)  
[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0) [![Download](https://img.shields.io/maven-central/v/dev.icerock.moko/permissions) ](https://repo1.maven.org/maven2/dev/icerock/moko/permissions) ![kotlin-version](https://kotlin-version.aws.icerock.dev/kotlin-version?group=dev.icerock.moko&name=permissions)

# Mobile Kotlin runtime permissions multiplatform controller
**moko-permissions** - Kotlin MultiPlatform library for providing runtime permissions on iOS & Android.

## Table of Contents
- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [List of supported permissions](#list-of-supported-permissions)
- [Usage](#usage)
- [Samples](#samples)
- [Set Up Locally](#set-up-locally)
- [Contributing](#contributing)
- [License](#license)

## Features
- **Permission** - enumeration with primary types of device permissions
- **PermissionsController** - handler for runtime permission requests can be used in the common code with lifecycle safety for Android
- **DeniedException** and **DeniedAlwaysException** - exceptions to handle user denial of permissions
- **Compose Multiplatform** support

## Requirements
- Gradle version 6.8+
- Android API 16+
- iOS version 12.0+

## Installation
root **build.gradle**
```groovy
allprojects {
    repositories {
      mavenCentral()
    }
}
```

project **build.gradle**
```groovy
dependencies {
    commonMainApi("dev.icerock.moko:permissions:0.20.1")
  
    // specific permissions support
    commonMainImplementation("dev.icerock.moko:permissions-bluetooth:0.20.1")
    commonMainImplementation("dev.icerock.moko:permissions-camera:0.20.1")
    commonMainImplementation("dev.icerock.moko:permissions-contacts:0.20.1")
    commonMainImplementation("dev.icerock.moko:permissions-gallery:0.20.1")
    commonMainImplementation("dev.icerock.moko:permissions-location:0.20.1")
    commonMainImplementation("dev.icerock.moko:permissions-microphone:0.20.1")
    commonMainImplementation("dev.icerock.moko:permissions-motion:0.20.1")
    commonMainImplementation("dev.icerock.moko:permissions-notifications:0.20.1")
    commonMainImplementation("dev.icerock.moko:permissions-storage:0.20.1")
    
    // compose multiplatform
    commonMainApi("dev.icerock.moko:permissions-compose:0.20.1") // permissions api + compose extensions
    
    commonTestImplementation("dev.icerock.moko:permissions-test:0.20.1")
}
```

## List of supported permissions

* `dev.icerock.moko:permissions-bluetooth`
  * Bluetooth LE: **Permission.BLUETOOTH_LE**
  * Bluetooth Scan: **Permission.BLUETOOTH_SCAN**
  * Bluetooth Connect: **Permission.BLUETOOTH_CONNECT**
  * Bluetooth Advertise: **Permission.BLUETOOTH_ADVERTISE**
* `dev.icerock.moko:permissions-camera`
  * Camera: **Permission.CAMERA**
* `dev.icerock.moko:permissions-contacts`
  * Contacts: **Permission.CONTACTS**
* `dev.icerock.moko:permissions-gallery`
  * Gallery: **Permission.GALLERY** 
* `dev.icerock.moko:permissions-location`
  * Fine location: **Permission.LOCATION**
  * Coarse location: **Permission.COARSE_LOCATION**
  * Background location: **Permission.BACKGROUND_LOCATION**
* `dev.icerock.moko:permissions-microphone`
  * Audio recording: **Permission.RECORD_AUDIO**
* `dev.icerock.moko:permissions-motion`
  * Motion: **Permission.MOTION**
* `dev.icerock.moko:permissions-notifications`
  * Remote notifications: **Permission.REMOTE_NOTIFICATION**
* `dev.icerock.moko:permissions-storage`
  * Storage read: **Permission.STORAGE**
  * Storage write: **Permission.WRITE_STORAGE**

## Usage

Common code:
```kotlin
class ViewModel(val permissionsController: PermissionsController): ViewModel() {
    fun onPhotoPressed() {
        viewModelScope.launch {
            try {
                permissionsController.providePermission(Permission.GALLERY)
                // Permission has been granted successfully.
            } catch(deniedAlways: DeniedAlwaysException) {
                // Permission is always denied.
            } catch(denied: DeniedException) {
                // Permission was denied.
            }
        }
    }
}
```

Android:
```kotlin
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
        
    val viewModel = getViewModel {
        // Pass the platform implementation of the permission controller to a common code.
        ViewModel(PermissionsController())
    }
    
    // Binds the permissions controller to the activity lifecycle.
    viewModel.permissionsController.bind(activity)
}
```

Compose:
```kotlin
@Composable
fun TestScreen() {
    val viewModel = getViewModel {
        // Pass the platform implementation of the permission controller to a common code.
        ViewModel(PermissionsController())
    }
    
    // Binds the permissions controller to the LocalLifecycleOwner lifecycle.
    BindEffect(viewModel.permissionsController)
}
```

iOS:
```swift
// Just pass the platform implementation of the permission controller to a common code.
let viewModel = ViewModel(permissionsController: PermissionsController())
```

### Compose Multiplatform
```kotlin
@Composable
fun Sample() {
    val factory: PermissionsControllerFactory = rememberPermissionsControllerFactory()
    val controller: PermissionsController = remember(factory) { factory.createPermissionsController() }
    val coroutineScope: CoroutineScope = rememberCoroutineScope()
    
    Button(
        onClick = {
            coroutineScope.launch {
                controller.providePermission(Permission.REMOTE_NOTIFICATION)
            }
        }
    ) {
        Text(text = "give permissions")
    }
}
```

Or with `moko-mvvm` with correct configuration change handle on android:
```kotlin
@Composable
fun Sample() {
    val factory: PermissionsControllerFactory = rememberPermissionsControllerFactory()
    val viewModel: PermissionsViewModel = getViewModel(
        key = "permissions-screen",
        factory = viewModelFactory { PermissionsViewModel(factory.createPermissionsController()) }
    )
    
    BindEffect(viewModel.permissionsController)

    Button(onClick = viewModel::onButtonClick) {
        Text(text = "give permissions")
    }
}

class PermissionsViewModel(
    val permissionsController: PermissionsController
) : ViewModel() {
    fun onButtonClick() {
        viewModelScope.launch {
            permissionsController.providePermission(Permission.REMOTE_NOTIFICATION)
        }
    }
}
```

## Samples
More examples can be found in the [sample directory](sample).

## Set Up Locally 
- In [permissions directory](permissions) contains `permissions` library;
- In [sample directory](sample) contains samples on android, ios & mpp-library connected to apps.

## Contributing
All development (both new features and bug fixes) is performed in `develop` branch. This way `master` sources always contain sources of the most recently released version. Please send PRs with bug fixes to `develop` branch. Fixes to documentation in markdown files are an exception to this rule. They are updated directly in `master`.

The `develop` branch is pushed to `master` during release.

More detailed guide for contributors see in [contributing guide](CONTRIBUTING.md).

## License
        
    Copyright 2019 IceRock MAG Inc
    
    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.


================================================
FILE: build.gradle.kts
================================================
/*
 * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

buildscript {
    repositories {
        mavenCentral()
        google()
        gradlePluginPortal()
    }

    dependencies {
        classpath(libs.kotlinGradlePlugin)
        classpath(libs.androidGradlePlugin)
        classpath(libs.mokoGradlePlugin)
        classpath(libs.mobileMultiplatformGradlePlugin)
        classpath(libs.kotlinSerializationGradlePlugin)
        classpath(libs.composeJetBrainsGradlePlugin)
        classpath(libs.detektGradlePlugin)
    }
}

apply(plugin = "dev.icerock.moko.gradle.publication.nexus")
val mokoVersion = libs.versions.mokoPermissionsVersion.get()
allprojects {
    group = "dev.icerock.moko"
    version = mokoVersion
}

tasks.register("clean", Delete::class).configure {
    delete(rootProject.buildDir)
}


================================================
FILE: gradle/libs.versions.toml
================================================
[versions]
kotlinVersion = "1.9.10"
androidAppCompatVersion = "1.6.1"
androidxCoreVersion = "1.9.0" # TODO we have two versions (1.8 + 1.9) - unify them
composeMaterialVersion = "1.4.1"
composeActivityVersion = "1.7.0"
activityVersion = "1.7.0"
materialDesignVersion = "1.8.0"
androidLifecycleVersion = "2.2.0"
androidCoreTestingVersion = "2.2.0"
coroutinesVersion = "1.6.4"
mokoMvvmVersion = "0.16.0"
mokoPermissionsVersion = "0.20.1"
composeJetBrainsVersion = "1.7.1"
lifecycleRuntime = "2.6.1"
composeUiVersion = "1.0.1"

[libraries]
androidxCore = { module = "androidx.core:core", version.ref = "androidxCoreVersion" }
appCompat = { module = "androidx.appcompat:appcompat", version.ref = "androidAppCompatVersion" }
material = { module = "com.google.android.material:material", version.ref = "materialDesignVersion" }
composeMaterial = { module = "androidx.compose.material:material", version.ref = "composeMaterialVersion" }
composeActivity = { module = "androidx.activity:activity-compose", version.ref = "composeActivityVersion" }
activity = { module = "androidx.activity:activity", version.ref = "activityVersion" }
composeUi = { module = "androidx.compose.ui:ui", version.ref = "composeUiVersion" }
lifecycle = { module = "androidx.lifecycle:lifecycle-extensions", version.ref = "androidLifecycleVersion" }
lifecycleRuntime = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "lifecycleRuntime" }
coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutinesVersion" }
mokoMvvmCore = { module = "dev.icerock.moko:mvvm-core", version.ref = "mokoMvvmVersion" }
mokoMvvmTest = { module = "dev.icerock.moko:mvvm-test", version.ref = "mokoMvvmVersion" }
kotlinTestJUnit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlinVersion" }
androidCoreTesting = { module = "androidx.arch.core:core-testing", version.ref = "androidCoreTestingVersion" }


kotlinGradlePlugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlinVersion" }
androidGradlePlugin = { module = "com.android.tools.build:gradle", version = "7.4.2" }
mokoGradlePlugin = { module = "dev.icerock.moko:moko-gradle-plugin", version = "0.5.1" }
mobileMultiplatformGradlePlugin = { module = "dev.icerock:mobile-multiplatform", version = "0.14.2" }
kotlinSerializationGradlePlugin = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlinVersion" }
composeJetBrainsGradlePlugin = { module = "org.jetbrains.compose:compose-gradle-plugin", version.ref = "composeJetBrainsVersion" }
detektGradlePlugin = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin", version = "1.22.0" }


================================================
FILE: gradle/wrapper/gradle-wrapper.properties
================================================
#Tue Jun 10 21:09:29 CEST 2025
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists


================================================
FILE: gradle.properties
================================================
org.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8
org.gradle.configureondemand=false
org.gradle.parallel=true

kotlin.code.style=official

kotlin.mpp.androidSourceSetLayoutVersion=2

android.useAndroidX=true

moko.android.targetSdk=34
moko.android.compileSdk=34
moko.android.minSdk=16

moko.publish.name=MOKO permissions
moko.publish.description=Runtime permissions controls for mobile (android & ios) Kotlin Multiplatform development
moko.publish.repo.org=icerockdev
moko.publish.repo.name=moko-permissions
moko.publish.license=Apache-2.0
moko.publish.developers=alex009|Aleksey Mikhailov|Aleksey.Mikhailov@icerockdev.com



================================================
FILE: gradlew
================================================
#!/usr/bin/env sh

#
# Copyright 2015 the original author or authors.
#
# 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
#
#      https://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.
#

##############################################################################
##
##  Gradle start up script for UN*X
##
##############################################################################

# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
    ls=`ls -ld "$PRG"`
    link=`expr "$ls" : '.*-> \(.*\)$'`
    if expr "$link" : '/.*' > /dev/null; then
        PRG="$link"
    else
        PRG=`dirname "$PRG"`"/$link"
    fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null

APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

warn () {
    echo "$*"
}

die () {
    echo
    echo "$*"
    echo
    exit 1
}

# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
  CYGWIN* )
    cygwin=true
    ;;
  Darwin* )
    darwin=true
    ;;
  MINGW* )
    msys=true
    ;;
  NONSTOP* )
    nonstop=true
    ;;
esac

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar


# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
        # IBM's JDK on AIX uses strange locations for the executables
        JAVACMD="$JAVA_HOME/jre/sh/java"
    else
        JAVACMD="$JAVA_HOME/bin/java"
    fi
    if [ ! -x "$JAVACMD" ] ; then
        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
    fi
else
    JAVACMD="java"
    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi

# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
    MAX_FD_LIMIT=`ulimit -H -n`
    if [ $? -eq 0 ] ; then
        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
            MAX_FD="$MAX_FD_LIMIT"
        fi
        ulimit -n $MAX_FD
        if [ $? -ne 0 ] ; then
            warn "Could not set maximum file descriptor limit: $MAX_FD"
        fi
    else
        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
    fi
fi

# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi

# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`

    JAVACMD=`cygpath --unix "$JAVACMD"`

    # We build the pattern for arguments to be converted via cygpath
    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
    SEP=""
    for dir in $ROOTDIRSRAW ; do
        ROOTDIRS="$ROOTDIRS$SEP$dir"
        SEP="|"
    done
    OURCYGPATTERN="(^($ROOTDIRS))"
    # Add a user-defined pattern to the cygpath arguments
    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
    fi
    # Now convert the arguments - kludge to limit ourselves to /bin/sh
    i=0
    for arg in "$@" ; do
        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option

        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
        else
            eval `echo args$i`="\"$arg\""
        fi
        i=`expr $i + 1`
    done
    case $i in
        0) set -- ;;
        1) set -- "$args0" ;;
        2) set -- "$args0" "$args1" ;;
        3) set -- "$args0" "$args1" "$args2" ;;
        4) set -- "$args0" "$args1" "$args2" "$args3" ;;
        5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
        6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
        7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
        8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
        9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
    esac
fi

# Escape application args
save () {
    for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
    echo " "
}
APP_ARGS=`save "$@"`

# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"

exec "$JAVACMD" "$@"


================================================
FILE: gradlew.bat
================================================
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem      https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem  Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega


================================================
FILE: permissions/build.gradle.kts
================================================
/*
 * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

plugins {
    id("dev.icerock.moko.gradle.multiplatform.mobile")
    id("dev.icerock.moko.gradle.publication")
    id("dev.icerock.moko.gradle.stub.javadoc")
    id("dev.icerock.moko.gradle.detekt")
}

android {
    namespace = "dev.icerock.moko.permissions"
}

dependencies {
    commonMainImplementation(libs.coroutines)
    androidMainImplementation(libs.activity)
    androidMainImplementation(libs.lifecycleRuntime)
}


================================================
FILE: permissions/src/androidMain/kotlin/dev/icerock/moko/permissions/PermissionDelegate.android.kt
================================================
/*
 * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

@file:Suppress("MatchingDeclarationName")

package dev.icerock.moko.permissions

import android.content.Context

@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
actual interface PermissionDelegate {
    fun getPermissionStateOverride(applicationContext: Context): PermissionState?
    fun getPlatformPermission(): List<String>
}


================================================
FILE: permissions/src/androidMain/kotlin/dev/icerock/moko/permissions/PermissionsController.kt
================================================
/*
 * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions

import android.content.Context
import androidx.activity.ComponentActivity

actual interface PermissionsController {
    actual suspend fun providePermission(permission: Permission)
    actual suspend fun isPermissionGranted(permission: Permission): Boolean
    actual suspend fun getPermissionState(permission: Permission): PermissionState
    actual fun openAppSettings()

    fun bind(activity: ComponentActivity)

    companion object {
        operator fun invoke(
            applicationContext: Context
        ): PermissionsController {
            return PermissionsControllerImpl(
                applicationContext = applicationContext
            )
        }
    }
}


================================================
FILE: permissions/src/androidMain/kotlin/dev/icerock/moko/permissions/PermissionsControllerImpl.kt
================================================
/*
 * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.net.Uri
import android.provider.Settings
import androidx.activity.ComponentActivity
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.ActivityResultRegistryOwner
import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleEventObserver
import androidx.lifecycle.LifecycleOwner
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import kotlinx.coroutines.withTimeoutOrNull
import java.util.UUID

@Suppress("TooManyFunctions")
class PermissionsControllerImpl(
    private val applicationContext: Context,
) : PermissionsController {
    private val activityHolder = MutableStateFlow<Activity?>(null)

    private val mutex: Mutex = Mutex()

    private val launcherHolder = MutableStateFlow<ActivityResultLauncher<Array<String>>?>(null)

    private val permissionRequestResultFlow = MutableSharedFlow<PermissionRequestResult>(extraBufferCapacity = 1)

    private val key = UUID.randomUUID().toString()

    override fun bind(activity: ComponentActivity) {
        unbindActivity()
        this.activityHolder.value = activity
        val activityResultRegistryOwner = activity as ActivityResultRegistryOwner

        val launcher = activityResultRegistryOwner.activityResultRegistry.register(
            key,
            ActivityResultContracts.RequestMultiplePermissions()
        ) { permissions ->
            val isCancelled = permissions.isEmpty()

            if (isCancelled) {
                permissionRequestResultFlow.tryEmit(PermissionRequestResult.CANCELLED)
                return@register
            }

            val success = permissions.values.all { it }

            if (success) {
                permissionRequestResultFlow.tryEmit(PermissionRequestResult.GRANTED)
            } else {
                if (shouldShowRequestPermissionRationale(activity, permissions.keys.first())) {
                    permissionRequestResultFlow.tryEmit(PermissionRequestResult.DENIED)
                } else {
                    permissionRequestResultFlow.tryEmit(PermissionRequestResult.DENIED_ALWAYS)
                }
            }
        }

        launcherHolder.value = launcher

        val observer = object : LifecycleEventObserver {
            override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) {
                if (event == Lifecycle.Event.ON_DESTROY) {
                    unbindActivity()
                    source.lifecycle.removeObserver(this)
                }
            }
        }
        activity.lifecycle.addObserver(observer)
    }

    override suspend fun providePermission(permission: Permission) {
        mutex.withLock {
            val launcher = awaitActivityResultLauncher()
            val platformPermission = permission.delegate.getPlatformPermission()
            launcher.launch(platformPermission.toTypedArray())

            when (permissionRequestResultFlow.first()) {
                PermissionRequestResult.GRANTED -> Unit
                PermissionRequestResult.DENIED -> throw DeniedException(permission)
                PermissionRequestResult.DENIED_ALWAYS -> throw DeniedAlwaysException(permission)
                PermissionRequestResult.CANCELLED -> throw RequestCanceledException(permission)
            }
        }
    }

    private suspend fun awaitActivityResultLauncher(): ActivityResultLauncher<Array<String>> {
        val activityResultLauncher = launcherHolder.value
        if (activityResultLauncher != null) return activityResultLauncher

        return withTimeoutOrNull(AWAIT_ACTIVITY_TIMEOUT_DURATION_MS) {
            launcherHolder.filterNotNull().first()
        } ?: error(
            "activityResultLauncher is null, `bind` function was never called," +
                " consider calling permissionsController.bind(activity)" +
                " or BindEffect(permissionsController) in the composable function," +
                " check the documentation for more info: " +
                "https://github.com/icerockdev/moko-permissions/blob/master/README.md"
        )
    }

    private suspend fun awaitActivity(): Activity {
        val activity = activityHolder.value
        if (activity != null) return activity

        return withTimeoutOrNull(AWAIT_ACTIVITY_TIMEOUT_DURATION_MS) {
            activityHolder.filterNotNull().first()
        } ?: error(
            "activity is null, `bind` function was never called," +
                " consider calling permissionsController.bind(activity)" +
                " or BindEffect(permissionsController) in the composable function," +
                " check the documentation for more info: " +
                "https://github.com/icerockdev/moko-permissions/blob/master/README.md"
        )
    }

    override suspend fun isPermissionGranted(permission: Permission): Boolean {
        return getPermissionState(permission) == PermissionState.Granted
    }

    @Suppress("ReturnCount")
    override suspend fun getPermissionState(permission: Permission): PermissionState {
        permission.delegate.getPermissionStateOverride(applicationContext)?.let { return it }
        val permissions: List<String> = permission.delegate.getPlatformPermission()
        val status: List<Int> = permissions.map {
            ContextCompat.checkSelfPermission(applicationContext, it)
        }
        val isAllGranted: Boolean = status.all { it == PackageManager.PERMISSION_GRANTED }
        if (isAllGranted) return PermissionState.Granted

        val isAllRequestRationale: Boolean = permissions.all {
            shouldShowRequestPermissionRationale(it)
        }
        return if (isAllRequestRationale) {
            PermissionState.Denied
        } else {
            PermissionState.NotGranted
        }
    }

    private suspend fun shouldShowRequestPermissionRationale(permission: String): Boolean {
        val activity = awaitActivity()
        return shouldShowRequestPermissionRationale(activity, permission)
    }

    private fun shouldShowRequestPermissionRationale(
        activity: Activity,
        permission: String
    ): Boolean {
        return ActivityCompat.shouldShowRequestPermissionRationale(
            activity,
            permission
        )
    }

    override fun openAppSettings() {
        val intent = Intent().apply {
            action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS
            data = Uri.fromParts("package", applicationContext.packageName, null)
            flags = Intent.FLAG_ACTIVITY_NEW_TASK
        }
        applicationContext.startActivity(intent)
    }

    private fun unbindActivity() {
        launcherHolder.value?.unregister()
        activityHolder.value = null
        launcherHolder.value = null
    }

    private companion object {
        private const val AWAIT_ACTIVITY_TIMEOUT_DURATION_MS = 2000L
    }
}

private enum class PermissionRequestResult {
    GRANTED, DENIED, DENIED_ALWAYS, CANCELLED
}


================================================
FILE: permissions/src/commonMain/kotlin/dev/icerock/moko/permissions/DeniedExceptions.kt
================================================
/*
 * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions

open class DeniedException(
    val permission: Permission,
    message: String? = null
) : Exception(message)

class DeniedAlwaysException(
    permission: Permission,
    message: String? = null
) : DeniedException(permission, message)


================================================
FILE: permissions/src/commonMain/kotlin/dev/icerock/moko/permissions/Permission.kt
================================================
package dev.icerock.moko.permissions

interface Permission {
    val delegate: PermissionDelegate

    // Extended by individual permission delegates
    companion object
}


================================================
FILE: permissions/src/commonMain/kotlin/dev/icerock/moko/permissions/PermissionDelegate.kt
================================================
package dev.icerock.moko.permissions

@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
expect interface PermissionDelegate


================================================
FILE: permissions/src/commonMain/kotlin/dev/icerock/moko/permissions/PermissionState.kt
================================================
/*
 * Copyright 2022 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions

enum class PermissionState {

    /**
     * Starting state for each permission.
     */
    NotDetermined,

    /**
     * Android-only. This could mean [NotDetermined] or [DeniedAlways], but the OS doesn't
     * expose which of the two it is in all scenarios.
     */
    NotGranted,

    Granted,

    /**
     * Android-only.
     */
    Denied,

    /**
     * On Android only applicable to Push Notifications.
     */
    DeniedAlways
}


================================================
FILE: permissions/src/commonMain/kotlin/dev/icerock/moko/permissions/PermissionsController.kt
================================================
/*
 * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions

expect interface PermissionsController {
    /**
     * Check is permission already granted and if not - request permission from user.
     *
     * @param permission what permission we want to provide
     *
     * @throws DeniedException if user decline request, but we can retry (only on Android)
     * @throws DeniedAlwaysException if user decline request and we can't show request again
     *  (we should send user to settings)
     * @throws RequestCanceledException if user cancel request without response (only on Android)
     */
    suspend fun providePermission(permission: Permission)

    /**
     * @return true if permission already granted. In all other cases - false.
     */
    suspend fun isPermissionGranted(permission: Permission): Boolean

    /**
     * Returns current state of permission. Can be suspended because on
     * Android detection of `Denied`/`NotDetermined` requires a bound FragmentManager.
     *
     * @param permission state of what permission we want
     *
     * @return current state. On Android can't be `DeniedAlways` (except push notifications).
     * On iOS can't be `Denied`.
     * @see PermissionState for a detailed description.
     */
    suspend fun getPermissionState(permission: Permission): PermissionState

    /**
     * Open system UI of application settings to change permissions state
     */
    fun openAppSettings()
}


================================================
FILE: permissions/src/commonMain/kotlin/dev/icerock/moko/permissions/RequestCanceledException.kt
================================================
/*
 * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions

class RequestCanceledException(
    val permission: Permission,
    message: String? = null
) : Exception(message)


================================================
FILE: permissions/src/iosMain/kotlin/dev/icerock/moko/permissions/Async.kt
================================================
/*
 * Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions

import platform.Foundation.NSThread

inline fun <T1> mainContinuation(
    noinline block: (T1) -> Unit
): (T1) -> Unit = { arg1 ->
    if (NSThread.isMainThread()) {
        block.invoke(arg1)
    } else {
        MainRunDispatcher.run {
            block.invoke(arg1)
        }
    }
}

inline fun <T1, T2> mainContinuation(
    noinline block: (T1, T2) -> Unit
): (T1, T2) -> Unit = { arg1, arg2 ->
    if (NSThread.isMainThread()) {
        block.invoke(arg1, arg2)
    } else {
        MainRunDispatcher.run {
            block.invoke(arg1, arg2)
        }
    }
}


================================================
FILE: permissions/src/iosMain/kotlin/dev/icerock/moko/permissions/MainRunDispatcher.kt
================================================
/*
 * Copyright 2023 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions

import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Runnable
import platform.Foundation.NSRunLoop
import platform.Foundation.performBlock
import kotlin.coroutines.CoroutineContext

/**
 * Simple object made to ensure dispatching to the main looper on iOS
 */
internal object MainRunDispatcher : CoroutineDispatcher() {
    override fun dispatch(context: CoroutineContext, block: Runnable) =
        NSRunLoop.mainRunLoop.performBlock { block.run() }
}


================================================
FILE: permissions/src/iosMain/kotlin/dev/icerock/moko/permissions/PermissionDelegate.ios.kt
================================================
/*
 * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

@file:Suppress("MatchingDeclarationName")

package dev.icerock.moko.permissions

@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
actual interface PermissionDelegate {
    suspend fun providePermission()
    suspend fun getPermissionState(): PermissionState
}


================================================
FILE: permissions/src/iosMain/kotlin/dev/icerock/moko/permissions/PermissionsController.kt
================================================
/*
 * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions

import dev.icerock.moko.permissions.ios.PermissionsControllerProtocol

actual typealias PermissionsController = PermissionsControllerProtocol


================================================
FILE: permissions/src/iosMain/kotlin/dev/icerock/moko/permissions/ios/PermissionsController.kt
================================================
/*
 * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.ios

import dev.icerock.moko.permissions.Permission
import dev.icerock.moko.permissions.PermissionState
import platform.Foundation.NSURL
import platform.UIKit.UIApplication
import platform.UIKit.UIApplicationOpenSettingsURLString

class PermissionsController : PermissionsControllerProtocol {

    override suspend fun providePermission(permission: Permission) {
        return permission.delegate.providePermission()
    }

    override suspend fun isPermissionGranted(permission: Permission): Boolean {
        return permission.delegate.getPermissionState() == PermissionState.Granted
    }

    override suspend fun getPermissionState(permission: Permission): PermissionState {
        return permission.delegate.getPermissionState()
    }

    override fun openAppSettings() {
        val settingsUrl: NSURL = NSURL.URLWithString(UIApplicationOpenSettingsURLString)!!
        UIApplication.sharedApplication.openURL(settingsUrl, mapOf<Any?, Any>(), null)
    }
}


================================================
FILE: permissions/src/iosMain/kotlin/dev/icerock/moko/permissions/ios/PermissionsControllerProtocol.kt
================================================
/*
 * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.ios

import dev.icerock.moko.permissions.Permission
import dev.icerock.moko.permissions.PermissionState

interface PermissionsControllerProtocol {
    suspend fun providePermission(permission: Permission)
    suspend fun isPermissionGranted(permission: Permission): Boolean
    suspend fun getPermissionState(permission: Permission): PermissionState
    fun openAppSettings()
}


================================================
FILE: permissions-avfoundation/build.gradle.kts
================================================
/*
 * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

import dev.icerock.moko.gradle.utils.connectTargetsToSourceSet
import dev.icerock.moko.gradle.utils.createMainTest
import dev.icerock.moko.gradle.utils.setupDependency

plugins {
    id("org.jetbrains.kotlin.multiplatform")
    id("dev.icerock.moko.gradle.publication")
    id("dev.icerock.moko.gradle.detekt")
}

kotlin {
    iosArm64()
    iosX64()
    iosSimulatorArm64()

    with(this.sourceSets) {
        // creation
        createMainTest("ios")

        // ios dependencies
        setupDependency("ios", "common")
        connectTargetsToSourceSet(
            targetNames = listOf("iosX64", "iosArm64", "iosSimulatorArm64"),
            sourceSetPrefix = "ios"
        )
    }
}

dependencies {
    commonMainApi(projects.permissions)
    commonMainImplementation(libs.coroutines)
}


================================================
FILE: permissions-avfoundation/src/iosMain/kotlin/dev/icerock/moko/permissions/avfoundation/AVCaptureDelegate.kt
================================================
/*
 * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.avfoundation

import dev.icerock.moko.permissions.DeniedAlwaysException
import dev.icerock.moko.permissions.Permission
import dev.icerock.moko.permissions.PermissionDelegate
import dev.icerock.moko.permissions.PermissionState
import dev.icerock.moko.permissions.mainContinuation
import platform.AVFoundation.AVAuthorizationStatus
import platform.AVFoundation.AVAuthorizationStatusAuthorized
import platform.AVFoundation.AVAuthorizationStatusDenied
import platform.AVFoundation.AVAuthorizationStatusNotDetermined
import platform.AVFoundation.AVAuthorizationStatusRestricted
import platform.AVFoundation.AVCaptureDevice
import platform.AVFoundation.AVMediaType
import platform.AVFoundation.authorizationStatusForMediaType
import platform.AVFoundation.requestAccessForMediaType
import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine

class AVCaptureDelegate(
    private val type: AVMediaType,
    private val permission: Permission,
) : PermissionDelegate {
    override suspend fun providePermission() {
        val status: AVAuthorizationStatus = currentAuthorizationStatus()
        when (status) {
            AVAuthorizationStatusAuthorized -> return
            AVAuthorizationStatusNotDetermined -> {
                val isGranted: Boolean = suspendCoroutine { continuation ->
                    AVCaptureDevice.requestAccess(type) { continuation.resume(it) }
                }
                if (isGranted) {
                    return
                } else {
                    throw DeniedAlwaysException(permission)
                }
            }

            AVAuthorizationStatusDenied -> throw DeniedAlwaysException(permission)
            else -> error("unknown authorization status $status")
        }
    }

    override suspend fun getPermissionState(): PermissionState {
        val status: AVAuthorizationStatus = currentAuthorizationStatus()
        return when (status) {
            AVAuthorizationStatusAuthorized -> PermissionState.Granted
            AVAuthorizationStatusNotDetermined -> PermissionState.NotDetermined
            AVAuthorizationStatusDenied -> PermissionState.DeniedAlways
            AVAuthorizationStatusRestricted -> PermissionState.Granted
            else -> error("unknown authorization status $status")
        }
    }

    private fun currentAuthorizationStatus(): AVAuthorizationStatus {
        return AVCaptureDevice.authorizationStatusForMediaType(type)
    }
}

private fun AVCaptureDevice.Companion.requestAccess(
    type: AVMediaType,
    callback: (isGranted: Boolean) -> Unit,
) {
    this.requestAccessForMediaType(
        type,
        mainContinuation { isGranted: Boolean ->
            callback(isGranted)
        }
    )
}


================================================
FILE: permissions-bluetooth/build.gradle.kts
================================================
/*
 * Copyright 2024 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

plugins {
    id("dev.icerock.moko.gradle.multiplatform.mobile")
    id("dev.icerock.moko.gradle.publication")
    id("dev.icerock.moko.gradle.stub.javadoc")
    id("dev.icerock.moko.gradle.detekt")
}

android {
    namespace = "dev.icerock.moko.permissions.bluetooth"
}

dependencies {
    commonMainApi(projects.permissions)
    commonMainImplementation(libs.coroutines)
}


================================================
FILE: permissions-bluetooth/src/androidMain/kotlin/dev/icerock/moko/permissions/bluetooth/BluetoothPermissions.android.kt
================================================
/*
 * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.bluetooth

import android.Manifest
import android.content.Context
import android.os.Build
import dev.icerock.moko.permissions.PermissionDelegate

/**
 * @see https://developer.android.com/guide/topics/connectivity/bluetooth/permissions
 */

actual val bluetoothLEDelegate = object : PermissionDelegate {
    override fun getPermissionStateOverride(applicationContext: Context) = null

    override fun getPlatformPermission() = allBluetoothPermissions()

    /**
     * Bluetooth permissions
     *
     * @see https://developer.android.com/guide/topics/connectivity/bluetooth/permissions
     */
    private fun allBluetoothPermissions(): List<String> = buildSet {
        addAll(bluetoothConnectCompat())
        addAll(bluetoothScanCompat())
        addAll(bluetoothAdvertiseCompat())
    }.toList()

    private fun bluetoothScanCompat(): List<String> {
        return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
            listOf(Manifest.permission.BLUETOOTH_SCAN)
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
            listOf(Manifest.permission.ACCESS_FINE_LOCATION)
        } else {
            listOf(Manifest.permission.ACCESS_COARSE_LOCATION)
        }
    }

    private fun bluetoothAdvertiseCompat(): List<String> {
        return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
            listOf(Manifest.permission.BLUETOOTH_ADVERTISE)
        } else {
            listOf(Manifest.permission.BLUETOOTH)
        }
    }

    private fun bluetoothConnectCompat(): List<String> {
        return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
            listOf(Manifest.permission.BLUETOOTH_CONNECT)
        } else {
            listOf(Manifest.permission.BLUETOOTH)
        }
    }
}

actual val bluetoothScanDelegate = object : PermissionDelegate {
    override fun getPermissionStateOverride(applicationContext: Context) = null

    override fun getPlatformPermission() =
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
            listOf(Manifest.permission.BLUETOOTH_SCAN)
        } else {
            listOf(Manifest.permission.BLUETOOTH)
        }
}

actual val bluetoothAdvertiseDelegate = object : PermissionDelegate {
    override fun getPermissionStateOverride(applicationContext: Context) = null

    override fun getPlatformPermission() =
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
            listOf(Manifest.permission.BLUETOOTH_ADVERTISE)
        } else {
            listOf(Manifest.permission.BLUETOOTH)
        }
}

actual val bluetoothConnectDelegate = object : PermissionDelegate {
    override fun getPermissionStateOverride(applicationContext: Context) = null

    override fun getPlatformPermission() =
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
            listOf(Manifest.permission.BLUETOOTH_CONNECT)
        } else {
            listOf(Manifest.permission.BLUETOOTH)
        }
}


================================================
FILE: permissions-bluetooth/src/commonMain/kotlin/dev/icerock/moko/permissions/bluetooth/BluetoothPermissions.kt
================================================
/*
 * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.bluetooth

import dev.icerock.moko.permissions.Permission
import dev.icerock.moko.permissions.PermissionDelegate

internal expect val bluetoothLEDelegate: PermissionDelegate
internal expect val bluetoothScanDelegate: PermissionDelegate
internal expect val bluetoothAdvertiseDelegate: PermissionDelegate
internal expect val bluetoothConnectDelegate: PermissionDelegate

object BluetoothLEPermission : Permission {
    override val delegate get() = bluetoothLEDelegate
}

object BluetoothScanPermission : Permission {
    override val delegate get() = bluetoothScanDelegate
}

object BluetoothAdvertisePermission : Permission {
    override val delegate get() = bluetoothAdvertiseDelegate
}

object BluetoothConnectPermission : Permission {
    override val delegate get() = bluetoothConnectDelegate
}

val Permission.Companion.BLUETOOTH_LE get() = BluetoothLEPermission
val Permission.Companion.BLUETOOTH_SCAN get() = BluetoothScanPermission
val Permission.Companion.BLUETOOTH_ADVERTISE get() = BluetoothAdvertisePermission
val Permission.Companion.BLUETOOTH_CONNECT get() = BluetoothConnectPermission


================================================
FILE: permissions-bluetooth/src/iosMain/kotlin/dev/icerock/moko/permissions/bluetooth/BluetoothPermissionDelegate.kt
================================================
/*
 * Copyright 2022 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.bluetooth

import dev.icerock.moko.permissions.DeniedAlwaysException
import dev.icerock.moko.permissions.DeniedException
import dev.icerock.moko.permissions.Permission
import dev.icerock.moko.permissions.PermissionDelegate
import dev.icerock.moko.permissions.PermissionState
import kotlinx.cinterop.ExperimentalForeignApi
import platform.CoreBluetooth.CBCentralManager
import platform.CoreBluetooth.CBCentralManagerDelegateProtocol
import platform.CoreBluetooth.CBManager
import platform.CoreBluetooth.CBManagerAuthorization
import platform.CoreBluetooth.CBManagerAuthorizationAllowedAlways
import platform.CoreBluetooth.CBManagerAuthorizationDenied
import platform.CoreBluetooth.CBManagerAuthorizationNotDetermined
import platform.CoreBluetooth.CBManagerAuthorizationRestricted
import platform.CoreBluetooth.CBManagerState
import platform.CoreBluetooth.CBManagerStatePoweredOff
import platform.CoreBluetooth.CBManagerStatePoweredOn
import platform.CoreBluetooth.CBManagerStateResetting
import platform.CoreBluetooth.CBManagerStateUnauthorized
import platform.CoreBluetooth.CBManagerStateUnknown
import platform.CoreBluetooth.CBManagerStateUnsupported
import platform.Foundation.NSSelectorFromString
import platform.darwin.NSObject
import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine

internal class BluetoothPermissionDelegate(
    private val permission: Permission,
) : PermissionDelegate {
    @OptIn(ExperimentalForeignApi::class)
    override suspend fun providePermission() {
        // To maintain compatibility with iOS 12 (@see https://developer.apple.com/documentation/corebluetooth/cbmanagerauthorization)
        val isNotDetermined: Boolean =
            if (CBManager.resolveClassMethod(NSSelectorFromString("authorization"))) {
                CBManager.authorization == CBManagerAuthorizationNotDetermined
            } else {
                CBCentralManager().state == CBManagerStateUnknown
            }

        val state: CBManagerState = if (isNotDetermined) {
            suspendCoroutine { continuation ->
                CBCentralManager(
                    object : NSObject(), CBCentralManagerDelegateProtocol {
                        override fun centralManagerDidUpdateState(central: CBCentralManager) {
                            continuation.resume(central.state)
                        }
                    },
                    null
                )
            }
        } else {
            CBCentralManager().state
        }

        when (state) {
            CBManagerStatePoweredOn -> return
            CBManagerStateUnauthorized -> throw DeniedAlwaysException(permission)
            CBManagerStatePoweredOff ->
                throw DeniedException(permission, "Bluetooth is powered off")

            CBManagerStateResetting ->
                throw DeniedException(permission, "Bluetooth is restarting")

            CBManagerStateUnsupported ->
                throw DeniedAlwaysException(permission, "Bluetooth is not supported on this device")

            CBManagerStateUnknown ->
                error("Bluetooth state should be known at this point")

            else ->
                error("Unknown state (Permissions library should be updated) : $state")
        }
    }

    @OptIn(ExperimentalForeignApi::class)
    override suspend fun getPermissionState(): PermissionState {
        // To maintain compatibility with iOS 12 (@see https://developer.apple.com/documentation/corebluetooth/cbmanagerauthorization)
        if (CBManager.resolveClassMethod(NSSelectorFromString("authorization"))) {
            val state: CBManagerAuthorization = CBManager.authorization
            return when (state) {
                CBManagerAuthorizationNotDetermined -> PermissionState.NotDetermined
                CBManagerAuthorizationAllowedAlways, CBManagerAuthorizationRestricted -> PermissionState.Granted
                CBManagerAuthorizationDenied -> PermissionState.DeniedAlways
                else -> error("unknown state $state")
            }
        }
        val state: CBManagerState = CBCentralManager().state
        return when (state) {
            CBManagerStatePoweredOn -> PermissionState.Granted
            CBManagerStateUnauthorized, CBManagerStatePoweredOff,
            CBManagerStateResetting, CBManagerStateUnsupported,
            -> PermissionState.DeniedAlways

            CBManagerStateUnknown -> PermissionState.NotDetermined
            else -> error("unknown state $state")
        }
    }
}

actual val bluetoothLEDelegate: PermissionDelegate =
    BluetoothPermissionDelegate(BluetoothLEPermission)
actual val bluetoothScanDelegate: PermissionDelegate =
    BluetoothPermissionDelegate(BluetoothScanPermission)
actual val bluetoothAdvertiseDelegate: PermissionDelegate =
    BluetoothPermissionDelegate(BluetoothAdvertisePermission)
actual val bluetoothConnectDelegate: PermissionDelegate =
    BluetoothPermissionDelegate(BluetoothConnectPermission)


================================================
FILE: permissions-camera/build.gradle.kts
================================================
/*
 * Copyright 2024 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

plugins {
    id("dev.icerock.moko.gradle.multiplatform.mobile")
    id("dev.icerock.moko.gradle.publication")
    id("dev.icerock.moko.gradle.stub.javadoc")
    id("dev.icerock.moko.gradle.detekt")
}

android {
    namespace = "dev.icerock.moko.permissions.camera"
}

dependencies {
    commonMainApi(projects.permissions)
    iosMainImplementation(projects.permissionsAvfoundation)
    commonMainImplementation(libs.coroutines)
}


================================================
FILE: permissions-camera/src/androidMain/kotlin/dev/icerock/moko/permissions/camera/CameraPermission.android.kt
================================================
/*
 * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.camera

import android.Manifest
import android.content.Context
import dev.icerock.moko.permissions.PermissionDelegate

actual val cameraDelegate = object : PermissionDelegate {
    override fun getPermissionStateOverride(applicationContext: Context) = null
    override fun getPlatformPermission() = listOf(Manifest.permission.CAMERA)
}


================================================
FILE: permissions-camera/src/commonMain/kotlin/dev/icerock/moko/permissions/camera/CameraPermission.kt
================================================
/*
 * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.camera

import dev.icerock.moko.permissions.Permission
import dev.icerock.moko.permissions.PermissionDelegate

internal expect val cameraDelegate: PermissionDelegate

object CameraPermission : Permission {
    override val delegate get() = cameraDelegate
}

val Permission.Companion.CAMERA get() = CameraPermission


================================================
FILE: permissions-camera/src/iosMain/kotlin/dev/icerock/moko/permissions/camera/CameraPermission.ios.kt
================================================
/*
 * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.camera

import dev.icerock.moko.permissions.Permission
import dev.icerock.moko.permissions.PermissionDelegate
import dev.icerock.moko.permissions.avfoundation.AVCaptureDelegate
import platform.AVFoundation.AVMediaTypeVideo

actual val cameraDelegate: PermissionDelegate = AVCaptureDelegate(
    AVMediaTypeVideo,
    Permission.CAMERA
)


================================================
FILE: permissions-compose/build.gradle.kts
================================================
/*
 * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

plugins {
    id("dev.icerock.moko.gradle.multiplatform.mobile")
    id("dev.icerock.moko.gradle.publication")
    id("dev.icerock.moko.gradle.stub.javadoc")
    id("dev.icerock.moko.gradle.detekt")
    id("org.jetbrains.compose")
}

android {
    namespace = "dev.icerock.moko.permissions.compose"

    defaultConfig {
        minSdk = 21
    }
}

dependencies {
    commonMainApi(projects.permissions)
    commonMainApi(compose.runtime)
    androidMainImplementation(libs.activity)
    androidMainImplementation(libs.composeUi)
    androidMainImplementation(libs.lifecycleRuntime)
}


================================================
FILE: permissions-compose/src/androidMain/kotlin/dev/icerock/moko/permissions/compose/BindEffect.android.kt
================================================
/*
 * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.compose

import android.content.Context
import androidx.activity.ComponentActivity
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.lifecycle.LifecycleOwner
import dev.icerock.moko.permissions.PermissionsController

@Suppress("FunctionNaming")
@Composable
actual fun BindEffect(permissionsController: PermissionsController) {
    val lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current
    val context: Context = LocalContext.current

    LaunchedEffect(permissionsController, lifecycleOwner, context) {
        val activity: ComponentActivity = checkNotNull(context as? ComponentActivity) {
            "$context context is not instance of ComponentActivity"
        }

        permissionsController.bind(activity)
    }
}


================================================
FILE: permissions-compose/src/androidMain/kotlin/dev/icerock/moko/permissions/compose/PermissionsControllerFactory.android.kt
================================================
/*
 * Copyright 2023 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.compose

import android.content.Context
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.platform.LocalContext
import dev.icerock.moko.permissions.PermissionsController

@Composable
actual fun rememberPermissionsControllerFactory(): PermissionsControllerFactory {
    val context: Context = LocalContext.current
    return remember(context) {
        PermissionsControllerFactory {
            PermissionsController(applicationContext = context.applicationContext)
        }
    }
}


================================================
FILE: permissions-compose/src/commonMain/kotlin/dev/icerock/moko/permissions/compose/BindEffect.kt
================================================
/*
 * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.compose

import androidx.compose.runtime.Composable
import dev.icerock.moko.permissions.PermissionsController

@Suppress("FunctionNaming")
@Composable
expect fun BindEffect(permissionsController: PermissionsController)


================================================
FILE: permissions-compose/src/commonMain/kotlin/dev/icerock/moko/permissions/compose/PermissionsControllerFactory.kt
================================================
/*
 * Copyright 2023 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.compose

import androidx.compose.runtime.Composable
import dev.icerock.moko.permissions.PermissionsController

fun interface PermissionsControllerFactory {
    fun createPermissionsController(): PermissionsController
}

@Composable
expect fun rememberPermissionsControllerFactory(): PermissionsControllerFactory


================================================
FILE: permissions-compose/src/iosMain/kotlin/dev/icerock/moko/permissions/compose/BindEffect.ios.kt
================================================
/*
 * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.compose

import androidx.compose.runtime.Composable
import dev.icerock.moko.permissions.PermissionsController

// on iOS side we should not do anything to prepare PermissionsController to work
@Suppress("FunctionNaming")
@Composable
actual fun BindEffect(permissionsController: PermissionsController) = Unit


================================================
FILE: permissions-compose/src/iosMain/kotlin/dev/icerock/moko/permissions/compose/PermissionsControllerFactory.ios.kt
================================================
/*
 * Copyright 2023 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.compose

import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember

@Composable
actual fun rememberPermissionsControllerFactory(): PermissionsControllerFactory {
    return remember {
        PermissionsControllerFactory {
            dev.icerock.moko.permissions.ios.PermissionsController()
        }
    }
}


================================================
FILE: permissions-contacts/build.gradle.kts
================================================
/*
 * Copyright 2024 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

plugins {
    id("dev.icerock.moko.gradle.multiplatform.mobile")
    id("dev.icerock.moko.gradle.publication")
    id("dev.icerock.moko.gradle.stub.javadoc")
    id("dev.icerock.moko.gradle.detekt")
}

android {
    namespace = "dev.icerock.moko.permissions.contacts"
}

dependencies {
    commonMainApi(projects.permissions)
    commonMainImplementation(libs.coroutines)
}


================================================
FILE: permissions-contacts/src/androidMain/kotlin/dev/icerock/moko/permissions/contacts/ContactsPermission.android.kt
================================================
/*
 * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.contacts

import android.Manifest
import android.content.Context
import dev.icerock.moko.permissions.PermissionDelegate

actual val contactsDelegate = object : PermissionDelegate {
    override fun getPermissionStateOverride(applicationContext: Context) = null

    override fun getPlatformPermission() =
        listOf(
            Manifest.permission.READ_CONTACTS,
            Manifest.permission.WRITE_CONTACTS
        )
}

actual val readContactsDelegate = object : PermissionDelegate {
    override fun getPermissionStateOverride(applicationContext: Context) = null

    override fun getPlatformPermission() =
        listOf(
            Manifest.permission.READ_CONTACTS
        )
}


================================================
FILE: permissions-contacts/src/commonMain/kotlin/dev/icerock/moko/permissions/contacts/ContactPermission.kt
================================================
/*
 * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.contacts

import dev.icerock.moko.permissions.Permission
import dev.icerock.moko.permissions.PermissionDelegate

internal expect val contactsDelegate: PermissionDelegate
internal expect val readContactsDelegate: PermissionDelegate

/**
 * Permission to read and write contacts.
 *
 * On Android, declare both `READ_CONTACTS` and `WRITE_CONTACTS` permissions
 * in `AndroidManifest.xml`
 */
object ContactPermission : Permission {
    override val delegate get() = contactsDelegate
}

/**
 * Permission to read contacts
 *
 * On Android, declare `READ_CONTACTS` permission in `AndroidManifest.xml`
 *
 * On iOS this permission is the same with [ContactPermission]
 */
object ReadContactPermission : Permission {
    override val delegate get() = readContactsDelegate
}

val Permission.Companion.CONTACTS get() = ContactPermission
val Permission.Companion.READ_CONTACTS get() = ReadContactPermission


================================================
FILE: permissions-contacts/src/iosMain/kotlin/dev/icerock/moko/permissions/contacts/ContactsPermission.ios.kt
================================================
/*
 * Copyright 2022 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.contacts

import dev.icerock.moko.permissions.DeniedAlwaysException
import dev.icerock.moko.permissions.Permission
import dev.icerock.moko.permissions.PermissionDelegate
import dev.icerock.moko.permissions.PermissionState
import platform.Contacts.CNAuthorizationStatus
import platform.Contacts.CNAuthorizationStatusAuthorized
import platform.Contacts.CNAuthorizationStatusDenied
import platform.Contacts.CNAuthorizationStatusNotDetermined
import platform.Contacts.CNAuthorizationStatusRestricted
import platform.Contacts.CNContactStore
import platform.Contacts.CNEntityType
import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine

private class ContactsPermissionDelegate(
    private val permission: Permission,
) : PermissionDelegate {
    private val contactStore = CNContactStore()

    override suspend fun providePermission() {
        return providePermission(
            CNContactStore.authorizationStatusForEntityType(
                CNEntityType.CNEntityTypeContacts
            )
        )
    }

    override suspend fun getPermissionState(): PermissionState {
        val status: CNAuthorizationStatus =
            CNContactStore.authorizationStatusForEntityType(CNEntityType.CNEntityTypeContacts)
        return when (status) {
            CNAuthorizationStatusAuthorized, CNAuthorizationStatusLimited -> PermissionState.Granted

            CNAuthorizationStatusNotDetermined -> PermissionState.NotDetermined
            CNAuthorizationStatusDenied, CNAuthorizationStatusRestricted -> PermissionState.DeniedAlways
            else -> error("unknown contacts $status")
        }
    }

    private suspend fun providePermission(status: CNAuthorizationStatus) {
        when (status) {
            CNAuthorizationStatusAuthorized,
            CNAuthorizationStatusLimited -> return

            CNAuthorizationStatusNotDetermined -> {
                val newStatus = suspendCoroutine<CNAuthorizationStatus> { continuation ->
                    contactStore.requestAccessForEntityType(CNEntityType.CNEntityTypeContacts) { _, _ ->
                        continuation.resume(
                            CNContactStore.authorizationStatusForEntityType(
                                CNEntityType.CNEntityTypeContacts
                            )
                        )
                    }
                }
                providePermission(newStatus)
            }

            CNAuthorizationStatusDenied, CNAuthorizationStatusRestricted -> throw DeniedAlwaysException(permission)
            else -> error("unknown location authorization status $status")
        }
    }
}

// declared as constant because at now we use kotlin 1.9.10 that not know about
// platform.Contacts.CNAuthorizationStatusLimited
@Suppress("TopLevelPropertyNaming")
private const val CNAuthorizationStatusLimited: Long = 4

actual val contactsDelegate: PermissionDelegate = ContactsPermissionDelegate(ContactPermission)
actual val readContactsDelegate: PermissionDelegate = ContactsPermissionDelegate(ReadContactPermission)


================================================
FILE: permissions-gallery/build.gradle.kts
================================================
/*
 * Copyright 2024 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

plugins {
    id("dev.icerock.moko.gradle.multiplatform.mobile")
    id("dev.icerock.moko.gradle.publication")
    id("dev.icerock.moko.gradle.stub.javadoc")
    id("dev.icerock.moko.gradle.detekt")
}

android {
    namespace = "dev.icerock.moko.permissions.gallery"
}

dependencies {
    commonMainApi(projects.permissions)
    commonMainImplementation(libs.coroutines)
}


================================================
FILE: permissions-gallery/src/androidMain/kotlin/dev/icerock/moko/permissions/gallery/GalleryPermission.android.kt
================================================
/*
 * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.gallery

import android.Manifest
import android.content.Context
import android.os.Build
import dev.icerock.moko.permissions.PermissionDelegate

actual val galleryDelegate = object : PermissionDelegate {
    override fun getPermissionStateOverride(applicationContext: Context) = null

    override fun getPlatformPermission() =
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
            listOf(
                Manifest.permission.READ_MEDIA_IMAGES,
                Manifest.permission.READ_MEDIA_VIDEO
            )
        } else {
            listOf(Manifest.permission.READ_EXTERNAL_STORAGE)
        }
}


================================================
FILE: permissions-gallery/src/commonMain/kotlin/dev/icerock/moko/permissions/gallery/GalleryPermission.kt
================================================
/*
 * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.gallery

import dev.icerock.moko.permissions.Permission
import dev.icerock.moko.permissions.PermissionDelegate

internal expect val galleryDelegate: PermissionDelegate

object GalleryPermission : Permission {
    override val delegate get() = galleryDelegate
}

val Permission.Companion.GALLERY get() = GalleryPermission


================================================
FILE: permissions-gallery/src/iosMain/kotlin/dev/icerock/moko/permissions/gallery/GalleryPermissionDelegate.kt
================================================
/*
 * Copyright 2022 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.gallery

import dev.icerock.moko.permissions.DeniedAlwaysException
import dev.icerock.moko.permissions.Permission
import dev.icerock.moko.permissions.PermissionDelegate
import dev.icerock.moko.permissions.PermissionState
import dev.icerock.moko.permissions.mainContinuation
import platform.Photos.PHAuthorizationStatus
import platform.Photos.PHAuthorizationStatusAuthorized
import platform.Photos.PHAuthorizationStatusDenied
import platform.Photos.PHAuthorizationStatusNotDetermined
import platform.Photos.PHPhotoLibrary
import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine

internal class GalleryPermissionDelegate : PermissionDelegate {
    override suspend fun providePermission() {
        providePermission(PHPhotoLibrary.authorizationStatus())
    }

    private suspend fun providePermission(status: PHAuthorizationStatus) {
        return when (status) {
            PHAuthorizationStatusAuthorized -> return
            PHAuthorizationStatusNotDetermined -> {
                val newStatus = suspendCoroutine<PHAuthorizationStatus> { continuation ->
                    requestGalleryAccess { continuation.resume(it) }
                }
                providePermission(newStatus)
            }

            PHAuthorizationStatusDenied -> throw DeniedAlwaysException(Permission.GALLERY)
            else -> error("unknown gallery authorization status $status")
        }
    }

    override suspend fun getPermissionState(): PermissionState {
        val status: PHAuthorizationStatus = PHPhotoLibrary.authorizationStatus()
        return when (status) {
            PHAuthorizationStatusAuthorized -> PermissionState.Granted
            PHAuthorizationStatusNotDetermined -> PermissionState.NotDetermined
            PHAuthorizationStatusDenied -> PermissionState.DeniedAlways
            else -> error("unknown gallery authorization status $status")
        }
    }
}

private fun requestGalleryAccess(callback: (PHAuthorizationStatus) -> Unit) {
    PHPhotoLibrary.requestAuthorization(
        mainContinuation { status: PHAuthorizationStatus ->
            callback(status)
        }
    )
}

actual val galleryDelegate: PermissionDelegate = GalleryPermissionDelegate()


================================================
FILE: permissions-location/build.gradle.kts
================================================
/*
 * Copyright 2024 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

plugins {
    id("dev.icerock.moko.gradle.multiplatform.mobile")
    id("dev.icerock.moko.gradle.publication")
    id("dev.icerock.moko.gradle.stub.javadoc")
    id("dev.icerock.moko.gradle.detekt")
}

android {
    namespace = "dev.icerock.moko.permissions.location"
}

dependencies {
    commonMainApi(projects.permissions)
    commonMainImplementation(libs.coroutines)
}


================================================
FILE: permissions-location/src/androidMain/kotlin/dev/icerock/moko/permissions/location/LocationPermission.android.kt
================================================
/*
 * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.location

import android.Manifest
import android.content.Context
import android.os.Build
import dev.icerock.moko.permissions.PermissionDelegate

actual val locationDelegate = object : PermissionDelegate {
    override fun getPermissionStateOverride(applicationContext: Context) = null

    override fun getPlatformPermission() =
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
            listOf(
                Manifest.permission.ACCESS_FINE_LOCATION,
                Manifest.permission.ACCESS_COARSE_LOCATION,
            )
        } else {
            listOf(Manifest.permission.ACCESS_FINE_LOCATION)
        }
}

actual val coarseLocationDelegate = object : PermissionDelegate {
    override fun getPermissionStateOverride(applicationContext: Context) = null

    override fun getPlatformPermission() =
        listOf(Manifest.permission.ACCESS_COARSE_LOCATION)
}

actual val backgroundLocationDelegate = object : PermissionDelegate {
    override fun getPermissionStateOverride(applicationContext: Context) = null

    override fun getPlatformPermission() =
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
            listOf(
                Manifest.permission.ACCESS_FINE_LOCATION,
                Manifest.permission.ACCESS_COARSE_LOCATION,
                Manifest.permission.ACCESS_BACKGROUND_LOCATION,
            )
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
            listOf(
                Manifest.permission.ACCESS_FINE_LOCATION,
                Manifest.permission.ACCESS_BACKGROUND_LOCATION,
            )
        } else {
            listOf(Manifest.permission.ACCESS_FINE_LOCATION)
        }
}


================================================
FILE: permissions-location/src/commonMain/kotlin/dev/icerock/moko/permissions/location/LocationPermission.kt
================================================
/*
 * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.location

import dev.icerock.moko.permissions.Permission
import dev.icerock.moko.permissions.PermissionDelegate

internal expect val locationDelegate: PermissionDelegate
internal expect val coarseLocationDelegate: PermissionDelegate
internal expect val backgroundLocationDelegate: PermissionDelegate

object LocationPermission : Permission {
    override val delegate get() = locationDelegate
}

object CoarseLocationPermission : Permission {
    override val delegate get() = coarseLocationDelegate
}

object BackgroundLocationPermission : Permission {
    override val delegate get() = backgroundLocationDelegate
}

val Permission.Companion.LOCATION get() = LocationPermission
val Permission.Companion.COARSE_LOCATION get() = CoarseLocationPermission
val Permission.Companion.BACKGROUND_LOCATION get() = BackgroundLocationPermission


================================================
FILE: permissions-location/src/iosMain/kotlin/dev/icerock/moko/permissions/location/LocationManagerDelegate.kt
================================================
/*
 * Copyright 2020 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.location

import platform.CoreLocation.CLAuthorizationStatus
import platform.CoreLocation.CLLocationManager
import platform.CoreLocation.CLLocationManagerDelegateProtocol
import platform.darwin.NSObject
import kotlin.experimental.ExperimentalObjCName

@OptIn(ExperimentalObjCName::class)
@ObjCName("LocationManagerDelegate")
internal class LocationManagerDelegate : NSObject(), CLLocationManagerDelegateProtocol {
    private var callback: ((CLAuthorizationStatus) -> Unit)? = null

    private val locationManager = CLLocationManager()

    init {
        locationManager.delegate = this
    }

    fun authorizationStatus(): CLAuthorizationStatus {
        return locationManager.authorizationStatus
    }

    fun requestWhenInUseAuthorization(callback: (CLAuthorizationStatus) -> Unit) {
        this.callback = callback

        locationManager.requestWhenInUseAuthorization()
    }

    fun requestAlwaysAuthorization(callback: (CLAuthorizationStatus) -> Unit) {
        this.callback = callback

        locationManager.requestAlwaysAuthorization()
    }

    override fun locationManagerDidChangeAuthorization(manager: CLLocationManager) {
        val authorizationStatus: CLAuthorizationStatus = manager.authorizationStatus
        callback?.invoke(authorizationStatus)
        callback = null
    }
}


================================================
FILE: permissions-location/src/iosMain/kotlin/dev/icerock/moko/permissions/location/LocationPermission.ios.kt
================================================
/*
 * Copyright 2022 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.location

import dev.icerock.moko.permissions.DeniedAlwaysException
import dev.icerock.moko.permissions.DeniedException
import dev.icerock.moko.permissions.Permission
import dev.icerock.moko.permissions.PermissionDelegate
import dev.icerock.moko.permissions.PermissionState
import platform.CoreLocation.CLAuthorizationStatus
import platform.CoreLocation.kCLAuthorizationStatusAuthorizedAlways
import platform.CoreLocation.kCLAuthorizationStatusAuthorizedWhenInUse
import platform.CoreLocation.kCLAuthorizationStatusDenied
import platform.CoreLocation.kCLAuthorizationStatusNotDetermined
import platform.CoreLocation.kCLAuthorizationStatusRestricted
import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine

private val locationManagerDelegate = LocationManagerDelegate()

private class LocationPermissionDelegate(
    private val permission: Permission
) : PermissionDelegate {
    override suspend fun providePermission() {
        return provideLocationPermission(
            status = locationManagerDelegate.authorizationStatus()
        )
    }

    override suspend fun getPermissionState(): PermissionState {
        val status: CLAuthorizationStatus = locationManagerDelegate.authorizationStatus()
        return when (status) {
            kCLAuthorizationStatusAuthorizedAlways -> PermissionState.Granted
            kCLAuthorizationStatusAuthorizedWhenInUse -> {
                when (permission) {
                    BackgroundLocationPermission -> PermissionState.NotGranted
                    else -> PermissionState.Granted
                }
            }

            kCLAuthorizationStatusNotDetermined -> PermissionState.NotDetermined
            kCLAuthorizationStatusDenied,
            kCLAuthorizationStatusRestricted -> PermissionState.DeniedAlways

            else -> error("unknown location authorization status $status")
        }
    }

    private suspend fun provideLocationPermission(
        status: CLAuthorizationStatus
    ) {
        when (status) {
            kCLAuthorizationStatusAuthorizedAlways -> Unit
            kCLAuthorizationStatusAuthorizedWhenInUse ->
                if (permission == BackgroundLocationPermission) {
                    // if we request background permission we should receive "always"
                    throw DeniedException(permission)
                }

            kCLAuthorizationStatusNotDetermined -> if (permission == BackgroundLocationPermission) {
                requestAlwaysAuthorization()
            } else {
                requestWhenInUseAuthorization()
            }

            kCLAuthorizationStatusDenied,
            kCLAuthorizationStatusRestricted -> throw DeniedAlwaysException(permission)

            else -> error("unknown location authorization status $status")
        }
    }

    private suspend fun requestWhenInUseAuthorization() {
        val newStatus = suspendCoroutine { continuation ->
            locationManagerDelegate.requestWhenInUseAuthorization { continuation.resume(it) }
        }
        provideLocationPermission(newStatus)
    }

    private suspend fun requestAlwaysAuthorization() {
        val newStatus = suspendCoroutine { continuation ->
            locationManagerDelegate.requestAlwaysAuthorization { continuation.resume(it) }
        }
        provideLocationPermission(newStatus)
    }
}

actual val locationDelegate: PermissionDelegate =
    LocationPermissionDelegate(LocationPermission)
actual val coarseLocationDelegate: PermissionDelegate =
    LocationPermissionDelegate(CoarseLocationPermission)
actual val backgroundLocationDelegate: PermissionDelegate =
    LocationPermissionDelegate(BackgroundLocationPermission)


================================================
FILE: permissions-microphone/build.gradle.kts
================================================
/*
 * Copyright 2024 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

plugins {
    id("dev.icerock.moko.gradle.multiplatform.mobile")
    id("dev.icerock.moko.gradle.publication")
    id("dev.icerock.moko.gradle.stub.javadoc")
    id("dev.icerock.moko.gradle.detekt")
}

android {
    namespace = "dev.icerock.moko.permissions.microphone"
}

dependencies {
    commonMainApi(projects.permissions)
    iosMainImplementation(projects.permissionsAvfoundation)
    commonMainImplementation(libs.coroutines)
}


================================================
FILE: permissions-microphone/src/androidMain/kotlin/dev/icerock/moko/permissions/microphone/MicrophonePermission.android.kt
================================================
/*
 * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.microphone

import android.Manifest
import android.content.Context
import dev.icerock.moko.permissions.PermissionDelegate

actual val recordAudioDelegate = object : PermissionDelegate {
    override fun getPermissionStateOverride(applicationContext: Context) = null
    override fun getPlatformPermission() = listOf(Manifest.permission.RECORD_AUDIO)
}


================================================
FILE: permissions-microphone/src/commonMain/kotlin/dev/icerock/moko/permissions/microphone/MicrophonePermission.kt
================================================
/*
 * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.microphone

import dev.icerock.moko.permissions.Permission
import dev.icerock.moko.permissions.PermissionDelegate

internal expect val recordAudioDelegate: PermissionDelegate

object RecordAudioPermission : Permission {
    override val delegate get() = recordAudioDelegate
}

val Permission.Companion.RECORD_AUDIO get() = RecordAudioPermission


================================================
FILE: permissions-microphone/src/iosMain/kotlin/dev/icerock/moko/permissions/microphone/MicrophonePermission.ios.kt
================================================
/*
 * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.microphone

import dev.icerock.moko.permissions.Permission
import dev.icerock.moko.permissions.PermissionDelegate
import dev.icerock.moko.permissions.avfoundation.AVCaptureDelegate
import platform.AVFoundation.AVMediaTypeAudio

actual val recordAudioDelegate: PermissionDelegate = AVCaptureDelegate(
    AVMediaTypeAudio,
    Permission.RECORD_AUDIO
)


================================================
FILE: permissions-motion/build.gradle.kts
================================================
/*
 * Copyright 2024 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

plugins {
    id("dev.icerock.moko.gradle.multiplatform.mobile")
    id("dev.icerock.moko.gradle.publication")
    id("dev.icerock.moko.gradle.stub.javadoc")
    id("dev.icerock.moko.gradle.detekt")
}

android {
    namespace = "dev.icerock.moko.permissions.motion"
}

dependencies {
    commonMainApi(projects.permissions)
    commonMainImplementation(libs.coroutines)
}


================================================
FILE: permissions-motion/src/androidMain/kotlin/dev/icerock/moko/permissions/motion/MotionPermission.android.kt
================================================
/*
 * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.motion

import android.Manifest
import android.content.Context
import android.os.Build
import dev.icerock.moko.permissions.PermissionDelegate

actual val motionDelegate = object : PermissionDelegate {
    override fun getPermissionStateOverride(applicationContext: Context) = null

    override fun getPlatformPermission() =
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
            listOf(
                Manifest.permission.ACTIVITY_RECOGNITION,
                Manifest.permission.BODY_SENSORS
            )
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
            listOf(Manifest.permission.BODY_SENSORS)
        } else {
            emptyList()
        }
}


================================================
FILE: permissions-motion/src/commonMain/kotlin/dev/icerock/moko/permissions/motion/MotionPermission.kt
================================================
/*
 * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.motion

import dev.icerock.moko.permissions.Permission
import dev.icerock.moko.permissions.PermissionDelegate

internal expect val motionDelegate: PermissionDelegate

object MotionPermission : Permission {
    override val delegate get() = motionDelegate
}

val Permission.Companion.MOTION get() = MotionPermission


================================================
FILE: permissions-motion/src/iosMain/kotlin/dev/icerock/moko/permissions/motion/MotionPermission.ios.kt
================================================
/*
 * Copyright 2022 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.motion

import dev.icerock.moko.permissions.PermissionDelegate
import dev.icerock.moko.permissions.PermissionState
import platform.CoreMotion.CMAuthorizationStatusAuthorized
import platform.CoreMotion.CMAuthorizationStatusDenied
import platform.CoreMotion.CMAuthorizationStatusNotDetermined
import platform.CoreMotion.CMAuthorizationStatusRestricted
import platform.CoreMotion.CMMotionActivityManager
import platform.Foundation.NSDate
import platform.Foundation.NSOperationQueue

private class MotionPermissionDelegate : PermissionDelegate {
    override suspend fun providePermission() {
        val cmActivityManager = CMMotionActivityManager()
        val now = NSDate()
        cmActivityManager.queryActivityStartingFromDate(
            now,
            now,
            NSOperationQueue.mainQueue()
        ) { _, _ -> }
    }

    @Suppress("MoveVariableDeclarationIntoWhen")
    override suspend fun getPermissionState(): PermissionState {
        val status = CMMotionActivityManager.authorizationStatus()
        return when (status) {
            CMAuthorizationStatusAuthorized,
            CMAuthorizationStatusRestricted, -> PermissionState.Granted
            CMAuthorizationStatusDenied -> PermissionState.DeniedAlways
            CMAuthorizationStatusNotDetermined -> PermissionState.NotDetermined
            else -> error("unknown motion authorization status $status")
        }
    }
}

actual val motionDelegate: PermissionDelegate = MotionPermissionDelegate()


================================================
FILE: permissions-notifications/build.gradle.kts
================================================
/*
 * Copyright 2024 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

plugins {
    id("dev.icerock.moko.gradle.multiplatform.mobile")
    id("dev.icerock.moko.gradle.publication")
    id("dev.icerock.moko.gradle.stub.javadoc")
    id("dev.icerock.moko.gradle.detekt")
}

android {
    namespace = "dev.icerock.moko.permissions.notifications"
}

dependencies {
    commonMainApi(projects.permissions)
    commonMainImplementation(libs.coroutines)
    androidMainImplementation(libs.androidxCore)
}


================================================
FILE: permissions-notifications/src/androidMain/kotlin/dev/icerock/moko/permissions/notifications/NotificationPermission.android.kt
================================================
/*
 * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.notifications

import android.Manifest
import android.content.Context
import android.os.Build
import androidx.core.app.NotificationManagerCompat
import dev.icerock.moko.permissions.PermissionDelegate
import dev.icerock.moko.permissions.PermissionState

actual val remoteNotificationDelegate = object : PermissionDelegate {
    override fun getPermissionStateOverride(applicationContext: Context): PermissionState? {
        if (Build.VERSION.SDK_INT !in VERSIONS_WITHOUT_NOTIFICATION_PERMISSION) return null

        val isNotificationsEnabled = NotificationManagerCompat.from(applicationContext)
            .areNotificationsEnabled()
        return if (isNotificationsEnabled) {
            PermissionState.Granted
        } else {
            PermissionState.DeniedAlways
        }
    }

    override fun getPlatformPermission() =
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
            listOf(Manifest.permission.POST_NOTIFICATIONS)
        } else {
            emptyList()
        }
}

private val VERSIONS_WITHOUT_NOTIFICATION_PERMISSION =
    Build.VERSION_CODES.KITKAT until Build.VERSION_CODES.TIRAMISU


================================================
FILE: permissions-notifications/src/commonMain/kotlin/dev/icerock/moko/permissions/notifications/NotificationPermission.kt
================================================
/*
 * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.notifications

import dev.icerock.moko.permissions.Permission
import dev.icerock.moko.permissions.PermissionDelegate

internal expect val remoteNotificationDelegate: PermissionDelegate

object RemoteNotificationPermission : Permission {
    override val delegate get() = remoteNotificationDelegate
}

val Permission.Companion.REMOTE_NOTIFICATION get() = RemoteNotificationPermission


================================================
FILE: permissions-notifications/src/iosMain/kotlin/dev/icerock/moko/permissions/notifications/RemoteNotificationPermissionDelegate.kt
================================================
/*
 * Copyright 2022 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.notifications

import dev.icerock.moko.permissions.DeniedAlwaysException
import dev.icerock.moko.permissions.Permission
import dev.icerock.moko.permissions.PermissionDelegate
import dev.icerock.moko.permissions.PermissionState
import dev.icerock.moko.permissions.mainContinuation
import platform.UserNotifications.UNAuthorizationOptionAlert
import platform.UserNotifications.UNAuthorizationOptionBadge
import platform.UserNotifications.UNAuthorizationOptionCarPlay
import platform.UserNotifications.UNAuthorizationOptionSound
import platform.UserNotifications.UNAuthorizationStatus
import platform.UserNotifications.UNAuthorizationStatusAuthorized
import platform.UserNotifications.UNAuthorizationStatusDenied
import platform.UserNotifications.UNAuthorizationStatusEphemeral
import platform.UserNotifications.UNAuthorizationStatusNotDetermined
import platform.UserNotifications.UNAuthorizationStatusProvisional
import platform.UserNotifications.UNNotificationSettings
import platform.UserNotifications.UNUserNotificationCenter
import kotlin.coroutines.suspendCoroutine

internal class RemoteNotificationPermissionDelegate : PermissionDelegate {
    override suspend fun providePermission() {
        return provideNotificationPermission(
            getPermissionStatus()
        )
    }

    override suspend fun getPermissionState(): PermissionState {
        val status: UNAuthorizationStatus = getPermissionStatus()

        return when (status) {
            UNAuthorizationStatusAuthorized,
            UNAuthorizationStatusProvisional,
            UNAuthorizationStatusEphemeral,
            -> PermissionState.Granted

            UNAuthorizationStatusNotDetermined -> PermissionState.NotDetermined
            UNAuthorizationStatusDenied -> PermissionState.DeniedAlways
            else -> error("unknown push authorization status $status")
        }
    }

    private suspend fun getPermissionStatus(): UNAuthorizationStatus {
        val currentCenter = UNUserNotificationCenter.currentNotificationCenter()
        return suspendCoroutine { continuation ->
            currentCenter.getNotificationSettingsWithCompletionHandler(
                mainContinuation { settings: UNNotificationSettings? ->
                    continuation.resumeWith(
                        Result.success(
                            settings?.authorizationStatus ?: UNAuthorizationStatusNotDetermined
                        )
                    )
                }
            )
        }
    }

    private suspend fun provideNotificationPermission(
        status: UNAuthorizationStatus
    ) {
        when (status) {
            UNAuthorizationStatusAuthorized,
            UNAuthorizationStatusProvisional,
            UNAuthorizationStatusEphemeral -> return

            UNAuthorizationStatusNotDetermined -> {
                // User has not yet chosen permission, request permission
                val newStatus = suspendCoroutine<UNAuthorizationStatus> { continuation ->
                    UNUserNotificationCenter.currentNotificationCenter()
                        .requestAuthorizationWithOptions(
                            UNAuthorizationOptionSound
                                .or(UNAuthorizationOptionAlert)
                                .or(UNAuthorizationOptionBadge)
                                .or(UNAuthorizationOptionCarPlay),
                            mainContinuation { isOk, error ->
                                if (isOk && error == null) {
                                    continuation.resumeWith(Result.success(UNAuthorizationStatusAuthorized))
                                } else {
                                    continuation.resumeWith(Result.success(UNAuthorizationStatusDenied))
                                }
                            }
                        )
                }
                provideNotificationPermission(newStatus)
            }

            UNAuthorizationStatusDenied -> throw DeniedAlwaysException(Permission.REMOTE_NOTIFICATION)
            else -> error("unknown notifications authorization status $status")
        }
    }
}

actual val remoteNotificationDelegate: PermissionDelegate = RemoteNotificationPermissionDelegate()


================================================
FILE: permissions-storage/build.gradle.kts
================================================
/*
 * Copyright 2024 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

plugins {
    id("dev.icerock.moko.gradle.multiplatform.mobile")
    id("dev.icerock.moko.gradle.publication")
    id("dev.icerock.moko.gradle.stub.javadoc")
    id("dev.icerock.moko.gradle.detekt")
}

android {
    namespace = "dev.icerock.moko.permissions.storage"
}

dependencies {
    commonMainApi(projects.permissions)
    commonMainImplementation(libs.coroutines)
}


================================================
FILE: permissions-storage/src/androidMain/kotlin/dev/icerock/moko/permissions/storage/StoragePermissions.android.kt
================================================
/*
 * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.storage

import android.Manifest
import android.content.Context
import android.os.Build
import dev.icerock.moko.permissions.PermissionDelegate

actual val storageDelegate = object : PermissionDelegate {
    override fun getPermissionStateOverride(applicationContext: Context) = null

    override fun getPlatformPermission() =
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
            listOf(
                Manifest.permission.READ_MEDIA_AUDIO,
                Manifest.permission.READ_MEDIA_IMAGES,
                Manifest.permission.READ_MEDIA_VIDEO
            )
        } else {
            listOf(Manifest.permission.READ_EXTERNAL_STORAGE)
        }
}

actual val writeStorageDelegate = object : PermissionDelegate {
    override fun getPermissionStateOverride(applicationContext: Context) = null

    override fun getPlatformPermission() = listOf(Manifest.permission.WRITE_EXTERNAL_STORAGE)
}


================================================
FILE: permissions-storage/src/commonMain/kotlin/dev/icerock/moko/permissions/storage/StoragePermissions.kt
================================================
/*
 * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.storage

import dev.icerock.moko.permissions.Permission
import dev.icerock.moko.permissions.PermissionDelegate

internal expect val storageDelegate: PermissionDelegate
internal expect val writeStorageDelegate: PermissionDelegate

object StoragePermission : Permission {
    override val delegate get() = storageDelegate
}

object WriteStoragePermission : Permission {
    override val delegate get() = writeStorageDelegate
}

val Permission.Companion.STORAGE get() = StoragePermission
val Permission.Companion.WRITE_STORAGE get() = WriteStoragePermission


================================================
FILE: permissions-storage/src/iosMain/kotlin/dev/icerock/moko/permissions/storage/AlwaysGrantedDelegate.kt
================================================
/*
 * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.storage

import dev.icerock.moko.permissions.PermissionDelegate
import dev.icerock.moko.permissions.PermissionState

object AlwaysGrantedDelegate : PermissionDelegate {
    override suspend fun providePermission() = Unit
    override suspend fun getPermissionState() = PermissionState.Granted
}


================================================
FILE: permissions-storage/src/iosMain/kotlin/dev/icerock/moko/permissions/storage/StoragePermissions.ios.kt
================================================
/*
 * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.storage

import dev.icerock.moko.permissions.PermissionDelegate

actual val storageDelegate: PermissionDelegate = AlwaysGrantedDelegate
actual val writeStorageDelegate: PermissionDelegate = AlwaysGrantedDelegate


================================================
FILE: permissions-test/build.gradle.kts
================================================
/*
 * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

plugins {
    id("org.jetbrains.kotlin.multiplatform")
    id("dev.icerock.moko.gradle.multiplatform.mobile")
    id("dev.icerock.moko.gradle.publication")
    id("dev.icerock.moko.gradle.stub.javadoc")
    id("dev.icerock.moko.gradle.detekt")
}

android {
    namespace = "dev.icerock.moko.permissions.test"
}

dependencies {
    commonMainImplementation(libs.coroutines)

    androidMainImplementation(libs.activity)

    commonMainApi(projects.permissions)
}


================================================
FILE: permissions-test/src/androidMain/kotlin/dev/icerock/moko/permissions/test/PermissionsControllerMock.kt
================================================
/*
 * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.test

import androidx.activity.ComponentActivity
import dev.icerock.moko.permissions.Permission
import dev.icerock.moko.permissions.PermissionsController

actual abstract class PermissionsControllerMock : PermissionsController {
    actual abstract override suspend fun providePermission(permission: Permission)

    actual abstract override suspend fun isPermissionGranted(permission: Permission): Boolean

    override fun bind(
        activity: ComponentActivity
    ) {
        TODO("Not yet implemented")
    }

    actual companion object
}


================================================
FILE: permissions-test/src/commonMain/kotlin/dev/icerock/moko/permissions/test/PermissionsControllerMock.kt
================================================
/*
 * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.test

import dev.icerock.moko.permissions.DeniedException
import dev.icerock.moko.permissions.Permission
import dev.icerock.moko.permissions.PermissionState
import dev.icerock.moko.permissions.PermissionsController

expect abstract class PermissionsControllerMock constructor() : PermissionsController {
    abstract override suspend fun providePermission(permission: Permission)

    abstract override suspend fun isPermissionGranted(permission: Permission): Boolean

    companion object
}

fun createPermissionControllerMock(
    allow: Set<Permission> = emptySet(),
    granted: Set<Permission> = emptySet(),
): PermissionsControllerMock = object : PermissionsControllerMock() {
    private val granted = mutableSetOf<Permission>().apply { addAll(granted) }

    override suspend fun providePermission(permission: Permission) {
        if (allow.contains(permission)) {
            this.granted.add(permission)
            return
        }
        if (this.granted.contains(permission)) return

        throw DeniedException(permission, "mock block permission")
    }

    override suspend fun isPermissionGranted(permission: Permission): Boolean {
        return this.granted.contains(permission)
    }

    override fun openAppSettings() = Unit

    override suspend fun getPermissionState(permission: Permission): PermissionState {
        return if (isPermissionGranted(permission)) {
            PermissionState.Granted
        } else {
            PermissionState.NotDetermined
        }
    }
}


================================================
FILE: permissions-test/src/iosMain/kotlin/dev/icerock/moko/permissions/test/PermissionsControllerMock.kt
================================================
/*
 * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

package dev.icerock.moko.permissions.test

import dev.icerock.moko.permissions.Permission
import dev.icerock.moko.permissions.PermissionsController

actual abstract class PermissionsControllerMock : PermissionsController {
    actual abstract override suspend fun providePermission(permission: Permission)

    actual abstract override suspend fun isPermissionGranted(permission: Permission): Boolean

    actual companion object
}


================================================
FILE: sample/android-app/build.gradle.kts
================================================
plugins {
    id("dev.icerock.moko.gradle.android.application")
    id("dev.icerock.moko.gradle.detekt")
}

android {
    namespace = "com.icerockdev"

    defaultConfig {
        applicationId = "dev.icerock.moko.samples.permissions"

        versionCode = 1
        versionName = "0.1.0"
    }
}

dependencies {
    implementation(libs.androidxCore)
    implementation(libs.material)

    implementation(projects.sample.mppLibrary)
    implementation(projects.permissionsContacts)
}


================================================
FILE: sample/android-app/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /opt/android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}


================================================
FILE: sample/android-app/src/main/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.icerockdev">

    <application
        android:label="moko-permissions test app"
        android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"
        tools:ignore="GoogleAppIndexingWarning">

        <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>


================================================
FILE: sample/android-app/src/main/java/com/icerockdev/MainActivity.kt
================================================
package com.icerockdev

import android.os.Bundle
import android.view.View
import android.widget.LinearLayout
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.google.android.material.snackbar.Snackbar
import com.icerockdev.library.SampleViewModel
import dev.icerock.moko.mvvm.dispatcher.eventsDispatcherOnMain
import dev.icerock.moko.mvvm.getViewModel
import dev.icerock.moko.permissions.DeniedAlwaysException
import dev.icerock.moko.permissions.DeniedException
import dev.icerock.moko.permissions.PermissionsController

class MainActivity : AppCompatActivity(), SampleViewModel.EventListener {

    private lateinit var viewModel: SampleViewModel

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        // Creates viewModel from common code.
        viewModel = getViewModel {
            SampleViewModel(
                eventsDispatcher = eventsDispatcherOnMain(),
                permissionsController = PermissionsController(applicationContext = applicationContext)
            )
        }.also {
            it.permissionsController.bind(this)
            it.eventsDispatcher.bind(this, this)
        }
    }

    fun onRequestButtonClick(@Suppress("UNUSED_PARAMETER") view: View?) {
        // Starts permission providing process.
        viewModel.onRequestPermissionButtonPressed()
    }

    override fun onSuccess() {
        showToast("Permission successfully granted!")
    }

    override fun onDenied(exception: DeniedException) {
        showToast("Permission denied!")
    }

    override fun onDeniedAlways(exception: DeniedAlwaysException) {
        Snackbar
            .make(
                findViewById<LinearLayout>(R.id.root_view),
                "Permission is always denied",
                Snackbar.LENGTH_LONG
            )
            .setAction("Settings") {
                openAppSettings()
            }
            .show()
    }

    private fun openAppSettings() {
        viewModel.permissionsController.openAppSettings()
    }

    private fun showToast(message: String) {
        Toast.makeText(this, message, Toast.LENGTH_SHORT).show()
    }
}


================================================
FILE: sample/android-app/src/main/res/layout/activity_main.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/root_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity">

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="32dp"
        android:onClick="onRequestButtonClick"
        android:text="Request permission" />

</LinearLayout>


================================================
FILE: sample/compose-android-app/build.gradle.kts
================================================
plugins {
    id("dev.icerock.moko.gradle.android.application")
    id("dev.icerock.moko.gradle.detekt")
    id("org.jetbrains.compose")
}

android {
    namespace = "com.icerockdev"

    defaultConfig {
        applicationId = "dev.icerock.moko.samples.permissions"
        minSdk = 21
        versionCode = 1
        versionName = "0.1.0"
    }
}

dependencies {
    implementation(libs.androidxCore)
    implementation(libs.composeActivity)
    implementation(libs.composeMaterial)
    implementation(projects.sample.mppLibrary)
    implementation(projects.permissionsCompose)
    implementation(projects.permissionsCamera)
}


================================================
FILE: sample/compose-android-app/src/main/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.icerockdev">

    <application
        android:label="moko-permissions test app"
        tools:ignore="GoogleAppIndexingWarning">

        <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>


================================================
FILE: sample/compose-android-app/src/main/java/com/icerockdev/MainActivity.kt
================================================
package com.icerockdev

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Button
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Scaffold
import androidx.compose.material.SnackbarDuration
import androidx.compose.material.SnackbarResult
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.material.rememberScaffoldState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalLifecycleOwner
import com.icerockdev.library.SampleViewModel
import dev.icerock.moko.mvvm.dispatcher.eventsDispatcherOnMain
import dev.icerock.moko.mvvm.getViewModel
import dev.icerock.moko.permissions.DeniedAlwaysException
import dev.icerock.moko.permissions.DeniedException
import dev.icerock.moko.permissions.PermissionsController
import dev.icerock.moko.permissions.compose.BindEffect
import kotlinx.coroutines.launch

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            MaterialTheme {
                Surface(modifier = Modifier.background(Color.White)) {
                    TestScreen(
                        viewModel = getViewModel {
                            SampleViewModel(
                                eventsDispatcher = eventsDispatcherOnMain(),
                                permissionsController = PermissionsController(
                                    applicationContext = applicationContext
                                )
                            )
                        }
                    )
                }
            }
        }
    }
}

@Suppress("FunctionNaming")
@Composable
fun TestScreen(viewModel: SampleViewModel) {
    val scaffoldState = rememberScaffoldState()
    val coroutineScope = rememberCoroutineScope()

    val eventsListener = remember {
        object : SampleViewModel.EventListener {
            override fun onSuccess() {
                coroutineScope.launch {
                    scaffoldState.snackbarHostState.showSnackbar(
                        message = "Permission successfully granted!"
                    )
                }
            }

            override fun onDenied(exception: DeniedException) {
                coroutineScope.launch {
                    scaffoldState.snackbarHostState.showSnackbar(
                        message = "Permission denied!"
                    )
                }
            }

            override fun onDeniedAlways(exception: DeniedAlwaysException) {
                coroutineScope.launch {
                    val result = scaffoldState.snackbarHostState.showSnackbar(
                        message = "Permission is always denied",
                        duration = SnackbarDuration.Long,
                        actionLabel = "Settings"
                    )

                    if (result == SnackbarResult.ActionPerformed) {
                        viewModel.permissionsController.openAppSettings()
                    }
                }
            }
        }
    }

    val lifecycleOwner = LocalLifecycleOwner.current
    LaunchedEffect(true) {
        viewModel.eventsDispatcher.bind(lifecycleOwner, eventsListener)
    }
    val permissionState by viewModel.permissionState.collectAsState()

    BindEffect(viewModel.permissionsController)

    Scaffold(scaffoldState = scaffoldState) {
        Column(
            modifier = Modifier
                .fillMaxSize()
                .padding(it),
            horizontalAlignment = Alignment.CenterHorizontally,
            verticalArrangement = Arrangement.Center
        ) {
            Text("Permission state: $permissionState")

            Button(
                onClick = viewModel::onRequestPermissionButtonPressed,
                content = { Text("Request permission") }
            )
        }
    }
}


================================================
FILE: sample/ios-app/Podfile
================================================
source 'https://cdn.cocoapods.org/'

# ignore all warnings from all pods
inhibit_all_warnings!

use_frameworks!
platform :ios, '12.0'

# workaround for https://github.com/CocoaPods/CocoaPods/issues/8073
# need for correct invalidate of cache MultiPlatformLibrary.framework
install! 'cocoapods', :disable_input_output_paths => true

target 'TestProj' do
  # MultiPlatformLibrary
  # для корректной установки фреймворка нужно сначала скомпилировать котлин библиотеку - compile-kotlin-framework.sh (в корневой директории репозитория)
  pod 'MultiPlatformLibrary', :path => '../mpp-library'
end


================================================
FILE: sample/ios-app/TestProj.xcodeproj/project.pbxproj
================================================
// !$*UTF8*$!
{
	archiveVersion = 1;
	classes = {
	};
	objectVersion = 50;
	objects = {

/* Begin PBXBuildFile section */
		2B70A10DE02726CA8E6981EB /* Pods_TestProj.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E8D683A7C91DCD56058C7435 /* Pods_TestProj.framework */; };
		45D74FCC22BFDDFD00CAB0C8 /* TestViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45D74FCB22BFDDFD00CAB0C8 /* TestViewController.swift */; };
		45F4791D219463C7003D25FA /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 45F47912219463C7003D25FA /* LaunchScreen.storyboard */; };
		45F4791E219463C7003D25FA /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 45F47914219463C7003D25FA /* Main.storyboard */; };
		45F47921219463C7003D25FA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 45F4791A219463C7003D25FA /* Assets.xcassets */; };
		45F47922219463C7003D25FA /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45F4791B219463C7003D25FA /* AppDelegate.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
		287627FF1F319065007FA12B /* mokoSamplePermissions.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = mokoSamplePermissions.app; sourceTree = BUILT_PRODUCTS_DIR; };
		45964D362282A1FD00C16658 /* mpp-library */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "mpp-library"; path = "../mpp-library"; sourceTree = "<group>"; };
		45D74FCB22BFDDFD00CAB0C8 /* TestViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestViewController.swift; sourceTree = "<group>"; };
		45F47913219463C7003D25FA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
		45F47915219463C7003D25FA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
		45F4791A219463C7003D25FA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
		45F4791B219463C7003D25FA /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
		45F4791C219463C7003D25FA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
		A644D2F1C5377C40A53FCD6A /* Pods-TestProj.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TestProj.release.xcconfig"; path = "Pods/Target Support Files/Pods-TestProj/Pods-TestProj.release.xcconfig"; sourceTree = "<group>"; };
		DFBDF7D3559D080FDCA444A6 /* Pods-TestProj.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TestProj.debug.xcconfig"; path = "Pods/Target Support Files/Pods-TestProj/Pods-TestProj.debug.xcconfig"; sourceTree = "<group>"; };
		E8D683A7C91DCD56058C7435 /* Pods_TestProj.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_TestProj.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
		287627FC1F319065007FA12B /* Frameworks */ = {
			isa = PBXFrameworksBuildPhase;
			buildActionMask = 2147483647;
			files = (
				2B70A10DE02726CA8E6981EB /* Pods_TestProj.framework in Frameworks */,
			);
			runOnlyForDeploymentPostprocessing = 0;
		};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
		0C46713DE6750675C174D0A7 /* Pods */ = {
			isa = PBXGroup;
			children = (
				DFBDF7D3559D080FDCA444A6 /* Pods-TestProj.debug.xcconfig */,
				A644D2F1C5377C40A53FCD6A /* Pods-TestProj.release.xcconfig */,
			);
			name = Pods;
			sourceTree = "<group>";
		};
		287627F61F319065007FA12B = {
			isa = PBXGroup;
			children = (
				45964D362282A1FD00C16658 /* mpp-library */,
				45F47910219463C7003D25FA /* src */,
				287628001F319065007FA12B /* Products */,
				EE1ABB3E79CE541540D3155F /* Frameworks */,
				0C46713DE6750675C174D0A7 /* Pods */,
			);
			indentWidth = 4;
			sourceTree = "<group>";
			tabWidth = 4;
			usesTabs = 0;
		};
		287628001F319065007FA12B /* Products */ = {
			isa = PBXGroup;
			children = (
				287627FF1F319065007FA12B /* mokoSamplePermissions.app */,
			);
			name = Products;
			sourceTree = "<group>";
		};
		45F47910219463C7003D25FA /* src */ = {
			isa = PBXGroup;
			children = (
				45F47911219463C7003D25FA /* Resources */,
				45F4791A219463C7003D25FA /* Assets.xcassets */,
				45F4791B219463C7003D25FA /* AppDelegate.swift */,
				45F4791C219463C7003D25FA /* Info.plist */,
				45D74FCB22BFDDFD00CAB0C8 /* TestViewController.swift */,
			);
			path = src;
			sourceTree = "<group>";
		};
		45F47911219463C7003D25FA /* Resources */ = {
			isa = PBXGroup;
			children = (
				45F47912219463C7003D25FA /* LaunchScreen.storyboard */,
				45F47914219463C7003D25FA /* Main.storyboard */,
			);
			path = Resources;
			sourceTree = "<group>";
		};
		EE1ABB3E79CE541540D3155F /* Frameworks */ = {
			isa = PBXGroup;
			children = (
				E8D683A7C91DCD56058C7435 /* Pods_TestProj.framework */,
			);
			name = Frameworks;
			sourceTree = "<group>";
		};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
		287627FE1F319065007FA12B /* TestProj */ = {
			isa = PBXNativeTarget;
			buildConfigurationList = 287628111F319065007FA12B /* Build configuration list for PBXNativeTarget "TestProj" */;
			buildPhases = (
				DDE4C06D580BF457BEDF8D0A /* [CP] Check Pods Manifest.lock */,
				287627FB1F319065007FA12B /* Sources */,
				287627FC1F319065007FA12B /* Frameworks */,
				287627FD1F319065007FA12B /* Resources */,
				27BD989196B22F0F966AEC23 /* [CP] Embed Pods Frameworks */,
			);
			buildRules = (
			);
			dependencies = (
			);
			name = TestProj;
			productName = TestProj;
			productReference = 287627FF1F319065007FA12B /* mokoSamplePermissions.app */;
			productType = "com.apple.product-type.application";
		};
/* End PBXNativeTarget section */

/* Begin PBXProject section */
		287627F71F319065007FA12B /* Project object */ = {
			isa = PBXProject;
			attributes = {
				LastSwiftUpdateCheck = 0830;
				LastUpgradeCheck = 0830;
				ORGANIZATIONNAME = "IceRock Development";
				TargetAttributes = {
					287627FE1F319065007FA12B = {
						CreatedOnToolsVersion = 8.3.3;
						LastSwiftMigration = 0940;
					};
				};
			};
			buildConfigurationList = 287627FA1F319065007FA12B /* Build configuration list for PBXProject "TestProj" */;
			compatibilityVersion = "Xcode 9.3";
			developmentRegion = English;
			hasScannedForEncodings = 0;
			knownRegions = (
				English,
				Base,
			);
			mainGroup = 287627F61F319065007FA12B;
			productRefGroup = 287628001F319065007FA12B /* Products */;
			projectDirPath = "";
			projectRoot = "";
			targets = (
				287627FE1F319065007FA12B /* TestProj */,
			);
		};
/* End PBXProject section */

/* Begin PBXResourcesBuildPhase section */
		287627FD1F319065007FA12B /* Resources */ = {
			isa = PBXResourcesBuildPhase;
			buildActionMask = 2147483647;
			files = (
				45F4791E219463C7003D25FA /* Main.storyboard in Resources */,
				45F4791D219463C7003D25FA /* LaunchScreen.storyboard in Resources */,
				45F47921219463C7003D25FA /* Assets.xcassets in Resources */,
			);
			runOnlyForDeploymentPostprocessing = 0;
		};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
		27BD989196B22F0F966AEC23 /* [CP] Embed Pods Frameworks */ = {
			isa = PBXShellScriptBuildPhase;
			buildActionMask = 2147483647;
			files = (
			);
			inputFileListPaths = (
			);
			name = "[CP] Embed Pods Frameworks";
			outputFileListPaths = (
			);
			runOnlyForDeploymentPostprocessing = 0;
			shellPath = /bin/sh;
			shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-TestProj/Pods-TestProj-frameworks.sh\"\n";
			showEnvVarsInLog = 0;
		};
		DDE4C06D580BF457BEDF8D0A /* [CP] Check Pods Manifest.lock */ = {
			isa = PBXShellScriptBuildPhase;
			buildActionMask = 2147483647;
			files = (
			);
			inputFileListPaths = (
			);
			inputPaths = (
				"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
				"${PODS_ROOT}/Manifest.lock",
			);
			name = "[CP] Check Pods Manifest.lock";
			outputFileListPaths = (
			);
			outputPaths = (
				"$(DERIVED_FILE_DIR)/Pods-TestProj-checkManifestLockResult.txt",
			);
			runOnlyForDeploymentPostprocessing = 0;
			shellPath = /bin/sh;
			shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n    # print error to STDERR\n    echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n    exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
			showEnvVarsInLog = 0;
		};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
		287627FB1F319065007FA12B /* Sources */ = {
			isa = PBXSourcesBuildPhase;
			buildActionMask = 2147483647;
			files = (
				45D74FCC22BFDDFD00CAB0C8 /* TestViewController.swift in Sources */,
				45F47922219463C7003D25FA /* AppDelegate.swift in Sources */,
			);
			runOnlyForDeploymentPostprocessing = 0;
		};
/* End PBXSourcesBuildPhase section */

/* Begin PBXVariantGroup section */
		45F47912219463C7003D25FA /* LaunchScreen.storyboard */ = {
			isa = PBXVariantGroup;
			children = (
				45F47913219463C7003D25FA /* Base */,
			);
			name = LaunchScreen.storyboard;
			sourceTree = "<group>";
		};
		45F47914219463C7003D25FA /* Main.storyboard */ = {
			isa = PBXVariantGroup;
			children = (
				45F47915219463C7003D25FA /* Base */,
			);
			name = Main.storyboard;
			sourceTree = "<group>";
		};
/* End PBXVariantGroup section */

/* Begin XCBuildConfiguration section */
		2876280F1F319065007FA12B /* Debug */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				CURRENT_PROJECT_VERSION = 0;
				DEFINES_MODULE = YES;
				ONLY_ACTIVE_ARCH = YES;
				SWIFT_VERSION = 4.0;
			};
			name = Debug;
		};
		287628101F319065007FA12B /* Release */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				CURRENT_PROJECT_VERSION = 0;
				DEFINES_MODULE = YES;
				ONLY_ACTIVE_ARCH = YES;
				SWIFT_VERSION = 4.0;
			};
			name = Release;
		};
		287628121F319065007FA12B /* Debug */ = {
			isa = XCBuildConfiguration;
			baseConfigurationReference = DFBDF7D3559D080FDCA444A6 /* Pods-TestProj.debug.xcconfig */;
			buildSettings = {
				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
				CODE_SIGN_IDENTITY = "iPhone Developer";
				CODE_SIGN_STYLE = Automatic;
				DEVELOPMENT_TEAM = 4VU932NX78;
				INFOPLIST_FILE = src/Info.plist;
				IPHONEOS_DEPLOYMENT_TARGET = 12.4;
				PRODUCT_BUNDLE_IDENTIFIER = dev.icerock.moko.sample.permissions;
				PRODUCT_NAME = mokoSamplePermissions;
				PROVISIONING_PROFILE_SPECIFIER = "";
				SDKROOT = iphoneos;
				SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
				SWIFT_SWIFT3_OBJC_INFERENCE = On;
			};
			name = Debug;
		};
		287628131F319065007FA12B /* Release */ = {
			isa = XCBuildConfiguration;
			baseConfigurationReference = A644D2F1C5377C40A53FCD6A /* Pods-TestProj.release.xcconfig */;
			buildSettings = {
				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
				CODE_SIGN_IDENTITY = "iPhone Developer";
				CODE_SIGN_STYLE = Automatic;
				DEVELOPMENT_TEAM = 4VU932NX78;
				INFOPLIST_FILE = src/Info.plist;
				IPHONEOS_DEPLOYMENT_TARGET = 12.4;
				PRODUCT_BUNDLE_IDENTIFIER = dev.icerock.moko.sample.permissions;
				PRODUCT_NAME = mokoSamplePermissions;
				PROVISIONING_PROFILE_SPECIFIER = "";
				SDKROOT = iphoneos;
				SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
				SWIFT_SWIFT3_OBJC_INFERENCE = On;
			};
			name = Release;
		};
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
		287627FA1F319065007FA12B /* Build configuration list for PBXProject "TestProj" */ = {
			isa = XCConfigurationList;
			buildConfigurations = (
				2876280F1F319065007FA12B /* Debug */,
				287628101F319065007FA12B /* Release */,
			);
			defaultConfigurationIsVisible = 0;
			defaultConfigurationName = Release;
		};
		287628111F319065007FA12B /* Build configuration list for PBXNativeTarget "TestProj" */ = {
			isa = XCConfigurationList;
			buildConfigurations = (
				287628121F319065007FA12B /* Debug */,
				287628131F319065007FA12B /* Release */,
			);
			defaultConfigurationIsVisible = 0;
			defaultConfigurationName = Release;
		};
/* End XCConfigurationList section */
	};
	rootObject = 287627F71F319065007FA12B /* Project object */;
}


================================================
FILE: sample/ios-app/TestProj.xcodeproj/project.xcworkspace/contents.xcworkspacedata
================================================
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
   version = "1.0">
   <FileRef
      location = "self:TestProj.xcodeproj">
   </FileRef>
</Workspace>


================================================
FILE: sample/ios-app/TestProj.xcworkspace/contents.xcworkspacedata
================================================
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
   version = "1.0">
   <FileRef
      location = "group:TestProj.xcodeproj">
   </FileRef>
   <FileRef
      location = "group:Pods/Pods.xcodeproj">
   </FileRef>
</Workspace>


================================================
FILE: sample/ios-app/TestProj.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>IDEDidComputeMac32BitWarning</key>
	<true/>
</dict>
</plist>


================================================
FILE: sample/ios-app/src/AppDelegate.swift
================================================
//
//  Copyright © 2018 IceRock Development. All rights reserved.
//

import MultiPlatformLibrary
import UIKit

@UIApplicationMain
class AppDelegate: NSObject, UIApplicationDelegate {
    
    var window: UIWindow?
    
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
        
        return true
    }
}


================================================
FILE: sample/ios-app/src/Assets.xcassets/AppIcon.appiconset/Contents.json
================================================
{
  "images" : [
    {
      "idiom" : "mac",
      "scale" : "1x",
      "size" : "16x16"
    },
    {
      "idiom" : "mac",
      "scale" : "2x",
      "size" : "16x16"
    },
    {
      "idiom" : "mac",
      "scale" : "1x",
      "size" : "32x32"
    },
    {
      "idiom" : "mac",
      "scale" : "2x",
      "size" : "32x32"
    },
    {
      "idiom" : "mac",
      "scale" : "1x",
      "size" : "128x128"
    },
    {
      "idiom" : "mac",
      "scale" : "2x",
      "size" : "128x128"
    },
    {
      "idiom" : "mac",
      "scale" : "1x",
      "size" : "256x256"
    },
    {
      "idiom" : "mac",
      "scale" : "2x",
      "size" : "256x256"
    },
    {
      "idiom" : "mac",
      "scale" : "1x",
      "size" : "512x512"
    },
    {
      "idiom" : "mac",
      "scale" : "2x",
      "size" : "512x512"
    }
  ],
  "info" : {
    "version" : 1,
    "author" : "xcode"
  }
}


================================================
FILE: sample/ios-app/src/Assets.xcassets/Contents.json
================================================
{
  "info" : {
    "version" : 1,
    "author" : "xcode"
  }
}


================================================
FILE: sample/ios-app/src/Info.plist
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>CFBundleDevelopmentRegion</key>
	<string>en</string>
	<key>CFBundleDisplayName</key>
	<string>moko-permissions</string>
	<key>CFBundleExecutable</key>
	<string>$(EXECUTABLE_NAME)</string>
	<key>CFBundleIdentifier</key>
	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>6.0</string>
	<key>CFBundleName</key>
	<string>$(BUNDLE_NAME)</string>
	<key>CFBundlePackageType</key>
	<string>APPL</string>
	<key>CFBundleShortVersionString</key>
	<string>0.1.0</string>
	<key>CFBundleVersion</key>
	<string>1</string>
	<key>LSApplicationCategoryType</key>
	<string>public.app-category.developer-tools</string>
	<key>LSRequiresIPhoneOS</key>
	<true/>
	<key>NSAppTransportSecurity</key>
	<dict>
		<key>NSAllowsArbitraryLoads</key>
		<true/>
	</dict>
	<key>NSMainStoryboardFile</key>
	<string>Main</string>
	<key>UILaunchStoryboardName</key>
	<string>LaunchScreen</string>
	<key>UIMainStoryboardFile</key>
	<string>Main</string>
	<key>UIRequiredDeviceCapabilities</key>
	<array>
		<string>armv7</string>
	</array>
	<key>UIRequiresFullScreen</key>
	<true/>
	<key>UIStatusBarHidden</key>
	<true/>
	<key>UIStatusBarHidden~ipad</key>
	<true/>
	<key>UIStatusBarStyle</key>
	<string>UIStatusBarStyleLightContent</string>
	<key>UISupportedInterfaceOrientations</key>
	<array>
		<string>UIInterfaceOrientationPortrait</string>
	</array>
	<key>UISupportedInterfaceOrientations~ipad</key>
	<array>
		<string>UIInterfaceOrientationPortrait</string>
		<string>UIInterfaceOrientationLandscapeRight</string>
		<string>UIInterfaceOrientationLandscapeLeft</string>
		<string>UIInterfaceOrientationPortraitUpsideDown</string>
	</array>
	<key>NSContactsUsageDescription</key>
	<string>Just for tests</string>
	<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
	<string>Just for tests</string>
	<key>NSLocationWhenInUseUsageDescription</key>
	<string>Just for tests</string>
</dict>
</plist>


================================================
FILE: sample/ios-app/src/Resources/Base.lproj/LaunchScreen.storyboard
================================================
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
    <device id="retina4_7" orientation="portrait">
        <adaptation id="fullscreen"/>
    </device>
    <dependencies>
        <deployment identifier="iOS"/>
        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
    </dependencies>
    <scenes>
        <!--View Controller-->
        <scene sceneID="EHf-IW-A2E">
            <objects>
                <viewController id="01J-lp-oVM" sceneMemberID="viewController">
                    <layoutGuides>
                        <viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
                        <viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
                    </layoutGuides>
                    <view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
                        <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                        <subviews>
                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="moko-permissions" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="SPr-40-z5d">
                                <rect key="frame" x="83.5" y="318" width="208.5" height="31.5"/>
                                <fontDescription key="fontDescription" style="UICTFontTextStyleTitle1"/>
                                <nil key="textColor"/>
                                <nil key="highlightedColor"/>
                            </label>
                        </subviews>
                        <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                        <constraints>
                            <constraint firstItem="SPr-40-z5d" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="centerY" id="StY-xE-mqI"/>
                            <constraint firstItem="SPr-40-z5d" firstAttribute="centerX" secondItem="Ze5-6b-2t3" secondAttribute="centerX" id="gMJ-d9-gfI"/>
                        </constraints>
                    </view>
                </viewController>
                <placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
            </objects>
            <point key="canvasLocation" x="53" y="375"/>
        </scene>
    </scenes>
</document>


================================================
FILE: sample/ios-app/src/Resources/Base.lproj/Main.storyboard
================================================
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="zIh-nI-gcX">
    <device id="retina4_0" orientation="portrait" appearance="light"/>
    <dependencies>
        <deployment identifier="iOS"/>
        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22685"/>
        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
    </dependencies>
    <scenes>
        <!--Navigation Controller-->
        <scene sceneID="snE-Ct-w85">
            <objects>
                <navigationController id="zIh-nI-gcX" sceneMemberID="viewController">
                    <navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="aGe-Yj-KQZ">
                        <rect key="frame" x="0.0" y="20" width="320" height="44"/>
                        <autoresizingMask key="autoresizingMask"/>
                    </navigationBar>
                    <connections>
                        <segue destination="TTy-86-aNs" kind="relationship" relationship="rootViewController" id="y6u-Ao-rTD"/>
                    </connections>
                </navigationController>
                <placeholder placeholderIdentifier="IBFirstResponder" id="dpF-aw-Lyj" userLabel="First Responder" sceneMemberID="firstResponder"/>
            </objects>
            <point key="canvasLocation" x="-5158" y="-1482"/>
        </scene>
        <!--Test-->
        <scene sceneID="B5V-K5-FDE">
            <objects>
                <viewController id="TTy-86-aNs" customClass="TestViewController" customModule="mokoSamplePermissions" customModuleProvider="target" sceneMemberID="viewController">
                    <layoutGuides>
                        <viewControllerLayoutGuide type="top" id="gcA-zH-akF"/>
                        <viewControllerLayoutGuide type="bottom" id="gTY-6T-yQv"/>
                    </layoutGuides>
                    <view key="view" contentMode="scaleToFill" id="KxK-oh-5KO">
                        <rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
                        <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                        <subviews>
                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="wrA-Wa-jvv">
                                <rect key="frame" x="128" y="269" width="64" height="30"/>
                                <state key="normal" title="Press me"/>
                                <connections>
                                    <action selector="onPermissionPressed" destination="TTy-86-aNs" eventType="touchUpInside" id="hg0-6b-MSX"/>
                                </connections>
                            </button>
                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="SC7-EO-Tfy">
                                <rect key="frame" x="139" y="307" width="42" height="21"/>
                                <fontDescription key="fontDescription" type="system" pointSize="17"/>
                                <nil key="textColor"/>
                                <nil key="highlightedColor"/>
                            </label>
                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="jlX-n2-E1L">
                                <rect key="frame" x="102" y="222" width="116.5" height="31"/>
                                <state key="normal" title="Button"/>
                                <buttonConfiguration key="configuration" style="plain" title="Open Settings">
                                    <fontDescription key="titleFontDescription" type="system" pointSize="14"/>
                                </buttonConfiguration>
                                <connections>
                                    <action selector="onOpenSettingsPressed" destination="TTy-86-aNs" eventType="touchUpInside" id="8gX-ul-uJn"/>
                                </connections>
                            </button>
                        </subviews>
                        <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                        <constraints>
                            <constraint firstItem="wrA-Wa-jvv" firstAttribute="centerY" secondItem="KxK-oh-5KO" secondAttribute="centerY" id="0g2-Uu-Q0F"/>
                            <constraint firstItem="wrA-Wa-jvv" firstAttribute="centerX" secondItem="KxK-oh-5KO" secondAttribute="centerX" id="FGq-2f-QAF"/>
                            <constraint firstItem="wrA-Wa-jvv" firstAttribute="top" secondItem="jlX-n2-E1L" secondAttribute="bottom" constant="16" id="Qps-Mk-tYJ"/>
                            <constraint firstItem="SC7-EO-Tfy" firstAttribute="centerX" secondItem="KxK-oh-5KO" secondAttribute="centerX" id="Qw1-Gl-wBe"/>
                            <constraint firstItem="jlX-n2-E1L" firstAttribute="centerX" secondItem="KxK-oh-5KO" secondAttribute="centerX" id="WvE-2P-C0q"/>
                            <constraint firstItem="SC7-EO-Tfy" firstAttribute="top" secondItem="wrA-Wa-jvv" secondAttribute="bottom" constant="8" id="hoL-Vh-IjN"/>
                        </constraints>
                    </view>
                    <navigationItem key="navigationItem" title="Test" id="0jM-60-fjM"/>
                    <connections>
                        <outlet property="label" destination="SC7-EO-Tfy" id="Jws-q5-vz2"/>
                    </connections>
                </viewController>
                <placeholder placeholderIdentifier="IBFirstResponder" id="Jxh-nl-GiI" userLabel="First Responder" sceneMemberID="firstResponder"/>
            </objects>
            <point key="canvasLocation" x="-4296" y="-1482"/>
        </scene>
    </scenes>
</document>


================================================
FILE: sample/ios-app/src/TestViewController.swift
================================================
//
//  Created by Aleksey Mikhailov on 23/06/2019.
//  Copyright © 2019 IceRock Development. All rights reserved.
//

import UIKit
import MultiPlatformLibrary

class TestViewController: UIViewController {
    
    @IBOutlet private var label: UILabel!
    
    private var viewModel: SampleViewModel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        label.text = "wait press..."
        
        viewModel = SampleViewModel(
            eventsDispatcher: EventsDispatcher(listener: self),
            permissionsController: PermissionsController()
        )
    }
    
    @IBAction func onPermissionPressed() {
        viewModel.onRequestPermissionButtonPressed()
    }
    
    @IBAction func onOpenSettingsPressed() {
        PermissionsController().openAppSettings()
    }
}

extension TestViewController: SampleViewModelEventListener {
    func onSuccess() {
        label.text = "success granted"
    }
    
    func onDenied(exception: DeniedException) {
        label.text = "denied" // on ios is impossible
    }
    
    func onDeniedAlways(exception: DeniedAlwaysException) {
        label.text = "denied always"
    }
}


================================================
FILE: sample/mpp-library/MultiPlatformLibrary.podspec
================================================
Pod::Spec.new do |spec|
    spec.name                     = 'MultiPlatformLibrary'
    spec.version                  = '0.1.0'
    spec.homepage                 = 'Link to a Kotlin/Native module homepage'
    spec.source                   = { :git => "Not Published", :tag => "Cocoapods/#{spec.name}/#{spec.version}" }
    spec.authors                  = 'IceRock Development'
    spec.license                  = ''
    spec.summary                  = 'Shared code between iOS and Android'

    spec.vendored_frameworks      = "build/cocoapods/framework/#{spec.name}.framework"
    spec.libraries                = "c++"
    spec.module_name              = "#{spec.name}_umbrella"

    spec.ios.deployment_target = '12.0'
    spec.osx.deployment_target = '10.6'

    spec.pod_target_xcconfig = {
        'KOTLIN_FRAMEWORK_BUILD_TYPE[config=*ebug]' => 'debug',
        'KOTLIN_FRAMEWORK_BUILD_TYPE[config=*elease]' => 'release',
        'CURENT_SDK[sdk=iphoneos*]' => 'iphoneos',
        'CURENT_SDK[sdk=iphonesimulator*]' => 'iphonesimulator',
    }

    spec.script_phases = [
        {
            :name => 'Compile Kotlin/Native',
            :execution_position => :before_compile,
            :shell_path => '/bin/sh',
            :script => <<-SCRIPT
if [ "$KOTLIN_FRAMEWORK_BUILD_TYPE" == "debug" ]; then
  CONFIG="Debug"
else
  CONFIG="Release"
fi

if [ "$CURENT_SDK" == "iphoneos" ]; then
  TARGET="Ios"
  ARCH="Arm64"
elif [ "$CURENT_SDK" == "iphonesimulator" ]; then
  if [ "$ARCHS" == "arm64" ]; then
    TARGET="IosSimulator"
    ARCH="Arm64"
  else
    TARGET="Ios"
    ARCH="X64"
  fi
else
  echo "unsupported $CURENT_SDK"
  exit 1
fi

MPP_PROJECT_ROOT="$SRCROOT/../../mpp-library"
GRADLE_TASK="syncMultiPlatformLibrary${CONFIG}Framework${TARGET}${ARCH}"

"$MPP_PROJECT_ROOT/../gradlew" -p "$MPP_PROJECT_ROOT" "$GRADLE_TASK"
            SCRIPT
        }
    ]
end

================================================
FILE: sample/mpp-library/build.gradle.kts
================================================
/*
 * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

plugins {
    id("dev.icerock.moko.gradle.multiplatform.mobile")
    id("dev.icerock.mobile.multiplatform.ios-framework")
    id("dev.icerock.moko.gradle.detekt")
}

android {
    namespace = "com.icerockdev.library"
}

dependencies {
    commonMainImplementation(libs.coroutines)

    commonMainApi(libs.mokoMvvmCore)
    commonMainApi(projects.permissions)
    commonMainImplementation(projects.permissionsContacts)
    commonMainImplementation(projects.permissionsLocation)

    androidMainImplementation(libs.lifecycle)

    commonTestImplementation(libs.mokoMvvmTest)
    commonTestImplementation(projects.permissionsTest)
    commonTestImplementation(projects.permissionsMicrophone)
}

framework {
    export(projects.permissions)
    export(libs.mokoMvvmCore)
}


================================================
FILE: sample/mpp-library/src/androidMain/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.icerockdev.library">

    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.WRITE_CONTACTS" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
</manifest>


================================================
FILE: sample/mpp-library/src/commonMain/kotlin/com/icerockdev/library/SampleViewModel.kt
================================================
package com.icerockdev.library

import dev.icerock.moko.mvvm.dispatcher.EventsDispatcher
import dev.icerock.moko.mvvm.dispatcher.EventsDispatcherOwner
import dev.icerock.moko.mvvm.viewmodel.ViewModel
import dev.icerock.moko.permissions.DeniedAlwaysException
import dev.icerock.moko.permissions.DeniedException
import dev.icerock.moko.permissions.Permission
import dev.icerock.moko.permissions.PermissionState
import dev.icerock.moko.permissions.PermissionsController
import dev.icerock.moko.permissions.contacts.CONTACTS
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch

class SampleViewModel(
    override val eventsDispatcher: EventsDispatcher<EventListener>,
    val permissionsController: PermissionsController
) : ViewModel(), EventsDispatcherOwner<SampleViewModel.EventListener> {

    private val permissionType = Permission.CONTACTS
    val permissionState = MutableStateFlow(PermissionState.NotDetermined)

    init {
        viewModelScope.launch {
            permissionState.update { permissionsController.getPermissionState(permissionType) }
            println(permissionState)
        }
    }

    /**
     * An example of using [PermissionsController] in common code.
     */
    fun onRequestPermissionButtonPressed() {
        requestPermission(permissionType)
    }

    private fun requestPermission(permission: Permission) {
        viewModelScope.launch {
            try {
                permissionsController.getPermissionState(permission)
                    .also { println("pre provide $it") }

                // Calls suspend function in a coroutine to request some permission.
                permissionsController.providePermission(permission)
                // If there are no exceptions, permission has been granted successfully.

                eventsDispatcher.dispatchEvent { onSuccess() }
            } catch (deniedAlwaysException: DeniedAlwaysException) {
                eventsDispatcher.dispatchEvent { onDeniedAlways(deniedAlwaysException) }
            } catch (deniedException: DeniedException) {
                eventsDispatcher.dispatchEvent { onDenied(deniedException) }
            } finally {
                permissionState.update {
                    permissionsController.getPermissionState(permission)
                        .also { println("post provide $it") }
                }
            }
        }
    }

    interface EventListener {

        fun onSuccess()

        fun onDenied(exception: DeniedException)

        fun onDeniedAlways(exception: DeniedAlwaysException)
    }
}


================================================
FILE: sample/mpp-library/src/commonTest/kotlin/com/icerockdev/library/SampleViewModelTest.kt
================================================
package com.icerockdev.library

import dev.icerock.moko.mvvm.test.TestViewModelScope
import dev.icerock.moko.mvvm.test.createTestEventsDispatcher
import dev.icerock.moko.permissions.DeniedAlwaysException
import dev.icerock.moko.permissions.DeniedException
import dev.icerock.moko.permissions.Permission
import dev.icerock.moko.permissions.PermissionsController
import dev.icerock.moko.permissions.contacts.CONTACTS
import dev.icerock.moko.permissions.test.createPermissionControllerMock
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlin.test.AfterTest
import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertEquals

class SampleViewModelTest {
    @BeforeTest
    fun setup() {
        TestViewModelScope.setupViewModelScope(CoroutineScope(Dispatchers.Unconfined))
    }

    @AfterTest
    fun tearDown() {
        TestViewModelScope.resetViewModelScope()
    }

    @Test
    fun `test successful permission`() {
        val eventsListener = EventsListenerCatcher()
        val controller: PermissionsController = createPermissionControllerMock(
            allow = setOf(Permission.CONTACTS)
        )
        val viewModel = SampleViewModel(
            eventsDispatcher = createTestEventsDispatcher(eventsListener),
            permissionsController = controller,
        )

        viewModel.onRequestPermissionButtonPressed()

        assertEquals(expected = listOf("onSuccess"), actual = eventsListener.events)
    }

    @Test
    fun `test already got permission`() {
        val eventsListener = EventsListenerCatcher()
        val controller: PermissionsController = createPermissionControllerMock(
            granted = setOf(Permission.CONTACTS)
        )
        val viewModel = SampleViewModel(
            eventsDispatcher = createTestEventsDispatcher(eventsListener),
            permissionsController = controller,
        )

        viewModel.onRequestPermissionButtonPressed()

        assertEquals(expected = listOf("onSuccess"), actual = eventsListener.events)
    }

    @Test
    fun `test reject permission`() {
        val eventsListener = EventsListenerCatcher()
        val controller: PermissionsController = createPermissionControllerMock(
            allow = emptySet()
        )
        val viewModel = SampleViewModel(
            eventsDispatcher = createTestEventsDispatcher(eventsListener),
            permissionsController = controller,
        )

        viewModel.onRequestPermissionButtonPressed()

        assertEquals(
            expected = listOf("onDenied(dev.icerock.moko.permissions.DeniedException: mock block permission)"),
            actual = eventsListener.events
        )
    }

    class EventsListenerCatcher : SampleViewModel.EventListener {
        private val _events = mutableListOf<String>()
        val events: List<String> = _events

        override fun onSuccess() {
            _events.add("onSuccess")
        }

        override fun onDenied(exception: DeniedException) {
            _events.add("onDenied($exception)")
        }

        override fun onDeniedAlways(exception: DeniedAlwaysException) {
            _events.add("onDeniedAlways($exception)")
        }
    }
}


================================================
FILE: settings.gradle.kts
================================================
/*
 * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
 */

enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")

dependencyResolutionManagement {
    repositories {
        mavenCentral()
        google()
        maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
    }
}

include(":permissions")
include(":permissions-compose")
include(":permissions-bluetooth")
include(":permissions-camera")
include(":permissions-contacts")
include(":permissions-gallery")
include(":permissions-location")
include(":permissions-avfoundation")
include(":permissions-microphone")
include(":permissions-motion")
include(":permissions-notifications")
include(":permissions-storage")
include(":permissions-test")
include(":sample:android-app")
include(":sample:compose-android-app")
include(":sample:mpp-library")
Download .txt
gitextract_m0_vw0yi/

├── .github/
│   └── workflows/
│       ├── compilation-check.yml
│       └── publish.yml
├── .gitignore
├── CONTRIBUTING.md
├── LICENSE.md
├── README.md
├── build.gradle.kts
├── gradle/
│   ├── libs.versions.toml
│   └── wrapper/
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── permissions/
│   ├── build.gradle.kts
│   └── src/
│       ├── androidMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       ├── PermissionDelegate.android.kt
│       │                       ├── PermissionsController.kt
│       │                       └── PermissionsControllerImpl.kt
│       ├── commonMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       ├── DeniedExceptions.kt
│       │                       ├── Permission.kt
│       │                       ├── PermissionDelegate.kt
│       │                       ├── PermissionState.kt
│       │                       ├── PermissionsController.kt
│       │                       └── RequestCanceledException.kt
│       └── iosMain/
│           └── kotlin/
│               └── dev/
│                   └── icerock/
│                       └── moko/
│                           └── permissions/
│                               ├── Async.kt
│                               ├── MainRunDispatcher.kt
│                               ├── PermissionDelegate.ios.kt
│                               ├── PermissionsController.kt
│                               └── ios/
│                                   ├── PermissionsController.kt
│                                   └── PermissionsControllerProtocol.kt
├── permissions-avfoundation/
│   ├── build.gradle.kts
│   └── src/
│       └── iosMain/
│           └── kotlin/
│               └── dev/
│                   └── icerock/
│                       └── moko/
│                           └── permissions/
│                               └── avfoundation/
│                                   └── AVCaptureDelegate.kt
├── permissions-bluetooth/
│   ├── build.gradle.kts
│   └── src/
│       ├── androidMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── bluetooth/
│       │                           └── BluetoothPermissions.android.kt
│       ├── commonMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── bluetooth/
│       │                           └── BluetoothPermissions.kt
│       └── iosMain/
│           └── kotlin/
│               └── dev/
│                   └── icerock/
│                       └── moko/
│                           └── permissions/
│                               └── bluetooth/
│                                   └── BluetoothPermissionDelegate.kt
├── permissions-camera/
│   ├── build.gradle.kts
│   └── src/
│       ├── androidMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── camera/
│       │                           └── CameraPermission.android.kt
│       ├── commonMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── camera/
│       │                           └── CameraPermission.kt
│       └── iosMain/
│           └── kotlin/
│               └── dev/
│                   └── icerock/
│                       └── moko/
│                           └── permissions/
│                               └── camera/
│                                   └── CameraPermission.ios.kt
├── permissions-compose/
│   ├── build.gradle.kts
│   └── src/
│       ├── androidMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── compose/
│       │                           ├── BindEffect.android.kt
│       │                           └── PermissionsControllerFactory.android.kt
│       ├── commonMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── compose/
│       │                           ├── BindEffect.kt
│       │                           └── PermissionsControllerFactory.kt
│       └── iosMain/
│           └── kotlin/
│               └── dev/
│                   └── icerock/
│                       └── moko/
│                           └── permissions/
│                               └── compose/
│                                   ├── BindEffect.ios.kt
│                                   └── PermissionsControllerFactory.ios.kt
├── permissions-contacts/
│   ├── build.gradle.kts
│   └── src/
│       ├── androidMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── contacts/
│       │                           └── ContactsPermission.android.kt
│       ├── commonMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── contacts/
│       │                           └── ContactPermission.kt
│       └── iosMain/
│           └── kotlin/
│               └── dev/
│                   └── icerock/
│                       └── moko/
│                           └── permissions/
│                               └── contacts/
│                                   └── ContactsPermission.ios.kt
├── permissions-gallery/
│   ├── build.gradle.kts
│   └── src/
│       ├── androidMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── gallery/
│       │                           └── GalleryPermission.android.kt
│       ├── commonMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── gallery/
│       │                           └── GalleryPermission.kt
│       └── iosMain/
│           └── kotlin/
│               └── dev/
│                   └── icerock/
│                       └── moko/
│                           └── permissions/
│                               └── gallery/
│                                   └── GalleryPermissionDelegate.kt
├── permissions-location/
│   ├── build.gradle.kts
│   └── src/
│       ├── androidMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── location/
│       │                           └── LocationPermission.android.kt
│       ├── commonMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── location/
│       │                           └── LocationPermission.kt
│       └── iosMain/
│           └── kotlin/
│               └── dev/
│                   └── icerock/
│                       └── moko/
│                           └── permissions/
│                               └── location/
│                                   ├── LocationManagerDelegate.kt
│                                   └── LocationPermission.ios.kt
├── permissions-microphone/
│   ├── build.gradle.kts
│   └── src/
│       ├── androidMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── microphone/
│       │                           └── MicrophonePermission.android.kt
│       ├── commonMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── microphone/
│       │                           └── MicrophonePermission.kt
│       └── iosMain/
│           └── kotlin/
│               └── dev/
│                   └── icerock/
│                       └── moko/
│                           └── permissions/
│                               └── microphone/
│                                   └── MicrophonePermission.ios.kt
├── permissions-motion/
│   ├── build.gradle.kts
│   └── src/
│       ├── androidMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── motion/
│       │                           └── MotionPermission.android.kt
│       ├── commonMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── motion/
│       │                           └── MotionPermission.kt
│       └── iosMain/
│           └── kotlin/
│               └── dev/
│                   └── icerock/
│                       └── moko/
│                           └── permissions/
│                               └── motion/
│                                   └── MotionPermission.ios.kt
├── permissions-notifications/
│   ├── build.gradle.kts
│   └── src/
│       ├── androidMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── notifications/
│       │                           └── NotificationPermission.android.kt
│       ├── commonMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── notifications/
│       │                           └── NotificationPermission.kt
│       └── iosMain/
│           └── kotlin/
│               └── dev/
│                   └── icerock/
│                       └── moko/
│                           └── permissions/
│                               └── notifications/
│                                   └── RemoteNotificationPermissionDelegate.kt
├── permissions-storage/
│   ├── build.gradle.kts
│   └── src/
│       ├── androidMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── storage/
│       │                           └── StoragePermissions.android.kt
│       ├── commonMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── storage/
│       │                           └── StoragePermissions.kt
│       └── iosMain/
│           └── kotlin/
│               └── dev/
│                   └── icerock/
│                       └── moko/
│                           └── permissions/
│                               └── storage/
│                                   ├── AlwaysGrantedDelegate.kt
│                                   └── StoragePermissions.ios.kt
├── permissions-test/
│   ├── build.gradle.kts
│   └── src/
│       ├── androidMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── test/
│       │                           └── PermissionsControllerMock.kt
│       ├── commonMain/
│       │   └── kotlin/
│       │       └── dev/
│       │           └── icerock/
│       │               └── moko/
│       │                   └── permissions/
│       │                       └── test/
│       │                           └── PermissionsControllerMock.kt
│       └── iosMain/
│           └── kotlin/
│               └── dev/
│                   └── icerock/
│                       └── moko/
│                           └── permissions/
│                               └── test/
│                                   └── PermissionsControllerMock.kt
├── sample/
│   ├── android-app/
│   │   ├── build.gradle.kts
│   │   ├── proguard-rules.pro
│   │   └── src/
│   │       └── main/
│   │           ├── AndroidManifest.xml
│   │           ├── java/
│   │           │   └── com/
│   │           │       └── icerockdev/
│   │           │           └── MainActivity.kt
│   │           └── res/
│   │               └── layout/
│   │                   └── activity_main.xml
│   ├── compose-android-app/
│   │   ├── build.gradle.kts
│   │   └── src/
│   │       └── main/
│   │           ├── AndroidManifest.xml
│   │           └── java/
│   │               └── com/
│   │                   └── icerockdev/
│   │                       └── MainActivity.kt
│   ├── ios-app/
│   │   ├── Podfile
│   │   ├── TestProj.xcodeproj/
│   │   │   ├── project.pbxproj
│   │   │   └── project.xcworkspace/
│   │   │       └── contents.xcworkspacedata
│   │   ├── TestProj.xcworkspace/
│   │   │   ├── contents.xcworkspacedata
│   │   │   └── xcshareddata/
│   │   │       └── IDEWorkspaceChecks.plist
│   │   └── src/
│   │       ├── AppDelegate.swift
│   │       ├── Assets.xcassets/
│   │       │   ├── AppIcon.appiconset/
│   │       │   │   └── Contents.json
│   │       │   └── Contents.json
│   │       ├── Info.plist
│   │       ├── Resources/
│   │       │   └── Base.lproj/
│   │       │       ├── LaunchScreen.storyboard
│   │       │       └── Main.storyboard
│   │       └── TestViewController.swift
│   └── mpp-library/
│       ├── MultiPlatformLibrary.podspec
│       ├── build.gradle.kts
│       └── src/
│           ├── androidMain/
│           │   └── AndroidManifest.xml
│           ├── commonMain/
│           │   └── kotlin/
│           │       └── com/
│           │           └── icerockdev/
│           │               └── library/
│           │                   └── SampleViewModel.kt
│           └── commonTest/
│               └── kotlin/
│                   └── com/
│                       └── icerockdev/
│                           └── library/
│                               └── SampleViewModelTest.kt
└── settings.gradle.kts
Condensed preview — 106 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (175K chars).
[
  {
    "path": ".github/workflows/compilation-check.yml",
    "chars": 757,
    "preview": "name: KMP library compilation check\n\non:\n  pull_request:\n    branches:\n      - master\n      - develop\n\njobs:\n  build:\n  "
  },
  {
    "path": ".github/workflows/publish.yml",
    "chars": 1312,
    "preview": "name: Create release\n\non:\n  workflow_dispatch:\n    inputs:\n      version:\n        description: 'Version'\n        default"
  },
  {
    "path": ".gitignore",
    "chars": 109,
    "preview": ".gradle\n.settings\n.project\n.classpath\n.vscode\n.idea\nbuild\n*.iml\nPods\nxcuserdata\nlocal.properties\nlocal.gradle"
  },
  {
    "path": "CONTRIBUTING.md",
    "chars": 1837,
    "preview": "# Do’s and Don’ts\n\n* **Search tickets before you file a new one.** Add to tickets if you have new information about the "
  },
  {
    "path": "LICENSE.md",
    "chars": 11356,
    "preview": "                                 Apache License\n                           Version 2.0, January 2004\n                   "
  },
  {
    "path": "README.md",
    "chars": 7935,
    "preview": "![moko-permissions](img/logo.png)  \n[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue."
  },
  {
    "path": "build.gradle.kts",
    "chars": 860,
    "preview": "/*\n * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\nbuildscript {\n"
  },
  {
    "path": "gradle/libs.versions.toml",
    "chars": 2675,
    "preview": "[versions]\nkotlinVersion = \"1.9.10\"\nandroidAppCompatVersion = \"1.6.1\"\nandroidxCoreVersion = \"1.9.0\" # TODO we have two v"
  },
  {
    "path": "gradle/wrapper/gradle-wrapper.properties",
    "chars": 231,
    "preview": "#Tue Jun 10 21:09:29 CEST 2025\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\ndistributionUrl=https\\:/"
  },
  {
    "path": "gradle.properties",
    "chars": 625,
    "preview": "org.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8\norg.gradle.configureondemand=false\norg.gradle.parallel=true\n\nkotlin.c"
  },
  {
    "path": "gradlew",
    "chars": 5766,
    "preview": "#!/usr/bin/env sh\n\n#\n# Copyright 2015 the original author or authors.\n#\n# Licensed under the Apache License, Version 2.0"
  },
  {
    "path": "gradlew.bat",
    "chars": 2674,
    "preview": "@rem\n@rem Copyright 2015 the original author or authors.\n@rem\n@rem Licensed under the Apache License, Version 2.0 (the \""
  },
  {
    "path": "permissions/build.gradle.kts",
    "chars": 529,
    "preview": "/*\n * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\nplugins {\n    "
  },
  {
    "path": "permissions/src/androidMain/kotlin/dev/icerock/moko/permissions/PermissionDelegate.android.kt",
    "chars": 446,
    "preview": "/*\n * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\n@file:Suppress"
  },
  {
    "path": "permissions/src/androidMain/kotlin/dev/icerock/moko/permissions/PermissionsController.kt",
    "chars": 822,
    "preview": "/*\n * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions/src/androidMain/kotlin/dev/icerock/moko/permissions/PermissionsControllerImpl.kt",
    "chars": 7538,
    "preview": "/*\n * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions/src/commonMain/kotlin/dev/icerock/moko/permissions/DeniedExceptions.kt",
    "chars": 382,
    "preview": "/*\n * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions/src/commonMain/kotlin/dev/icerock/moko/permissions/Permission.kt",
    "chars": 173,
    "preview": "package dev.icerock.moko.permissions\n\ninterface Permission {\n    val delegate: PermissionDelegate\n\n    // Extended by in"
  },
  {
    "path": "permissions/src/commonMain/kotlin/dev/icerock/moko/permissions/PermissionDelegate.kt",
    "chars": 133,
    "preview": "package dev.icerock.moko.permissions\n\n@Suppress(\"EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING\")\nexpect interface Permis"
  },
  {
    "path": "permissions/src/commonMain/kotlin/dev/icerock/moko/permissions/PermissionState.kt",
    "chars": 588,
    "preview": "/*\n * Copyright 2022 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions/src/commonMain/kotlin/dev/icerock/moko/permissions/PermissionsController.kt",
    "chars": 1534,
    "preview": "/*\n * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions/src/commonMain/kotlin/dev/icerock/moko/permissions/RequestCanceledException.kt",
    "chars": 259,
    "preview": "/*\n * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions/src/iosMain/kotlin/dev/icerock/moko/permissions/Async.kt",
    "chars": 719,
    "preview": "/*\n * Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage d"
  },
  {
    "path": "permissions/src/iosMain/kotlin/dev/icerock/moko/permissions/MainRunDispatcher.kt",
    "chars": 616,
    "preview": "/*\n * Copyright 2023 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions/src/iosMain/kotlin/dev/icerock/moko/permissions/PermissionDelegate.ios.kt",
    "chars": 376,
    "preview": "/*\n * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\n@file:Suppress"
  },
  {
    "path": "permissions/src/iosMain/kotlin/dev/icerock/moko/permissions/PermissionsController.kt",
    "chars": 286,
    "preview": "/*\n * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions/src/iosMain/kotlin/dev/icerock/moko/permissions/ios/PermissionsController.kt",
    "chars": 1111,
    "preview": "/*\n * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions/src/iosMain/kotlin/dev/icerock/moko/permissions/ios/PermissionsControllerProtocol.kt",
    "chars": 521,
    "preview": "/*\n * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-avfoundation/build.gradle.kts",
    "chars": 900,
    "preview": "/*\n * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\nimport dev.ice"
  },
  {
    "path": "permissions-avfoundation/src/iosMain/kotlin/dev/icerock/moko/permissions/avfoundation/AVCaptureDelegate.kt",
    "chars": 2857,
    "preview": "/*\n * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-bluetooth/build.gradle.kts",
    "chars": 481,
    "preview": "/*\n * Copyright 2024 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\nplugins {\n    "
  },
  {
    "path": "permissions-bluetooth/src/androidMain/kotlin/dev/icerock/moko/permissions/bluetooth/BluetoothPermissions.android.kt",
    "chars": 3067,
    "preview": "/*\n * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-bluetooth/src/commonMain/kotlin/dev/icerock/moko/permissions/bluetooth/BluetoothPermissions.kt",
    "chars": 1244,
    "preview": "/*\n * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-bluetooth/src/iosMain/kotlin/dev/icerock/moko/permissions/bluetooth/BluetoothPermissionDelegate.kt",
    "chars": 5108,
    "preview": "/*\n * Copyright 2022 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-camera/build.gradle.kts",
    "chars": 538,
    "preview": "/*\n * Copyright 2024 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\nplugins {\n    "
  },
  {
    "path": "permissions-camera/src/androidMain/kotlin/dev/icerock/moko/permissions/camera/CameraPermission.android.kt",
    "chars": 480,
    "preview": "/*\n * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-camera/src/commonMain/kotlin/dev/icerock/moko/permissions/camera/CameraPermission.kt",
    "chars": 458,
    "preview": "/*\n * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-camera/src/iosMain/kotlin/dev/icerock/moko/permissions/camera/CameraPermission.ios.kt",
    "chars": 480,
    "preview": "/*\n * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-compose/build.gradle.kts",
    "chars": 691,
    "preview": "/*\n * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\nplugins {\n    "
  },
  {
    "path": "permissions-compose/src/androidMain/kotlin/dev/icerock/moko/permissions/compose/BindEffect.android.kt",
    "chars": 1038,
    "preview": "/*\n * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-compose/src/androidMain/kotlin/dev/icerock/moko/permissions/compose/PermissionsControllerFactory.android.kt",
    "chars": 688,
    "preview": "/*\n * Copyright 2023 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-compose/src/commonMain/kotlin/dev/icerock/moko/permissions/compose/BindEffect.kt",
    "chars": 362,
    "preview": "/*\n * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-compose/src/commonMain/kotlin/dev/icerock/moko/permissions/compose/PermissionsControllerFactory.kt",
    "chars": 455,
    "preview": "/*\n * Copyright 2023 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-compose/src/iosMain/kotlin/dev/icerock/moko/permissions/compose/BindEffect.ios.kt",
    "chars": 451,
    "preview": "/*\n * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-compose/src/iosMain/kotlin/dev/icerock/moko/permissions/compose/PermissionsControllerFactory.ios.kt",
    "chars": 479,
    "preview": "/*\n * Copyright 2023 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-contacts/build.gradle.kts",
    "chars": 480,
    "preview": "/*\n * Copyright 2024 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\nplugins {\n    "
  },
  {
    "path": "permissions-contacts/src/androidMain/kotlin/dev/icerock/moko/permissions/contacts/ContactsPermission.android.kt",
    "chars": 833,
    "preview": "/*\n * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-contacts/src/commonMain/kotlin/dev/icerock/moko/permissions/contacts/ContactPermission.kt",
    "chars": 1041,
    "preview": "/*\n * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-contacts/src/iosMain/kotlin/dev/icerock/moko/permissions/contacts/ContactsPermission.ios.kt",
    "chars": 3185,
    "preview": "/*\n * Copyright 2022 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-gallery/build.gradle.kts",
    "chars": 479,
    "preview": "/*\n * Copyright 2024 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\nplugins {\n    "
  },
  {
    "path": "permissions-gallery/src/androidMain/kotlin/dev/icerock/moko/permissions/gallery/GalleryPermission.android.kt",
    "chars": 772,
    "preview": "/*\n * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-gallery/src/commonMain/kotlin/dev/icerock/moko/permissions/gallery/GalleryPermission.kt",
    "chars": 464,
    "preview": "/*\n * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-gallery/src/iosMain/kotlin/dev/icerock/moko/permissions/gallery/GalleryPermissionDelegate.kt",
    "chars": 2349,
    "preview": "/*\n * Copyright 2022 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-location/build.gradle.kts",
    "chars": 480,
    "preview": "/*\n * Copyright 2024 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\nplugins {\n    "
  },
  {
    "path": "permissions-location/src/androidMain/kotlin/dev/icerock/moko/permissions/location/LocationPermission.android.kt",
    "chars": 1816,
    "preview": "/*\n * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-location/src/commonMain/kotlin/dev/icerock/moko/permissions/location/LocationPermission.kt",
    "chars": 978,
    "preview": "/*\n * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-location/src/iosMain/kotlin/dev/icerock/moko/permissions/location/LocationManagerDelegate.kt",
    "chars": 1454,
    "preview": "/*\n * Copyright 2020 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-location/src/iosMain/kotlin/dev/icerock/moko/permissions/location/LocationPermission.ios.kt",
    "chars": 3819,
    "preview": "/*\n * Copyright 2022 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-microphone/build.gradle.kts",
    "chars": 542,
    "preview": "/*\n * Copyright 2024 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\nplugins {\n    "
  },
  {
    "path": "permissions-microphone/src/androidMain/kotlin/dev/icerock/moko/permissions/microphone/MicrophonePermission.android.kt",
    "chars": 495,
    "preview": "/*\n * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-microphone/src/commonMain/kotlin/dev/icerock/moko/permissions/microphone/MicrophonePermission.kt",
    "chars": 488,
    "preview": "/*\n * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-microphone/src/iosMain/kotlin/dev/icerock/moko/permissions/microphone/MicrophonePermission.ios.kt",
    "chars": 495,
    "preview": "/*\n * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-motion/build.gradle.kts",
    "chars": 478,
    "preview": "/*\n * Copyright 2024 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\nplugins {\n    "
  },
  {
    "path": "permissions-motion/src/androidMain/kotlin/dev/icerock/moko/permissions/motion/MotionPermission.android.kt",
    "chars": 857,
    "preview": "/*\n * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-motion/src/commonMain/kotlin/dev/icerock/moko/permissions/motion/MotionPermission.kt",
    "chars": 458,
    "preview": "/*\n * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-motion/src/iosMain/kotlin/dev/icerock/moko/permissions/motion/MotionPermission.ios.kt",
    "chars": 1626,
    "preview": "/*\n * Copyright 2022 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-notifications/build.gradle.kts",
    "chars": 534,
    "preview": "/*\n * Copyright 2024 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\nplugins {\n    "
  },
  {
    "path": "permissions-notifications/src/androidMain/kotlin/dev/icerock/moko/permissions/notifications/NotificationPermission.android.kt",
    "chars": 1281,
    "preview": "/*\n * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-notifications/src/commonMain/kotlin/dev/icerock/moko/permissions/notifications/NotificationPermission.kt",
    "chars": 526,
    "preview": "/*\n * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-notifications/src/iosMain/kotlin/dev/icerock/moko/permissions/notifications/RemoteNotificationPermissionDelegate.kt",
    "chars": 4360,
    "preview": "/*\n * Copyright 2022 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-storage/build.gradle.kts",
    "chars": 479,
    "preview": "/*\n * Copyright 2024 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\nplugins {\n    "
  },
  {
    "path": "permissions-storage/src/androidMain/kotlin/dev/icerock/moko/permissions/storage/StoragePermissions.android.kt",
    "chars": 1068,
    "preview": "/*\n * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-storage/src/commonMain/kotlin/dev/icerock/moko/permissions/storage/StoragePermissions.kt",
    "chars": 698,
    "preview": "/*\n * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-storage/src/iosMain/kotlin/dev/icerock/moko/permissions/storage/AlwaysGrantedDelegate.kt",
    "chars": 438,
    "preview": "/*\n * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-storage/src/iosMain/kotlin/dev/icerock/moko/permissions/storage/StoragePermissions.ios.kt",
    "chars": 355,
    "preview": "/*\n * Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-test/build.gradle.kts",
    "chars": 568,
    "preview": "/*\n * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\nplugins {\n    "
  },
  {
    "path": "permissions-test/src/androidMain/kotlin/dev/icerock/moko/permissions/test/PermissionsControllerMock.kt",
    "chars": 691,
    "preview": "/*\n * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-test/src/commonMain/kotlin/dev/icerock/moko/permissions/test/PermissionsControllerMock.kt",
    "chars": 1649,
    "preview": "/*\n * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "permissions-test/src/iosMain/kotlin/dev/icerock/moko/permissions/test/PermissionsControllerMock.kt",
    "chars": 538,
    "preview": "/*\n * Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\npackage dev.ic"
  },
  {
    "path": "sample/android-app/build.gradle.kts",
    "chars": 485,
    "preview": "plugins {\n    id(\"dev.icerock.moko.gradle.android.application\")\n    id(\"dev.icerock.moko.gradle.detekt\")\n}\n\nandroid {\n  "
  },
  {
    "path": "sample/android-app/proguard-rules.pro",
    "chars": 647,
    "preview": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in /o"
  },
  {
    "path": "sample/android-app/src/main/AndroidManifest.xml",
    "chars": 725,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:to"
  },
  {
    "path": "sample/android-app/src/main/java/com/icerockdev/MainActivity.kt",
    "chars": 2224,
    "preview": "package com.icerockdev\n\nimport android.os.Bundle\nimport android.view.View\nimport android.widget.LinearLayout\nimport andr"
  },
  {
    "path": "sample/android-app/src/main/res/layout/activity_main.xml",
    "chars": 681,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmln"
  },
  {
    "path": "sample/compose-android-app/build.gradle.kts",
    "chars": 629,
    "preview": "plugins {\n    id(\"dev.icerock.moko.gradle.android.application\")\n    id(\"dev.icerock.moko.gradle.detekt\")\n    id(\"org.jet"
  },
  {
    "path": "sample/compose-android-app/src/main/AndroidManifest.xml",
    "chars": 657,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:to"
  },
  {
    "path": "sample/compose-android-app/src/main/java/com/icerockdev/MainActivity.kt",
    "chars": 4608,
    "preview": "package com.icerockdev\n\nimport android.os.Bundle\nimport androidx.activity.ComponentActivity\nimport androidx.activity.com"
  },
  {
    "path": "sample/ios-app/Podfile",
    "chars": 591,
    "preview": "source 'https://cdn.cocoapods.org/'\n\n# ignore all warnings from all pods\ninhibit_all_warnings!\n\nuse_frameworks!\nplatform"
  },
  {
    "path": "sample/ios-app/TestProj.xcodeproj/project.pbxproj",
    "chars": 12862,
    "preview": "// !$*UTF8*$!\n{\n\tarchiveVersion = 1;\n\tclasses = {\n\t};\n\tobjectVersion = 50;\n\tobjects = {\n\n/* Begin PBXBuildFile section *"
  },
  {
    "path": "sample/ios-app/TestProj.xcodeproj/project.xcworkspace/contents.xcworkspacedata",
    "chars": 153,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Workspace\n   version = \"1.0\">\n   <FileRef\n      location = \"self:TestProj.xcodep"
  },
  {
    "path": "sample/ios-app/TestProj.xcworkspace/contents.xcworkspacedata",
    "chars": 226,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Workspace\n   version = \"1.0\">\n   <FileRef\n      location = \"group:TestProj.xcode"
  },
  {
    "path": "sample/ios-app/TestProj.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist",
    "chars": 238,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/P"
  },
  {
    "path": "sample/ios-app/src/AppDelegate.swift",
    "chars": 409,
    "preview": "//\n//  Copyright © 2018 IceRock Development. All rights reserved.\n//\n\nimport MultiPlatformLibrary\nimport UIKit\n\n@UIAppli"
  },
  {
    "path": "sample/ios-app/src/Assets.xcassets/AppIcon.appiconset/Contents.json",
    "chars": 904,
    "preview": "{\n  \"images\" : [\n    {\n      \"idiom\" : \"mac\",\n      \"scale\" : \"1x\",\n      \"size\" : \"16x16\"\n    },\n    {\n      \"idiom\" : "
  },
  {
    "path": "sample/ios-app/src/Assets.xcassets/Contents.json",
    "chars": 63,
    "preview": "{\n  \"info\" : {\n    \"version\" : 1,\n    \"author\" : \"xcode\"\n  }\n}\n"
  },
  {
    "path": "sample/ios-app/src/Info.plist",
    "chars": 2089,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/P"
  },
  {
    "path": "sample/ios-app/src/Resources/Base.lproj/LaunchScreen.storyboard",
    "chars": 3027,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<document type=\"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB\" version=\"3"
  },
  {
    "path": "sample/ios-app/src/Resources/Base.lproj/Main.storyboard",
    "chars": 6613,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<document type=\"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB\" version=\"3"
  },
  {
    "path": "sample/ios-app/src/TestViewController.swift",
    "chars": 1167,
    "preview": "//\n//  Created by Aleksey Mikhailov on 23/06/2019.\n//  Copyright © 2019 IceRock Development. All rights reserved.\n//\n\nim"
  },
  {
    "path": "sample/mpp-library/MultiPlatformLibrary.podspec",
    "chars": 1877,
    "preview": "Pod::Spec.new do |spec|\n    spec.name                     = 'MultiPlatformLibrary'\n    spec.version                  = '"
  },
  {
    "path": "sample/mpp-library/build.gradle.kts",
    "chars": 875,
    "preview": "/*\n * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\nplugins {\n    "
  },
  {
    "path": "sample/mpp-library/src/androidMain/AndroidManifest.xml",
    "chars": 464,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package="
  },
  {
    "path": "sample/mpp-library/src/commonMain/kotlin/com/icerockdev/library/SampleViewModel.kt",
    "chars": 2615,
    "preview": "package com.icerockdev.library\n\nimport dev.icerock.moko.mvvm.dispatcher.EventsDispatcher\nimport dev.icerock.moko.mvvm.di"
  },
  {
    "path": "sample/mpp-library/src/commonTest/kotlin/com/icerockdev/library/SampleViewModelTest.kt",
    "chars": 3211,
    "preview": "package com.icerockdev.library\n\nimport dev.icerock.moko.mvvm.test.TestViewModelScope\nimport dev.icerock.moko.mvvm.test.c"
  },
  {
    "path": "settings.gradle.kts",
    "chars": 853,
    "preview": "/*\n * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.\n */\n\nenableFeatureP"
  }
]

// ... and 1 more files (download for full content)

About this extraction

This page contains the full source code of the icerockdev/moko-permissions GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 106 files (153.9 KB), approximately 41.7k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!