dial_preview_card.dart 2.08 KB
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:doublefeel_flutter/l10n/l10n_extensions.dart';

import 'watch_face_preview.dart';
import 'watch_theme_section_card.dart';

class DialPreviewCard extends StatelessWidget {
  final bool showFriend;
  final String? themeImageUrl;
  final String? themeImageUrl2;
  final Function()? switchFriend;
  const DialPreviewCard(
      {super.key,
      required this.showFriend,
      this.themeImageUrl,
      this.themeImageUrl2,
      this.switchFriend});

  @override
  Widget build(BuildContext context) {
    return WatchThemeSectionCard(
      padding: EdgeInsets.fromLTRB(0, 20, 0, 27),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          WatchThemeSectionTitle(context.l10n.watchThemeDialPreview)
              .paddingOnly(left: 20),
          SizedBox(height: 16),
          SizedBox(
            height: showFriend ? 172 : 136,
            child: ListView.separated(
              padding: EdgeInsets.fromLTRB(20, 0, 20, 0),
              scrollDirection: Axis.horizontal,
              physics: const AlwaysScrollableScrollPhysics(),
              itemBuilder: (context, index) {
                if (index == 0) {
                  return WatchFacePreview(
                    type: WatchFacePreviewType.surface,
                    themeImageUrl: themeImageUrl,
                  );
                } else if (showFriend && index == 1) {
                  return WatchFacePreview(
                    type: WatchFacePreviewType.coupleSmall,
                    themeImageUrl: themeImageUrl,
                    themeImageUrl2: themeImageUrl2,
                    switchFriend: switchFriend,
                  );
                }
                return WatchFacePreview(
                  type: WatchFacePreviewType.singleSmall,
                  themeImageUrl: themeImageUrl,
                );
              },
              separatorBuilder: (context, index) => SizedBox(width: 12),
              itemCount: showFriend ? 3 : 2,
            ),
          ),
        ],
      ),
    );
  }
}