update_dailog.dart 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import 'package:get/get.dart';
  4. import 'package:nomo/config/theme/theme_extensions/theme_extension.dart';
  5. import '../../config/translations/strings_enum.dart';
  6. import '../data/models/launch/upgrade.dart';
  7. import '../widgets/submit_btn.dart';
  8. class UpdateDialog extends StatelessWidget {
  9. final Upgrade? upgrade;
  10. final VoidCallback? onUpdate;
  11. final VoidCallback? onLater;
  12. const UpdateDialog({
  13. super.key,
  14. required this.upgrade,
  15. this.onUpdate,
  16. this.onLater,
  17. });
  18. @override
  19. Widget build(BuildContext context) {
  20. return Dialog(
  21. backgroundColor: Colors.transparent,
  22. shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24.r)),
  23. child: Container(
  24. constraints: BoxConstraints(
  25. maxWidth: MediaQuery.of(context).size.width * 0.85,
  26. maxHeight: 360.w,
  27. ),
  28. child: Stack(
  29. alignment: Alignment.topCenter,
  30. children: [
  31. Container(
  32. width: double.infinity,
  33. decoration: BoxDecoration(
  34. color: Get.reactiveTheme.highlightColor,
  35. border: Border.all(
  36. color: Get.reactiveTheme.dividerColor,
  37. width: 1.w,
  38. ),
  39. borderRadius: BorderRadius.all(
  40. Radius.circular(24.r),
  41. ), // 四个角 16dp
  42. ),
  43. child: Column(
  44. children: [
  45. 24.verticalSpace,
  46. Icon(
  47. Icons.rocket,
  48. size: 96.w,
  49. color: Get.reactiveTheme.primaryColor,
  50. ),
  51. 16.verticalSpace,
  52. // Title
  53. Text(
  54. Strings.newVersionAvailable.tr,
  55. style: TextStyle(
  56. fontSize: 16.sp,
  57. fontWeight: FontWeight.w600,
  58. height: 1.4,
  59. color: Get.reactiveTheme.textTheme.bodyLarge!.color,
  60. ),
  61. ),
  62. 4.verticalSpace,
  63. // Version
  64. Text(
  65. "${upgrade?.versionName}",
  66. style: TextStyle(
  67. fontSize: 12.sp,
  68. height: 1.4,
  69. color: Get.reactiveTheme.hintColor,
  70. ),
  71. ),
  72. 12.verticalSpace,
  73. SingleChildScrollView(
  74. child: Padding(
  75. padding: EdgeInsets.symmetric(horizontal: 24.w),
  76. child: ConstrainedBox(
  77. constraints: BoxConstraints(
  78. maxHeight: 80.w, // 设置最大高度
  79. ),
  80. child: SingleChildScrollView(
  81. child: Column(
  82. crossAxisAlignment: CrossAxisAlignment.start,
  83. children: [
  84. ...upgrade!.info!
  85. .split('\n')
  86. .map(
  87. (text) => Column(
  88. children: [
  89. _buildBulletPoint(text),
  90. 4.verticalSpace,
  91. ],
  92. ),
  93. ),
  94. 16.verticalSpace,
  95. ],
  96. ),
  97. ),
  98. ),
  99. ),
  100. ),
  101. ],
  102. ),
  103. ),
  104. Positioned(
  105. bottom: 24.w,
  106. left: 0,
  107. right: 0,
  108. child: Padding(
  109. padding: EdgeInsets.symmetric(horizontal: 16.w),
  110. child: Row(
  111. children: [
  112. if (upgrade?.forced == false)
  113. Expanded(
  114. child: SubmitButton(
  115. onPressed: onLater ?? () {},
  116. text: Strings.later.tr,
  117. ),
  118. ),
  119. if (upgrade?.forced == false) 8.horizontalSpace,
  120. Expanded(
  121. child: SubmitButton(
  122. text: Strings.updateNow.tr,
  123. onPressed: onUpdate,
  124. ),
  125. ),
  126. ],
  127. ),
  128. ),
  129. ),
  130. ],
  131. ),
  132. ),
  133. );
  134. }
  135. Widget _buildBulletPoint(String text) {
  136. return Row(
  137. crossAxisAlignment: CrossAxisAlignment.start,
  138. children: [
  139. Text(
  140. '• ',
  141. style: TextStyle(
  142. fontSize: 12.sp,
  143. height: 1.4,
  144. color: Get.reactiveTheme.hintColor,
  145. ),
  146. ),
  147. Expanded(
  148. child: Text(
  149. text,
  150. style: TextStyle(
  151. fontSize: 12.sp,
  152. height: 1.4,
  153. color: Get.reactiveTheme.hintColor,
  154. ),
  155. ),
  156. ),
  157. ],
  158. );
  159. }
  160. }