Skip to content

Commit

Permalink
minor code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
aldrinzigmundv committed Oct 13, 2023
1 parent 2f27bce commit 8fa83fd
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 45 deletions.
7 changes: 2 additions & 5 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ void main() {
// WidgetsFlutterBinding.ensureInitialized();
// MobileAds.instance.initialize();

runApp(MaterialApp(
runApp(const MaterialApp(
title: "Digilog TV",
initialRoute: '/',
routes: {
'/': (context) => const LoadingPage(),
},
home: LoadingPage(),
));
}
16 changes: 10 additions & 6 deletions lib/pages/channelpage-iptv.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ class _ChannelPageIPTVState extends State<ChannelPageIPTV> {

bool _appBarVisibility = true;

_setupVideoPlayerController() {
_videoPlayerController = VideoPlayerController.networkUrl(
Uri.parse(storage.channels.channelList[index].link))
..initialize().then((_) {
setState(() {});
_videoPlayerController.play();
});
}

_hideUnhideAppBar() {
setState(() {
_appBarVisibility = !_appBarVisibility;
Expand All @@ -50,12 +59,7 @@ class _ChannelPageIPTVState extends State<ChannelPageIPTV> {
index = widget.index;
storage = widget.storage;
WakelockPlus.enable();
_videoPlayerController = VideoPlayerController.networkUrl(
Uri.parse(storage.channels.channelList[index].link))
..initialize().then((_) {
setState(() {});
_videoPlayerController.play();
});
_setupVideoPlayerController();
}

@override
Expand Down
12 changes: 6 additions & 6 deletions lib/pages/home pages/channellistpage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class _ChannelListPageState extends State<ChannelListPage> {
// )..load();
// }

favoriteIcon(String channelName) {
_favoriteIcon(String channelName) {
if (!storage.favoritedChannels.contains(channelName)) {
return Icon(
Icons.star_border,
Expand All @@ -65,7 +65,7 @@ class _ChannelListPageState extends State<ChannelListPage> {
}
}

favoriteChange(int index) async {
_favoriteChange(int index) async {
if (storage.favoritedChannels
.contains(storage.channels.channelList[index].channelName)) {
setState(() {
Expand All @@ -81,7 +81,7 @@ class _ChannelListPageState extends State<ChannelListPage> {
await storage.saveChanges();
}

goToChannel(int index) {
_goToChannel(int index) {
if (storage.channels.channelList[index].source == Source.iptv) {
goToChannelPageIPTV(context: context, index: index, storage: storage);
} else {
Expand Down Expand Up @@ -128,7 +128,7 @@ class _ChannelListPageState extends State<ChannelListPage> {
return Padding(
padding: const EdgeInsets.all(3.0),
child: GestureDetector(
onTap: () => goToChannel(index),
onTap: () => _goToChannel(index),
child: Card(
child: Padding(
padding: const EdgeInsets.all(18.0),
Expand All @@ -151,11 +151,11 @@ class _ChannelListPageState extends State<ChannelListPage> {
)),
),
GestureDetector(
onTap: () => favoriteChange(index),
onTap: () => _favoriteChange(index),
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 9.0),
child: favoriteIcon(storage
child: _favoriteIcon(storage
.channels.channelList[index].channelName),
),
),
Expand Down
30 changes: 9 additions & 21 deletions lib/pages/home pages/contactpage.dart
Original file line number Diff line number Diff line change
@@ -1,28 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

class ContactPage extends StatelessWidget {
const ContactPage({super.key});

copyBitcoinAddress(BuildContext context) {
Clipboard.setData(const ClipboardData(
text: 'bc1qruus6vnxrww6pqac3hvg6vsepmqv8d66dwjm59'));
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text("Bitcoin Address copied to clipboard."),
duration: Duration(seconds: 2),
));
}

copyMoneroAddress(BuildContext context) {
Clipboard.setData(const ClipboardData(
text:
'86cQoPfKTJ2bRfGH5Ts2kzaXCRcVRiX8CUHKc9xmeUmQ8YM8Uzk9S97T5gQaqYu58C9wuFK7opDH7cM9EJyR4V5LAq9RGv4'));
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text("Monero Address copied to clipboard."),
duration: Duration(seconds: 2),
));
}

@override
Widget build(BuildContext context) {
return Center(
Expand Down Expand Up @@ -50,11 +30,19 @@ class ContactPage extends StatelessWidget {
const Padding(
padding: EdgeInsets.fromLTRB(18.0, 36.0, 18.0, 18.0),
child: Text(
'You have downloaded the ad-supported version of this app from Google Play. An ad-free version is available on GitHub. Other ads are provided by their respective TV news channels.',
'You have downloaded the ad-free version of this app. Other ads are provided by their respective TV news channels.',
style: TextStyle(fontSize: 18.0),
textAlign: TextAlign.center,
),
),
// const Padding(
// padding: EdgeInsets.fromLTRB(18.0, 36.0, 18.0, 18.0),
// child: Text(
// 'You have downloaded the ad-supported version of this app from Google Play. An ad-free version is available on GitHub. Other ads are provided by their respective TV news channels.',
// style: TextStyle(fontSize: 18.0),
// textAlign: TextAlign.center,
// ),
// ),
],
),
),
Expand Down
8 changes: 4 additions & 4 deletions lib/pages/home pages/favoritespage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class _FavoritesPageState extends State<FavoritesPage> {
// )..load();
// }

favoriteChange(int index) async {
_favoriteChange(int index) async {
setState(() {
storage.favoritedChannels
.remove(storage.arrangedChannelList[index].channelName);
Expand All @@ -60,7 +60,7 @@ class _FavoritesPageState extends State<FavoritesPage> {
await storage.saveChanges();
}

goToChannel(int index) {
_goToChannel(int index) {
if (storage.arrangedChannelList[index].source == Source.iptv) {
goToChannelPageIPTV(context: context, index: storage.channels.getIndexByChannelName(storage.arrangedChannelList[index].channelName), storage: storage);
} else {
Expand Down Expand Up @@ -109,7 +109,7 @@ class _FavoritesPageState extends State<FavoritesPage> {
return Padding(
padding: const EdgeInsets.all(3.0),
child: GestureDetector(
onTap: () => goToChannel(index),
onTap: () => _goToChannel(index),
child: Card(
child: Padding(
padding: const EdgeInsets.all(18.0),
Expand All @@ -134,7 +134,7 @@ class _FavoritesPageState extends State<FavoritesPage> {
)),
),
GestureDetector(
onTap: () => favoriteChange(index),
onTap: () => _favoriteChange(index),
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 9.0),
Expand Down
6 changes: 3 additions & 3 deletions lib/pages/loadingpage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class _LoadingPageState extends State<LoadingPage> {
final StorageProvider storage = StorageProvider();
final FormattingProvider formatingProvider = FormattingProvider();

startup() async {
_startup() async {
await storage.initialize();
Future.delayed(const Duration(seconds: 1), () async {
goToHomePage(
Expand All @@ -28,7 +28,7 @@ class _LoadingPageState extends State<LoadingPage> {
@override
void initState() {
super.initState();
startup();
_startup();
}

@override
Expand All @@ -40,7 +40,7 @@ class _LoadingPageState extends State<LoadingPage> {
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: EdgeInsets.all(9.0),
padding: const EdgeInsets.all(9.0),
child: Image.asset('assets/icons/icon.png')),
const Padding(
padding: EdgeInsets.all(9.0),
Expand Down

0 comments on commit 8fa83fd

Please sign in to comment.