appBar method

Widget appBar(
  1. BuildContext context
)

AppBar widget. 顶栏部件

Implementation

Widget appBar(BuildContext context) {
  return ValueListenableBuilder<bool>(
    valueListenable: isDisplayingDetail,
    builder: (_, bool value, Widget? child) => AnimatedPositionedDirectional(
      duration: kThemeAnimationDuration,
      curve: Curves.easeInOut,
      top: value ? 0.0 : -(context.topPadding + kToolbarHeight),
      start: 0.0,
      end: 0.0,
      height: context.topPadding + kToolbarHeight,
      child: child!,
    ),
    child: Container(
      padding: EdgeInsetsDirectional.only(top: context.topPadding),
      color: themeData.canvasColor,
      child: Stack(
        fit: StackFit.expand,
        children: <Widget>[
          Row(
            children: <Widget>[
              IconButton(
                icon: const Icon(Icons.close),
                onPressed: Navigator.of(context).maybePop,
              ),
              const Spacer(),
              if (isAppleOS && provider != null) selectButton(context),
              if (!isAppleOS && (provider != null || isWeChatMoment))
                Padding(
                  padding: const EdgeInsetsDirectional.only(end: 14),
                  child: confirmButton(context),
                ),
            ],
          ),
          if (!isAppleOS && specialPickerType == null)
            StreamBuilder<int>(
              initialData: currentIndex,
              stream: pageStreamController.stream,
              builder: (_, AsyncSnapshot<int> snapshot) => Center(
                child: ScaleText(
                  '${snapshot.data! + 1}/${previewAssets.length}',
                  style: const TextStyle(
                    fontSize: 17,
                    fontWeight: FontWeight.w500,
                  ),
                ),
              ),
            ),
        ],
      ),
    ),
  );
}