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/l10n/localizations.dart';
import 'package:neon/src/models/branding.dart'; import 'package:neon/src/models/branding.dart';
import 'package:neon/src/router.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/utils/validators.dart';
import 'package:neon/src/widgets/nextcloud_logo.dart'; import 'package:neon/src/widgets/nextcloud_logo.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@ -59,9 +60,7 @@ class _LoginPageState extends State<LoginPage> {
), ),
body: Center( body: Center(
child: ConstrainedBox( child: ConstrainedBox(
constraints: const BoxConstraints( constraints: Theme.of(context).extension<NeonTheme>()?.tabletLayout ?? const BoxConstraints(),
maxWidth: 640,
),
child: Scrollbar( child: Scrollbar(
interactive: true, interactive: true,
child: SingleChildScrollView( 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/blocs/login_check_account.dart';
import 'package:neon/src/models/account.dart'; import 'package:neon/src/models/account.dart';
import 'package:neon/src/router.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/account_tile.dart';
import 'package:neon/src/widgets/exception.dart'; import 'package:neon/src/widgets/exception.dart';
import 'package:neon/src/widgets/linear_progress_indicator.dart'; import 'package:neon/src/widgets/linear_progress_indicator.dart';
@ -57,9 +58,7 @@ class _LoginCheckAccountPageState extends State<LoginCheckAccountPage> {
child: Padding( child: Padding(
padding: const EdgeInsets.all(10), padding: const EdgeInsets.all(10),
child: ConstrainedBox( child: ConstrainedBox(
constraints: const BoxConstraints( constraints: Theme.of(context).extension<NeonTheme>()?.tabletLayout ?? const BoxConstraints(),
maxWidth: 640,
),
child: ResultBuilder.behaviorSubject( child: ResultBuilder.behaviorSubject(
stream: bloc.state, stream: bloc.state,
builder: (final context, final state) => Column( 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.dart';
import 'package:neon/src/bloc/result_builder.dart'; import 'package:neon/src/bloc/result_builder.dart';
import 'package:neon/src/blocs/login_check_server_status.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/exception.dart';
import 'package:neon/src/widgets/linear_progress_indicator.dart'; import 'package:neon/src/widgets/linear_progress_indicator.dart';
import 'package:neon/src/widgets/validation_tile.dart'; import 'package:neon/src/widgets/validation_tile.dart';
@ -45,9 +46,7 @@ class _LoginCheckServerStatusPageState extends State<LoginCheckServerStatusPage>
child: Padding( child: Padding(
padding: const EdgeInsets.all(10), padding: const EdgeInsets.all(10),
child: ConstrainedBox( child: ConstrainedBox(
constraints: const BoxConstraints( constraints: Theme.of(context).extension<NeonTheme>()?.tabletLayout ?? const BoxConstraints(),
maxWidth: 640,
),
child: ResultBuilder.behaviorSubject( child: ResultBuilder.behaviorSubject(
stream: bloc.state, stream: bloc.state,
builder: (final context, final state) => Column( builder: (final context, final state) => Column(

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

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

Loading…
Cancel
Save