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

Refactor PlatformChannel #163

Conversation

swift-kim
Copy link
Member

Before:

  • platform_channel.cc & platform_channel_stub.cc

After:

  • platform_channel.cc: Common code that processes arguments and sends results.
  • platform_channel_tizen.cc: Tizen-specific implementation.
  • platform_channel_linux.cc: Linux desktop implementation.

Notable changes:

  • JSON (method arguments) processing is always performed by the PlatformChannel class. Thus, clipboard::GetData and clipboard::SetData are no longer required.
  • FeedbackManager has been refactored for simplicity and readability.
  • SystemSound and HapticFeedback no longer throw exceptions. Errors are logged to the console via FT_LOG(Error).

@swift-kim
Copy link
Member Author

The test code I used for testing:

Column(
  mainAxisAlignment: MainAxisAlignment.center,
  children: <Widget>[
    ElevatedButton(
      onPressed: () async {
        var data = await Clipboard.getData(Clipboard.kTextPlain);
        print(data?.text ?? 'null');
      },
      child: Text('Clipboard.getData'),
    ),
    ElevatedButton(
      onPressed: () async {
        await Clipboard.setData(
            ClipboardData(text: 'Counter: $_counter'));
        _counter++;
      },
      child: Text('Clipboard.setData'),
    ),
    ElevatedButton(
      onPressed: () async {
        await SystemSound.play(SystemSoundType.alert);
      },
      child: Text('SystemSound.play (alert)'),
    ),
    ElevatedButton(
      onPressed: () async {
        await SystemSound.play(SystemSoundType.click);
      },
      child: Text('SystemSound.play (click)'),
    ),
    ElevatedButton(
      onPressed: () async {
        await HapticFeedback.vibrate();
        print('brrr!');
      },
      child: Text('HapticFeedback.vibrate'),
    ),
    ElevatedButton(
      onPressed: () async {
        await SystemNavigator.pop();
      },
      child: Text('SystemNavigator.pop'),
    ),
    ElevatedButton(
      onPressed: () async {
        _landscape = !_landscape;
        await SystemChrome.setPreferredOrientations(<DeviceOrientation>[
          if (_landscape) DeviceOrientation.landscapeLeft,
        ]);
        print('landscape = $_landscape');
      },
      child: Text('SystemChrome.setPreferredOrientations'),
    ),
  ],
),

Copy link

@bbrto21 bbrto21 left a comment

Choose a reason for hiding this comment

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

LGTM

@swift-kim swift-kim mentioned this pull request Aug 3, 2021
Copy link
Member

@bwikbs bwikbs left a comment

Choose a reason for hiding this comment

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

Goooood!! 👍

@swift-kim swift-kim merged commit 1e7b2fa into flutter-tizen:flutter-2.2.1-tizen Aug 4, 2021
swift-kim added a commit that referenced this pull request Sep 27, 2021
swift-kim added a commit that referenced this pull request Nov 14, 2021
swift-kim added a commit that referenced this pull request Dec 9, 2021
swift-kim added a commit that referenced this pull request Dec 17, 2021
swift-kim added a commit that referenced this pull request Feb 7, 2022
swift-kim added a commit that referenced this pull request Feb 11, 2022
swift-kim added a commit that referenced this pull request May 12, 2022
swift-kim added a commit that referenced this pull request Aug 5, 2022
swift-kim added a commit that referenced this pull request Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants