Skip to content

Commit 6259d1f

Browse files
committed
refactor(about_screen): make version card tappable to show About dialog and tidy custom name edit UI
1 parent 68942a7 commit 6259d1f

File tree

1 file changed

+149
-80
lines changed

1 file changed

+149
-80
lines changed

lib/settings/about_screen.dart

Lines changed: 149 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ import 'package:orion/util/orion_config.dart';
3232
import 'package:orion/util/orion_kb/orion_keyboard_expander.dart';
3333
import 'package:orion/util/orion_kb/orion_textfield_spawn.dart';
3434
import 'package:orion/backend_service/backend_service.dart';
35+
import 'package:orion/settings/about_dialog.dart';
36+
import 'package:orion/util/markdown_screen.dart';
37+
import 'package:orion/settings/fancy_license_screen.dart';
3538

3639
Logger _logger = Logger('AboutScreen');
3740
OrionConfig config = OrionConfig();
@@ -177,17 +180,80 @@ class AboutScreenState extends State<AboutScreen> {
177180
return GlassCard(
178181
elevation: 1.0,
179182
outlined: true,
180-
child: ListTile(
181-
title: const Text('UI & API Version'),
182-
subtitle: FutureBuilder<String>(
183-
future: getVersionNumber(),
184-
builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
185-
return AutoSizeText(
186-
snapshot.data ?? 'N/A',
187-
maxLines: 1,
188-
minFontSize: 12,
189-
);
190-
},
183+
child: InkWell(
184+
onTap: () {
185+
showOrionAboutDialog(
186+
context: context,
187+
applicationName: 'Orion',
188+
applicationVersion:
189+
'Version ${Pubspec.version} - ${Pubspec.versionFull.toString().split('+')[1] == 'SELFCOMPILED' ? 'Local Build' : 'Commit ${Pubspec.versionFull.toString().split('+')[1]}'}',
190+
applicationLegalese:
191+
'Apache License 2.0 - Copyright © ${DateTime.now().year} Open Resin Alliance',
192+
applicationIcon: const FlutterLogo(size: 100),
193+
children: <Widget>[
194+
Padding(
195+
padding: const EdgeInsets.only(left: 10, right: 10),
196+
child: GlassCard(
197+
child: ListTile(
198+
leading: const Icon(Icons.list, size: 30),
199+
title: const Text('Changelog'),
200+
onTap: () {
201+
Navigator.push(
202+
context,
203+
MaterialPageRoute(
204+
builder: (context) =>
205+
const MarkdownScreen(filename: 'CHANGELOG.md'),
206+
),
207+
);
208+
},
209+
),
210+
),
211+
),
212+
Padding(
213+
padding: const EdgeInsets.all(10),
214+
child: GlassCard(
215+
child: ListTile(
216+
title: const Text('Open-Source Licenses'),
217+
leading: const Icon(Icons.favorite, size: 30),
218+
onTap: () {
219+
showFancyLicensePage(
220+
context: context,
221+
applicationName: 'Orion',
222+
applicationVersion: Pubspec.version,
223+
);
224+
},
225+
),
226+
),
227+
),
228+
],
229+
);
230+
},
231+
child: ListTile(
232+
title: Text.rich(
233+
TextSpan(
234+
style: Theme.of(context).textTheme.titleMedium,
235+
children: [
236+
const TextSpan(text: 'UI & API Version '),
237+
TextSpan(
238+
text: '(Tap for more info)',
239+
style: TextStyle(
240+
color: Theme.of(context).colorScheme.primary,
241+
fontWeight: FontWeight.w600,
242+
),
243+
),
244+
],
245+
),
246+
),
247+
subtitle: FutureBuilder<String>(
248+
future: getVersionNumber(),
249+
builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
250+
return AutoSizeText(
251+
snapshot.data ?? 'N/A',
252+
maxLines: 1,
253+
minFontSize: 12,
254+
);
255+
},
256+
),
191257
),
192258
),
193259
);
@@ -233,81 +299,84 @@ class AboutScreenState extends State<AboutScreen> {
233299
softWrap: false,
234300
),
235301
),
236-
GlassButton(
237-
style: ElevatedButton.styleFrom(
238-
shape: RoundedRectangleBorder(
239-
borderRadius: BorderRadius.circular(15),
302+
if (config.enableCustomName()) ...[
303+
GlassButton(
304+
style: ElevatedButton.styleFrom(
305+
shape: RoundedRectangleBorder(
306+
borderRadius: BorderRadius.circular(15),
307+
),
308+
minimumSize: const Size(90, 50), // Same width as Edit button
240309
),
241-
minimumSize: const Size(90, 50), // Same width as Edit button
242-
),
243-
onPressed: () {
244-
showDialog(
245-
context: context,
246-
builder: (BuildContext context) {
247-
return GlassAlertDialog(
248-
title: const Center(child: Text('Custom Machine Name')),
249-
content: SizedBox(
250-
width: MediaQuery.of(context).size.width * 0.5,
251-
child: SingleChildScrollView(
252-
child: Column(
253-
children: [
254-
SpawnOrionTextField(
255-
key: cNameTextFieldKey,
256-
keyboardHint: 'Enter a custom name',
257-
locale:
258-
Localizations.localeOf(context).toString(),
259-
scrollController: _scrollController,
260-
presetText: config.getString('machineName',
261-
category: 'machine'),
262-
),
263-
OrionKbExpander(textFieldKey: cNameTextFieldKey),
264-
],
310+
onPressed: () {
311+
showDialog(
312+
context: context,
313+
builder: (BuildContext context) {
314+
return GlassAlertDialog(
315+
title: const Center(child: Text('Custom Machine Name')),
316+
content: SizedBox(
317+
width: MediaQuery.of(context).size.width * 0.5,
318+
child: SingleChildScrollView(
319+
child: Column(
320+
children: [
321+
SpawnOrionTextField(
322+
key: cNameTextFieldKey,
323+
keyboardHint: 'Enter a custom name',
324+
locale: Localizations.localeOf(context)
325+
.toString(),
326+
scrollController: _scrollController,
327+
presetText: config.getString('machineName',
328+
category: 'machine'),
329+
),
330+
OrionKbExpander(
331+
textFieldKey: cNameTextFieldKey),
332+
],
333+
),
265334
),
266335
),
336+
actions: [
337+
GlassButton(
338+
onPressed: () {
339+
Navigator.of(context).pop();
340+
},
341+
style: ElevatedButton.styleFrom(
342+
minimumSize: const Size(0, 60)),
343+
child: const Text('Close',
344+
style: TextStyle(fontSize: 20)),
345+
),
346+
GlassButton(
347+
onPressed: () {
348+
setState(() {
349+
customName = cNameTextFieldKey.currentState!
350+
.getCurrentText();
351+
config.setString('machineName', customName,
352+
category: 'machine');
353+
});
354+
Navigator.of(context).pop();
355+
},
356+
style: ElevatedButton.styleFrom(
357+
minimumSize: const Size(0, 60)),
358+
child: const Text('Confirm',
359+
style: TextStyle(fontSize: 20)),
360+
),
361+
],
362+
);
363+
},
364+
);
365+
},
366+
child: Row(
367+
children: [
368+
const Text(
369+
'Edit',
370+
style: TextStyle(
371+
fontSize: 20,
267372
),
268-
actions: [
269-
GlassButton(
270-
onPressed: () {
271-
Navigator.of(context).pop();
272-
},
273-
style: ElevatedButton.styleFrom(
274-
minimumSize: const Size(0, 60)),
275-
child: const Text('Close',
276-
style: TextStyle(fontSize: 20)),
277-
),
278-
GlassButton(
279-
onPressed: () {
280-
setState(() {
281-
customName = cNameTextFieldKey.currentState!
282-
.getCurrentText();
283-
config.setString('machineName', customName,
284-
category: 'machine');
285-
});
286-
Navigator.of(context).pop();
287-
},
288-
style: ElevatedButton.styleFrom(
289-
minimumSize: const Size(0, 60)),
290-
child: const Text('Confirm',
291-
style: TextStyle(fontSize: 20)),
292-
),
293-
],
294-
);
295-
},
296-
);
297-
},
298-
child: Row(
299-
children: [
300-
const Text(
301-
'Edit',
302-
style: TextStyle(
303-
fontSize: 20,
304373
),
305-
),
306-
const SizedBox(width: 10),
307-
PhosphorIcon(PhosphorIcons.notePencil()),
308-
],
374+
const SizedBox(width: 10),
375+
PhosphorIcon(PhosphorIcons.notePencil()),
376+
],
377+
),
309378
),
310-
),
379+
],
311380
],
312381
),
313382
),

0 commit comments

Comments
 (0)