|
1 | 1 | // ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables |
2 | | - |
3 | 2 | import 'package:darq/darq.dart'; |
4 | 3 | import 'package:dynamic_color/dynamic_color.dart'; |
5 | 4 | import 'package:enum_flag/enum_flag.dart'; |
@@ -112,79 +111,79 @@ class DataPageState extends State<DataPage> with TickerProviderStateMixin { |
112 | 111 | pinned: true, |
113 | 112 | snap: false, |
114 | 113 | floating: false, |
115 | | - flexibleSpace: LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) { |
116 | | - var top = constraints.biggest.height; |
117 | | - var padding = 100.0 - ((constraints.maxHeight - 64) * 100 / (242 - 64)); |
118 | | - |
119 | | - return FlexibleSpaceBar( |
120 | | - centerTitle: false, |
121 | | - titlePadding: EdgeInsets.only(left: (isChildPage ?? false) ? padding : 20, bottom: 15, right: 20), |
122 | | - title: AnimatedOpacity( |
123 | | - duration: Duration(milliseconds: 250), |
124 | | - opacity: (top > 110 || widget.leading == null) ? 1.0 : 0.0, |
125 | | - child: Text(widget.title, maxLines: 1, overflow: TextOverflow.ellipsis)), |
126 | | - background: Stack(children: <Widget>[ |
127 | | - // Search icon |
128 | | - if (widget.pageFlags.hasFlag(DataPageType.searchable)) |
129 | | - SearchAnchor( |
130 | | - isFullScreen: true, |
131 | | - builder: (context, controller) => Padding( |
132 | | - padding: (isChildPage ?? false) && widget.trailing != null |
133 | | - ? const EdgeInsets.only(left: 65, top: 17) |
134 | | - : const EdgeInsets.all(15.0), |
135 | | - child: Align( |
136 | | - alignment: |
137 | | - (isChildPage ?? false) && widget.trailing == null ? Alignment.topRight : Alignment.topLeft, |
138 | | - child: SafeArea( |
139 | | - child: Icon( |
140 | | - Icons.search, |
141 | | - size: 25, |
142 | | - color: Theme.of(context).colorScheme.onSurface, |
143 | | - ))), |
| 114 | + flexibleSpace: LayoutBuilder( |
| 115 | + builder: (BuildContext context, BoxConstraints constraints) => FlexibleSpaceBar( |
| 116 | + centerTitle: false, |
| 117 | + titlePadding: EdgeInsets.only( |
| 118 | + left: (isChildPage ?? false) ? (100.0 - ((constraints.maxHeight - 64) * 100 / (242 - 64))) : 20, |
| 119 | + bottom: 15, |
| 120 | + right: 20), |
| 121 | + title: Text(widget.title, maxLines: 1, overflow: TextOverflow.ellipsis), |
| 122 | + background: Stack(children: <Widget>[ |
| 123 | + // Search icon |
| 124 | + if (widget.pageFlags.hasFlag(DataPageType.searchable)) |
| 125 | + SearchAnchor( |
| 126 | + isFullScreen: true, |
| 127 | + builder: (context, controller) => Padding( |
| 128 | + padding: (isChildPage ?? false) && widget.trailing != null |
| 129 | + ? const EdgeInsets.only(left: 65, top: 17) |
| 130 | + : const EdgeInsets.all(15.0), |
| 131 | + child: Align( |
| 132 | + alignment: (isChildPage ?? false) && widget.trailing == null |
| 133 | + ? Alignment.topRight |
| 134 | + : Alignment.topLeft, |
| 135 | + child: SafeArea( |
| 136 | + child: Icon( |
| 137 | + Icons.search, |
| 138 | + size: 25, |
| 139 | + color: Theme.of(context).colorScheme.onSurface, |
| 140 | + ))), |
| 141 | + ), |
| 142 | + suggestionsBuilder: widget.searchBuilder ?? |
| 143 | + (context, controller) => (widget.children ?? []).prepend(SizedBox(height: 15)), |
| 144 | + ), |
| 145 | + // Refresh progress status |
| 146 | + if ((Share.session.refreshStatus.progressStatus?.isNotEmpty ?? false) && |
| 147 | + widget.pageFlags.hasFlag(DataPageType.refreshable)) |
| 148 | + SafeArea( |
| 149 | + child: Padding( |
| 150 | + padding: switch (isChildPage ?? false) { |
| 151 | + false when widget.pageFlags.hasFlag(DataPageType.searchable) => |
| 152 | + const EdgeInsets.only(left: 45), // Search icon only |
| 153 | + false when !widget.pageFlags.hasFlag(DataPageType.searchable) => |
| 154 | + const EdgeInsets.only(left: 5), // Nothing in the way |
| 155 | + true when widget.pageFlags.hasFlag(DataPageType.searchable) && widget.trailing == null => |
| 156 | + const EdgeInsets.only(left: 45), // Back icon only |
| 157 | + true when widget.pageFlags.hasFlag(DataPageType.searchable) && widget.trailing != null => |
| 158 | + const EdgeInsets.only(left: 100), // Two icons ::before |
| 159 | + _ => const EdgeInsets.all(0), |
| 160 | + }, |
| 161 | + child: Container( |
| 162 | + margin: const EdgeInsets.only(top: 10, left: 10), |
| 163 | + child: ConstrainedBox( |
| 164 | + constraints: const BoxConstraints(maxWidth: 150), |
| 165 | + child: Row(children: [ |
| 166 | + Flexible( |
| 167 | + child: Text( |
| 168 | + Share.session.refreshStatus.progressStatus ?? '', |
| 169 | + maxLines: 2, |
| 170 | + overflow: TextOverflow.ellipsis, |
| 171 | + style: const TextStyle( |
| 172 | + color: CupertinoColors.inactiveGray, fontSize: 13, fontWeight: FontWeight.w300), |
| 173 | + )) |
| 174 | + ]))), |
| 175 | + ), |
144 | 176 | ), |
145 | | - suggestionsBuilder: widget.searchBuilder ?? |
146 | | - (context, controller) => (widget.children ?? []).prepend(SizedBox(height: 15)), |
147 | | - ), |
148 | | - // Refresh progress status |
149 | | - if ((Share.session.refreshStatus.progressStatus?.isNotEmpty ?? false) && |
150 | | - widget.pageFlags.hasFlag(DataPageType.refreshable)) |
151 | | - SafeArea( |
152 | | - child: Padding( |
153 | | - padding: switch (isChildPage ?? false) { |
154 | | - false when widget.pageFlags.hasFlag(DataPageType.searchable) => |
155 | | - const EdgeInsets.only(left: 45), // Search icon only |
156 | | - false when !widget.pageFlags.hasFlag(DataPageType.searchable) => |
157 | | - const EdgeInsets.only(left: 5), // Nothing in the way |
158 | | - true when widget.pageFlags.hasFlag(DataPageType.searchable) && widget.trailing == null => |
159 | | - const EdgeInsets.only(left: 45), // Back icon only |
160 | | - true when widget.pageFlags.hasFlag(DataPageType.searchable) && widget.trailing != null => |
161 | | - const EdgeInsets.only(left: 100), // Two icons ::before |
162 | | - _ => const EdgeInsets.all(0), |
163 | | - }, |
164 | | - child: Container( |
165 | | - margin: const EdgeInsets.only(top: 10, left: 10), |
166 | | - child: ConstrainedBox( |
167 | | - constraints: const BoxConstraints(maxWidth: 150), |
168 | | - child: Text( |
169 | | - Share.session.refreshStatus.progressStatus ?? '', |
170 | | - maxLines: 2, |
171 | | - overflow: TextOverflow.ellipsis, |
172 | | - style: const TextStyle( |
173 | | - color: CupertinoColors.inactiveGray, fontSize: 13, fontWeight: FontWeight.w300), |
174 | | - ))), |
| 177 | + if (widget.leading != null && |
| 178 | + (!widget.pageFlags.hasFlag(DataPageType.refreshable) || |
| 179 | + (Share.session.refreshStatus.progressStatus?.isEmpty ?? true))) |
| 180 | + SafeArea( |
| 181 | + child: SizedBox( |
| 182 | + height: 60, |
| 183 | + width: 150, |
| 184 | + child: Container(margin: EdgeInsets.only(left: 10, top: 3, bottom: 1), child: widget.leading)), |
175 | 185 | ), |
176 | | - ), |
177 | | - if (widget.leading != null && |
178 | | - (!widget.pageFlags.hasFlag(DataPageType.refreshable) || |
179 | | - (Share.session.refreshStatus.progressStatus?.isEmpty ?? true))) |
180 | | - SafeArea( |
181 | | - child: SizedBox( |
182 | | - height: 60, |
183 | | - width: 150, |
184 | | - child: Container(margin: EdgeInsets.only(left: 10, top: 3, bottom: 1), child: widget.leading)), |
185 | | - ), |
186 | | - ])); |
187 | | - }), |
| 186 | + ]))), |
188 | 187 | leadingWidth: widget.leading != null ? 150 : null, |
189 | 188 | leading: widget.leading != null ? Container() : null, |
190 | 189 | actions: <Widget>[Container(margin: EdgeInsets.only(right: 10), child: widget.trailing)], |
@@ -217,9 +216,21 @@ class DataPageState extends State<DataPage> with TickerProviderStateMixin { |
217 | 216 | SliverFillRemaining( |
218 | 217 | child: TabBarView( |
219 | 218 | controller: tabController, |
| 219 | + viewportFraction: MediaQuery.of(context).size.width >= 640 ? (1 / 3) : 1.0, |
220 | 220 | children: List.generate(widget.segments!.length, |
221 | 221 | (index) => widget.pageBuilder!(context, widget.segments!.keys.elementAt(index))), |
222 | 222 | ), |
| 223 | + // hasScrollBody: false, |
| 224 | + // child: Column( |
| 225 | + // children: [ |
| 226 | + // AutoScaleTabBarView( |
| 227 | + // controller: tabController, |
| 228 | + // // viewportFraction: MediaQuery.of(context).size.width >= 640 ? (1 / 3) : 1.0, |
| 229 | + // children: List.generate(widget.segments!.length, |
| 230 | + // (index) => widget.pageBuilder!(context, widget.segments!.keys.elementAt(index))), |
| 231 | + // ), |
| 232 | + // ], |
| 233 | + // ), |
223 | 234 | ), |
224 | 235 | ], |
225 | 236 | ); |
|
0 commit comments