Skip to content

Commit

Permalink
Last minute changes
Browse files Browse the repository at this point in the history
  • Loading branch information
arianneorpilla committed Apr 30, 2023
1 parent 11f7cb6 commit f0ad97f
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 29 deletions.
10 changes: 7 additions & 3 deletions yuuna/lib/src/models/app_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ class AppModel with ChangeNotifier {
/// grayscale.
final ChangeNotifier incognitoNotifier = ChangeNotifier();

/// Notifies app to stop showing any screens.
final ChangeNotifier databaseCloseNotifier = ChangeNotifier();

/// These directories are prepared at startup in order to reduce redundancy
/// in actual runtime.
/// Directory where data that may be dumped is stored.
Expand Down Expand Up @@ -2355,12 +2358,13 @@ class AppModel with ChangeNotifier {

await _audioHandler?.stop();

mediaSource.mediaType.refreshTab();
DictionaryMediaType.instance.refreshTab();

if (_shouldKillMediaOnPop) {
databaseCloseNotifier.notifyListeners();
shutdown();
}

mediaSource.mediaType.refreshTab();
DictionaryMediaType.instance.refreshTab();
}

/// A helper function for opening the creator from any page in the
Expand Down
6 changes: 6 additions & 0 deletions yuuna/lib/src/pages/implementations/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class _HomePageState extends BasePageState<HomePage>
super.initState();

WidgetsBinding.instance.addObserver(this);
appModelNoUpdate.databaseCloseNotifier.addListener(refresh);

/// Populate and define the tabs and their respective content bodies based
/// on the media types specified and ordered by [AppModel]. As [ref.watch]
Expand Down Expand Up @@ -61,9 +62,14 @@ class _HomePageState extends BasePageState<HomePage>
});
}

void refresh() {
setState(() {});
}

@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
appModelNoUpdate.databaseCloseNotifier.removeListener(refresh);
super.dispose();
}

Expand Down
66 changes: 42 additions & 24 deletions yuuna/lib/src/pages/implementations/network_stream_dialog_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,18 @@ class _NetworkStreamDialogPageState
@override
Widget build(BuildContext context) {
return AlertDialog(
contentPadding: Spacing.of(context).insets.all.big,
contentPadding: MediaQuery.of(context).orientation == Orientation.portrait
? Spacing.of(context).insets.exceptBottom.big
: Spacing.of(context).insets.exceptBottom.normal.copyWith(
left: Spacing.of(context).spaces.semiBig,
right: Spacing.of(context).spaces.semiBig,
),
actionsPadding: Spacing.of(context).insets.exceptBottom.normal.copyWith(
left: Spacing.of(context).spaces.normal,
right: Spacing.of(context).spaces.normal,
bottom: Spacing.of(context).spaces.normal,
top: Spacing.of(context).spaces.extraSmall,
),
content: buildContent(),
actions: actions,
);
Expand All @@ -42,31 +53,38 @@ class _NetworkStreamDialogPageState
List<Widget> get actions => [buildPlayButton()];

Widget buildContent() {
return SingleChildScrollView(
child: SizedBox(
width: MediaQuery.of(context).size.width * (2 / 3),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
TextField(
autofocus: true,
controller: _controller,
decoration: InputDecoration(
floatingLabelBehavior: FloatingLabelBehavior.always,
suffixIcon: JidoujishoIconButton(
size: 18,
tooltip: t.paste,
onTap: () async {
_controller.text =
(await Clipboard.getData('text/plain'))?.text ?? '';
},
icon: Icons.paste,
ScrollController scrollController = ScrollController();

return RawScrollbar(
thickness: 3,
thumbVisibility: true,
controller: scrollController,
child: SingleChildScrollView(
controller: scrollController,
child: SizedBox(
width: MediaQuery.of(context).size.width * (1 / 3),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
TextField(
autofocus: true,
controller: _controller,
decoration: InputDecoration(
floatingLabelBehavior: FloatingLabelBehavior.always,
suffixIcon: JidoujishoIconButton(
size: 18,
tooltip: t.paste,
onTap: () async {
_controller.text =
(await Clipboard.getData('text/plain'))?.text ?? '';
},
icon: Icons.paste,
),
labelText: t.stream_url,
),
labelText: t.stream_url,
),
),
const SizedBox(height: 10),
],
],
),
),
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ class _PlayerSourcePageState extends BaseSourcePageState<PlayerSourcePage>
});
});

if (mounted) {
if (mounted && appModel.isMediaOpen) {
if (appModelNoUpdate.isPlayerOrientationPortrait) {
await SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
Expand Down
6 changes: 5 additions & 1 deletion yuuna/lib/src/pages/implementations/reader_chatgpt_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,11 @@ class _ReaderChatgptPageState extends BaseSourcePageState<ReaderChatgptPage> {
return;
}

source.setCurrentSentence(text);
String sentence = appModel.targetLanguage.getSentenceFromParagraph(
paragraph: text,
index: index,
);
source.setCurrentSentence(sentence);

double x = details.globalPosition.dx;
double y = details.globalPosition.dy;
Expand Down

0 comments on commit f0ad97f

Please sign in to comment.