video controls prep
This commit is contained in:
parent
b97000e8e4
commit
dbb19e1f31
1 changed files with 67 additions and 62 deletions
|
@ -31,76 +31,81 @@ class VideoControlRow extends StatelessWidget {
|
||||||
return Selector<Settings, VideoControls>(
|
return Selector<Settings, VideoControls>(
|
||||||
selector: (context, s) => s.videoControls,
|
selector: (context, s) => s.videoControls,
|
||||||
builder: (context, videoControls, child) {
|
builder: (context, videoControls, child) {
|
||||||
switch (videoControls) {
|
final actions = _toActions(videoControls);
|
||||||
case VideoControls.play:
|
|
||||||
return Padding(
|
if (actions.isEmpty) {
|
||||||
padding: const EdgeInsets.only(left: padding),
|
|
||||||
child: _buildOverlayButton(
|
|
||||||
child: PlayToggler(
|
|
||||||
controller: controller,
|
|
||||||
onPressed: () => onActionSelected(EntryAction.videoTogglePlay),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
case VideoControls.playSeek:
|
|
||||||
return Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
textDirection: ViewerBottomOverlay.actionsDirection,
|
|
||||||
children: [
|
|
||||||
const SizedBox(width: padding),
|
|
||||||
_buildIconButton(
|
|
||||||
context,
|
|
||||||
EntryAction.videoReplay10,
|
|
||||||
borderRadius: const BorderRadius.only(topLeft: radius, bottomLeft: radius),
|
|
||||||
),
|
|
||||||
_buildOverlayButton(
|
|
||||||
child: PlayToggler(
|
|
||||||
controller: controller,
|
|
||||||
onPressed: () => onActionSelected(EntryAction.videoTogglePlay),
|
|
||||||
),
|
|
||||||
borderRadius: const BorderRadius.all(Radius.zero),
|
|
||||||
),
|
|
||||||
_buildIconButton(
|
|
||||||
context,
|
|
||||||
EntryAction.videoSkip10,
|
|
||||||
borderRadius: const BorderRadius.only(topRight: radius, bottomRight: radius),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
case VideoControls.playOutside:
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.only(left: padding),
|
|
||||||
child: _buildIconButton(context, EntryAction.openVideo, enabled: !entry.trashed),
|
|
||||||
);
|
|
||||||
case VideoControls.none:
|
|
||||||
return const SizedBox();
|
return const SizedBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (actions.length == 1) {
|
||||||
|
final action = actions.first;
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(left: padding),
|
||||||
|
child: _buildOverlayButton(context, action),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(left: padding),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
textDirection: ViewerBottomOverlay.actionsDirection,
|
||||||
|
children: actions.map((action) {
|
||||||
|
var borderRadius = const BorderRadius.all(Radius.zero);
|
||||||
|
if (action == actions.first) {
|
||||||
|
borderRadius = const BorderRadius.only(topLeft: radius, bottomLeft: radius);
|
||||||
|
} else if (action == actions.last) {
|
||||||
|
borderRadius = const BorderRadius.only(topRight: radius, bottomRight: radius);
|
||||||
|
}
|
||||||
|
return _buildOverlayButton(context, action, borderRadius: borderRadius);
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildOverlayButton({
|
List<EntryAction> _toActions(VideoControls videoControls) {
|
||||||
|
switch (videoControls) {
|
||||||
|
case VideoControls.play:
|
||||||
|
return [EntryAction.videoTogglePlay];
|
||||||
|
case VideoControls.playSeek:
|
||||||
|
return [
|
||||||
|
EntryAction.videoReplay10,
|
||||||
|
EntryAction.videoTogglePlay,
|
||||||
|
EntryAction.videoSkip10,
|
||||||
|
];
|
||||||
|
case VideoControls.playOutside:
|
||||||
|
return [EntryAction.openVideo];
|
||||||
|
case VideoControls.none:
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildOverlayButton(
|
||||||
|
BuildContext context,
|
||||||
|
EntryAction action, {
|
||||||
BorderRadius? borderRadius,
|
BorderRadius? borderRadius,
|
||||||
required Widget child,
|
}) {
|
||||||
}) =>
|
Widget child;
|
||||||
OverlayButton(
|
if (action == EntryAction.videoTogglePlay) {
|
||||||
|
child = PlayToggler(
|
||||||
|
controller: controller,
|
||||||
|
onPressed: () => onActionSelected(action),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
final enabled = action == EntryAction.openVideo ? !entry.trashed : true;
|
||||||
|
child = IconButton(
|
||||||
|
icon: action.getIcon(),
|
||||||
|
onPressed: enabled ? () => onActionSelected(action) : null,
|
||||||
|
tooltip: action.getText(context),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return OverlayButton(
|
||||||
scale: scale,
|
scale: scale,
|
||||||
borderRadius: borderRadius,
|
borderRadius: borderRadius,
|
||||||
child: child,
|
child: child,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
Widget _buildIconButton(
|
|
||||||
BuildContext context,
|
|
||||||
EntryAction action, {
|
|
||||||
bool enabled = true,
|
|
||||||
BorderRadius? borderRadius,
|
|
||||||
}) =>
|
|
||||||
_buildOverlayButton(
|
|
||||||
borderRadius: borderRadius,
|
|
||||||
child: IconButton(
|
|
||||||
icon: action.getIcon(),
|
|
||||||
onPressed: enabled ? () => onActionSelected(action) : null,
|
|
||||||
tooltip: action.getText(context),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue