Skip to content

Commit

Permalink
Start adding editor
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Nov 26, 2024
1 parent f341dc7 commit 36160b6
Show file tree
Hide file tree
Showing 8 changed files with 186 additions and 10 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,13 @@ jobs:
- uses: subosito/[email protected]
with:
flutter-version-file: app/pubspec.yaml
- name: Build nessesary files
working-directory: ./
run: |
cd tools
dart pub get
cd ..
dart run tools/generate.dart
- name: 📦 Get dependencies
run: |
flutter pub get
Expand Down
4 changes: 2 additions & 2 deletions app/android/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ GEM
atomos (0.1.3)
aws-eventstream (1.3.0)
aws-partitions (1.1013.0)
aws-sdk-core (3.213.0)
aws-sdk-core (3.214.0)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.992.0)
aws-sigv4 (~> 1.9)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.96.0)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.173.0)
aws-sdk-s3 (1.174.0)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
Expand Down
5 changes: 4 additions & 1 deletion app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,8 @@
"version": "Version",
"author": "Author",
"lastUsed": "Last used",
"size": "Size"
"size": "Size",
"backgrounds": "Backgorunds",
"translations": "Translations",
"editor": "Editor"
}
8 changes: 8 additions & 0 deletions app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_web_plugins/url_strategy.dart';
import 'package:material_leap/l10n/leap_localizations.dart';
import 'package:material_leap/material_leap.dart';
import 'package:setonix/pages/editor/general.dart';
import 'package:setonix/pages/game/page.dart';
import 'package:setonix/pages/home/page.dart';
import 'package:setonix/pages/settings/data.dart';
Expand Down Expand Up @@ -124,6 +125,13 @@ class SetonixApp extends StatelessWidget {
name: state.pathParameters['name'],
),
),
GoRoute(
name: 'editor',
path: 'editor/:name',
builder: (context, state) => GeneralEditorPage(
name: state.pathParameters['name']!,
),
),
GoRoute(
name: 'connect',
path: 'connect',
Expand Down
48 changes: 48 additions & 0 deletions app/lib/pages/editor/general.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:material_leap/material_leap.dart';
import 'package:setonix/pages/editor/navigation.dart';

class GeneralEditorPage extends StatelessWidget {
final String name;

const GeneralEditorPage({super.key, required this.name});

@override
Widget build(BuildContext context) {
return EditorScaffold(
currentPage: EditorPage.general,
body: SingleChildScrollView(
child: Center(
child: ConstrainedBox(
constraints: BoxConstraints(maxWidth: LeapBreakpoints.expanded),
child: Column(
children: [
TextField(
decoration: InputDecoration(
labelText: AppLocalizations.of(context).name,
filled: true,
),
),
TextField(
decoration: InputDecoration(
labelText: AppLocalizations.of(context).version,
filled: true,
),
),
TextField(
decoration: InputDecoration(
labelText: AppLocalizations.of(context).description,
border: OutlineInputBorder(),
),
minLines: 3,
maxLines: 5,
),
],
),
),
),
),
);
}
}
87 changes: 87 additions & 0 deletions app/lib/pages/editor/navigation.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:material_leap/material_leap.dart';
import 'package:phosphor_flutter/phosphor_flutter.dart';

enum EditorPage {
general,
figures,
decks,
backgrounds,
translations;

IconGetter get icon => switch (this) {
EditorPage.general => PhosphorIcons.house,
EditorPage.figures => PhosphorIcons.cube,
EditorPage.decks => PhosphorIcons.stack,
EditorPage.backgrounds => PhosphorIcons.image,
EditorPage.translations => PhosphorIcons.translate,
};

String getLocalizedName(BuildContext context) {
final loc = AppLocalizations.of(context);
return switch (this) {
EditorPage.general => loc.general,
EditorPage.figures => loc.figures,
EditorPage.decks => loc.decks,
EditorPage.backgrounds => loc.backgrounds,
EditorPage.translations => loc.translations,
};
}
}

class EditorNavigatorView extends StatelessWidget {
final EditorPage currentPage;

const EditorNavigatorView({
super.key,
required this.currentPage,
});

@override
Widget build(BuildContext context) {
return NavigationRail(
destinations: EditorPage.values
.map((e) => NavigationRailDestination(
icon: Icon(e.icon(PhosphorIconsStyle.light)),
label: Text(e.getLocalizedName(context)),
selectedIcon: Icon(e.icon(PhosphorIconsStyle.fill)),
))
.toList(),
selectedIndex: currentPage.index,
labelType: NavigationRailLabelType.all,
);
}
}

class EditorScaffold extends StatelessWidget {
final EditorPage currentPage;
final Widget body;

const EditorScaffold({
super.key,
required this.currentPage,
required this.body,
});

@override
Widget build(BuildContext context) {
final width = MediaQuery.sizeOf(context).width;
final isMobile = width < LeapBreakpoints.medium;
final navigator = EditorNavigatorView(currentPage: currentPage);
return Row(
children: [
if (!isMobile) navigator,
Expanded(
child: Scaffold(
appBar: AppBar(
title: Text(currentPage.getLocalizedName(context)),
),
drawer: isMobile ? navigator : null,
body: body,
),
),
],
);
}
}
25 changes: 24 additions & 1 deletion app/lib/pages/home/packs.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:go_router/go_router.dart';
import 'package:intl/intl.dart';
import 'package:material_leap/material_leap.dart';
import 'package:phosphor_flutter/phosphor_flutter.dart';
Expand Down Expand Up @@ -39,7 +40,7 @@ class _PacksDialogState extends State<PacksDialog>
@override
void initState() {
super.initState();
_tabController = TabController(length: isWorldLoaded ? 3 : 2, vsync: this);
_tabController = TabController(length: 3, vsync: this);
_controller.addStatusListener((status) {
if (status == AnimationStatus.dismissed) {
setState(() {
Expand Down Expand Up @@ -257,6 +258,11 @@ class _PacksDialogState extends State<PacksDialog>
icon: const PhosphorIcon(PhosphorIconsLight.globe),
label: Text(AppLocalizations.of(context).browse),
),
if (!isWorldLoaded)
HorizontalTab(
icon: const PhosphorIcon(PhosphorIconsLight.notePencil),
label: Text(AppLocalizations.of(context).editor),
),
],
),
const SizedBox(height: 8),
Expand Down Expand Up @@ -313,6 +319,7 @@ class _PacksDialogState extends State<PacksDialog>
child:
Text(AppLocalizations.of(context).comingSoon),
),
if (bloc == null) _EditorPacksView(),
],
);
});
Expand Down Expand Up @@ -539,3 +546,19 @@ class _WorldPacksView extends StatelessWidget {
);
}
}

class _EditorPacksView extends StatelessWidget {
const _EditorPacksView({super.key});

@override
Widget build(BuildContext context) {
return ListView.builder(
itemCount: 5,
itemBuilder: (context, index) {
return ListTile(
title: Text('Pack $index'),
onTap: () => GoRouter.of(context).go('/editor/$index'));
},
);
}
}
12 changes: 6 additions & 6 deletions app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,10 @@ packages:
dependency: transitive
description:
name: file_selector_linux
sha256: b2b91daf8a68ecfa4a01b778a6f52edef9b14ecd506e771488ea0f2e0784198b
sha256: "54cbbd957e1156d29548c7d9b9ec0c0ebb6de0a90452198683a7d23aed617a33"
url: "https://pub.dev"
source: hosted
version: "0.9.3+1"
version: "0.9.3+2"
file_selector_macos:
dependency: transitive
description:
Expand Down Expand Up @@ -837,10 +837,10 @@ packages:
dependency: transitive
description:
name: path_provider_android
sha256: c464428172cb986b758c6d1724c603097febb8fb855aa265aeecc9280c294d4a
sha256: "8c4967f8b7cb46dc914e178daa29813d83ae502e0529d7b0478330616a691ef7"
url: "https://pub.dev"
source: hosted
version: "2.2.12"
version: "2.2.14"
path_provider_foundation:
dependency: transitive
description:
Expand Down Expand Up @@ -1321,10 +1321,10 @@ packages:
dependency: transitive
description:
name: vector_graphics_compiler
sha256: ab9ff38fc771e9ee1139320adbe3d18a60327370c218c60752068ebee4b49ab1
sha256: "1b4b9e706a10294258727674a340ae0d6e64a7231980f9f9a3d12e4b42407aad"
url: "https://pub.dev"
source: hosted
version: "1.1.15"
version: "1.1.16"
vector_math:
dependency: transitive
description:
Expand Down

0 comments on commit 36160b6

Please sign in to comment.