Skip to content

Commit

Permalink
fix: remove text from splash screen
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgomesdev committed Dec 18, 2024
1 parent 1d51228 commit b0e9874
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 65 deletions.
6 changes: 0 additions & 6 deletions assets/json_files/splash_texts.json

This file was deleted.

12 changes: 10 additions & 2 deletions lib/ui/screen/boot_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class BootScreen extends StatefulWidget {
}

class _BootScreenState extends State<BootScreen> {
DateTime startedAt = DateTime.timestamp();

@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down Expand Up @@ -48,12 +50,18 @@ class _BootScreenState extends State<BootScreen> {
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();
}
}
25 changes: 11 additions & 14 deletions lib/ui/screen/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,17 @@ class _HomeScreenState extends State<HomeScreen>
)
],
),
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,
Expand Down
45 changes: 3 additions & 42 deletions lib/ui/screen/splash_screen.dart
Original file line number Diff line number Diff line change
@@ -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});
Expand All @@ -15,57 +8,25 @@ class SplashScreen extends StatefulWidget {
}

class _SplashScreenState extends State<SplashScreen> {
late Future<String> 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<String> _getRandomSplashText() async {
final jsonFile =
await rootBundle.loadString("assets/json_files/splash_texts.json");
final texts = jsonDecode(jsonFile);

return texts[Random().nextInt(texts.length)];
}
}
1 change: 0 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b0e9874

Please sign in to comment.