help_view.dart 12.6 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427
import 'package:doublefeel_flutter/app/routes/app_pages.dart';
import 'package:doublefeel_flutter/app/utils/platform_compact.dart';
import 'package:doublefeel_flutter/core/theme/app_colors.dart';
import 'package:doublefeel_flutter/core/theme/app_theme.dart';
import 'package:doublefeel_flutter/l10n/l10n_extensions.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../controllers/help_controller.dart';

class HelpView extends GetView<HelpController> {
  const HelpView({super.key});

  @override
  Widget build(BuildContext context) {
    final faqItems = _buildFaqItems(context);

    return Scaffold(
      appBar: AppBar(
        title: Text(
          context.l10n.help,
        ),
        leadingWidth: 56,
        leading: IconButton(
          highlightColor: Colors.transparent,
          splashColor: Colors.transparent,
          padding: EdgeInsets.zero,
          onPressed: Get.back,
          icon: Image.asset(
            'assets/images/common/ic_nav_back.webp',
            width: 24,
            height: 24,
          ),
        ),
      ),
      body: Stack(
        children: [
          ListView(
            physics: const ClampingScrollPhysics(),
            padding: EdgeInsets.fromLTRB(
              16,
              16,
              16,
              132 + MediaQuery.paddingOf(context).bottom,
            ),
            children: [
              _FaqCard(items: faqItems),
              SizedBox(height: 12),
              _ActionRow(
                title: context.l10n.feedbackLog,
                onTap: () => Get.toNamed(Routes.FEEDBACK_LIST),
              ),
            ],
          ),
          Positioned(
            left: 0,
            right: 0,
            bottom: 36 + MediaQuery.paddingOf(context).bottom,
            child: Center(
              child: _PrimaryHelpButton(
                label: context.l10n.reportAnIssue,
                onTap: () => Get.toNamed(Routes.SUBMIT_FEEDBACK),
              ),
            ),
          ),
        ],
      ),
    );
  }

  List<({String title, List<String> body})> _buildFaqItems(
      BuildContext context) {
    final l10n = context.l10n;

    if (isOhos()) {
      return [
        (
          title: "APP没有数据怎么办",
          body: [
            "1、 确定手表系统在 5.1.0.32SP3 及以上,手表型号需为 WATCH GT 5 系列(含 Pro)/ WATCH 4 系列以上,手环从华为手环 10 及以上。",
            "2、确认设备是否处于省电模式、低电量状态或手表佩戴未贴紧,以上情况会影响手表数据采集。",
            l10n.helpNoDataReasonFooter,
          ],
        ),
        (
          title: l10n.todayFaqLinkHrvRealtimeUpdate,
          body: [
            "在智能手表的默认设置下,HRV 每1小时更新一次。",
            "为了解决 HRV 更新间隔较长的问题,DoubleFeel 设计了实时压力功能:",
            "实时压力每6分钟更新一次(好友状态更新依赖 华为健康 同步,受系统机制影响可能存在短暂延迟。若好友经常使用DoubleFeel,健康状态会更新得更加及时)",
            l10n.todayRealtimeStressScenarioTimely,
            l10n.todayRealtimeStressScenarioConsistentTrend,
            l10n.todayRealtimeStressScenarioSummary,
          ],
        )
      ];
    }

    return [
      (
        title: l10n.todayFaqLinkNoData,
        body: [
          l10n.helpNoDataReason1,
          l10n.helpNoDataReason2,
          l10n.helpNoDataReason3,
          l10n.helpNoDataReasonFooter,
        ],
      ),
      (
        title: l10n.todayFaqLinkHrvRealtimeUpdate,
        body: [
          l10n.todayRealtimeStressScenarioHrvDefault,
          l10n.todayRealtimeStressScenarioRegionLimit,
          l10n.todayRealtimeStressScenarioIntro,
          l10n.todayRealtimeStressScenarioUpdateEvery6Min,
          l10n.todayRealtimeStressScenarioTimely,
          l10n.todayRealtimeStressScenarioConsistentTrend,
          l10n.todayRealtimeStressScenarioSummary,
        ],
      ),
      (
        title: l10n.todayFaqLinkWatchNoStatusAndInteractionNotification,
        body: [
          l10n.todayFaqWatchNoNotificationDescription1,
          l10n.todayFaqWatchNoNotificationDescription2,
          l10n.todayFaqWatchNoNotificationCheckPhoneNotification,
          l10n.todayFaqWatchNoNotificationCheckPhoneBackgroundRefresh,
          l10n.todayFaqWatchNoNotificationCheckWatchBackgroundRefresh,
          l10n.todayFaqWatchNoNotificationCheckModes,
          l10n.todayFaqWatchNoNotificationReinstall,
        ],
      ),
      (
        title: l10n.todayFaqLinkWatchFaceDataDelay,
        body: [
          l10n.todayFaqWatchFaceDelayDescription1,
          l10n.todayFaqWatchFaceDelayIfOverOneHour,
          l10n.todayFaqWatchFaceDelayOpenWatchApp,
          l10n.todayFaqWatchFaceDelayIfStill,
          l10n.todayFaqWatchFaceDelayRestartApp,
          l10n.todayFaqWatchFaceDelayCheckIntro,
          l10n.todayFaqWatchFaceDelayCheckData,
          l10n.todayFaqWatchFaceDelayCheckPhoneHealth,
          l10n.todayFaqWatchFaceDelayCheckWatchHealth,
          l10n.todayFaqWatchFaceDelayCheckBackgroundRefresh,
          l10n.todayFaqWatchFaceDelayRestartWatch,
        ],
      ),
      (
        title: l10n.todayFaqLinkWatchFaceBlackScreen,
        body: [
          l10n.todayFaqWatchFaceBlackScreenDescription,
        ],
      ),
    ];
  }
}

class _FaqCard extends StatelessWidget {
  const _FaqCard({required this.items});

  final List<({String title, List<String> body})> items;

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.fromLTRB(20, 20, 20, 9),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(16),
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            AppLocalizations.of(context)!.frequentlyAskedQuestions,
            style: TextStyle(
              color: context.colors.textPrimary,
              fontSize: 14,
              fontWeight: FontWeight.w600,
              height: 1.4,
            ),
          ),
          SizedBox(height: 8),
          ...items.map(
            (item) => _QuestionRow(
              title: item.title,
              onTap: () => _showQuestionBottomSheet(item),
            ),
          ),
        ],
      ),
    );
  }

  void _showQuestionBottomSheet(({String title, List<String> body}) item) {
    Get.bottomSheet(
      _QuestionBottomSheet(item: item),
      barrierColor: Colors.black.withValues(alpha: 0.7),
      enableDrag: true,
      isScrollControlled: true,
      persistent: false,
    );
  }
}

class _QuestionRow extends StatelessWidget {
  const _QuestionRow({
    required this.title,
    required this.onTap,
  });

  final String title;
  final VoidCallback onTap;

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      behavior: HitTestBehavior.opaque,
      onTap: onTap,
      child: SizedBox(
        height: 40,
        child: Row(
          children: [
            Expanded(
              child: Text(
                title,
                maxLines: 1,
                overflow: TextOverflow.ellipsis,
                style: TextStyle(
                  color: context.colors.textPrimary,
                  fontSize: 13,
                  fontWeight: FontWeight.w400,
                  height: 1.4,
                ),
              ),
            ),
            SizedBox(width: 12),
            Image.asset(
              'assets/images/common/ic_more_gray.png',
              width: 16,
              height: 16,
            ),
          ],
        ),
      ),
    );
  }
}

class _ActionRow extends StatelessWidget {
  const _ActionRow({
    required this.title,
    required this.onTap,
  });

  final String title;
  final VoidCallback onTap;

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      behavior: HitTestBehavior.opaque,
      onTap: onTap,
      child: Container(
        height: 56,
        padding: EdgeInsets.symmetric(horizontal: 20),
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(16),
        ),
        child: Row(
          children: [
            Expanded(
              child: Text(
                title,
                maxLines: 1,
                overflow: TextOverflow.ellipsis,
                style: TextStyle(
                  color: context.colors.textPrimary,
                  fontSize: 14,
                  fontWeight: FontWeight.w600,
                  height: 1.4,
                ),
              ),
            ),
            Image.asset(
              'assets/images/common/ic_more_gray.png',
              width: 16,
              height: 16,
            ),
          ],
        ),
      ),
    );
  }
}

class _PrimaryHelpButton extends StatelessWidget {
  const _PrimaryHelpButton({
    required this.label,
    required this.onTap,
  });

  final String label;
  final VoidCallback onTap;

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      behavior: HitTestBehavior.opaque,
      onTap: onTap,
      child: Container(
        width: 280,
        height: 48,
        alignment: Alignment.center,
        decoration: BoxDecoration(
          color: AppColors.primary,
          borderRadius: BorderRadius.circular(24),
        ),
        child: Text(
          label,
          style: const TextStyle(
            color: Colors.white,
            fontSize: 16,
            fontWeight: FontWeight.w600,
          ),
        ),
      ),
    );
  }
}

class _QuestionBottomSheet extends StatelessWidget {
  const _QuestionBottomSheet({required this.item});

  final ({String title, List<String> body}) item;

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      height: 331,
      child: Container(
        decoration: BoxDecoration(
          color: context.colors.backgroundPage,
          borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
        ),
        child: SafeArea(
          top: false,
          child: Column(
            children: [
              SizedBox(height: 8),
              SizedBox(
                height: 56,
                child: Row(
                  // alignment: Alignment.center,

                  children: [
                    GestureDetector(
                      behavior: HitTestBehavior.opaque,
                      onTap: Get.back,
                      child: SizedBox(
                        width: 44,
                        height: 44,
                        child: Center(
                          child: Image.asset(
                            'assets/images/common/ic_close.png',
                            width: 20,
                            height: 20,
                            color: context.colors.chartPurple,
                          ),
                        ),
                      ),
                    ),
                    Expanded(
                      child: Text(
                        item.title,
                        maxLines: 1,
                        overflow: TextOverflow.ellipsis,
                        textAlign: TextAlign.center,
                        style: TextStyle(
                          color: context.colors.textPrimary,
                          fontSize: 16,
                          fontWeight: FontWeight.w600,
                          height: 1.2,
                        ),
                      ),
                    ),
                    SizedBox(
                      width: 44,
                    )
                  ],
                ),
              ),
              Container(
                height: 215,
                margin: EdgeInsets.symmetric(horizontal: 16),
                padding: EdgeInsets.fromLTRB(20, 20, 20, 18),
                decoration: BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.circular(16),
                ),
                child: ListView.separated(
                  physics: const ClampingScrollPhysics(),
                  padding: EdgeInsets.zero,
                  itemCount: item.body.length,
                  separatorBuilder: (_, __) => SizedBox(height: 12),
                  itemBuilder: (context, index) {
                    return Text(
                      item.body[index],
                      style: TextStyle(
                        color: context.colors.textSecondary,
                        fontSize: 13,
                        fontWeight: FontWeight.w400,
                        height: 17 / 12,
                      ),
                    );
                  },
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}