|
1 | 1 | import 'dart:async';
|
| 2 | +import 'dart:math'; |
2 | 3 |
|
3 | 4 | import 'package:flutter/material.dart';
|
4 | 5 | import 'package:get_10101/common/color.dart';
|
@@ -89,72 +90,80 @@ class _TaskStatusDialog extends State<TaskStatusDialog> {
|
89 | 90 | });
|
90 | 91 | }
|
91 | 92 |
|
92 |
| - Widget closeButton = SizedBox( |
93 |
| - width: MediaQuery.of(context).size.width * 0.65, |
94 |
| - child: ElevatedButton( |
95 |
| - onPressed: () { |
96 |
| - var goRouter = GoRouter.of(context); |
97 |
| - if (goRouter.canPop()) { |
98 |
| - goRouter.pop(); |
99 |
| - } |
100 |
| - |
101 |
| - if (widget.onClose != null) { |
102 |
| - widget.onClose!(); |
103 |
| - } |
104 |
| - }, |
105 |
| - style: ElevatedButton.styleFrom( |
106 |
| - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), |
107 |
| - padding: EdgeInsets.zero, |
108 |
| - backgroundColor: tenTenOnePurple), |
109 |
| - child: const Text("Close")), |
110 |
| - ); |
| 93 | + double width = min((MediaQuery.of(context).size.width), 350); |
| 94 | + |
| 95 | + Widget closeButton = ElevatedButton( |
| 96 | + onPressed: () { |
| 97 | + var goRouter = GoRouter.of(context); |
| 98 | + if (goRouter.canPop()) { |
| 99 | + goRouter.pop(); |
| 100 | + } |
| 101 | + |
| 102 | + if (widget.onClose != null) { |
| 103 | + widget.onClose!(); |
| 104 | + } |
| 105 | + }, |
| 106 | + style: ElevatedButton.styleFrom( |
| 107 | + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), |
| 108 | + padding: EdgeInsets.zero, |
| 109 | + backgroundColor: tenTenOnePurple), |
| 110 | + child: const Text("Close")); |
111 | 111 |
|
112 | 112 | AlertDialog dialog = AlertDialog(
|
113 | 113 | contentPadding: EdgeInsets.zero,
|
| 114 | + clipBehavior: Clip.antiAlias, |
| 115 | + backgroundColor: Colors.transparent, |
114 | 116 | shape: RoundedRectangleBorder(
|
115 | 117 | borderRadius: BorderRadius.circular(18.0),
|
116 | 118 | ),
|
117 |
| - content: Container( |
118 |
| - decoration: BoxDecoration( |
119 |
| - color: Colors.white, |
120 |
| - borderRadius: BorderRadius.circular(18.0), |
121 |
| - ), |
122 |
| - clipBehavior: Clip.antiAlias, |
123 |
| - width: MediaQuery.of(context).size.shortestSide, |
| 119 | + content: SizedBox( |
| 120 | + width: width, |
124 | 121 | child: Column(
|
125 | 122 | mainAxisSize: MainAxisSize.min,
|
| 123 | + mainAxisAlignment: MainAxisAlignment.start, |
126 | 124 | children: [
|
127 |
| - Container( |
| 125 | + SizedBox( |
128 | 126 | width: double.infinity,
|
129 | 127 | height: 110,
|
130 |
| - clipBehavior: Clip.antiAlias, |
131 |
| - decoration: const BoxDecoration( |
132 |
| - color: Colors.white, |
133 |
| - ), |
134 | 128 | child: coverImage,
|
135 | 129 | ),
|
136 |
| - const SizedBox(height: 15), |
137 |
| - if (widget.showSuccessTitle) buildTitle(widget.task.status), |
138 |
| - Padding( |
139 |
| - padding: EdgeInsets.only( |
140 |
| - top: 10.0, left: 15.0, right: 15.0, bottom: isPending ? 25.0 : 0.0), |
141 |
| - child: widget.content), |
142 |
| - if (widget.task.status == TaskStatus.failed && widget.task.error != null) |
143 |
| - Padding( |
144 |
| - padding: const EdgeInsets.only(top: 10.0, left: 15.0, right: 15.0), |
145 |
| - child: ErrorDetails(details: widget.task.error!), |
| 130 | + Container( |
| 131 | + decoration: const BoxDecoration(color: Colors.white), |
| 132 | + child: Column( |
| 133 | + mainAxisSize: MainAxisSize.min, |
| 134 | + crossAxisAlignment: CrossAxisAlignment.stretch, |
| 135 | + children: [ |
| 136 | + const SizedBox(height: 15), |
| 137 | + if (widget.showSuccessTitle) buildTitle(widget.task.status), |
| 138 | + Padding( |
| 139 | + padding: EdgeInsets.only( |
| 140 | + top: 10.0, left: 15.0, right: 15.0, bottom: isPending ? 25.0 : 0.0), |
| 141 | + child: widget.content), |
| 142 | + if (widget.task.status == TaskStatus.failed && widget.task.error != null) |
| 143 | + Padding( |
| 144 | + padding: const EdgeInsets.only(top: 10.0, left: 15.0, right: 15.0), |
| 145 | + child: ErrorDetails(details: widget.task.error!), |
| 146 | + ), |
| 147 | + if (!isPending || timeout) |
| 148 | + ConstrainedBox( |
| 149 | + constraints: BoxConstraints( |
| 150 | + maxWidth: width * 0.65, |
| 151 | + ), |
| 152 | + child: Padding( |
| 153 | + padding: |
| 154 | + const EdgeInsets.only(top: 20.0, left: 15.0, right: 15.0, bottom: 15.0), |
| 155 | + child: Row( |
| 156 | + crossAxisAlignment: CrossAxisAlignment.end, |
| 157 | + mainAxisAlignment: MainAxisAlignment.center, |
| 158 | + children: [ |
| 159 | + Expanded(child: closeButton), |
| 160 | + ], |
| 161 | + ), |
| 162 | + ), |
| 163 | + ) |
| 164 | + ], |
146 | 165 | ),
|
147 |
| - if (!isPending || timeout) |
148 |
| - Padding( |
149 |
| - padding: const EdgeInsets.only(top: 20.0, left: 15.0, right: 15.0, bottom: 15.0), |
150 |
| - child: Row( |
151 |
| - crossAxisAlignment: CrossAxisAlignment.end, |
152 |
| - mainAxisAlignment: MainAxisAlignment.center, |
153 |
| - children: [ |
154 |
| - closeButton, |
155 |
| - ], |
156 |
| - ), |
157 |
| - ) |
| 166 | + ) |
158 | 167 | ],
|
159 | 168 | ),
|
160 | 169 | ),
|
|
0 commit comments