Skip to content

Commit

Permalink
feat: added in app update notification
Browse files Browse the repository at this point in the history
  • Loading branch information
reyyuuki committed Dec 1, 2024
1 parent b604abb commit f5f7f8c
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 63 deletions.
45 changes: 34 additions & 11 deletions lib/Screens/Bottom_Menu/_setting.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// ignore_for_file: prefer_const_constructors

import 'dart:io';

Expand All @@ -8,6 +9,7 @@ import 'package:azyx/Screens/settings/_theme_changer.dart';
import 'package:azyx/Screens/settings/download_settings.dart';
import 'package:azyx/auth/auth_provider.dart';
import 'package:azyx/components/Common/setting_tile.dart';
import 'package:azyx/utils/update_notifier.dart';
import 'package:flutter/material.dart';
import 'package:iconsax/iconsax.dart';
import 'package:ionicons/ionicons.dart';
Expand All @@ -29,19 +31,19 @@ class _SettingState extends State<Setting> {
@override
Widget build(BuildContext context) {
final provider = Provider.of<AniListProvider>(context, listen: false);

String userName = provider.userData['name'] ?? "Guest";
String image = provider.userData?['avatar']?['large'] ?? "";
return Scaffold(
backgroundColor: Theme.of(context).colorScheme.surface,
appBar: AppBar(
title: const Text("Settings",
style: TextStyle(fontFamily: "Poppins-Bold",fontSize: 20)),
style: TextStyle(fontFamily: "Poppins-Bold", fontSize: 20)),
leading: IconButton(
onPressed: () {
Navigator.pop(context);
},
iconSize: Platform.isAndroid ? 25 : 35,
iconSize: Platform.isAndroid || Platform.isIOS ? 25 : 35,
icon: const Icon(Icons.arrow_back_ios)),
centerTitle: true,
),
Expand Down Expand Up @@ -70,8 +72,8 @@ class _SettingState extends State<Setting> {
),
Text(
userName,
style: const TextStyle(
fontFamily: "Poppins-Bold", fontSize: 20),
style:
const TextStyle(fontFamily: "Poppins-Bold", fontSize: 20),
)
],
),
Expand Down Expand Up @@ -105,21 +107,42 @@ class _SettingState extends State<Setting> {
? const SizedBox(
height: 10,
)
: const SizedBox.shrink(),
const SettingTile(
: const SizedBox.shrink(),
const SettingTile(
icon: Icon(Ionicons.cloud_download_sharp),
name: "Download settings",
routeName: DownloadSettings(),
),
const SizedBox(height: 10,),
const SizedBox(
height: 10,
),
const SettingTile(
icon: Icon(Iconsax.info_circle),
name: "About",
routeName: About(),
),
// ElevatedButton(onPressed: (){
// fetchChapters("/title/124815/9016878");
// }, child: const Text("Fetch"))
const SizedBox(height: 10,),
Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surfaceContainerHigh,
borderRadius: BorderRadius.circular(10)),
child: ListTile(
title: Text(
"Check for updates",
style: const TextStyle(
fontFamily: "Poppins-Bold",
),
),
leading: Icon(Icons.update),
trailing: Transform.rotate(
angle: 3.14,
child: const Icon(Icons.arrow_back_ios),
),
onTap: () {
checkUpdate(context);
},
),
)
],
));
}
Expand Down
2 changes: 2 additions & 0 deletions lib/Screens/Home/_homepage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:azyx/components/Common/user_lists.dart';
import 'package:azyx/components/Common/Header.dart';
import 'package:azyx/components/Recently-added/animeCarousale.dart';
import 'package:azyx/components/Recently-added/mangaCarousale.dart';
import 'package:azyx/utils/update_notifier.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

Expand All @@ -25,6 +26,7 @@ class _HomePageState extends State<HomePage> {
super.initState();
if (mounted) {
data();
autoCheckUpdate(context);
}
}

Expand Down
51 changes: 3 additions & 48 deletions lib/components/Desktop/anime/desktop_details_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:developer';

import 'package:animated_segmented_tab_control/animated_segmented_tab_control.dart';
import 'package:azyx/components/Common/snackbar.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:azyx/Hive_Data/appDatabase.dart';
import 'package:azyx/Provider/sources_provider.dart';
Expand Down Expand Up @@ -1468,56 +1469,10 @@ class _DetailsState extends State<DesktopDetailsPage> {
listen: false)
.userData['name'] ==
null) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
"Whoa there! 🛑 You’re not logged in! Let’s fix that 😜",
style: TextStyle(
fontFamily: "Poppins-Bold",
fontSize: 16,
color: Theme.of(context)
.colorScheme
.inverseSurface,
)),
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(20),
),
backgroundColor: Theme.of(context)
.colorScheme
.surfaceContainer,
duration: const Duration(seconds: 2),
),
);
showSnackBar("Whoa there! 🛑 You’re not logged in! Let’s fix that 😜",context);
} else {
if (filteredEpisodes == null) {
ScaffoldMessenger.of(context)
.showSnackBar(
SnackBar(
content: Center(
child: Text(
'🍿 Hold tight! like a ninja... 🥷',
style: TextStyle(
fontSize: 16,
fontFamily: "Poppins-Bold",
color: Theme.of(context)
.colorScheme
.inverseSurface,
),
),
),
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(20),
),
backgroundColor: Theme.of(context)
.colorScheme
.surfaceBright,
duration: const Duration(seconds: 2),
),
);
showSnackBar("🍿 Hold tight! like a ninja... 🥷',", context);
} else {
addToList(context);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/components/Novel/novel_floater.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class _NovelFloaterState extends State<NovelFloater> {
),
const SizedBox(width: 8),
Text(
Platform.isAndroid ?
Platform.isAndroid || Platform.isIOS ?
(widget.currentChapterTitle.length > 15 ? "${widget.currentChapterTitle.substring(0,15)}..." : widget.currentChapterTitle) : (widget.currentChapterTitle.length > 40 ? "${widget.currentChapterTitle.substring(0,40)}..." : widget.currentChapterTitle),
style: TextStyle(
color: Theme.of(context).colorScheme.primary,
Expand Down
4 changes: 1 addition & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'dart:ui';

import 'package:azyx/Provider/sources_provider.dart';
import 'package:azyx/Screens/Bottom_Menu/_profile.dart';
import 'package:azyx/Screens/Bottom_Menu/_setting.dart';
Expand Down Expand Up @@ -44,7 +42,7 @@ void main() async {
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
SystemChrome.setSystemUIOverlayStyle(
const SystemUiOverlayStyle(systemNavigationBarColor: Colors.transparent));

runApp(MultiProvider(
providers: [
ChangeNotifierProvider(create: (_) => Data()),
Expand Down

0 comments on commit f5f7f8c

Please sign in to comment.