Skip to content

Commit

Permalink
feat: comply with apple's guidelines (part 1)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdlukaa committed Dec 8, 2023
1 parent 739ecf6 commit a281dee
Show file tree
Hide file tree
Showing 15 changed files with 149 additions and 98 deletions.
1 change: 1 addition & 0 deletions lib/providers/downloads_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ class DownloadsManager extends ChangeNotifier {
headers: {HttpHeaders.acceptEncodingHeader: '*'}, // disable gzip
),
onReceiveProgress: (received, total) {
// TODO(bdlukaa): update window progress bar
if (total != -1) {
downloading[event] = received / total;
notifyListeners();
Expand Down
114 changes: 67 additions & 47 deletions lib/utils/widgets/tree_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,55 +18,75 @@ Widget buildCheckbox({
double checkboxScale = 0.8,
FlexFit textFit = FlexFit.loose,
}) {
final checkbox = Transform.scale(
scale: checkboxScale,
child: Checkbox(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
visualDensity: const VisualDensity(horizontal: -4, vertical: -4),
splashRadius: 0.0,
tristate: true,
value: value,
isError: isError,
onChanged: onChanged,
),
);

return Builder(builder: (context) {
final theme = Theme.of(context);
return Row(children: [
checkbox,
Expanded(
child: MouseRegion(
cursor: SystemMouseCursors.click,
child: GestureDetector(
onTap: () {
onChanged(value == null ? true : !value);
},
child: Row(children: [
SizedBox(width: gapCheckboxText),
Flexible(
fit: textFit,
child: Text(
text,
overflow: TextOverflow.ellipsis,
maxLines: 1,
softWrap: false,
style: TextStyle(
decoration: isError ? TextDecoration.lineThrough : null,
),
),
final loc = AppLocalizations.of(context);
final checkbox = SizedBox.fromSize(
size: const Size(24.0, 24.0),
child: isError
? Tooltip(
message: loc.offline,
child: Icon(
Icons.videocam_off_outlined,
size: 16.0,
color: theme.colorScheme.error,
),
)
: Transform.scale(
scale: checkboxScale,
child: Checkbox.adaptive(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
visualDensity:
const VisualDensity(horizontal: -4, vertical: -4),
splashRadius: 0.0,
tristate: true,
value: value,
isError: isError,
onChanged: onChanged,
side:
isError ? BorderSide(color: theme.colorScheme.error) : null,
),
if (secondaryText != null)
Text(
secondaryText,
style: theme.textTheme.labelSmall,
),
);

return SizedBox(
height: isError ? 18.0 : 24.0,
child: Row(children: [
checkbox,
Expanded(
child: MouseRegion(
cursor: SystemMouseCursors.click,
child: GestureDetector(
onTap: () {
onChanged(value == null ? true : !value);
},
child: Row(children: [
SizedBox(width: gapCheckboxText),
Flexible(
fit: textFit,
child: Text(
text,
overflow: TextOverflow.ellipsis,
maxLines: 1,
softWrap: false,
style: TextStyle(
color: isError ? theme.colorScheme.error : null,
// decoration: isError ? TextDecoration.lineThrough : null,
),
),
),
const SizedBox(width: 10.0),
]),
if (secondaryText != null)
Text(
secondaryText,
style: theme.textTheme.labelSmall,
),
const SizedBox(width: 10.0),
]),
),
),
),
)
]);
)
]),
);
});
}

Expand Down Expand Up @@ -228,12 +248,12 @@ class _NodeWidgetState extends State<NodeWidget> {
Row(children: [
if (!_isLeaf && _isEnabled)
Padding(
padding: const EdgeInsetsDirectional.only(start: 8.0),
padding: const EdgeInsetsDirectional.only(start: 8.0, end: 4.0),
child: Tooltip(
message: _isExpanded ? loc.collapse : loc.expand,
child: InkWell(
onTap: onIconPressed,
borderRadius: BorderRadius.circular(100),
borderRadius: BorderRadius.circular(6.0),
child: Padding(
padding: const EdgeInsetsDirectional.all(4.5),
child: Icon(icon, size: widget.iconSize),
Expand All @@ -243,7 +263,7 @@ class _NodeWidgetState extends State<NodeWidget> {
)
// If it is not leaf nor enabled, mimic the space of the icon button
else if (!_isLeaf && !_isEnabled)
const SizedBox(width: 35.0),
const SizedBox(width: 39.0),
Expanded(child: widget.treeNode.content),
]),
if (_isExpanded && !_isLeaf)
Expand Down
24 changes: 10 additions & 14 deletions lib/utils/window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,17 @@ const kInitialWindowSize = Size(1066, 645);
/// Configures the current window
Future<void> configureWindow() async {
await WindowManager.instance.ensureInitialized();
windowManager.waitUntilReadyToShow().then((_) async {
await windowManager.setTitleBarStyle(
TitleBarStyle.hidden,
windowManager.waitUntilReadyToShow(
const WindowOptions(
minimumSize: kDebugMode ? Size(100, 100) : kInitialWindowSize,
skipTaskbar: false,
titleBarStyle: TitleBarStyle.hidden,
windowButtonVisibility: true,
);
// await windowManager.setMinimumSize(kInitialWindowSize);
if (kDebugMode) {
await windowManager.setMinimumSize(const Size(100, 100));
} else {
await windowManager.setSize(kInitialWindowSize);
}
// await windowManager.center();
await windowManager.setSkipTaskbar(false);
await windowManager.show();
});
),
() async {
await windowManager.show();
},
);
}

/// Configures the camera sub window
Expand Down
37 changes: 21 additions & 16 deletions lib/widgets/desktop_buttons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,20 +151,24 @@ class _WindowButtonsState extends State<WindowButtons> with WindowListener {
child: Row(children: [
if (isMacOSPlatform) const SizedBox(width: 70.0, height: 40.0),
if (canPop)
InkWell(
onTap: () async {
await widget.onBack?.call();
await navigatorKey.currentState?.maybePop();
if (mounted) setState(() {});
},
child: Container(
height: 40.0,
width: 40.0,
alignment: AlignmentDirectional.center,
child: Icon(
Icons.arrow_back,
size: 20.0,
color: theme.hintColor,
Padding(
padding: const EdgeInsetsDirectional.only(start: 8.0),
child: SquaredIconButton(
onPressed: () async {
await widget.onBack?.call();
await navigatorKey.currentState?.maybePop();
if (mounted) setState(() {});
},
icon: Container(
padding: const EdgeInsetsDirectional.all(4.0),
// height: 40.0,
// width: 40.0,
alignment: AlignmentDirectional.center,
child: Icon(
Icons.adaptive.arrow_back,
size: 20.0,
color: theme.hintColor,
),
),
),
)
Expand Down Expand Up @@ -318,15 +322,16 @@ class _UnityLoadingIndicatorState extends State<UnityLoadingIndicator> {
return LayoutBuilder(builder: (context, constraints) {
final willFitY = constraints.maxHeight - (pos.dy + box.size.height) >
CurrentTasks.width;
const margin = 12.0;

return Stack(children: [
Positioned(
top: willFitY ? pos.dy + box.size.height : null,
bottom: willFitY ? null : constraints.maxHeight - pos.dy + 1.0,
left: clampDouble(
pos.dx - (CurrentTasks.width / 2),
0,
constraints.maxWidth,
margin,
constraints.maxWidth - CurrentTasks.width - margin,
),
child: const CurrentTasks(),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/device_grid/desktop/stream_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class _StreamDataState extends State<StreamData> {
),
style: theme.textTheme.headlineSmall,
),
Slider(
Slider.adaptive(
value: widget.video.player.volume,
onChanged: (v) {
widget.video.player.setVolume(v);
Expand Down
7 changes: 7 additions & 0 deletions lib/widgets/downloads_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import 'package:bluecherry_client/utils/theme.dart';
import 'package:bluecherry_client/utils/widgets/squared_icon_button.dart';
import 'package:bluecherry_client/utils/window.dart';
import 'package:bluecherry_client/widgets/misc.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
Expand Down Expand Up @@ -359,6 +360,12 @@ class DownloadProgressIndicator extends StatelessWidget {
Widget build(BuildContext context) {
final theme = Theme.of(context);

if (isCupertino) {
return CupertinoActivityIndicator.partiallyRevealed(
progress: progress,
);
}

return Stack(children: [
Padding(
padding: const EdgeInsetsDirectional.all(8.0),
Expand Down
7 changes: 4 additions & 3 deletions lib/widgets/events/event_player_desktop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,14 @@ class _EventPlayerDesktopState extends State<EventPlayerDesktop> {
),
padd,
Expanded(
child: Slider(
child: Slider.adaptive(
value: (_position ?? pos.inMilliseconds)
.clamp(0.0, duration.inMilliseconds)
.toDouble(),
max: duration.inMilliseconds.toDouble(),
secondaryTrackValue: videoController
.currentBuffer.inMilliseconds
.clamp(0.0, duration.inMilliseconds)
.toDouble(),
onChangeStart: (v) {
shouldAutoplay = videoController.isPlaying;
Expand Down Expand Up @@ -298,7 +299,7 @@ class _EventPlayerDesktopState extends State<EventPlayerDesktop> {
const SizedBox(width: 6.0),
SizedBox(
width: kSliderControlerWidth,
child: Slider(
child: Slider.adaptive(
value: volume,
onChanged: (v) {
setState(() => volume = v);
Expand All @@ -315,7 +316,7 @@ class _EventPlayerDesktopState extends State<EventPlayerDesktop> {
Text(loc.speed(speed.toStringAsFixed(2))),
SizedBox(
width: kSliderControlerWidth,
child: Slider(
child: Slider.adaptive(
value: speed,
min: 0.25,
max: 2,
Expand Down
20 changes: 17 additions & 3 deletions lib/widgets/events/event_player_mobile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,21 @@ class _VideoViewportState extends State<VideoViewport> {
top: MediaQuery.paddingOf(context).top,
child: SafeArea(
child: Row(children: [
const BackButton(),
// const BackButton(),
Padding(
padding: const EdgeInsetsDirectional.only(start: 8.0),
child: SquaredIconButton(
onPressed: Navigator.of(context).pop,
icon: Container(
padding: const EdgeInsetsDirectional.all(4.0),
child: Icon(
Icons.adaptive.arrow_back,
size: 20.0,
color: theme.hintColor,
),
),
),
),
Expanded(
child: Text(
'${widget.event.deviceName} (${widget.event.server.name})',
Expand Down Expand Up @@ -300,7 +314,7 @@ class _VideoViewportState extends State<VideoViewport> {
enabledThumbRadius: 6.0,
),
),
child: Slider(
child: Slider.adaptive(
label: player.position.humanReadableCompact(context),
value: player.position.inMilliseconds.toDouble(),
max: player.duration.inMilliseconds.toDouble(),
Expand Down Expand Up @@ -382,7 +396,7 @@ class __DesktopVideoViewportState extends State<_DesktopVideoViewport> {
style: theme.textTheme.bodyMedium!.copyWith(color: Colors.white),
),
Expanded(
child: Slider(
child: Slider.adaptive(
value: widget.player.currentPos.inMilliseconds.toDouble(),
max: widget.player.duration.inMilliseconds.toDouble(),
secondaryTrackValue:
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/events_timeline/desktop/timeline.dart
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ class _TimelineEventsViewState extends State<TimelineEventsView> {
),
ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 120.0),
child: Slider(
child: Slider.adaptive(
value: _speed ?? timeline.speed,
min: 0.5,
max: 2.0,
Expand Down Expand Up @@ -580,7 +580,7 @@ class _TimelineEventsViewState extends State<TimelineEventsView> {
child: Row(children: [
ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 120.0),
child: Slider(
child: Slider.adaptive(
value:
_volume ?? (timeline.isMuted ? 0.0 : timeline.volume),
onChanged: (v) => setState(() => _volume = v),
Expand Down
1 change: 1 addition & 0 deletions lib/widgets/servers/add_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Widget _buildCardAppBar({
}) {
return Builder(builder: (context) {
final theme = Theme.of(context);

return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/settings/desktop/updates.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class BetaFeatures extends StatelessWidget {
final settings = context.watch<SettingsProvider>();

return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
CheckboxListTile(
CheckboxListTile.adaptive(
secondary: CircleAvatar(
backgroundColor: Colors.transparent,
foregroundColor: theme.iconTheme.color,
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/settings/mobile/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class _MobileSettingsState extends State<MobileSettings> {
),
),
children: UnityVideoFit.values.map((e) {
return RadioListTile(
return RadioListTile<UnityVideoFit>.adaptive(
contentPadding: const EdgeInsetsDirectional.only(
start: 68.0,
end: 16.0,
Expand Down
Loading

0 comments on commit a281dee

Please sign in to comment.