Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#128 Fixed openAppSettings on iOS #133

Merged
merged 6 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ allprojects {
project **build.gradle**
```groovy
dependencies {
commonMainApi("dev.icerock.moko:permissions:0.18.0")
commonMainApi("dev.icerock.moko:permissions:0.18.1")

// compose multiplatform
commonMainApi("dev.icerock.moko:permissions-compose:0.18.0") // permissions api + compose extensions
commonMainApi("dev.icerock.moko:permissions-compose:0.18.1") // permissions api + compose extensions

commonTestImplementation("dev.icerock.moko:permissions-test:0.18.0")
commonTestImplementation("dev.icerock.moko:permissions-test:0.18.1")
}
```

Expand All @@ -65,6 +65,7 @@ The full list can be found in `dev.icerock.moko.permissions.Permission` enum.
* Bluetooth Scan: **Permission.BLUETOOTH_SCAN**
* Bluetooth Connect: **Permission.BLUETOOTH_CONNECT**
* Bluetooth Advertise: **Permission.BLUETOOTH_ADVERTISE**
* Contacts: **Permission.CONTACTS**
* Motion: **Permission.MOTION**

## Usage
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ androidLifecycleVersion = "2.2.0"
androidCoreTestingVersion = "2.2.0"
coroutinesVersion = "1.6.4"
mokoMvvmVersion = "0.16.0"
mokoPermissionsVersion = "0.18.0"
mokoPermissionsVersion = "0.18.1"
composeJetBrainsVersion = "1.5.1"
lifecycleRuntime = "2.6.1"
composeUiVersion = "1.0.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class PermissionsController : PermissionsControllerProtocol {

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

private fun getDelegate(permission: Permission): PermissionDelegate {
Expand Down
22 changes: 16 additions & 6 deletions sample/ios-app/src/Resources/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?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" useTraitCollections="YES" colorMatched="YES" initialViewController="zIh-nI-gcX">
<device id="retina4_0" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<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="14490.49"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22685"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand Down Expand Up @@ -37,7 +35,7 @@
<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="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="wrA-Wa-jvv">
<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>
Expand All @@ -50,12 +48,24 @@
<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>
Expand Down
4 changes: 4 additions & 0 deletions sample/ios-app/src/TestViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ class TestViewController: UIViewController {
@IBAction func onPermissionPressed() {
viewModel.onRequestPermissionButtonPressed()
}

@IBAction func onOpenSettingsPressed() {
PermissionsController().openAppSettings()
}
}

extension TestViewController: SampleViewModelEventListener {
Expand Down
15 changes: 5 additions & 10 deletions sample/mpp-library/MultiPlatformLibrary.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Pod::Spec.new do |spec|
'KOTLIN_FRAMEWORK_BUILD_TYPE[config=*elease]' => 'release',
'CURENT_SDK[sdk=iphoneos*]' => 'iphoneos',
'CURENT_SDK[sdk=iphonesimulator*]' => 'iphonesimulator',
'CURENT_SDK[sdk=macosx*]' => 'macos'
}

spec.script_phases = [
Expand All @@ -37,21 +36,17 @@ fi
if [ "$CURENT_SDK" == "iphoneos" ]; then
TARGET="Ios"
ARCH="Arm64"
elif [ "$CURENT_SDK" == "macos" ]; then
TARGET="Macos"
if [ "$NATIVE_ARCH" == "arm64" ]; then
ARCH="Arm64"
else
ARCH="X64"
fi
else
if [ "$NATIVE_ARCH" == "arm64" ]; then
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"
Expand Down
Loading