Skip to content

Commit

Permalink
chore: clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmercerind committed Oct 6, 2022
1 parent c5a832b commit f191683
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 263 deletions.
270 changes: 78 additions & 192 deletions lib/widgets/device_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import 'dart:io';
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:dart_vlc/dart_vlc.dart' hide Device;
import 'package:fijkplayer/fijkplayer.dart';
import 'package:status_bar_control/status_bar_control.dart';

Expand All @@ -35,9 +34,6 @@ class DeviceTile extends StatefulWidget {
final int tab;
final int index;

/// Taking [Player] as [Widget] argument to avoid disposition responsiblity & [Player] recreations due to UI re-draw.
final Player? libvlcPlayer;

final double width;
final double height;

Expand All @@ -46,7 +42,6 @@ class DeviceTile extends StatefulWidget {
required this.device,
required this.tab,
required this.index,
this.libvlcPlayer,
this.width = 640.0,
this.height = 360.0,
}) : super(key: key);
Expand Down Expand Up @@ -181,204 +176,95 @@ class DeviceTileState extends State<DeviceTile> {

@override
Widget build(BuildContext context) {
return isDesktop
? MouseRegion(
onEnter: (e) {
setState(() {
hover = true;
});
},
onExit: (e) {
setState(() {
hover = false;
});
},
child: Card(
color: Colors.transparent,
clipBehavior: Clip.antiAlias,
elevation: 4.0,
margin: EdgeInsets.zero,
key: PageStorageKey(widget.device.uri.hashCode),
child: Stack(
children: [
AnimatedScale(
scale: hover ? 1.05 : 1.0,
duration: const Duration(milliseconds: 200),
curve: Curves.easeInOut,
child: Video(
player: widget.libvlcPlayer,
showControls: false,
),
),
Positioned.fill(
child: AnimatedOpacity(
opacity: hover ? 1.0 : 0.0,
duration: const Duration(milliseconds: 200),
curve: Curves.easeInOut,
child: Container(
width: widget.width,
height: widget.height,
alignment: Alignment.bottomLeft,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Colors.transparent,
Colors.black.withOpacity(0.7),
],
stops: const [0.0, 0.8],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
),
child: AnimatedSlide(
offset: Offset(0, hover ? 0.0 : 1.0),
duration: const Duration(milliseconds: 200),
curve: Curves.easeInOut,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
children: [
const Icon(
Icons.camera_alt,
color: Colors.white,
size: 24.0,
),
const SizedBox(width: 16.0),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
widget.device.name
.split(' ')
.map((e) =>
e[0].toUpperCase() +
e.substring(1))
.join(' '),
style: Theme.of(context)
.textTheme
.headline1
?.copyWith(
color: Colors.white,
fontSize: 18.0,
),
),
Text(
widget.device.uri,
style: Theme.of(context)
.textTheme
.headline3
?.copyWith(
color: Colors.white70,
),
),
],
),
),
const SizedBox(width: 16.0),
],
),
),
),
return GestureDetectorWithReducedDoubleTapTime(
onTap: () {
setState(() {
hover = !hover;
});
},
// Fullscreen on double-tap.
onDoubleTap: () => Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => DeviceFullscreenViewer(
device: widget.device,
ijkPlayer: ijkPlayer,
),
),
),
child: ClipRect(
child: Stack(
children: [
ijkPlayer == null
? Container(
color: Colors.black,
width: double.infinity,
height: double.infinity,
)
: ijkView,
Positioned(
bottom: 0.0,
left: 0.0,
right: 0.0,
child: AnimatedSlide(
offset: Offset(0, hover ? 0.0 : 1.0),
duration: const Duration(milliseconds: 200),
curve: Curves.easeInOut,
child: Container(
height: 48.0,
alignment: Alignment.centerRight,
color: Colors.black26,
child: Row(
children: [
const SizedBox(width: 16.0),
const Icon(
Icons.camera_alt,
color: Colors.white,
size: 20.0,
),
),
),
],
),
),
)
: GestureDetectorWithReducedDoubleTapTime(
onTap: () {
setState(() {
hover = !hover;
});
},
// Fullscreen on double-tap.
onDoubleTap: () => Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => DeviceFullscreenViewer(
device: widget.device,
ijkPlayer: ijkPlayer,
),
),
),
child: ClipRect(
child: Stack(
children: [
ijkPlayer == null
? Container(
color: Colors.black,
width: double.infinity,
height: double.infinity,
)
: ijkView,
Positioned(
bottom: 0.0,
left: 0.0,
right: 0.0,
child: AnimatedSlide(
offset: Offset(0, hover ? 0.0 : 1.0),
duration: const Duration(milliseconds: 200),
curve: Curves.easeInOut,
child: Container(
height: 48.0,
alignment: Alignment.centerRight,
color: Colors.black26,
child: Row(
const SizedBox(width: 16.0),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(width: 16.0),
const Icon(
Icons.camera_alt,
color: Colors.white,
size: 20.0,
),
const SizedBox(width: 16.0),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.device.name
.split(' ')
.map((e) =>
e[0].toUpperCase() + e.substring(1))
.join(' '),
style: Theme.of(context)
.textTheme
.headline1
?.copyWith(
color: Colors.white,
fontSize: 14.0,
),
Text(
widget.device.name
.split(' ')
.map((e) =>
e[0].toUpperCase() + e.substring(1))
.join(' '),
style: Theme.of(context)
.textTheme
.headline1
?.copyWith(
color: Colors.white,
fontSize: 14.0,
),
Text(
widget.device.uri,
style: Theme.of(context)
.textTheme
.headline3
?.copyWith(
color: Colors.white70,
fontSize: 10.0,
),
),
Text(
widget.device.uri,
style: Theme.of(context)
.textTheme
.headline3
?.copyWith(
color: Colors.white70,
fontSize: 10.0,
),
],
),
),
const SizedBox(width: 16.0),
],
),
),
),
const SizedBox(width: 16.0),
],
),
],
),
),
),
);
],
),
),
);
}
}

Expand Down
Loading

0 comments on commit f191683

Please sign in to comment.