Browse Source

neon: Use theme extension for tablet layout

pull/452/head
jld3103 1 year ago
parent
commit
ac12e98df9
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 5
      packages/neon/neon/lib/src/pages/login.dart
  2. 5
      packages/neon/neon/lib/src/pages/login_check_account.dart
  3. 5
      packages/neon/neon/lib/src/pages/login_check_server_status.dart
  4. 23
      packages/neon/neon/lib/src/utils/theme.dart

5
packages/neon/neon/lib/src/pages/login.dart

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:neon/l10n/localizations.dart';
import 'package:neon/src/models/branding.dart';
import 'package:neon/src/router.dart';
import 'package:neon/src/utils/theme.dart';
import 'package:neon/src/utils/validators.dart';
import 'package:neon/src/widgets/nextcloud_logo.dart';
import 'package:provider/provider.dart';
@ -59,9 +60,7 @@ class _LoginPageState extends State<LoginPage> {
),
body: Center(
child: ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: 640,
),
constraints: Theme.of(context).extension<NeonTheme>()?.tabletLayout ?? const BoxConstraints(),
child: Scrollbar(
interactive: true,
child: SingleChildScrollView(

5
packages/neon/neon/lib/src/pages/login_check_account.dart

@ -6,6 +6,7 @@ import 'package:neon/src/blocs/accounts.dart';
import 'package:neon/src/blocs/login_check_account.dart';
import 'package:neon/src/models/account.dart';
import 'package:neon/src/router.dart';
import 'package:neon/src/utils/theme.dart';
import 'package:neon/src/widgets/account_tile.dart';
import 'package:neon/src/widgets/exception.dart';
import 'package:neon/src/widgets/linear_progress_indicator.dart';
@ -57,9 +58,7 @@ class _LoginCheckAccountPageState extends State<LoginCheckAccountPage> {
child: Padding(
padding: const EdgeInsets.all(10),
child: ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: 640,
),
constraints: Theme.of(context).extension<NeonTheme>()?.tabletLayout ?? const BoxConstraints(),
child: ResultBuilder.behaviorSubject(
stream: bloc.state,
builder: (final context, final state) => Column(

5
packages/neon/neon/lib/src/pages/login_check_server_status.dart

@ -3,6 +3,7 @@ import 'package:neon/l10n/localizations.dart';
import 'package:neon/src/bloc/result.dart';
import 'package:neon/src/bloc/result_builder.dart';
import 'package:neon/src/blocs/login_check_server_status.dart';
import 'package:neon/src/utils/theme.dart';
import 'package:neon/src/widgets/exception.dart';
import 'package:neon/src/widgets/linear_progress_indicator.dart';
import 'package:neon/src/widgets/validation_tile.dart';
@ -45,9 +46,7 @@ class _LoginCheckServerStatusPageState extends State<LoginCheckServerStatusPage>
child: Padding(
padding: const EdgeInsets.all(10),
child: ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: 640,
),
constraints: Theme.of(context).extension<NeonTheme>()?.tabletLayout ?? const BoxConstraints(),
child: ResultBuilder.behaviorSubject(
stream: bloc.state,
builder: (final context, final state) => Column(

23
packages/neon/neon/lib/src/utils/theme.dart

@ -48,7 +48,11 @@ class AppTheme {
snackBarTheme: _snackBarTheme,
dividerTheme: _dividerTheme,
extensions: [
const NeonTheme(),
const NeonTheme(
tabletLayout: BoxConstraints(
maxWidth: 640,
),
),
...?appThemes,
],
);
@ -70,16 +74,27 @@ class AppTheme {
@internal
@immutable
class NeonTheme extends ThemeExtension<NeonTheme> {
const NeonTheme();
const NeonTheme({
required this.tabletLayout,
});
final BoxConstraints? tabletLayout;
@override
NeonTheme copyWith() => const NeonTheme();
NeonTheme copyWith({
final BoxConstraints? tabletLayout,
}) =>
NeonTheme(
tabletLayout: tabletLayout ?? this.tabletLayout,
);
@override
NeonTheme lerp(final NeonTheme? other, final double t) {
if (other is! NeonTheme) {
return this;
}
return const NeonTheme();
return NeonTheme(
tabletLayout: BoxConstraints.lerp(tabletLayout, other.tabletLayout, t),
);
}
}

Loading…
Cancel
Save