Skip to content

Commit 3d3f0d3

Browse files
Merge branch 'dev'
2 parents 59d78bd + 2ec78ee commit 3d3f0d3

10 files changed

Lines changed: 294 additions & 285 deletions

File tree

taletime/lib/listener/screens/detailed_playlist_page.dart

Lines changed: 106 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -19,117 +19,121 @@ class DetailedPlaylistPage extends StatefulWidget {
1919
}
2020

2121
class _DetailedPlaylistPageState extends State<DetailedPlaylistPage> {
22-
23-
2422
@override
2523
Widget build(BuildContext context) {
2624
return StreamBuilder(
27-
stream: Provider.of<ProfileState>(context).playlistsRef!.doc(widget.playlistId).snapshots(),
28-
builder: (context, playlistSnap) {
29-
var playlist = playlistSnap.data?.data();
25+
stream: Provider.of<ProfileState>(context)
26+
.playlistsRef!
27+
.doc(widget.playlistId)
28+
.snapshots(),
29+
builder: (context, playlistSnap) {
30+
var playlist = playlistSnap.data?.data();
3031

31-
if (playlist == null) {
32-
return const Center(child: CircularProgressIndicator(),);
33-
}
34-
35-
return Scaffold(
36-
appBar: AppBar(
37-
title: Text(playlist.title ?? AppLocalizations.of(context)!.noTitle,
38-
style: const TextStyle(fontSize: 24, color: Colors.white)),
39-
actions: [
40-
PopupMenuButton(
41-
offset: const Offset(0, 40),
42-
icon: const Icon(Icons.more_vert),
43-
itemBuilder: (context) => [
44-
PopupMenuItem(
45-
onTap: () {
46-
Navigator.push(
47-
context,
48-
MaterialPageRoute(
49-
builder: (context) => EditPlaylistPage(
50-
playlist: playlist,
32+
if (playlist == null) {
33+
return const Center(
34+
child: CircularProgressIndicator(),
35+
);
36+
}
37+
38+
return Scaffold(
39+
appBar: AppBar(
40+
title: Text(
41+
playlist.title ?? AppLocalizations.of(context)!.noTitle,
42+
style: const TextStyle(fontSize: 24, color: Colors.white)),
43+
actions: [
44+
PopupMenuButton(
45+
offset: const Offset(0, 40),
46+
icon: const Icon(Icons.more_vert),
47+
itemBuilder: (context) => [
48+
PopupMenuItem(
49+
onTap: () {
50+
Navigator.push(
51+
context,
52+
MaterialPageRoute(
53+
builder: (context) => EditPlaylistPage(
54+
playlist: playlist,
55+
),
5156
),
52-
),
53-
);
54-
},
55-
value: AppLocalizations.of(context)!.edit,
56-
child: Text(AppLocalizations.of(context)!.edit),
57+
);
58+
},
59+
value: AppLocalizations.of(context)!.edit,
60+
child: Text(AppLocalizations.of(context)!.edit),
61+
),
62+
PopupMenuItem(
63+
onTap: () {
64+
Provider.of<ProfileState>(context, listen: false)
65+
.playlistsRef
66+
?.doc(playlist.id)
67+
.delete();
68+
Navigator.pop(context);
69+
},
70+
value: AppLocalizations.of(context)!.delete,
71+
child: Text(AppLocalizations.of(context)!.delete),
72+
),
73+
],
74+
),
75+
],
76+
),
77+
body: Padding(
78+
padding: const EdgeInsets.all(8.0),
79+
child: Column(
80+
mainAxisAlignment: MainAxisAlignment.start,
81+
crossAxisAlignment: CrossAxisAlignment.start,
82+
children: [
83+
Text(
84+
playlist.description ??
85+
AppLocalizations.of(context)!.noDescriptionAvailable,
86+
textAlign: TextAlign.left,
87+
softWrap: true,
88+
style: const TextStyle(fontSize: 16, color: Colors.black45),
5789
),
58-
PopupMenuItem(
59-
onTap: () {
60-
Provider.of<ProfileState>(context, listen: false)
61-
.playlistsRef
62-
?.doc(playlist.id)
63-
.delete();
64-
Navigator.pop(context);
65-
},
66-
value: AppLocalizations.of(context)!.delete,
67-
child: Text(AppLocalizations.of(context)!.delete),
90+
const SizedBox(width: 8.0),
91+
Text(AppLocalizations.of(context)!.stories,
92+
textAlign: TextAlign.center,
93+
style:
94+
const TextStyle(fontSize: 24, color: Colors.black)),
95+
Expanded(
96+
child: ListView.builder(
97+
itemCount: playlist.stories != null
98+
? playlist.stories!.length
99+
: 0,
100+
itemBuilder: (context, index) {
101+
return Padding(
102+
padding: const EdgeInsets.all(8.0),
103+
child: StoryListItem(
104+
story: playlist.stories![index],
105+
buttons: [
106+
StoryActionButton(
107+
icon: Icons.play_arrow,
108+
onTap: () {
109+
if (playlist.stories == null) return;
110+
if (audioHandler.customState.value
111+
is CustomPlayerState) {
112+
var state = audioHandler.customState.value
113+
as CustomPlayerState;
114+
state.setPlaylist(playlist.stories!);
115+
state.currentStoryPlayed = index;
116+
}
117+
StoryPlayer.playStory(
118+
context, playlist.stories![index]);
119+
120+
Navigator.of(context).push(
121+
MaterialPageRoute(
122+
builder: (context) => const StoryPlayer(),
123+
),
124+
);
125+
},
126+
),
127+
],
128+
),
129+
);
130+
},
131+
),
68132
),
69133
],
70134
),
71-
],
72-
),
73-
body: Padding(
74-
padding: const EdgeInsets.all(8.0),
75-
child: Column(
76-
mainAxisAlignment: MainAxisAlignment.start,
77-
crossAxisAlignment: CrossAxisAlignment.start,
78-
children: [
79-
Text(
80-
playlist.description ??
81-
AppLocalizations.of(context)!.noDescriptionAvailable,
82-
textAlign: TextAlign.left,
83-
softWrap: true,
84-
style: const TextStyle(fontSize: 16, color: Colors.black45),
85-
),
86-
const SizedBox(width: 8.0),
87-
Text(AppLocalizations.of(context)!.stories,
88-
textAlign: TextAlign.center,
89-
style: const TextStyle(fontSize: 24, color: Colors.black)),
90-
Expanded(
91-
child: ListView.builder(
92-
93-
itemCount:
94-
playlist.stories != null ? playlist.stories!.length : 0,
95-
itemBuilder: (context, index) {
96-
return Padding(
97-
padding: const EdgeInsets.all(8.0),
98-
child: StoryListItem(
99-
story: playlist.stories![index],
100-
buttons: [
101-
StoryActionButton(
102-
icon: Icons.play_arrow,
103-
onTap: () {
104-
if (playlist.stories == null) return;
105-
if (audioHandler.customState.value
106-
is CustomPlayerState) {
107-
var state = audioHandler.customState.value
108-
as CustomPlayerState;
109-
state.setPlaylist(playlist.stories!);
110-
state.currentStoryPlayed = index;
111-
}
112-
StoryPlayer.playStory(
113-
context, playlist.stories![index]);
114-
115-
Navigator.of(context).push(
116-
MaterialPageRoute(
117-
builder: (context) => const StoryPlayer(),
118-
),
119-
);
120-
},
121-
),
122-
],
123-
),
124-
);
125-
},
126-
),
127-
),
128-
],
129135
),
130-
),
131-
);
132-
}
133-
);
136+
);
137+
});
134138
}
135139
}

taletime/lib/listener/utils/navbar_widget_listener.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import "package:taletime/common/models/added_story.dart";
55
import "package:taletime/common/models/story.dart";
66
import "package:taletime/internationalization/localizations_ext.dart";
77

8-
import "../../settings/settings.dart";
98
import "../../state/profile_state.dart";
109
import "../screens/add_story_page.dart";
1110
import "../screens/favorites_page.dart";
@@ -79,8 +78,7 @@ class _NavBarListenerState extends State<NavBarListener> {
7978
),
8079
navBarItems(
8180
Icons.favorite_sharp, AppLocalizations.of(context)!.favorites),
82-
navBarItems(
83-
Icons.add, AppLocalizations.of(context)!.addStory),
81+
navBarItems(Icons.add, AppLocalizations.of(context)!.addStory),
8482
navBarItems(Icons.playlist_add_circle,
8583
AppLocalizations.of(context)!.playlists),
8684
],

taletime/lib/listener/utils/playlist_list.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ class PlaylistList extends StatelessWidget {
6666
),
6767
Text(
6868
playlist.description ??
69-
AppLocalizations.of(context)!.noDescriptionAvailable,
69+
AppLocalizations.of(context)!
70+
.noDescriptionAvailable,
7071
softWrap: true,
7172
overflow: TextOverflow.fade,
7273
style: const TextStyle(

taletime/lib/login and registration/utils/authentification_util.dart

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,14 @@ class AuthentificationUtil {
4141
content: Text(AppLocalizations.of(context)!.signInSuccesful),
4242
backgroundColor: kPrimaryColor);
4343
ScaffoldMessenger.of(context).showSnackBar(signinSuccesful);
44-
Navigator.of(context).pushReplacement(MaterialPageRoute(
44+
Navigator.of(context).pushAndRemoveUntil(
45+
MaterialPageRoute(
4546
builder: (context) => ProfilesPage(
46-
redirectTo: redirectTo,
47-
)));
47+
redirectTo: redirectTo,
48+
),
49+
),
50+
(route) => false,
51+
);
4852
}
4953
} on FirebaseAuthException catch (e) {
5054
final SnackBar snackBar = ErrorUtil().showLoginError(e, context);
@@ -86,10 +90,14 @@ class AuthentificationUtil {
8690

8791
addUserInfoToDB(auth.currentUser!.uid, userInfoMap);
8892

89-
Navigator.of(context).pushReplacement(MaterialPageRoute(
93+
Navigator.of(context).pushAndRemoveUntil(
94+
MaterialPageRoute(
9095
builder: (context) => ProfilesPage(
91-
redirectTo: redirectTo,
92-
)));
96+
redirectTo: redirectTo,
97+
),
98+
),
99+
(route) => false,
100+
);
93101
}
94102
} on FirebaseAuthException catch (e) {
95103
final SnackBar snackBar = ErrorUtil().showRegisterError(e, context);

taletime/lib/main.dart

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ import "package:flutter/material.dart";
55
import "package:flutter_localizations/flutter_localizations.dart";
66
import "package:flutter_native_splash/flutter_native_splash.dart";
77
import "package:flutter_web_plugins/url_strategy.dart";
8-
import "package:go_router/go_router.dart";
98
import "package:provider/provider.dart";
109
import "package:taletime/common%20utils/theme_provider.dart";
1110
import "package:taletime/internationalization/l10n.dart";
1211
import "package:taletime/internationalization/locale_provider.dart";
1312
import "package:taletime/login%20and%20registration/screens/welcome.dart";
14-
import 'package:taletime/player/services/audio_handler.dart';
13+
import "package:taletime/player/services/audio_handler.dart";
1514
import "package:taletime/profiles/screens/profiles_page.dart";
1615
import "package:taletime/share/screens/shared_story.dart";
1716
import "package:taletime/state/profile_state.dart";
@@ -92,21 +91,22 @@ class Providers extends StatelessWidget {
9291
final languageProvider = Provider.of<LocaleProvider>(context);
9392
final themeProvider = Provider.of<ThemeProvider>(context);
9493

95-
return MaterialApp.router(
96-
routerConfig: GoRouter(
97-
routes: [
98-
GoRoute(
99-
path: "/",
100-
builder: (_, __) => HomePage(),
101-
routes: [
102-
GoRoute(
103-
path: "shared",
104-
builder: (_, __) => const SharedStory(),
105-
),
106-
],
107-
),
108-
],
109-
),
94+
return MaterialApp(
95+
routes: {"/": (_) => HomePage(), "/shared": (_) => const SharedStory()},
96+
initialRoute: "/",
97+
onGenerateRoute: (settings) {
98+
var uri = Uri.parse(settings.name ?? "");
99+
100+
// Only react to shared route. Other routes have no matching screen.
101+
if (uri.path == "/shared") {
102+
return MaterialPageRoute(
103+
builder: (_) => SharedStory(
104+
storyId: uri.queryParameters["storyId"],
105+
));
106+
}
107+
108+
return null;
109+
},
110110
debugShowCheckedModeBanner: false,
111111
themeMode: themeProvider.themeMode,
112112
theme: MyThemes.lightTheme,

taletime/lib/profiles/screens/profiles_page.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class _ProfilesPageState extends State<ProfilesPage> {
8181
padding: const EdgeInsets.only(right: 15.0),
8282
child: IconButton(
8383
onPressed: () {
84-
Navigator.of(context).pushReplacement(MaterialPageRoute(
84+
Navigator.of(context).push(MaterialPageRoute(
8585
builder: (context) => CreateEditProfile(
8686
profile: defaultProfile,
8787
)));

taletime/lib/profiles/utils/create_edit_profile.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import "../../common utils/theme_provider.dart";
1111
import "../../internationalization/locale_provider.dart";
1212
import "../../internationalization/localizations_ext.dart";
1313
import "../models/profile_model.dart";
14-
import "../screens/profiles_page.dart";
1514

1615
class CreateEditProfile extends StatefulWidget {
1716
const CreateEditProfile({super.key, required this.profile});
@@ -78,8 +77,12 @@ class _CreateEditProfileState extends State<CreateEditProfile> {
7877
? widget.profile.name
7978
: textEditingController.text;
8079

81-
DocumentReference<Profile>? profileRef =
82-
Provider.of<UserState>(context).profilesRef?.doc(widget.profile.id);
80+
DocumentReference<Profile>? profileRef;
81+
82+
if (widget.profile.id != "") {
83+
profileRef =
84+
Provider.of<UserState>(context).profilesRef?.doc(widget.profile.id);
85+
}
8386

8487
return Scaffold(
8588
appBar: AppBar(
@@ -211,17 +214,14 @@ class _CreateEditProfileState extends State<CreateEditProfile> {
211214
Navigator.of(context).pop();
212215
} else {
213216
ProfileService.addProfile(
214-
Provider.of<UserState>(context).profilesRef!,
217+
Provider.of<UserState>(context, listen: false)
218+
.profilesRef!,
215219
image,
216220
name,
217221
title,
218222
languageProvider.locale.toString(),
219223
!themeProvider.isDarkMode);
220-
Navigator.push(
221-
context,
222-
MaterialPageRoute(
223-
builder: (context) =>
224-
const ProfilesPage()));
224+
Navigator.of(context).pop();
225225
}
226226
},
227227
child: Text(

0 commit comments

Comments
 (0)