From b0e9874cafdb0d76eb0a9d7f2c32e8ffc27b7eac Mon Sep 17 00:00:00 2001 From: David Gomes <10091092+davidgomesdev@users.noreply.github.com> Date: Tue, 17 Dec 2024 22:57:19 +0000 Subject: [PATCH] fix: remove text from splash screen --- assets/json_files/splash_texts.json | 6 ---- lib/ui/screen/boot_screen.dart | 12 ++++++-- lib/ui/screen/home_screen.dart | 25 +++++++--------- lib/ui/screen/splash_screen.dart | 45 ++--------------------------- pubspec.yaml | 1 - 5 files changed, 24 insertions(+), 65 deletions(-) delete mode 100644 assets/json_files/splash_texts.json diff --git a/assets/json_files/splash_texts.json b/assets/json_files/splash_texts.json deleted file mode 100644 index 047b6b7..0000000 --- a/assets/json_files/splash_texts.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - "O poeta é um fingidor\nFinge tão completamente\nQue chega a fingir que é dor\nA dor que deveras sente.", - "Tenho em mim todos os sonhos do mundo.", - "Valeu a pena? Tudo vale a pena\nSe a alma não é pequena.", - "Deus quer, o homem sonha, a obra nasce." -] \ No newline at end of file diff --git a/lib/ui/screen/boot_screen.dart b/lib/ui/screen/boot_screen.dart index f9ff172..e9b475a 100644 --- a/lib/ui/screen/boot_screen.dart +++ b/lib/ui/screen/boot_screen.dart @@ -20,6 +20,8 @@ class BootScreen extends StatefulWidget { } class _BootScreenState extends State { + DateTime startedAt = DateTime.timestamp(); + @override Widget build(BuildContext context) { return Scaffold( @@ -48,12 +50,18 @@ class _BootScreenState extends State { Get.put(await HistoryRepository.initialize(), permanent: true); Get.put(await CollapsableRepository.initialize(), permanent: true); - Get.offAndToNamed(Routes.homeScreen); - final version = (await PackageInfo.fromPlatform()).version; log.i("Running version '$version'"); + Duration durationSinceStart = + DateTime.timestamp().difference(startedAt); + + log.d("Took ${durationSinceStart.inMilliseconds}ms " + "to load dependencies."); + + Get.offAndToNamed(Routes.homeScreen); + return Future.value(); } } diff --git a/lib/ui/screen/home_screen.dart b/lib/ui/screen/home_screen.dart index bb35792..555d224 100644 --- a/lib/ui/screen/home_screen.dart +++ b/lib/ui/screen/home_screen.dart @@ -68,20 +68,17 @@ class _HomeScreenState extends State ) ], ), - drawer: AnimatedContainer( - duration: Durations.extralong4, - child: TextSelectionDrawer( - mainIndex: storeService.mainIndex, - fullIndex: storeService.fullIndex, - selectionSink: _streamController.sink, - scrollController: drawerScrollController, - selectedText: text, - scaffoldKey: _scaffoldKey, - isFullReading: isFullReading, - onFullReadingChange: (newValue) => setState(() { - isFullReading = newValue; - }), - ), + drawer: TextSelectionDrawer( + mainIndex: storeService.mainIndex, + fullIndex: storeService.fullIndex, + selectionSink: _streamController.sink, + scrollController: drawerScrollController, + selectedText: text, + scaffoldKey: _scaffoldKey, + isFullReading: isFullReading, + onFullReadingChange: (newValue) => setState(() { + isFullReading = newValue; + }), ), body: HomeScreenBody( text: text, diff --git a/lib/ui/screen/splash_screen.dart b/lib/ui/screen/splash_screen.dart index 0b8e4a4..a1d588a 100644 --- a/lib/ui/screen/splash_screen.dart +++ b/lib/ui/screen/splash_screen.dart @@ -1,11 +1,4 @@ -import 'dart:convert'; -import 'dart:math'; - import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:get/get.dart'; - -import '../bonito_theme.dart'; class SplashScreen extends StatefulWidget { const SplashScreen({super.key}); @@ -15,57 +8,25 @@ class SplashScreen extends StatefulWidget { } class _SplashScreenState extends State { - late Future splashText; late Image splashArt; @override void initState() { super.initState(); - splashText = _getRandomSplashText(); splashArt = Image.asset("assets/images/splash_art.jpg"); } @override Widget build(BuildContext context) { - return FutureBuilder( - builder: (context, snapshot) { - final text = snapshot.data; - - if (snapshot.hasError) { - snapshot.printError(); - return ErrorWidget(snapshot.error!); - } - - if (text == null) return Container(); - - return Column( + return Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - const Spacer(), + const Spacer(flex: 2), Expanded(flex: 2, child: Center(child: splashArt)), - Expanded( + const Spacer( flex: 2, - child: Padding( - padding: const EdgeInsets.only(top: 16.0), - child: Text( - text, - style: bonitoTextTheme.bodySmall! - .copyWith(fontStyle: FontStyle.italic), - ), ), - ), ], - ); - }, - future: splashText, ); } - - Future _getRandomSplashText() async { - final jsonFile = - await rootBundle.loadString("assets/json_files/splash_texts.json"); - final texts = jsonDecode(jsonFile); - - return texts[Random().nextInt(texts.length)]; - } } diff --git a/pubspec.yaml b/pubspec.yaml index 305b957..d617a0e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -51,7 +51,6 @@ flutter: uses-material-design: true assets: - assets/json_files/all_texts.json - - assets/json_files/splash_texts.json - assets/images/splash_art.jpg # fonts - assets/fonts/Roboto/Roboto-Black.ttf