Skip to content

基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。

2.4 KB
Raw Blame
import 'package:flutter/material.dart';
import 'package:kazumi/bean/appbar/sys_app_bar.dart';

class SettingsPaneScope extends InheritedWidget {
  const SettingsPaneScope({
    super.key,
    required this.embedded,
    required this.showBackButton,
    required this.onBack,
    required super.child,
  });

  final bool embedded;
  final bool showBackButton;
  final VoidCallback onBack;

  static SettingsPaneScope? of(BuildContext context) {
    return context.dependOnInheritedWidgetOfExactType<SettingsPaneScope>();
  }

  @override
  bool updateShouldNotify(SettingsPaneScope oldWidget) {
    return embedded != oldWidget.embedded ||
        showBackButton != oldWidget.showBackButton ||
        onBack != oldWidget.onBack;
  }
}

class SettingsDetailScaffold extends StatelessWidget {
  const SettingsDetailScaffold({
    super.key,
    required this.title,
    required this.body,
    this.actions,
    this.leading,
    this.floatingActionButton,
    this.bottomNavigationBar,
  });

  final Widget title;
  final Widget body;
  final List<Widget>? actions;
  final Widget? leading;
  final Widget? floatingActionButton;
  final Widget? bottomNavigationBar;

  @override
  Widget build(BuildContext context) {
    final scope = SettingsPaneScope.of(context);
    final PreferredSizeWidget appBar;

    if (scope != null && scope.embedded) {
      final paneLeading =
          leading ??
          ((scope.showBackButton ||
                  (ModalRoute.of(context)?.impliesAppBarDismissal ?? false))
              ? BackButton(onPressed: scope.onBack)
              : null);
      appBar = AppBar(
        backgroundColor: Colors.transparent,
        scrolledUnderElevation: 0,
        automaticallyImplyLeading: false,
        toolbarHeight: 64,
        titleSpacing: paneLeading == null
            ? 24
            : NavigationToolbar.kMiddleSpacing,
        leading: paneLeading,
        title: title,
        titleTextStyle: Theme.of(context).textTheme.headlineSmall,
        actions: actions,
      );
    } else {
      appBar = SysAppBar(
        title: title,
        actions: actions,
        leading:
            leading ??
            (scope == null ? null : BackButton(onPressed: scope.onBack)),
      );
    }

    // Keep routed panes opaque during transitions.
    return Scaffold(
      appBar: appBar,
      body: body,
      floatingActionButton: floatingActionButton,
      bottomNavigationBar: bottomNavigationBar,
    );
  }
}