Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Add OLED theme, fix login screen UX

Nathan Poulson8d58089b7d0f
diff --git a/lib/main.dart b/lib/main.dart
index 59b6a84e..da7f93e5 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -31,6 +31,9 @@ import 'widgets/absorb_wave_icon.dart';
/// Global notifier so any widget (e.g. settings) can change the theme instantly.
final ValueNotifier<ThemeMode> themeNotifier = ValueNotifier(ThemeMode.dark);
+/// Whether OLED (pure black) dark theme is active.
+final ValueNotifier<bool> oledNotifier = ValueNotifier(false);
+
/// Global key so non-widget code (e.g. providers) can show snackbars.
final GlobalKey<ScaffoldMessengerState> scaffoldMessengerKey =
GlobalKey<ScaffoldMessengerState>();
@@ -39,10 +42,16 @@ ThemeMode parseThemeMode(String value) {
switch (value) {
case 'light': return ThemeMode.light;
case 'system': return ThemeMode.system;
+ case 'oled': return ThemeMode.dark;
default: return ThemeMode.dark;
}
}
+void applyThemeMode(String value) {
+ themeNotifier.value = parseThemeMode(value);
+ oledNotifier.value = value == 'oled';
+}
+
void main() async {
final widgetsBinding = WidgetsFlutterBinding.ensureInitialized();
@@ -64,7 +73,7 @@ void main() async {
// Load saved theme preference so we render the correct theme immediately
try {
final savedTheme = await PlayerSettings.getThemeMode();
- themeNotifier.value = parseThemeMode(savedTheme);
+ applyThemeMode(savedTheme);
} catch (_) {}
// Capture Flutter framework errors (widget build failures, etc.)
@@ -106,6 +115,9 @@ class AbsorbApp extends StatelessWidget {
return ValueListenableBuilder<ThemeMode>(
valueListenable: themeNotifier,
builder: (context, currentMode, _) {
+ return ValueListenableBuilder<bool>(
+ valueListenable: oledNotifier,
+ builder: (context, isOled, _) {
// Set system chrome to match active theme
final isDark = currentMode == ThemeMode.dark ||
(currentMode == ThemeMode.system &&
@@ -131,6 +143,18 @@ class AbsorbApp extends StatelessWidget {
);
}
+ // OLED: pure black surfaces so OLED pixels turn fully off
+ if (isOled) {
+ darkScheme = darkScheme.copyWith(
+ surface: Colors.black,
+ surfaceContainerLowest: Colors.black,
+ surfaceContainerLow: Colors.black,
+ surfaceContainer: const Color(0xFF050505),
+ surfaceContainerHigh: const Color(0xFF0A0A0A),
+ surfaceContainerHighest: const Color(0xFF0F0F0F),
+ );
+ }
+
// Light scheme for users who prefer it
ColorScheme lightScheme;
if (lightDynamic != null) {
@@ -213,7 +237,7 @@ class AbsorbApp extends StatelessWidget {
darkTheme: ThemeData(
useMaterial3: true,
colorScheme: darkScheme,
- scaffoldBackgroundColor: const Color(0xFF0E0E0E),
+ scaffoldBackgroundColor: isOled ? Colors.black : const Color(0xFF0E0E0E),
cardTheme: CardThemeData(
color: darkScheme.surfaceContainerHigh,
elevation: 0,
@@ -222,7 +246,7 @@ class AbsorbApp extends StatelessWidget {
),
),
navigationBarTheme: NavigationBarThemeData(
- backgroundColor: const Color(0xFF0E0E0E),
+ backgroundColor: isOled ? Colors.black : const Color(0xFF0E0E0E),
indicatorColor: darkScheme.primary.withValues(alpha: 0.15),
labelTextStyle: WidgetStatePropertyAll(
TextStyle(
@@ -233,7 +257,7 @@ class AbsorbApp extends StatelessWidget {
),
),
appBarTheme: AppBarTheme(
- backgroundColor: const Color(0xFF0E0E0E),
+ backgroundColor: isOled ? Colors.black : const Color(0xFF0E0E0E),
surfaceTintColor: Colors.transparent,
scrolledUnderElevation: 0,
),
@@ -248,8 +272,8 @@ class AbsorbApp extends StatelessWidget {
),
),
),
- bottomSheetTheme: const BottomSheetThemeData(
- backgroundColor: Color(0xFF1A1A1A),
+ bottomSheetTheme: BottomSheetThemeData(
+ backgroundColor: isOled ? Colors.black : const Color(0xFF1A1A1A),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(24)),
),
@@ -269,6 +293,8 @@ class AbsorbApp extends StatelessWidget {
);
},
);
+ },
+ );
},
);
}
diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart
index c90b4768..b41a9117 100644
--- a/lib/screens/home_screen.dart
+++ b/lib/screens/home_screen.dart
@@ -12,6 +12,7 @@ import '../widgets/shimmer.dart';
import '../widgets/book_detail_sheet.dart';
import '../widgets/card_buttons.dart';
import '../widgets/episode_list_sheet.dart';
+import '../main.dart' show oledNotifier;
import 'app_shell.dart';
class HomeScreen extends StatefulWidget {
@@ -282,7 +283,7 @@ class _HomeScreenState extends State<HomeScreen> {
return Scaffold(
backgroundColor: scaffoldBg,
body: Container(
- decoration: BoxDecoration(
+ decoration: oledNotifier.value ? null : BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
diff --git a/lib/screens/login_screen.dart b/lib/screens/login_screen.dart
index 45070de6..00146c19 100644
--- a/lib/screens/login_screen.dart
+++ b/lib/screens/login_screen.dart
@@ -12,6 +12,7 @@ import '../services/backup_service.dart';
import '../services/oidc_service.dart';
import '../services/user_account_service.dart';
import '../widgets/absorb_wave_icon.dart';
+import '../main.dart' show oledNotifier;
class LoginScreen extends StatefulWidget {
const LoginScreen({super.key});
@@ -180,9 +181,7 @@ class _LoginScreenState extends State<LoginScreen>
}
});
- Future.delayed(const Duration(milliseconds: 200), () {
- if (mounted) _usernameFocus.requestFocus();
- });
+ // Don't auto-focus — user may still be typing IP:port
}
} catch (e) {
if (!mounted) return;
@@ -196,9 +195,17 @@ class _LoginScreenState extends State<LoginScreen>
}
Future<void> _handleLogin() async {
- if (!_serverValid) return;
if (!_formKey.currentState!.validate()) return;
+ // Validate server first if not yet checked
+ if (!_serverValid) {
+ await _checkServer();
+ if (!_serverValid) {
+ setState(() => _loginError = _serverError ?? 'Could not reach server');
+ return;
+ }
+ }
+
setState(() {
_isConnecting = true;
_loginError = null;
@@ -289,8 +296,9 @@ class _LoginScreenState extends State<LoginScreen>
final tt = Theme.of(context).textTheme;
return Scaffold(
+ resizeToAvoidBottomInset: true,
body: Container(
- decoration: BoxDecoration(
+ decoration: oledNotifier.value ? null : BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
@@ -304,11 +312,14 @@ class _LoginScreenState extends State<LoginScreen>
),
),
child: SafeArea(
- child: Center(
- child: SingleChildScrollView(
+ child: LayoutBuilder(
+ builder: (context, constraints) => SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 28, vertical: 24),
- child: Column(
- mainAxisSize: MainAxisSize.min,
+ child: ConstrainedBox(
+ constraints: BoxConstraints(minHeight: constraints.maxHeight - 48),
+ child: Column(
+ mainAxisAlignment: MainAxisAlignment.center,
+ mainAxisSize: MainAxisSize.min,
children: [
// ── Logo + Tagline ──
FadeTransition(
@@ -411,11 +422,18 @@ class _LoginScreenState extends State<LoginScreen>
_buildInputField(
controller: _serverController,
label: 'Server address',
- hint: 'abs.example.com',
+ hint: 'my.server.com',
+ helperText: 'IP:port works too (e.g. 192.168.1.5:13378)',
keyboardType: TextInputType.url,
textInputAction: TextInputAction.next,
onFieldSubmitted: (_) {
- if (!_serverValid && !_serverChecking) _checkServer();
+ if (!_serverValid && !_serverChecking) {
+ _checkServer().then((_) {
+ if (mounted && _serverValid) _usernameFocus.requestFocus();
+ });
+ } else if (_serverValid) {
+ _usernameFocus.requestFocus();
+ }
},
cs: cs,
prefixIcon: Padding(
@@ -568,7 +586,7 @@ class _LoginScreenState extends State<LoginScreen>
),
],
- // SSO / OIDC button — shown right below server URL so keyboard doesn't hide it
+ // SSO / OIDC button — only shown when server supports it
AnimatedSize(
duration: const Duration(milliseconds: 350),
curve: Curves.easeOutCubic,
@@ -578,15 +596,8 @@ class _LoginScreenState extends State<LoginScreen>
: const SizedBox.shrink(),
),
- // Credentials — animated in when server is valid
- AnimatedSize(
- duration: const Duration(milliseconds: 350),
- curve: Curves.easeOutCubic,
- alignment: Alignment.topCenter,
- child: _serverValid
- ? _buildCredentialFields(cs, tt)
- : const SizedBox.shrink(),
- ),
+ // Credentials — always visible
+ _buildCredentialFields(cs, tt),
],
),
),
@@ -636,6 +647,7 @@ class _LoginScreenState extends State<LoginScreen>
),
),
),
+ ),
);
}
@@ -831,6 +843,7 @@ class _LoginScreenState extends State<LoginScreen>
required String label,
required ColorScheme cs,
String? hint,
+ String? helperText,
TextInputType? keyboardType,
TextInputAction? textInputAction,
FocusNode? focusNode,
@@ -854,6 +867,9 @@ class _LoginScreenState extends State<LoginScreen>
decoration: InputDecoration(
labelText: label,
hintText: hint,
+ helperText: helperText,
+ helperStyle: TextStyle(color: cs.onSurfaceVariant.withValues(alpha: 0.5), fontSize: 11),
+ helperMaxLines: 2,
prefixIcon: prefixIcon,
suffixIcon: suffixIcon,
errorText: errorText,
diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dart
index 4826ab29..6ddfeeac 100644
--- a/lib/screens/settings_screen.dart
+++ b/lib/screens/settings_screen.dart
@@ -21,7 +21,7 @@ import '../screens/app_shell.dart';
import '../screens/admin_screen.dart';
import '../screens/downloads_screen.dart';
import '../screens/bookmarks_screen.dart';
-import '../main.dart' show themeNotifier, parseThemeMode;
+import '../main.dart' show applyThemeMode, oledNotifier;
import '../widgets/absorb_page_header.dart';
import '../widgets/absorb_slider.dart';
@@ -350,7 +350,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
return Scaffold(
body: Container(
- decoration: BoxDecoration(
+ decoration: oledNotifier.value ? null : BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
@@ -384,9 +384,10 @@ class _SettingsScreenState extends State<SettingsScreen> {
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
decoration: BoxDecoration(
- gradient: LinearGradient(
+ gradient: oledNotifier.value ? null : LinearGradient(
colors: [cs.primaryContainer, cs.tertiaryContainer],
),
+ color: oledNotifier.value ? cs.surfaceContainerHigh : null,
borderRadius: BorderRadius.circular(16),
),
child: Row(
@@ -414,45 +415,30 @@ class _SettingsScreenState extends State<SettingsScreen> {
// ── User Profile ──
Padding(
padding: const EdgeInsets.fromLTRB(20, 8, 20, 0),
- child: Row(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
children: [
- CircleAvatar(
- radius: 28,
- backgroundColor: cs.primaryContainer,
- child: Text(
- (auth.username ?? 'U')[0].toUpperCase(),
- style: tt.headlineSmall?.copyWith(
- color: cs.onPrimaryContainer,
- fontWeight: FontWeight.w700,
- ),
- ),
- ),
- const SizedBox(width: 16),
- Expanded(child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
+ Row(
children: [
- Text(auth.username ?? 'User', style: tt.titleLarge?.copyWith(
- fontWeight: FontWeight.w700)),
- const SizedBox(height: 2),
- Text(
- auth.serverUrl?.replaceAll(RegExp(r'^https?://'), '').replaceAll(RegExp(r'/+$'), '') ?? '',
- maxLines: 1, overflow: TextOverflow.ellipsis,
- style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),
+ Expanded(child: Text(auth.username ?? 'User', style: tt.titleLarge?.copyWith(
+ fontWeight: FontWeight.w700))),
if (auth.isAdmin)
- Padding(
- padding: const EdgeInsets.only(top: 4),
- child: Container(
- padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
- decoration: BoxDecoration(
- color: auth.isRoot ? Colors.amber.withValues(alpha: 0.12) : cs.primary.withValues(alpha: 0.12),
- borderRadius: BorderRadius.circular(6),
- ),
- child: Text(auth.isRoot ? 'Root Admin' : 'Admin', style: tt.labelSmall?.copyWith(
- color: auth.isRoot ? Colors.amber : cs.primary, fontWeight: FontWeight.w600, fontSize: 10)),
+ Container(
+ padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
+ decoration: BoxDecoration(
+ color: auth.isRoot ? Colors.amber.withValues(alpha: 0.12) : cs.primary.withValues(alpha: 0.12),
+ borderRadius: BorderRadius.circular(6),
),
+ child: Text(auth.isRoot ? 'Root Admin' : 'Admin', style: tt.labelSmall?.copyWith(
+ color: auth.isRoot ? Colors.amber : cs.primary, fontWeight: FontWeight.w600, fontSize: 10)),
),
],
- )),
+ ),
+ const SizedBox(height: 2),
+ Text(
+ auth.serverUrl?.replaceAll(RegExp(r'^https?://'), '').replaceAll(RegExp(r'/+$'), '') ?? '',
+ maxLines: 1, overflow: TextOverflow.ellipsis,
+ style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),
],
),
),
@@ -515,17 +501,19 @@ class _SettingsScreenState extends State<SettingsScreen> {
SizedBox(
width: double.infinity,
child: SegmentedButton<String>(
+ showSelectedIcon: false,
segments: const [
- ButtonSegment(value: 'dark', icon: Icon(Icons.dark_mode_rounded), label: Text('Dark')),
- ButtonSegment(value: 'light', icon: Icon(Icons.light_mode_rounded), label: Text('Light')),
- ButtonSegment(value: 'system', icon: Icon(Icons.brightness_auto_rounded), label: Text('System')),
+ ButtonSegment(value: 'dark', label: Text('Dark')),
+ ButtonSegment(value: 'oled', label: Text('OLED')),
+ ButtonSegment(value: 'light', label: Text('Light')),
+ ButtonSegment(value: 'system', label: Text('Auto')),
],
selected: {_themeMode},
onSelectionChanged: _loaded ? (selected) {
final mode = selected.first;
setState(() => _themeMode = mode);
PlayerSettings.setThemeMode(mode);
- themeNotifier.value = parseThemeMode(mode);
+ applyThemeMode(mode);
} : null,
style: const ButtonStyle(
visualDensity: VisualDensity.compact,
@@ -2130,7 +2118,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
// Apply theme immediately
final theme = data['settings']?['themeMode'] as String?;
if (theme != null) {
- themeNotifier.value = parseThemeMode(theme);
+ applyThemeMode(theme);
}
// Refresh UI
diff --git a/lib/screens/stats_screen.dart b/lib/screens/stats_screen.dart
index 03d5f26c..f8448ed3 100644
--- a/lib/screens/stats_screen.dart
+++ b/lib/screens/stats_screen.dart
@@ -7,6 +7,7 @@ import '../providers/auth_provider.dart';
import '../providers/library_provider.dart';
import '../widgets/absorb_page_header.dart';
import '../widgets/absorb_wave_icon.dart';
+import '../main.dart' show oledNotifier;
class StatsScreen extends StatefulWidget {
const StatsScreen({super.key});
@@ -116,7 +117,7 @@ class _StatsScreenState extends State<StatsScreen>
return Scaffold(
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
body: Container(
- decoration: BoxDecoration(
+ decoration: oledNotifier.value ? null : BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
@@ -287,7 +288,7 @@ class _StatsScreenState extends State<StatsScreen>
padding: const EdgeInsets.symmetric(vertical: 28, horizontal: 20),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
- gradient: LinearGradient(
+ gradient: oledNotifier.value ? null : LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
@@ -295,7 +296,7 @@ class _StatsScreenState extends State<StatsScreen>
cs.primary.withValues(alpha: 0.04),
],
),
- border: Border.all(color: cs.primary.withValues(alpha: 0.15)),
+ border: Border.all(color: cs.primary.withValues(alpha: oledNotifier.value ? 0.08 : 0.15)),
),
child: Column(children: [
Text('TOTAL LISTENING TIME',