Skip to content

Commit

Permalink
➕ Use wechat_picker_library (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 authored Feb 2, 2024
1 parent 414b7dc commit cc966c0
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 94 deletions.
1 change: 0 additions & 1 deletion .github/workflows/runnable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,4 @@ jobs:
- run: dart --version
- run: flutter --version
- run: flutter pub get
- run: sudo echo "y" | sudo $ANDROID_HOME/tools/bin/sdkmanager "ndk;21.4.7075529"
- run: cd example; flutter build apk --debug
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ that can be found in the LICENSE file. -->

See the [Migration Guide](guides/migration_guide.md) for breaking changes between versions.

## 4.2.0-dev.4

### Improvements

- Use `wechat_picker_library`.

## 4.2.0-dev.3

### Improvements
Expand Down
8 changes: 0 additions & 8 deletions lib/src/constants/styles.dart

This file was deleted.

19 changes: 0 additions & 19 deletions lib/src/internals/extensions.dart

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import '../delegates/camera_picker_text_delegate.dart';

export 'package:photo_manager/photo_manager.dart';

final class Constants {
const Constants._();
final class Singleton {
const Singleton._();

static CameraPickerTextDelegate textDelegate =
const CameraPickerTextDelegate();
Expand Down
11 changes: 5 additions & 6 deletions lib/src/states/camera_picker_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ import 'package:flutter/material.dart';
import 'package:flutter/semantics.dart';
import 'package:flutter/services.dart';
import 'package:sensors_plus/sensors_plus.dart';
import 'package:wechat_picker_library/wechat_picker_library.dart';

import '../constants/config.dart';
import '../constants/constants.dart';
import '../internals/singleton.dart';
import '../constants/enums.dart';
import '../constants/styles.dart';
import '../delegates/camera_picker_text_delegate.dart';
import '../internals/extensions.dart';
import '../internals/methods.dart';
import '../widgets/camera_focus_point.dart';
import '../widgets/camera_picker.dart';
Expand Down Expand Up @@ -204,9 +203,9 @@ class CameraPickerState extends State<CameraPicker>
/// If there's no theme provided from the user, use [CameraPicker.themeData] .
/// 如果用户未提供主题,通过 [CameraPicker.themeData] 创建。
late final ThemeData theme =
pickerConfig.theme ?? CameraPicker.themeData(wechatThemeColor);
pickerConfig.theme ?? CameraPicker.themeData(defaultThemeColorWeChat);

CameraPickerTextDelegate get textDelegate => Constants.textDelegate;
CameraPickerTextDelegate get textDelegate => Singleton.textDelegate;

/// If controller methods were failed to called for camera descriptions,
/// it will be recorded as invalid and never gets called again.
Expand All @@ -225,7 +224,7 @@ class CameraPickerState extends State<CameraPicker>
void initState() {
super.initState();
ambiguate(WidgetsBinding.instance)?.addObserver(this);
Constants.textDelegate = widget.pickerConfig.textDelegate ??
Singleton.textDelegate = widget.pickerConfig.textDelegate ??
cameraPickerTextDelegateFromLocale(widget.locale);
initCameras();
initAccelerometerSubscription();
Expand Down
19 changes: 9 additions & 10 deletions lib/src/states/camera_picker_viewer_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ import 'package:flutter/material.dart';
import 'package:flutter/semantics.dart';
import 'package:path/path.dart' as path;
import 'package:video_player/video_player.dart';
import 'package:wechat_picker_library/wechat_picker_library.dart';

import '../constants/constants.dart';
import '../internals/singleton.dart';
import '../constants/enums.dart';
import '../constants/styles.dart';
import '../constants/type_defs.dart';
import '../internals/extensions.dart';
import '../internals/methods.dart';
import '../widgets/camera_picker.dart';
import '../widgets/camera_picker_viewer.dart';
Expand All @@ -25,8 +24,8 @@ class CameraPickerViewerState extends State<CameraPickerViewer> {
/// 播放器是否在播放
final ValueNotifier<bool> isPlaying = ValueNotifier<bool>(false);

late final ThemeData theme =
widget.pickerConfig.theme ?? CameraPicker.themeData(wechatThemeColor);
late final ThemeData theme = widget.pickerConfig.theme ??
CameraPicker.themeData(defaultThemeColorWeChat);

/// Construct an [File] instance through [previewXFile].
/// 通过 [previewXFile] 构建 [File] 实例。
Expand Down Expand Up @@ -253,9 +252,9 @@ class CameraPickerViewerState extends State<CameraPickerViewer> {
}
return MergeSemantics(
child: Semantics(
label: Constants.textDelegate.sActionPreviewHint,
label: Singleton.textDelegate.sActionPreviewHint,
image: true,
onTapHint: Constants.textDelegate.sActionPreviewHint,
onTapHint: Singleton.textDelegate.sActionPreviewHint,
sortKey: const OrdinalSortKey(1),
child: builder,
),
Expand All @@ -276,7 +275,7 @@ class CameraPickerViewerState extends State<CameraPickerViewer> {
onPressed: createAssetEntityAndPop,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
child: Text(
Constants.textDelegate.confirm,
Singleton.textDelegate.confirm,
style: TextStyle(
color: theme.textTheme.bodyLarge?.color,
fontSize: 17,
Expand Down Expand Up @@ -352,7 +351,7 @@ class CameraPickerViewerState extends State<CameraPickerViewer> {
child: AnimatedOpacity(
duration: kThemeAnimationDuration,
opacity: isSavingEntity ? 1 : 0,
child: _WechatLoading(tip: Constants.textDelegate.saving),
child: _WechatLoading(tip: Singleton.textDelegate.saving),
),
);
}
Expand All @@ -362,7 +361,7 @@ class CameraPickerViewerState extends State<CameraPickerViewer> {
if (hasErrorWhenInitializing) {
return Center(
child: Text(
Constants.textDelegate.loadFailed,
Singleton.textDelegate.loadFailed,
style: const TextStyle(inherit: false),
),
);
Expand Down
41 changes: 0 additions & 41 deletions lib/src/widgets/builder/tween_animation_builder_2.dart

This file was deleted.

3 changes: 1 addition & 2 deletions lib/src/widgets/camera_focus_point.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
// in the LICENSE file.

import 'package:flutter/material.dart';

import 'builder/tween_animation_builder_2.dart';
import 'package:wechat_picker_library/wechat_picker_library.dart';

final class CameraFocusPoint extends StatelessWidget {
const CameraFocusPoint({
Expand Down
2 changes: 1 addition & 1 deletion lib/src/widgets/camera_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import '../constants/config.dart';
import '../constants/constants.dart';
import '../internals/singleton.dart';
import '../states/camera_picker_state.dart';

import 'camera_picker_page_route.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/widgets/camera_picker_viewer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:camera/camera.dart';
import 'package:flutter/material.dart';

import '../constants/config.dart';
import '../constants/constants.dart';
import '../internals/singleton.dart';
import '../constants/enums.dart';
import '../states/camera_picker_viewer_state.dart';

Expand Down
4 changes: 2 additions & 2 deletions lib/src/widgets/camera_progress_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// in the LICENSE file.

import 'package:flutter/material.dart';
import 'package:wechat_picker_library/wechat_picker_library.dart';

import '../constants/styles.dart';
import '../internals/methods.dart';

final class CameraProgressButton extends StatefulWidget {
Expand All @@ -14,7 +14,7 @@ final class CameraProgressButton extends StatefulWidget {
required this.isBusy,
required this.size,
required this.ringsWidth,
this.ringsColor = wechatThemeColor,
this.ringsColor = defaultThemeColorWeChat,
this.duration = const Duration(seconds: 15),
});

Expand Down
4 changes: 3 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: wechat_camera_picker
version: 4.2.0-dev.3
version: 4.2.0-dev.4
description: |
A camera picker for Flutter projects based on WeChat's UI,
which is also a separate runnable extension to the
Expand All @@ -22,6 +22,8 @@ dependencies:
flutter:
sdk: flutter

wechat_picker_library: ^1.0.0-0

camera: ^0.10.0
camera_platform_interface: ^2.1.5
path: ^1.8.0
Expand Down

0 comments on commit cc966c0

Please sign in to comment.