Compare commits
4 Commits
v1.0.21+21
...
v1.0.23+23
Author | SHA1 | Date | |
---|---|---|---|
189f9a6efd | |||
7130ad9817 | |||
c236049c0a | |||
003797981e |
@ -13,6 +13,13 @@ jobs:
|
||||
- name: checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: cache pub deps
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.pub-cache
|
||||
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.yaml') }}
|
||||
restore-keys: ${{ runner.os }}-pub-
|
||||
|
||||
- name: set up jdk
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
|
BIN
assets/images/music.webp
Normal file
BIN
assets/images/music.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 634 KiB |
@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'package:f0ckapp/mediagrid.dart';
|
||||
import 'package:f0ckapp/screens/MediaGrid.dart';
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
@ -1,9 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:f0ckapp/models/mediaitem.dart';
|
||||
import 'package:f0ckapp/services/api.dart';
|
||||
import 'package:f0ckapp/widgets/video_widget.dart';
|
||||
import 'package:f0ckapp/models/MediaItem.dart';
|
||||
import 'package:f0ckapp/services/Api.dart';
|
||||
import 'package:f0ckapp/widgets/VideoWidget.dart';
|
||||
import 'package:f0ckapp/utils/SmartRefreshIndicator.dart';
|
||||
import 'package:f0ckapp/utils/PageTransformer.dart';
|
||||
|
||||
class DetailView extends StatefulWidget {
|
||||
final int initialItemId;
|
||||
@ -109,20 +110,18 @@ class _DetailViewState extends State<DetailView> {
|
||||
title: Text('f0ck #$currentItemId (${widget.type})'),
|
||||
centerTitle: true,
|
||||
),
|
||||
body: PageView.builder(
|
||||
body: PageTransformer(
|
||||
controller: _pageController,
|
||||
itemCount: mediaItems.length,
|
||||
itemBuilder: (context, index) {
|
||||
final MediaItem item = mediaItems[index];
|
||||
pages: mediaItems.map((item) {
|
||||
return Scaffold(
|
||||
body: SafeArea(
|
||||
child: SmartRefreshIndicator(
|
||||
onRefresh: _refreshMediaItem,
|
||||
child: _buildMediaItem(item)
|
||||
child: _buildMediaItem(item),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
}).toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -130,6 +129,7 @@ class _DetailViewState extends State<DetailView> {
|
||||
Widget _buildMediaItem(MediaItem item) {
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
if (item.mime.startsWith('image'))
|
||||
CachedNetworkImage(
|
||||
@ -145,7 +145,7 @@ class _DetailViewState extends State<DetailView> {
|
||||
item.mime,
|
||||
style: const TextStyle(color: Colors.white, fontSize: 18),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
const SizedBox(height: 10, width: double.infinity),
|
||||
Wrap(
|
||||
alignment: WrapAlignment.center,
|
||||
spacing: 5.0,
|
||||
@ -155,7 +155,7 @@ class _DetailViewState extends State<DetailView> {
|
||||
backgroundColor: switch (tag.id) {
|
||||
1 => Colors.green,
|
||||
2 => Colors.red,
|
||||
_ => const Color(0xFF090909)
|
||||
_ => const Color(0xFF090909),
|
||||
},
|
||||
labelStyle: const TextStyle(color: Colors.white),
|
||||
);
|
@ -1,8 +1,8 @@
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:f0ckapp/services/api.dart';
|
||||
import 'package:f0ckapp/models/mediaitem.dart';
|
||||
import 'package:f0ckapp/screens/detailview.dart';
|
||||
import 'package:f0ckapp/services/Api.dart';
|
||||
import 'package:f0ckapp/models/MediaItem.dart';
|
||||
import 'package:f0ckapp/screens/DetailView.dart';
|
||||
import 'dart:async';
|
||||
|
||||
class MediaGrid extends StatefulWidget {
|
||||
@ -14,7 +14,7 @@ class MediaGrid extends StatefulWidget {
|
||||
|
||||
class _MediaGridState extends State<MediaGrid> {
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
final String _version = '1.0.21+21';
|
||||
final String _version = '1.0.23+23';
|
||||
List<MediaItem> mediaItems = [];
|
||||
bool isLoading = false;
|
||||
Timer? _debounceTimer;
|
||||
@ -252,7 +252,7 @@ class _MediaGridState extends State<MediaGrid> {
|
||||
CachedNetworkImage(
|
||||
imageUrl: item.thumbnailUrl,
|
||||
fit: BoxFit.cover,
|
||||
placeholder: (context, url) => CircularProgressIndicator(),
|
||||
placeholder: (context, url) => SizedBox.shrink(),
|
||||
errorWidget: (context, url, error) => Icon(Icons.error),
|
||||
),
|
||||
Align(
|
@ -1,7 +1,7 @@
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import 'package:f0ckapp/models/mediaitem.dart';
|
||||
import 'package:f0ckapp/models/MediaItem.dart';
|
||||
|
||||
Future<List<MediaItem>> fetchMedia({
|
||||
String? older,
|
42
lib/utils/PageTransformer.dart
Normal file
42
lib/utils/PageTransformer.dart
Normal file
@ -0,0 +1,42 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class PageTransformer extends StatelessWidget {
|
||||
final List<Widget> pages;
|
||||
final PageController controller;
|
||||
|
||||
const PageTransformer({
|
||||
super.key,
|
||||
required this.pages,
|
||||
required this.controller,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PageView.builder(
|
||||
controller: controller,
|
||||
itemCount: pages.length,
|
||||
itemBuilder: (context, index) {
|
||||
return _buildPage(pages[index], index);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPage(Widget page, int index) {
|
||||
return AnimatedBuilder(
|
||||
animation: controller,
|
||||
builder: (context, child) {
|
||||
double value = 1.0;
|
||||
if (controller.position.haveDimensions) {
|
||||
value = controller.page! - index;
|
||||
value = (1 - (value.abs() * 0.5)).clamp(0.0, 1.0);
|
||||
}
|
||||
return Transform(
|
||||
transform: Matrix4.identity()..scale(value, value),
|
||||
alignment: Alignment.center,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
child: page,
|
||||
);
|
||||
}
|
||||
}
|
@ -1,9 +1,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:video_player/video_player.dart';
|
||||
import 'package:cached_video_player_plus/cached_video_player_plus.dart';
|
||||
|
||||
class VideoControlsOverlay extends StatelessWidget {
|
||||
final VideoPlayerController controller;
|
||||
const VideoControlsOverlay({super.key, required this.controller});
|
||||
final CachedVideoPlayerPlusController controller;
|
||||
final VoidCallback button;
|
||||
|
||||
const VideoControlsOverlay({
|
||||
super.key,
|
||||
required this.controller,
|
||||
required this.button,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -15,22 +21,25 @@ class VideoControlsOverlay extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
_ControlButton(Icons.replay_10, () {
|
||||
button();
|
||||
controller.seekTo(
|
||||
controller.value.position - Duration(seconds: 10),
|
||||
);
|
||||
}),
|
||||
SizedBox(width: 32),
|
||||
SizedBox(width: 40),
|
||||
_ControlButton(
|
||||
controller.value.isPlaying ? Icons.pause : Icons.play_arrow,
|
||||
() {
|
||||
button();
|
||||
controller.value.isPlaying
|
||||
? controller.pause()
|
||||
: controller.play();
|
||||
},
|
||||
size: 64,
|
||||
),
|
||||
SizedBox(width: 32),
|
||||
SizedBox(width: 40),
|
||||
_ControlButton(Icons.forward_10, () {
|
||||
button();
|
||||
controller.seekTo(
|
||||
controller.value.position + Duration(seconds: 10),
|
||||
);
|
||||
@ -38,7 +47,7 @@ class VideoControlsOverlay extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
_ProgressIndicator(controller: controller),
|
||||
_ProgressIndicator(controller: controller)
|
||||
],
|
||||
);
|
||||
}
|
||||
@ -67,7 +76,8 @@ class _ControlButton extends StatelessWidget {
|
||||
}
|
||||
|
||||
class _ProgressIndicator extends StatelessWidget {
|
||||
final VideoPlayerController controller;
|
||||
final CachedVideoPlayerPlusController controller;
|
||||
|
||||
const _ProgressIndicator({required this.controller});
|
||||
|
||||
@override
|
||||
@ -77,20 +87,16 @@ class _ProgressIndicator extends StatelessWidget {
|
||||
child: Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
Container(
|
||||
height: 20,
|
||||
alignment: Alignment.bottomCenter,
|
||||
color: Colors.transparent,
|
||||
child: VideoProgressIndicator(
|
||||
VideoProgressIndicator(
|
||||
controller,
|
||||
allowScrubbing: true,
|
||||
padding: const EdgeInsets.only(top: 25.0),
|
||||
colors: VideoProgressColors(
|
||||
playedColor: Colors.red,
|
||||
backgroundColor: Colors.grey,
|
||||
bufferedColor: Colors.white54,
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
left:
|
||||
(controller.value.position.inMilliseconds /
|
||||
@ -123,8 +129,6 @@ class _ProgressIndicator extends StatelessWidget {
|
||||
|
||||
String _formatDuration(Duration duration) {
|
||||
String twoDigits(int n) => n.toString().padLeft(2, '0');
|
||||
final minutes = twoDigits(duration.inMinutes.remainder(60));
|
||||
final seconds = twoDigits(duration.inSeconds.remainder(60));
|
||||
return "$minutes:$seconds";
|
||||
return "${twoDigits(duration.inMinutes % 60)}:${twoDigits(duration.inSeconds % 60)}";
|
||||
}
|
||||
}
|
@ -1,10 +1,9 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:video_player/video_player.dart';
|
||||
import 'package:cached_video_player_plus/cached_video_player_plus.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:f0ckapp/models/mediaitem.dart';
|
||||
import 'package:f0ckapp/widgets/video_overlay.dart';
|
||||
import 'package:f0ckapp/models/MediaItem.dart';
|
||||
import 'package:f0ckapp/widgets/VideoOverlay.dart';
|
||||
import 'dart:async';
|
||||
|
||||
class VideoWidget extends StatefulWidget {
|
||||
final MediaItem details;
|
||||
@ -15,8 +14,9 @@ class VideoWidget extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _VideoWidgetState extends State<VideoWidget> {
|
||||
late VideoPlayerController _controller;
|
||||
late CachedVideoPlayerPlusController _controller;
|
||||
bool _showControls = false;
|
||||
Timer? _hideControlsTimer;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -25,7 +25,7 @@ class _VideoWidgetState extends State<VideoWidget> {
|
||||
}
|
||||
|
||||
Future<void> _initController() async {
|
||||
_controller = VideoPlayerController.networkUrl(
|
||||
_controller = CachedVideoPlayerPlusController.networkUrl(
|
||||
Uri.parse(widget.details.mediaUrl),
|
||||
);
|
||||
await _controller.initialize();
|
||||
@ -39,9 +39,23 @@ class _VideoWidgetState extends State<VideoWidget> {
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
_hideControlsTimer?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _onTap({bool ctrlButton = false}) {
|
||||
if (!ctrlButton) {
|
||||
setState(() => _showControls = !_showControls);
|
||||
}
|
||||
|
||||
if (_showControls) {
|
||||
_hideControlsTimer?.cancel();
|
||||
_hideControlsTimer = Timer(Duration(seconds: 5), () {
|
||||
setState(() => _showControls = false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
bool isAudio = widget.details.mime.startsWith('audio');
|
||||
@ -54,27 +68,24 @@ class _VideoWidgetState extends State<VideoWidget> {
|
||||
? _controller.value.aspectRatio
|
||||
: 9 / 16,
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
alignment: Alignment.topCenter,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_showControls = !_showControls;
|
||||
});
|
||||
},
|
||||
onTap: _onTap,
|
||||
child: isAudio
|
||||
? CachedNetworkImage(
|
||||
imageUrl: widget.details.coverUrl,
|
||||
fit: BoxFit.cover,
|
||||
placeholder: (context, url) =>
|
||||
CircularProgressIndicator(),
|
||||
errorWidget: (context, url, error) => Image.network(
|
||||
"https://f0ck.me/s/img/music.webp",
|
||||
errorWidget: (context, url, error) => Image.asset(
|
||||
'assets/images/music.webp',
|
||||
fit: BoxFit.contain,
|
||||
width: double.infinity
|
||||
),
|
||||
)
|
||||
: _controller.value.isInitialized
|
||||
? VideoPlayer(_controller)
|
||||
? CachedVideoPlayerPlus(_controller)
|
||||
: Center(child: CircularProgressIndicator()),
|
||||
),
|
||||
if (_controller.value.isInitialized && _showControls) ...[
|
||||
@ -86,7 +97,10 @@ class _VideoWidgetState extends State<VideoWidget> {
|
||||
height: double.infinity,
|
||||
),
|
||||
),
|
||||
VideoControlsOverlay(controller: _controller),
|
||||
VideoControlsOverlay(
|
||||
controller: _controller,
|
||||
button: () => _onTap(ctrlButton: true),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
32
pubspec.lock
32
pubspec.lock
@ -41,6 +41,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.1"
|
||||
cached_video_player_plus:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: cached_video_player_plus
|
||||
sha256: "451ee48bdbd28fac3d49b4389929c44d259b1def5be6dab0c5bfd3ae1f05e8b5"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.3"
|
||||
characters:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -152,6 +160,22 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
get:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: get
|
||||
sha256: c79eeb4339f1f3deffd9ec912f8a923834bec55f7b49c9e882b8fef2c139d425
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.7.2"
|
||||
get_storage:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: get_storage
|
||||
sha256: "39db1fffe779d0c22b3a744376e86febe4ade43bf65e06eab5af707dc84185a2"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
html:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -453,14 +477,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.0"
|
||||
video_player:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: video_player
|
||||
sha256: "7d78f0cfaddc8c19d4cb2d3bebe1bfef11f2103b0a03e5398b303a1bf65eeb14"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.9.5"
|
||||
video_player_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
# In Windows, build-name is used as the major, minor, and patch parts
|
||||
# of the product and file versions while build-number is used as the build suffix.
|
||||
version: 1.0.21+21
|
||||
version: 1.0.23+23
|
||||
|
||||
environment:
|
||||
sdk: ^3.9.0-100.2.beta
|
||||
@ -31,12 +31,12 @@ dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
http: ^1.4.0
|
||||
video_player: ^2.2.10
|
||||
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
cupertino_icons: ^1.0.8
|
||||
cached_network_image: ^3.4.1
|
||||
cached_video_player_plus: ^3.0.3
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
@ -61,7 +61,8 @@ flutter:
|
||||
uses-material-design: true
|
||||
|
||||
# To add assets to your application, add an assets section, like this:
|
||||
# assets:
|
||||
assets:
|
||||
- assets/images/
|
||||
# - images/a_dot_burr.jpeg
|
||||
# - images/a_dot_ham.jpeg
|
||||
|
||||
|
Reference in New Issue
Block a user