Skip to content

Commit cdc396c

Browse files
committed
🔥 Resolves conflict with camera picker.
1 parent 3f152be commit cdc396c

File tree

8 files changed

+137
-17
lines changed

8 files changed

+137
-17
lines changed

example/lib/constants/extensions.dart

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
///
2+
/// [Author] Alex (https://github.com/AlexV525)
3+
/// [Date] 2020/8/19 14:12
4+
///
5+
import 'package:flutter/material.dart';
6+
7+
extension BrightnessExtension on Brightness {
8+
bool get isDark => this == Brightness.dark;
9+
bool get isLight => this == Brightness.light;
10+
}
11+
12+
extension BuildContextExtension on BuildContext {
13+
MediaQueryData get mediaQuery => MediaQuery.of(this);
14+
ThemeData get themeData => Theme.of(this);
15+
}
16+
17+
extension ColorExtension on Color {
18+
bool get isTransparent => this == Colors.transparent;
19+
20+
MaterialColor get swatch => Colors.primaries.firstWhere(
21+
(Color c) => c.value == value,
22+
orElse: () => _swatch,
23+
);
24+
25+
Map<int, Color> get getMaterialColorValues => <int, Color>{
26+
50: _swatchShade(50),
27+
100: _swatchShade(100),
28+
200: _swatchShade(200),
29+
300: _swatchShade(300),
30+
400: _swatchShade(400),
31+
500: _swatchShade(500),
32+
600: _swatchShade(600),
33+
700: _swatchShade(700),
34+
800: _swatchShade(800),
35+
900: _swatchShade(900),
36+
};
37+
38+
MaterialColor get _swatch => MaterialColor(value, getMaterialColorValues);
39+
40+
Color _swatchShade(int swatchValue) => HSLColor.fromColor(this)
41+
.withLightness(1 - (swatchValue / 1000))
42+
.toColor();
43+
}

example/lib/constants/screens.dart

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
///
2+
/// [Author] Alex (https://github.com/AlexV525)
3+
/// [Date] 2020/8/19 10:29
4+
///
5+
import 'dart:ui' as ui;
6+
7+
import 'package:flutter/material.dart';
8+
import 'package:flutter/services.dart';
9+
10+
/// Screens utils with multiple properties access.
11+
/// 获取屏幕各项属性的工具类
12+
class Screens {
13+
const Screens._();
14+
15+
/// Get [MediaQueryData] from [ui.window]
16+
/// 通过 [ui.window] 获取 [MediaQueryData]
17+
static MediaQueryData get mediaQuery => MediaQueryData.fromWindow(ui.window);
18+
19+
/// The number of device pixels for each logical pixel.
20+
/// 设备每个逻辑像素对应的dp比例
21+
static double get scale => mediaQuery.devicePixelRatio;
22+
23+
/// The horizontal extent of this size.
24+
/// 水平范围的大小
25+
static double get width => mediaQuery.size.width;
26+
27+
/// The horizontal pixels of this size.
28+
/// 水平范围的像素值
29+
static int get widthPixels => (width * scale).toInt();
30+
31+
/// The vertical extent of this size.
32+
/// 垂直范围的大小
33+
static double get height => mediaQuery.size.height;
34+
35+
/// The vertical pixels of this size.
36+
/// 垂直范围的像素值
37+
static int get heightPixels => (height * scale).toInt();
38+
39+
/// Top offset in the [ui.window], usually is the notch size.
40+
/// 从 [ui.window] 获取的顶部偏移(间距),通常是刘海的大小。
41+
static double get topSafeHeight => mediaQuery.padding.top;
42+
43+
/// Bottom offset in the [ui.window], usually is the action bar/navigation bar size.
44+
/// 从 [ui.window] 获取的底部偏移(间距),通常是操作条/导航条的大小。
45+
static double get bottomSafeHeight => mediaQuery.padding.bottom;
46+
47+
/// Height exclude top and bottom safe height.
48+
/// 去除顶部和底部安全区域的高度
49+
static double get safeHeight => height - topSafeHeight - bottomSafeHeight;
50+
51+
/// Method to update status bar's style.
52+
/// 更新状态栏样式的方法
53+
static void updateStatusBarStyle(SystemUiOverlayStyle style) {
54+
SystemChrome.setSystemUIOverlayStyle(style);
55+
}
56+
57+
/// Scale factor for the text.
58+
/// 文字缩放的倍数
59+
static double get textScaleFactor => mediaQuery.textScaleFactor;
60+
61+
/// Return a fixed font size according to text scale factor.
62+
/// 根据文字缩放计算出的固定文字大小
63+
static double fixedFontSize(double fontSize) => fontSize / textScaleFactor;
64+
}

example/lib/main.dart

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
///
55
import 'package:flutter/material.dart';
66
import 'package:flutter/services.dart';
7-
import 'package:flutter_common_exports/flutter_common_exports.dart';
87
import 'package:wechat_assets_picker/wechat_assets_picker.dart';
98

9+
import 'constants/extensions.dart';
10+
import 'constants/screens.dart';
1011
import 'pages/splash_page.dart';
1112

1213
const Color themeColor = Color(0xff00bc56);
@@ -41,3 +42,12 @@ class MyApp extends StatelessWidget {
4142
);
4243
}
4344
}
45+
46+
class NoGlowScrollBehavior extends ScrollBehavior {
47+
const NoGlowScrollBehavior();
48+
49+
@override
50+
Widget buildViewportChrome(
51+
BuildContext context, Widget child, AxisDirection axisDirection) =>
52+
child;
53+
}

example/lib/pages/home_page.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
///
55
import 'package:flutter/material.dart';
66
import 'package:flutter/services.dart';
7-
import 'package:flutter_common_exports/flutter_common_exports.dart';
87

8+
import '../constants/extensions.dart';
99
import '../constants/resource.dart';
10+
import '../constants/screens.dart';
1011
import 'multi_assets_page.dart';
1112
import 'single_assets_page.dart';
1213

example/lib/pages/multi_assets_page.dart

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
/// [Date] 2020-05-31 20:21
44
///
55
import 'package:flutter/material.dart';
6-
import 'package:flutter_common_exports/flutter_common_exports.dart';
76
import 'package:wechat_assets_picker/wechat_assets_picker.dart';
87
import 'package:wechat_camera_picker/wechat_camera_picker.dart';
98

9+
import '../constants/extensions.dart';
1010
import '../constants/picker_model.dart';
1111
import '../main.dart';
1212

@@ -162,9 +162,9 @@ class _MultiAssetsPageState extends State<MultiAssetsPage> {
162162
filterOptions: FilterOptionGroup()
163163
..setOption(
164164
AssetType.video,
165-
FilterOption(
165+
const FilterOption(
166166
durationConstraint: DurationConstraint(
167-
max: 1.minutes,
167+
max: Duration(minutes: 1),
168168
),
169169
),
170170
),
@@ -306,10 +306,13 @@ class _MultiAssetsPageState extends State<MultiAssetsPage> {
306306
}
307307

308308
Widget get methodListView => Expanded(
309-
child: ListView.builder(
310-
padding: const EdgeInsets.symmetric(vertical: 10.0),
311-
itemCount: pickMethods.length,
312-
itemBuilder: methodItemBuilder,
309+
child: Padding(
310+
padding: const EdgeInsets.only(bottom: 10.0),
311+
child: ListView.builder(
312+
padding: const EdgeInsets.symmetric(vertical: 10.0),
313+
itemCount: pickMethods.length,
314+
itemBuilder: methodItemBuilder,
315+
),
313316
),
314317
);
315318

@@ -503,7 +506,6 @@ class _MultiAssetsPageState extends State<MultiAssetsPage> {
503506

504507
Widget get selectedAssetsListView => Expanded(
505508
child: ListView.builder(
506-
shrinkWrap: true,
507509
physics: const BouncingScrollPhysics(),
508510
padding: const EdgeInsets.symmetric(horizontal: 8.0),
509511
scrollDirection: Axis.horizontal,

example/lib/pages/single_assets_page.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
/// [Date] 2020-05-31 21:17
44
///
55
import 'package:flutter/material.dart';
6-
import 'package:flutter_common_exports/flutter_common_exports.dart';
76
import 'package:wechat_assets_picker/wechat_assets_picker.dart';
87
import 'package:wechat_camera_picker/wechat_camera_picker.dart';
98

9+
import '../constants/extensions.dart';
1010
import '../constants/picker_model.dart';
1111
import '../main.dart';
1212

@@ -161,9 +161,9 @@ class _SingleAssetPageState extends State<SingleAssetPage> {
161161
filterOptions: FilterOptionGroup()
162162
..setOption(
163163
AssetType.video,
164-
FilterOption(
164+
const FilterOption(
165165
durationConstraint: DurationConstraint(
166-
max: 1.minutes,
166+
max: Duration(minutes: 1),
167167
),
168168
),
169169
),

example/lib/pages/splash_page.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
///
55
import 'package:flutter/material.dart';
66
import 'package:flutter/scheduler.dart';
7-
import 'package:flutter_common_exports/flutter_common_exports.dart';
87

8+
import '../constants/extensions.dart';
99
import '../constants/resource.dart';
1010
import 'home_page.dart';
1111

@@ -23,7 +23,7 @@ class _SplashPageState extends State<SplashPage> {
2323
SchedulerBinding.instance.addPostFrameCallback(
2424
(Duration _) {
2525
Future<void>.delayed(
26-
2.seconds,
26+
const Duration(seconds: 2),
2727
() {
2828
Navigator.of(context).pushReplacement(
2929
PageRouteBuilder<void>(
@@ -45,7 +45,7 @@ class _SplashPageState extends State<SplashPage> {
4545
child: child,
4646
);
4747
},
48-
transitionDuration: 1.seconds,
48+
transitionDuration: const Duration(seconds: 1),
4949
),
5050
);
5151
},

example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencies:
1212

1313
wechat_assets_picker:
1414
path: ../
15-
wechat_camera_picker: ^1.0.0
15+
wechat_camera_picker: ^1.1.2
1616

1717
dev_dependencies:
1818
flutter_asset_generator: ">=0.4.7 <2.0.0"

0 commit comments

Comments
 (0)