mirror of
https://github.com/RxReader/link_kit.git
synced 2025-08-14 18:55:38 +08:00
format
This commit is contained in:
49
.github/workflows/build.yml
vendored
Normal file
49
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
name: build
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build_ios:
|
||||
name: Build iOS on ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: 'stable'
|
||||
- name: Run llvm/clang-format@shell
|
||||
run: |
|
||||
brew install clang-format
|
||||
- run: clang-format -style=file -i ios/Classes/*.h ios/Classes/*.m --dry-run --Werror
|
||||
- run: flutter --version
|
||||
- run: flutter pub get
|
||||
- run: flutter format --dry-run --set-exit-if-changed .
|
||||
- run: flutter pub publish --dry-run
|
||||
- run: flutter analyze lib example/lib
|
||||
- run: cd example; flutter build ios --no-codesign
|
||||
|
||||
build_android:
|
||||
name: Build Android on ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [windows-latest, ubuntu-latest, macos-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: '11'
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: 'stable'
|
||||
- run: flutter --version
|
||||
- run: flutter pub get
|
||||
- run: flutter format --dry-run --set-exit-if-changed .
|
||||
- run: flutter pub publish --dry-run
|
||||
- run: flutter analyze lib example/lib
|
||||
- run: cd example; flutter build apk --debug
|
34
.github/workflows/publish.yml
vendored
Normal file
34
.github/workflows/publish.yml
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
name: publish
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
name: Publish
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: 'stable'
|
||||
- name: Run pub.dev/inject-credentials@shell
|
||||
env:
|
||||
CREDENTIALS: ${{ secrets.CREDENTIALS_JSON }}
|
||||
run: |
|
||||
if [ -z $PUB_CACHE ];then
|
||||
PUB_CACHE=~/.pub-cache
|
||||
fi
|
||||
mkdir -p $PUB_CACHE
|
||||
echo $CREDENTIALS > $PUB_CACHE/credentials.json
|
||||
- run: flutter --version
|
||||
- run: flutter pub get
|
||||
- run: flutter format --dry-run --set-exit-if-changed .
|
||||
- run: echo "y" | flutter pub publish
|
||||
- name: Run pub.dev/update-credentials@shell
|
||||
env:
|
||||
UPDATE_SECRETS_PAT_TOKEN: ${{ secrets.UPDATE_SECRETS_PAT_TOKEN }}
|
||||
run: |
|
||||
gh auth login --with-token <<< $UPDATE_SECRETS_PAT_TOKEN
|
||||
gh secret set CREDENTIALS_JSON < $PUB_CACHE/credentials.json
|
32
.github/workflows/publish_manually.yml
vendored
Normal file
32
.github/workflows/publish_manually.yml
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
name: publish manually
|
||||
|
||||
on: workflow_dispatch
|
||||
|
||||
jobs:
|
||||
publish_manually:
|
||||
name: Publish Manually
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: 'stable'
|
||||
- name: Run pub.dev/inject-credentials@shell
|
||||
env:
|
||||
CREDENTIALS: ${{ secrets.CREDENTIALS_JSON }}
|
||||
run: |
|
||||
if [ -z $PUB_CACHE ];then
|
||||
PUB_CACHE=~/.pub-cache
|
||||
fi
|
||||
mkdir -p $PUB_CACHE
|
||||
echo $CREDENTIALS > $PUB_CACHE/credentials.json
|
||||
- run: flutter --version
|
||||
- run: flutter pub get
|
||||
- run: flutter format --dry-run --set-exit-if-changed .
|
||||
- run: echo "y" | flutter pub publish
|
||||
- name: Run pub.dev/update-credentials@shell
|
||||
env:
|
||||
UPDATE_SECRETS_PAT_TOKEN: ${{ secrets.UPDATE_SECRETS_PAT_TOKEN }}
|
||||
run: |
|
||||
gh auth login --with-token <<< $UPDATE_SECRETS_PAT_TOKEN
|
||||
gh secret set CREDENTIALS_JSON < $PUB_CACHE/credentials.json
|
@ -18,6 +18,7 @@ class MyApp extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _MyAppState extends State<MyApp> {
|
||||
String? _initialLink;
|
||||
StreamSubscription<String>? _linkClickSubs;
|
||||
|
||||
@override
|
||||
@ -27,6 +28,9 @@ class _MyAppState extends State<MyApp> {
|
||||
if (kDebugMode) {
|
||||
print('initialLink: $value');
|
||||
}
|
||||
setState(() {
|
||||
_initialLink = value;
|
||||
});
|
||||
});
|
||||
_linkClickSubs = Link.instance.linkClickStream().listen((String event) {
|
||||
if (kDebugMode) {
|
||||
@ -48,6 +52,9 @@ class _MyAppState extends State<MyApp> {
|
||||
appBar: AppBar(
|
||||
title: Text('Link Kit'),
|
||||
),
|
||||
body: Center(
|
||||
child: Text(_initialLink ?? ''),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -18,8 +18,8 @@ void main() {
|
||||
// Verify that platform version is retrieved.
|
||||
expect(
|
||||
find.byWidgetPredicate(
|
||||
(Widget widget) => widget is Text &&
|
||||
widget.data!.startsWith('Running on:'),
|
||||
(Widget widget) =>
|
||||
widget is Text && widget.data!.startsWith('Running on:'),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
|
@ -1,10 +1,10 @@
|
||||
#import <Flutter/Flutter.h>
|
||||
|
||||
@interface LinkKitPlugin : NSObject<FlutterPlugin>
|
||||
@interface LinkKitPlugin : NSObject <FlutterPlugin>
|
||||
@end
|
||||
|
||||
@interface LinkKitLinkClickEventHandler : NSObject<FlutterStreamHandler>
|
||||
@interface LinkKitLinkClickEventHandler : NSObject <FlutterStreamHandler>
|
||||
|
||||
- (void)addEvent: (NSString *)event;
|
||||
- (void)addEvent:(NSString *)event;
|
||||
|
||||
@end
|
||||
|
@ -5,7 +5,7 @@
|
||||
NSString *_initialLink;
|
||||
}
|
||||
|
||||
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
|
||||
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
|
||||
FlutterEventChannel *linkClickEventChannel = [FlutterEventChannel eventChannelWithName:@"v7lin.github.io/link_kit#click_event" binaryMessenger:[registrar messenger]];
|
||||
LinkKitLinkClickEventHandler *linkClickEventHandler = [[LinkKitLinkClickEventHandler alloc] init];
|
||||
[linkClickEventChannel setStreamHandler:linkClickEventHandler];
|
||||
@ -26,7 +26,7 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
|
||||
- (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result {
|
||||
if ([@"getInitialLink" isEqualToString:call.method]) {
|
||||
result(_initialLink);
|
||||
} else {
|
||||
@ -48,7 +48,7 @@
|
||||
@throw [[NSException alloc] initWithName:@"UnsupportedError" reason:@"未配置 flk scheme" userInfo:nil];
|
||||
}
|
||||
|
||||
- (BOOL) isFLKURL:(NSURL *) url {
|
||||
- (BOOL)isFLKURL:(NSURL *)url {
|
||||
NSString *scheme = [self getFLKURLScheme];
|
||||
return [scheme isEqualToString:url.scheme];
|
||||
}
|
||||
@ -70,7 +70,7 @@
|
||||
return [self handleLinkClickEvent:url];
|
||||
}
|
||||
|
||||
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
|
||||
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
|
||||
return [self handleLinkClickEvent:url];
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@
|
||||
FlutterEventSink _events;
|
||||
}
|
||||
|
||||
- (FlutterError * _Nullable)onListenWithArguments:(id _Nullable)arguments eventSink:(nonnull FlutterEventSink)events {
|
||||
- (FlutterError *_Nullable)onListenWithArguments:(id _Nullable)arguments eventSink:(nonnull FlutterEventSink)events {
|
||||
if (_events != nil) {
|
||||
return nil;
|
||||
}
|
||||
@ -104,7 +104,7 @@
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (FlutterError * _Nullable)onCancelWithArguments:(id _Nullable)arguments {
|
||||
- (FlutterError *_Nullable)onCancelWithArguments:(id _Nullable)arguments {
|
||||
if (_events == nil) {
|
||||
return nil;
|
||||
}
|
||||
@ -112,7 +112,7 @@
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)addEvent: (NSString *)event {
|
||||
- (void)addEvent:(NSString *)event {
|
||||
if (_events != nil) {
|
||||
_events(event);
|
||||
}
|
||||
|
@ -6,9 +6,11 @@ import 'package:link_kit/src/link_kit_platform_interface.dart';
|
||||
class MethodChannelLinkKit extends LinkKitPlatform {
|
||||
/// The method channel used to interact with the native platform.
|
||||
@visibleForTesting
|
||||
final MethodChannel methodChannel = const MethodChannel('v7lin.github.io/link_kit');
|
||||
final MethodChannel methodChannel =
|
||||
const MethodChannel('v7lin.github.io/link_kit');
|
||||
@visibleForTesting
|
||||
final EventChannel linkClickEventChannel = const EventChannel('v7lin.github.io/link_kit#click_event');
|
||||
final EventChannel linkClickEventChannel =
|
||||
const EventChannel('v7lin.github.io/link_kit#click_event');
|
||||
|
||||
@override
|
||||
Future<String?> getInitialLink() {
|
||||
@ -19,9 +21,8 @@ class MethodChannelLinkKit extends LinkKitPlatform {
|
||||
|
||||
@override
|
||||
Stream<String> linkClickStream() {
|
||||
_onLinkClickStream ??= linkClickEventChannel
|
||||
.receiveBroadcastStream()
|
||||
.map((dynamic event) {
|
||||
_onLinkClickStream ??=
|
||||
linkClickEventChannel.receiveBroadcastStream().map((dynamic event) {
|
||||
return event as String;
|
||||
});
|
||||
return _onLinkClickStream!;
|
||||
|
Reference in New Issue
Block a user