-
-
Notifications
You must be signed in to change notification settings - Fork 149
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
Implements feature to influence position of camera controls in horizontal mode #209
base: main
Are you sure you want to change the base?
Conversation
…amera controls in horizontal mode based on the user's dominant hand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late review. I like the general idea.
@@ -5,3 +5,5 @@ | |||
/// Two types for the viewer: image and video. | |||
/// 两种预览类型:图片和视频 | |||
enum CameraPickerViewType { image, video } | |||
|
|||
enum DominantHand { left, right } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need docs here, make it as a template so the config can ref it directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please give me an example, as I'm not sure what to do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Define:
flutter_wechat_camera_picker/lib/src/constants/type_defs.dart
Lines 66 to 72 in 5370cca
/// {@template wechat_camera_picker.ForegroundBuilder} | |
/// Build the foreground/overlay widget with the given [CameraValue]. | |
/// 根据给定的 [CameraValue] 构建自定义的前景 widget | |
/// | |
/// The `controller` will be null until initialized. | |
/// 在 [CameraController] 完成初始化前,`controller` 将为空。 | |
/// {@endtemplate} |
Use:
/// {@macro wechat_camera_picker.ForegroundBuilder} |
@@ -1635,6 +1635,14 @@ class CameraPickerState extends State<CameraPicker> | |||
); | |||
} | |||
|
|||
TextDirection determineTextDirection(Enum orientation, DominantHand hand) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs too.
@@ -1635,6 +1635,14 @@ class CameraPickerState extends State<CameraPicker> | |||
); | |||
} | |||
|
|||
TextDirection determineTextDirection(Enum orientation, DominantHand hand) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use DeviceOrientation
instead of Enum
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was my initial thought too, but the code on line 1652 cause issues, specifically:
final orientation = deviceOrientation ?? MediaQuery.of(context).orientation
it's a bit tricky. deviceOrientation
is enum of type DeviceOrientation
, but MediaQuery.of(context).orientation
is enum of type Orientation
. The type for final orientation is therefore Enum
. DeviceOrientation
(four values) doesn't inherit from Orientation
(two values).
I realise now that my determineTextDirection
will crash if the MediaQuery
-method's values are returned. I'll update my code, and then await your feedback on this to see if I should refactor more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turn those values into string so you don't need an Enum
, like what we've already did.
@@ -1635,6 +1635,14 @@ class CameraPickerState extends State<CameraPicker> | |||
); | |||
} | |||
|
|||
TextDirection determineTextDirection(Enum orientation, DominantHand hand) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name determineTextDirection
was not straightforward to understand which part of UI it handles. Consider making it inlined or a more general name.
? TextDirection.rtl | ||
: TextDirection.ltr, | ||
textDirection: | ||
determineTextDirection(orientation, pickerConfig.dominantHand), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add the trailing comma here.
Tested using
Summary
This PR introduces an option for developers to align camera control widgets either to the left or right in horizontal mode for the
flutter_wechat_camera_picker
.Description
At present, the
flutter_wechat_camera_picker
positions its camera control widgets to the left when operated in horizontal mode. This alignment contrasts with the native iOS camera preview view, which aligns its controls to the right. It's possible that this leftward alignment might be the default for most WeChat-related components. I personally favor the native iOS style, with the controls on the right. Previously, the only workaround was to setcameraQuarterTurns
to2
, which would align the controls to the right but in an upside-down manner. This PR offers a more streamlined solution, enabling developers to decide the preferred alignment for the camera controls.