Skip to content

Commit

Permalink
Fix multiple settings button on home page
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Nov 2, 2024
1 parent 7f9a26a commit baf5157
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 104 deletions.
4 changes: 2 additions & 2 deletions api/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ packages:
dependency: transitive
description:
name: code_builder
sha256: f692079e25e7869c14132d39f223f8eec9830eb76131925143b2129c4bb01b37
sha256: "0ec10bf4a89e4c613960bf1e8b42c64127021740fb21640c29c909826a5eea3e"
url: "https://pub.dev"
source: hosted
version: "4.10.0"
version: "4.10.1"
collection:
dependency: transitive
description:
Expand Down
175 changes: 96 additions & 79 deletions app/lib/pages/game/dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ class GameDialogOverlay extends StatelessWidget {
);
}

final image = state.world.images[dialog.image];

final header = image == null ? null : Image.memory(image, height: 200);

final isMobile =
MediaQuery.of(context).size.width < LeapBreakpoints.medium;

return Stack(
children: [
GestureDetector(
Expand All @@ -57,89 +64,99 @@ class GameDialogOverlay extends StatelessWidget {
icon: const Icon(PhosphorIconsLight.x),
onPressed: () => submitValue(),
),
constraints:
const BoxConstraints(maxWidth: LeapBreakpoints.medium),
content: ListView.separated(
shrinkWrap: true,
itemCount: dialog.components.length + 1,
separatorBuilder: (context, index) =>
const SizedBox(height: 12),
itemBuilder: (context, cIndex) {
if (cIndex == 0) {
final image = state.world.images[dialog.image];
return Column(
children: [
if (image != null) Image.memory(image, height: 200),
Card.filled(
child: Padding(
padding: const EdgeInsets.all(12),
child: Row(
children: [
Icon(PhosphorIconsLight.warning),
const SizedBox(width: 12),
Expanded(
child: Text(
AppLocalizations.of(context)
.thirdPartyContent,
style: Theme.of(context)
.textTheme
.bodyMedium,
constraints: BoxConstraints(
maxWidth: header == null
? LeapBreakpoints.medium
: LeapBreakpoints.expanded),
content: Row(
children: [
if (!isMobile && header != null) Expanded(child: header),
Expanded(
child: ListView.separated(
shrinkWrap: true,
itemCount: dialog.components.length + 1,
separatorBuilder: (context, index) =>
const SizedBox(height: 12),
itemBuilder: (context, cIndex) {
if (cIndex == 0) {
return Column(
children: [
if (isMobile && header != null) header,
Card.filled(
child: Padding(
padding: const EdgeInsets.all(12),
child: Row(
children: [
Icon(PhosphorIconsLight.warning),
const SizedBox(width: 12),
Expanded(
child: Text(
AppLocalizations.of(context)
.thirdPartyContent,
style: Theme.of(context)
.textTheme
.bodyMedium,
),
),
],
),
),
],
),
),
),
],
);
}
cIndex--;
final component = dialog.components[cIndex];
switch (component) {
case GameDialogMarkdownComponent():
return MarkdownBody(
extensionSet: md.ExtensionSet(
md.ExtensionSet.gitHubWeb.blockSyntaxes,
<md.InlineSyntax>[
md.EmojiSyntax(),
...md.ExtensionSet.gitHubWeb.inlineSyntaxes
],
),
data: component.content,
);
case GameDialogTextFieldComponent():
final multiline =
component.multiline && !component.password;
final initialValue =
value.getValue(component.idOrLabel).getAsString();
void updateComponent(
String text,
) =>
updateValue(
value.copyWith.values.put(
component.idOrLabel,
GameDialogTextFieldValue(
value: text,
component: cIndex,
),
),
],
);
updateComponent(initialValue);
return TextFormField(
decoration: InputDecoration(
labelText: component.label,
hintText: component.placeholder,
filled: !multiline,
border:
multiline ? const OutlineInputBorder() : null,
),
maxLines: multiline ? null : 1,
obscureText: component.password,
initialValue: initialValue,
onChanged: updateComponent,
);
}
}),
}
cIndex--;
final component = dialog.components[cIndex];
switch (component) {
case GameDialogMarkdownComponent():
return MarkdownBody(
extensionSet: md.ExtensionSet(
md.ExtensionSet.gitHubWeb.blockSyntaxes,
<md.InlineSyntax>[
md.EmojiSyntax(),
...md.ExtensionSet.gitHubWeb.inlineSyntaxes
],
),
data: component.content,
);
case GameDialogTextFieldComponent():
final multiline =
component.multiline && !component.password;
final initialValue = value
.getValue(component.idOrLabel)
.getAsString();
void updateComponent(
String text,
) =>
updateValue(
value.copyWith.values.put(
component.idOrLabel,
GameDialogTextFieldValue(
value: text,
component: cIndex,
),
),
);
updateComponent(initialValue);
return TextFormField(
decoration: InputDecoration(
labelText: component.label,
hintText: component.placeholder,
filled: !multiline,
border: multiline
? const OutlineInputBorder()
: null,
),
maxLines: multiline ? null : 1,
obscureText: component.password,
initialValue: initialValue,
onChanged: updateComponent,
);
}
}),
),
],
),
actions: [
TextButton(
onPressed: () {
Expand Down
5 changes: 0 additions & 5 deletions app/lib/pages/home/header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ class _HeaderHomeViewState extends State<HeaderHomeView> {
icon: const PhosphorIcon(PhosphorIconsLight.bookOpen),
label: Text(AppLocalizations.of(context).documentation),
),
IconButton(
onPressed: () => openSettings(context),
icon: const PhosphorIcon(PhosphorIconsLight.gear),
tooltip: AppLocalizations.of(context).settings,
),
],
);
final style = FilledButton.styleFrom(
Expand Down
28 changes: 14 additions & 14 deletions app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -507,10 +507,10 @@ packages:
dependency: "direct main"
description:
name: flutter_svg
sha256: "7b4ca6cf3304575fe9c8ec64813c8d02ee41d2afe60bcfe0678bcb5375d596a2"
sha256: "1b7723a814d84fb65869ea7115cdb3ee7c3be5a27a755c1ec60e049f6b9fcbb2"
url: "https://pub.dev"
source: hosted
version: "2.0.10+1"
version: "2.0.11"
flutter_test:
dependency: "direct dev"
description: flutter
Expand Down Expand Up @@ -821,10 +821,10 @@ packages:
dependency: transitive
description:
name: path_parsing
sha256: caa17e8f0b386eb190dd5b6a3b71211c76375aa8b6ffb4465b5863d019bdb334
sha256: "883402936929eac138ee0a45da5b0f2c80f89913e6dc3bf77eb65b84b409c6ca"
url: "https://pub.dev"
source: hosted
version: "1.0.3"
version: "1.1.0"
path_provider:
dependency: "direct main"
description:
Expand Down Expand Up @@ -1241,10 +1241,10 @@ packages:
dependency: transitive
description:
name: url_launcher_android
sha256: "0dea215895a4d254401730ca0ba8204b29109a34a99fb06ae559a2b60988d2de"
sha256: "6fc2f56536ee873eeb867ad176ae15f304ccccc357848b351f6f0d8d4a40d193"
url: "https://pub.dev"
source: hosted
version: "6.3.13"
version: "6.3.14"
url_launcher_ios:
dependency: transitive
description:
Expand Down Expand Up @@ -1305,26 +1305,26 @@ packages:
dependency: transitive
description:
name: vector_graphics
sha256: "32c3c684e02f9bc0afb0ae0aa653337a2fe022e8ab064bcd7ffda27a74e288e3"
sha256: "0b9149c6ddb013818075b072b9ddc1b89a5122fff1275d4648d297086b46c4f0"
url: "https://pub.dev"
source: hosted
version: "1.1.11+1"
version: "1.1.12"
vector_graphics_codec:
dependency: transitive
description:
name: vector_graphics_codec
sha256: c86987475f162fadff579e7320c7ddda04cd2fdeffbe1129227a85d9ac9e03da
sha256: "2430b973a4ca3c4dbc9999b62b8c719a160100dcbae5c819bae0cacce32c9cdb"
url: "https://pub.dev"
source: hosted
version: "1.1.11+1"
version: "1.1.12"
vector_graphics_compiler:
dependency: transitive
description:
name: vector_graphics_compiler
sha256: "12faff3f73b1741a36ca7e31b292ddeb629af819ca9efe9953b70bd63fc8cd81"
sha256: f3b9b6e4591c11394d4be4806c63e72d3a41778547b2c1e2a8a04fadcfd7d173
url: "https://pub.dev"
source: hosted
version: "1.1.11+1"
version: "1.1.12"
vector_math:
dependency: transitive
description:
Expand Down Expand Up @@ -1385,10 +1385,10 @@ packages:
dependency: transitive
description:
name: win32
sha256: "10169d3934549017f0ae278ccb07f828f9d6ea21573bab0fb77b0e1ef0fce454"
sha256: "84ba388638ed7a8cb3445a320c8273136ab2631cd5f2c57888335504ddab1bc2"
url: "https://pub.dev"
source: hosted
version: "5.7.2"
version: "5.8.0"
win32_registry:
dependency: transitive
description:
Expand Down
2 changes: 2 additions & 0 deletions metadata/en-US/changelogs/3.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
* Add protection to cells if they are hidden
* Add dialog image support ([#40](https://github.com/LinwoodDev/Setonix/issues/40))
* Fix multiple settings button on home page
* Make build reproducable

Read more here: https://linwood.dev/setonix/0.1.2
4 changes: 2 additions & 2 deletions server/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ packages:
dependency: transitive
description:
name: code_builder
sha256: f692079e25e7869c14132d39f223f8eec9830eb76131925143b2129c4bb01b37
sha256: "0ec10bf4a89e4c613960bf1e8b42c64127021740fb21640c29c909826a5eea3e"
url: "https://pub.dev"
source: hosted
version: "4.10.0"
version: "4.10.1"
collection:
dependency: transitive
description:
Expand Down
4 changes: 2 additions & 2 deletions tools/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ packages:
dependency: transitive
description:
name: clock
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b
url: "https://pub.dev"
source: hosted
version: "1.1.1"
version: "1.1.2"
collection:
dependency: transitive
description:
Expand Down

0 comments on commit baf5157

Please sign in to comment.