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

feat: Initialize the iOS support #218

Merged
merged 8 commits into from
Jan 1, 2025
Merged

feat: Initialize the iOS support #218

merged 8 commits into from
Jan 1, 2025

Conversation

XMLHexagram
Copy link
Collaborator

@XMLHexagram XMLHexagram commented Dec 31, 2024

Summary by Sourcery

Add initial iOS support, including audio session initialization and file selection capabilities.

New Features:

  • Implement file selection for iOS using a Flutter method channel and a native Swift file selector.

Tests:

  • Update tests to reflect changes in bundle ID retrieval.

Copy link

sourcery-ai bot commented Dec 31, 2024

Reviewer's Guide by Sourcery

This pull request implements initial iOS support. It introduces a new iOS file selector and initializes the audio session to allow background audio playback. Additionally, it updates the build process to support iOS by using swift-rs to link the necessary libraries and sets the minimum iOS version to 14. Finally, it updates the platform-specific code for media playback and control to include iOS.

Sequence diagram for iOS file selection

sequenceDiagram
    actor User
    participant UI as Flutter UI
    participant Channel as Method Channel
    participant Selector as iOS File Selector
    participant System as iOS System

    User->>UI: Select Directory
    UI->>Channel: getDirectoryPath()
    Channel->>Selector: get_directory_path
    Selector->>System: UIDocumentPicker
    System-->>User: Show Directory Picker
    User->>System: Select Directory
    System-->>Selector: Selected Path
    Selector-->>Channel: Return Path
    Channel-->>UI: Return Path
Loading

Class diagram for iOS integration components

classDiagram
    class AppDelegate {
        +application(didFinishLaunchingWithOptions) Bool
    }
    class FileSelector {
        -result: FlutterResult
        +shared: FileSelector
        +getDirectoryPath(result: FlutterResult)
        +documentPicker(controller, urls)
    }
    class IosFileSelector {
        +shared: IosFileSelector
        -platform: MethodChannel
        +getDirectoryPath() Future~String?~
    }

    AppDelegate --|> FlutterAppDelegate
    FileSelector ..|> UIDocumentPickerDelegate
    note for FileSelector "Handles native iOS file selection"
Loading

File-Level Changes

Change Details Files
Implement iOS file selector
  • Add a Flutter method channel to handle file selection requests from Dart.
  • Implement the getDirectoryPath method in Swift to open the document picker and return the selected directory path.
  • Update the getDirPath function in Dart to call the iOS file selector when running on iOS.
ios/Runner/AppDelegate.swift
lib/utils/get_dir_path.dart
lib/utils/ios_file_selector.dart
Initialize audio session for background audio playback
  • Add initAudioSession function to initialize and activate the audio session.
  • Add audio background mode to Info.plist.
ios/Runner/AppDelegate.swift
ios/Runner/Info.plist
Update build process for iOS support
  • Use swift-rs to link the apple-bridge-library package.
  • Set the minimum iOS version to 14 in Package.swift.
  • Add swift-rs dependency to Cargo.toml.
native/hub/build.rs
native/hub/apple-bridge-library/Package.swift
native/hub/Cargo.toml
Update platform-specific code for media playback and control
  • Include iOS in the platform-specific code for media playback.
  • Update conditional compilation directives to include iOS.
playback/src/lib.rs
playback/Cargo.toml
playback/src/controller.rs
Update license check for iOS
  • Use get_bundle_id function to retrieve the bundle ID on iOS.
native/hub/src/license.rs
Add iOS support to apple-bridge library
  • Implement the bundle_id function in Swift.
  • Update the Rust code to call the Swift function using swift-rs.
native/hub/src/apple_bridge/mod.rs
native/hub/apple-bridge-library/src/lib.swift

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@XMLHexagram XMLHexagram requested a review from Losses December 31, 2024 11:23
@XMLHexagram XMLHexagram marked this pull request as ready for review December 31, 2024 13:21
@dosubot dosubot bot added the R - enhancement New feature or request label Dec 31, 2024
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @XMLHexagram - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟡 Security: 1 issue found
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

ios/Runner/AppDelegate.swift Outdated Show resolved Hide resolved
ios/Runner/AppDelegate.swift Show resolved Hide resolved
@Losses Losses changed the title RE: feat: Initial iOS support feat: Initialize the iOS support Dec 31, 2024
}

// #[cfg(target_os = "macos")]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please cleanup these code.

@Losses Losses merged commit d4beced into master Jan 1, 2025
1 of 2 checks passed
@Losses Losses deleted the init-ios-support branch January 1, 2025 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
R - enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants