import 'package:app/router/route_paths.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';


class LoginAgree extends StatelessWidget {
  final ValueChanged<bool?>? onChanged;
  final bool value;

  const LoginAgree({
    super.key,
    this.onChanged,
    required this.value,
  });

  @override
  Widget build(BuildContext context) {
    return Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        SizedBox(
          width: 25,
          child: Transform.scale(
            scale: 0.8,
            child: Checkbox(
              value: value,
              shape: CircleBorder(),
              onChanged: onChanged,
            ),
          ),
        ),
        RichText(
          text: TextSpan(
            style: Theme.of(context).textTheme.labelMedium,
            children: [
              TextSpan(
                text: "注册或登录即表示您了解并同意",
              ),
              TextSpan(
                text: "服务条款",
                style: TextStyle(color: Theme.of(context).primaryColor),
                recognizer: TapGestureRecognizer()
                  ..onTap = () => context.push(
                    RoutePaths.agreement,
                    extra: {
                      "title": "Terms of Service",
                      "url": "https://support.curain.ai/privacy/foodcura/terms_service.html",
                    },
                  ),
              ),
              TextSpan(text: " 和 "),
              TextSpan(
                text: "隐私协议",
                style: TextStyle(color: Theme.of(context).primaryColor),
                recognizer: TapGestureRecognizer()
                  ..onTap = () => context.push(
                    RoutePaths.agreement,
                    extra: {
                      "title": "Privacy",
                      "url": "https://support.curain.ai/privacy/foodcura/privacy_policy.html",
                    },
                  ),
              ),
            ],
          ),
        ),
      ],
    );
  }
}
