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: Row(
        children: <Widget>[
          Expanded(
            child: Align(
              alignment: AlignmentDirectional.centerStart,
              child: Semantics(
                sortKey: ordinalSortKey(0),
                child: IconButton(
                  icon: const Icon(Icons.close),
                  tooltip: MaterialLocalizations.of(
                    context,
                  ).backButtonTooltip,
                  onPressed: Navigator.of(context).maybePop,
                ),
              ),
            ),
          ),
          if (!isAppleOS && specialPickerType == null)
            Expanded(
              child: Center(
                child: Semantics(
                  sortKey: ordinalSortKey(0.1),
                  child: StreamBuilder<int>(
                    initialData: currentIndex,
                    stream: pageStreamController.stream,
                    builder: (_, AsyncSnapshot<int> snapshot) => ScaleText(
                      '${snapshot.data! + 1}/${previewAssets.length}',
                      style: const TextStyle(
                        fontSize: 17,
                        fontWeight: FontWeight.w500,
                      ),
                    ),
                  ),
                ),
              ),
            ),
          if (isAppleOS && provider != null)
            Expanded(
              child: Align(
                alignment: AlignmentDirectional.centerEnd,
                child: Semantics(
                  sortKey: ordinalSortKey(0.2),
                  child: selectButton(context),
                ),
              ),
            )
          else if (isAppleOS)
            const Spacer(),
          if (!isAppleOS && (provider != null || isWeChatMoment))
            Expanded(
              child: Align(
                alignment: AlignmentDirectional.centerEnd,
                child: Semantics(
                  sortKey: ordinalSortKey(0.3),
                  child: Padding(
                    padding: const EdgeInsetsDirectional.only(end: 14),
                    child: confirmButton(context),
                  ),
                ),
              ),
            )
          else if (!isAppleOS)
            const Spacer(),
        ],
      ),
    ),
  );
}