Skip to content

Commit

Permalink
Merge pull request #220 from AmosHuKe/ci-code-analysis
Browse files Browse the repository at this point in the history
CI: Action - Code Analysis
  • Loading branch information
xdd666t authored Sep 18, 2024
2 parents 8b71392 + 4dff5c5 commit bccd733
Show file tree
Hide file tree
Showing 16 changed files with 105 additions and 32 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/code-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Code Analysis

on:
workflow_dispatch:
push:
branches:
- master
paths-ignore:
- '**.md'
pull_request:
branches:
- master
paths-ignore:
- '**.md'

jobs:
code-analysis:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
- name: Prepare dependencies
run: |
flutter --version
flutter pub get
- name: Check Dart code formatting
run: |
dart format . -o none --set-exit-if-changed
- name: Analyze Dart code
run: |
flutter analyze .
- name: Generate dartdoc
run: |
dart pub global activate dartdoc
dart pub global run dartdoc .
test:
needs: [code-analysis]
runs-on: ubuntu-latest
strategy:
matrix:
flutter-version: ['']
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
flutter-version: ${{ matrix.flutter-version }}
- name: Prepare dependencies
run: |
flutter --version
flutter pub get
- name: Test
run: flutter test
5 changes: 4 additions & 1 deletion example/lib/demo/issue181_overstep.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ class _TestingDialogState extends State<_TestingDialog>
alignment: Alignment.bottomCenter,
children: [
// 这里,点击事件也可以传递到遮罩
SizedBox(height: MediaQuery.of(context).size.height,width: MediaQuery.of(context).size.width),
SizedBox(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
),
Container(height: 300, color: Colors.blue),
AnimatedBuilder(
animation: animationController,
Expand Down
2 changes: 1 addition & 1 deletion example/lib/demo/issue183_visibility.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,4 @@ class Page1 extends StatelessWidget {
],
);
}
}
}
2 changes: 1 addition & 1 deletion example/lib/demo/issue188_quick_close.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class MyApp extends StatelessWidget {
);
}

void _show() async{
void _show() async {
SmartDialog.show(
builder: (_) {
return Container(
Expand Down
2 changes: 1 addition & 1 deletion example/lib/demo/issue190_release.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class MyApp extends StatelessWidget {
);
},
animationType: SmartAnimationType.centerFade_otherSlide,
backDismiss: true,
backType: SmartBackType.normal,
keepSingle: true,
debounce: true,
);
Expand Down
2 changes: 1 addition & 1 deletion example/lib/demo/issue191_toast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class MyApp extends StatelessWidget {
},
displayTime: const Duration(milliseconds: 2000),
keepSingle: true,
backDismiss: false,
backType: SmartBackType.block,
);

// SmartDialog.showLoading();
Expand Down
17 changes: 8 additions & 9 deletions example/lib/demo/issue200_loading.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class MyApp extends StatelessWidget {
}
}


/// @Describe: 测试
///
/// @Author: LiWeNHuI
Expand Down Expand Up @@ -63,7 +62,7 @@ class _DemoPageState extends State<DemoPage> {
maskColor: Colors.transparent,
clickMaskDismiss: false,
displayTime: const Duration(milliseconds: 1500),
backDismiss: false,
backType: SmartBackType.block,
);
}

Expand All @@ -74,7 +73,7 @@ class _DemoPageState extends State<DemoPage> {
builder: (BuildContext ctx) {
return Dialog(
insetPadding:
const EdgeInsets.symmetric(vertical: 24, horizontal: 32),
const EdgeInsets.symmetric(vertical: 24, horizontal: 32),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
child: PopScope(
canPop: false,
Expand Down Expand Up @@ -113,7 +112,7 @@ class _DemoPageState extends State<DemoPage> {
animationBuilder: (_, Widget child, ___) =>
TestAnimation(animationParam: ___, child: child),
displayTime: const Duration(milliseconds: 2300),
backDismiss: false,
backType: SmartBackType.block,
keepSingle: true,
);
},
Expand Down Expand Up @@ -165,12 +164,12 @@ class _TestAnimationState extends State<TestAnimation>
duration: const Duration(milliseconds: 300),
vsync: this,
)..addListener(() {
if (controller.value > .3 && !isStart) {
isStart = true;
if (controller.value > .3 && !isStart) {
isStart = true;

bodyController.forward();
}
});
bodyController.forward();
}
});

bodyController = AnimationController(
duration: const Duration(milliseconds: 8000),
Expand Down
7 changes: 5 additions & 2 deletions example/lib/demo/issue205_dark_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ class MyApp extends StatelessWidget {
useMaterial3: true,
),
darkTheme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple, brightness: Brightness.dark),
colorScheme: ColorScheme.fromSeed(
seedColor: Colors.deepPurple,
brightness: Brightness.dark,
),
brightness: Brightness.dark,
useMaterial3: true,
),
Expand Down Expand Up @@ -76,4 +79,4 @@ class _MyHomePageState extends State<MyHomePage> {
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
}
8 changes: 4 additions & 4 deletions example/lib/demo/issue209.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ class MyApp extends StatelessWidget {
}

void _show() async {
print("before:${DateTime.now().millisecondsSinceEpoch}");
debugPrint("before:${DateTime.now().millisecondsSinceEpoch}");
var result = await SmartDialog.show<bool>(
tag: 'tag',
backDismiss: false,
backType: SmartBackType.block,
clickMaskDismiss: false,
builder: (_) {
return ElevatedButton(
Expand All @@ -37,12 +37,12 @@ class MyApp extends StatelessWidget {
);
},
onDismiss: () {
print("onDismiss:${DateTime.now().millisecondsSinceEpoch}");
debugPrint("onDismiss:${DateTime.now().millisecondsSinceEpoch}");
// showLoading()放在这里能正常显示
// SmartDialog.showLoading();
});

print("aftermiss:${DateTime.now().millisecondsSinceEpoch}");
debugPrint("aftermiss:${DateTime.now().millisecondsSinceEpoch}");
if (result == true) {
// showLoading() 放在这里需要加一点延时才能显示Loading
// await Future.delayed(const Duration(seconds: 1));
Expand Down
5 changes: 4 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ class MyApp extends StatelessWidget {
navigatorObservers: [FlutterSmartDialog.observer],
builder: FlutterSmartDialog.init(),
darkTheme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple, brightness: Brightness.dark),
colorScheme: ColorScheme.fromSeed(
seedColor: Colors.deepPurple,
brightness: Brightness.dark,
),
brightness: Brightness.dark,
useMaterial3: true,
),
Expand Down
1 change: 1 addition & 0 deletions lib/flutter_smart_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export 'src/config/smart_config_notify.dart';
export 'src/config/smart_config_toast.dart';
export 'src/data/animation_param.dart' show AnimationParam;
export 'src/data/notify_style.dart';

/// dialog
export 'src/init_dialog.dart';
export 'src/smart_dialog.dart';
Expand Down
3 changes: 0 additions & 3 deletions lib/src/data/loading_info.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import 'dart:async';

import '../../flutter_smart_dialog.dart';
import '../custom/custom_loading.dart';
import '../kit/typedef.dart';
import 'base_dialog.dart';

class LoadingInfo {
late CustomLoading loadingWidget;
Expand Down
7 changes: 6 additions & 1 deletion lib/src/helper/pop_monitor/boost_route_monitor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,17 @@ class BoostRouteMonitor {
if (route is ModalRoute) {
willPopCallback() async {
if (_handleSmartDialog()) {
DialogProxy.instance.dismiss(status: SmartStatus.smart, closeType: CloseType.back);
DialogProxy.instance.dismiss(
status: SmartStatus.smart,
closeType: CloseType.back,
);
return false;
}
return true;
}

// TODO: `addScopedWillPopCallback()` was deprecated after v3.12.0-1.0.pre.
// ignore: deprecated_member_use
route.addScopedWillPopCallback(willPopCallback);
DialogProxy.contextNavigator = route.subtreeContext;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/kit/typedef.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import 'dart:async';

typedef FutureVoidCallback = Future<void> Function();

typedef SmartOnBack = FutureOr<bool> Function();
typedef SmartOnBack = FutureOr<bool> Function();
17 changes: 12 additions & 5 deletions lib/src/widget/helper/attach_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ class _AttachWidgetState extends State<AttachWidget> {
return Opacity(opacity: _postFrameOpacity, child: _originChild);
});

List<Widget> below = widget.belowBuilder?.call(targetOffset, targetSize) ?? [];
List<Widget> above = widget.aboveBuilder?.call(targetOffset, targetSize) ?? [];
List<Widget> below =
widget.belowBuilder?.call(targetOffset, targetSize) ?? [];
List<Widget> above =
widget.aboveBuilder?.call(targetOffset, targetSize) ?? [];
return Stack(children: [
//blow
for (var belowWidget in below) belowWidget,
Expand Down Expand Up @@ -152,7 +154,9 @@ class _AttachWidgetState extends State<AttachWidget> {
} else if (alignment == Alignment.topRight) {
_targetRect = _adjustReactInfo(
bottom: screen.height - targetOffset.dy,
left: targetOffset.dx + targetSize.width + _calculateDx(alignment, selfSize),
left: targetOffset.dx +
targetSize.width +
_calculateDx(alignment, selfSize),
fixedVertical: true,
);
} else if (alignment == Alignment.centerLeft) {
Expand Down Expand Up @@ -188,7 +192,9 @@ class _AttachWidgetState extends State<AttachWidget> {
} else if (alignment == Alignment.bottomRight) {
_targetRect = _adjustReactInfo(
top: targetOffset.dy + targetSize.height,
left: targetOffset.dx + targetSize.width + _calculateDx(alignment, selfSize),
left: targetOffset.dx +
targetSize.width +
_calculateDx(alignment, selfSize),
fixedVertical: true,
);
}
Expand Down Expand Up @@ -227,7 +233,8 @@ class _AttachWidgetState extends State<AttachWidget> {
} else {
offset = -(selfSize.width / 2);
}
} else if (alignment == Alignment.topRight || alignment == Alignment.bottomRight) {
} else if (alignment == Alignment.topRight ||
alignment == Alignment.bottomRight) {
if (type == SmartAttachAlignmentType.inside) {
offset = -selfSize.width;
} else if (type == SmartAttachAlignmentType.outside) {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/widget/helper/smart_overlay_entry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class SmartOverlayEntry extends OverlayEntry {

@override
void remove() {
if(!mounted) {
if (!mounted) {
return;
}
super.remove();
Expand Down

0 comments on commit bccd733

Please sign in to comment.