Skip to content

Commit

Permalink
Add new home page
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Jul 2, 2023
1 parent 0b1cb65 commit a22b4e9
Show file tree
Hide file tree
Showing 8 changed files with 785 additions and 655 deletions.
194 changes: 121 additions & 73 deletions app/lib/pages/home/page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ 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:material_leap/material_leap.dart';
import 'package:phosphor_flutter/phosphor_flutter.dart';
import 'package:qeck/main.dart';
import 'package:qeck/models/server.dart';
Expand All @@ -22,81 +21,130 @@ class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: WindowTitleBar(
title: const Text(shortApplicationName),
actions: [
IconButton(
icon: const PhosphorIcon(PhosphorIconsLight.gear),
onPressed: () => openSettings(context),
)
],
),
body: StreamBuilder<List<GameServer>>(
stream: context.read<ConnectionService>().fetchServers(),
builder: (context, snapshot) {
if (snapshot.hasError) {
return Center(
child: Text(snapshot.error.toString()),
);
}
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(
child: CircularProgressIndicator(),
);
}
final servers = snapshot.data ?? [];
return ListView.builder(
itemCount: servers.length,
itemBuilder: (context, index) {
final server = servers[index];
return ListTile(
title: Text(server.property.name),
subtitle: Text(server.address),
);
},
);
},
),
floatingActionButton: FloatingActionButton(
onPressed: () => showLeapBottomSheet(
context: context,
title: AppLocalizations.of(context).servers,
childrenBuilder: (context) => [
ListTile(
title: Text(AppLocalizations.of(context).connect),
onTap: () async {
final address = await showDialog<Uri>(
context: context,
builder: (context) => const ConnectGameDialog(),
);
if (address == null) return;
if (context.mounted) {
final connection = ClientGameConnection.connect(address);
context.push('/game', extra: connection);
}
},
),
if (!kIsWeb)
ListTile(
title: Text(AppLocalizations.of(context).create),
onTap: () async {
final property = await showDialog<GameProperty>(
context: context,
builder: (context) => const CreateGameDialog(),
);
if (property == null) return;
if (context.mounted) {
final connection =
await ClientServerGameConnection.create();
if (context.mounted) {
context.push('/game', extra: connection);
}
appBar: WindowTitleBar(
title: const Text(shortApplicationName),
actions: [
IconButton(
icon: const PhosphorIcon(PhosphorIconsLight.gear),
onPressed: () => openSettings(context),
)
],
),
body: SingleChildScrollView(
child: Align(
child: Container(
padding: const EdgeInsets.all(16),
constraints: const BoxConstraints(maxWidth: 600),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
applicationName,
style: Theme.of(context).textTheme.displayMedium,
textAlign: TextAlign.center,
),
const SizedBox(height: 16),
Wrap(
alignment: WrapAlignment.center,
children: [
(
AppLocalizations.of(context).connect,
PhosphorIconsLight.globe,
() async {
final address = await showDialog<Uri>(
context: context,
builder: (context) => const ConnectGameDialog(),
);
if (address == null) return;
if (context.mounted) {
final connection =
ClientGameConnection.connect(address);
context.push('/game', extra: connection);
}
},
),
if (!kIsWeb)
(
AppLocalizations.of(context).create,
PhosphorIconsLight.plus,
() async {
final property = await showDialog<GameProperty>(
context: context,
builder: (context) => const CreateGameDialog(),
);
if (property == null) return;
if (context.mounted) {
final connection =
await ClientServerGameConnection.create();
if (context.mounted) {
context.push('/game', extra: connection);
}
}
},
),
]
.map((e) => SizedBox(
height: 200,
width: 200,
child: Card(
clipBehavior: Clip.antiAlias,
margin: const EdgeInsets.all(8),
child: InkWell(
onTap: e.$3,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Icon(e.$2, size: 48),
const SizedBox(height: 16),
Text(
e.$1,
style: Theme.of(context)
.textTheme
.headlineSmall,
textAlign: TextAlign.center,
),
],
),
),
)),
))
.toList()),
StreamBuilder<List<GameServer>>(
stream: context.read<ConnectionService>().fetchServers(),
builder: (context, snapshot) {
if (snapshot.hasError) {
return Center(
child: Text(snapshot.error.toString()),
);
}
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(
child: CircularProgressIndicator(),
);
}
final servers = snapshot.data ?? [];
return ListView.builder(
itemCount: servers.length,
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
final server = servers[index];
return ListTile(
title: Text(server.property.name),
subtitle: Text(server.address),
);
},
);
},
),
],
],
),
),
child: const Icon(Icons.add),
));
),
),
);
}
}
4 changes: 2 additions & 2 deletions app/linux/my_application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ static void my_application_activate(GApplication* application) {
if (use_header_bar) {
GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
gtk_widget_show(GTK_WIDGET(header_bar));
gtk_header_bar_set_title(header_bar, "qeck");
gtk_header_bar_set_title(header_bar, "Qeck");
gtk_header_bar_set_show_close_button(header_bar, TRUE);
gtk_window_set_titlebar(window, GTK_WIDGET(header_bar));
} else {
gtk_window_set_title(window, "qeck");
gtk_window_set_title(window, "Qeck");
}

gtk_window_set_default_size(window, 1280, 720);
Expand Down
32 changes: 16 additions & 16 deletions app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ packages:
dependency: "direct dev"
description:
name: build_runner
sha256: "5e1929ad37d48bd382b124266cb8e521de5548d406a45a5ae6656c13dab73e37"
sha256: "10c6bcdbf9d049a0b666702cf1cee4ddfdc38f02a19d35ae392863b47519848b"
url: "https://pub.dev"
source: hosted
version: "2.4.5"
version: "2.4.6"
build_runner_core:
dependency: transitive
description:
Expand Down Expand Up @@ -267,10 +267,10 @@ packages:
dependency: "direct dev"
description:
name: flutter_lints
sha256: aeb0b80a8b3709709c9cc496cdc027c5b3216796bc0af0ce1007eaf24464fd4c
sha256: "2118df84ef0c3ca93f96123a616ae8540879991b8b57af2f81b76a7ada49b2a4"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
version: "2.0.2"
flutter_localizations:
dependency: "direct main"
description: flutter
Expand Down Expand Up @@ -338,10 +338,10 @@ packages:
dependency: "direct main"
description:
name: go_router
sha256: "2cb236ba3f923043fdbe14a6a3a796b8c250e85658e28caee3e86c0c275847e5"
sha256: "1531542666c2d052c44bbf6e2b48011bf3771da0404b94c60eabec1228a62906"
url: "https://pub.dev"
source: hosted
version: "8.2.0"
version: "9.0.0"
graphs:
dependency: transitive
description:
Expand All @@ -354,10 +354,10 @@ packages:
dependency: "direct main"
description:
name: http
sha256: "4c3f04bfb64d3efd508d06b41b825542f08122d30bda4933fb95c069d22a4fa3"
sha256: "759d1a329847dd0f39226c688d3e06a6b8679668e350e2891a6474f8b4bb8525"
url: "https://pub.dev"
source: hosted
version: "1.0.0"
version: "1.1.0"
http_multi_server:
dependency: transitive
description:
Expand Down Expand Up @@ -410,10 +410,10 @@ packages:
dependency: "direct dev"
description:
name: json_serializable
sha256: "61a60716544392a82726dd0fa1dd6f5f1fd32aec66422b6e229e7b90d52325c4"
sha256: aa1f5a8912615733e0fdc7a02af03308933c93235bdc8d50d0b0c8a8ccb0b969
url: "https://pub.dev"
source: hosted
version: "6.7.0"
version: "6.7.1"
lints:
dependency: transitive
description:
Expand Down Expand Up @@ -668,10 +668,10 @@ packages:
dependency: "direct main"
description:
name: shared_preferences
sha256: "396f85b8afc6865182610c0a2fc470853d56499f75f7499e2a73a9f0539d23d0"
sha256: "0344316c947ffeb3a529eac929e1978fcd37c26be4e8468628bac399365a3ca1"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
version: "2.2.0"
shared_preferences_android:
dependency: transitive
description:
Expand Down Expand Up @@ -700,10 +700,10 @@ packages:
dependency: transitive
description:
name: shared_preferences_platform_interface
sha256: fb5cf25c0235df2d0640ac1b1174f6466bd311f621574997ac59018a6664548d
sha256: "23b052f17a25b90ff2b61aad4cc962154da76fb62848a9ce088efe30d7c50ab1"
url: "https://pub.dev"
source: hosted
version: "2.2.0"
version: "2.3.0"
shared_preferences_web:
dependency: transitive
description:
Expand Down Expand Up @@ -953,10 +953,10 @@ packages:
dependency: "direct main"
description:
name: window_manager
sha256: "95096fede562cbb65f30d38b62d819a458f59ba9fe4a317f6cee669710f6676b"
sha256: "9eef00e393e7f9308309ce9a8b2398c9ee3ca78b50c96e8b4f9873945693ac88"
url: "https://pub.dev"
source: hosted
version: "0.3.4"
version: "0.3.5"
xdg_directories:
dependency: transitive
description:
Expand Down
16 changes: 8 additions & 8 deletions app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ version: 0.1.0+1
publish_to: none

environment:
sdk: '>=2.17.0 <3.0.0'
sdk: '>=3.0.0 <4.0.0'

dependencies:
flutter:
Expand All @@ -40,20 +40,20 @@ dependencies:
path: packages/material_leap
flex_color_scheme: ^7.1.2
flutter_svg: ^2.0.7
window_manager: ^0.3.4
window_manager: ^0.3.5
# Database
shared_preferences: ^2.1.2
shared_preferences: ^2.2.0
# Generation
barcode: ^2.2.4
# Internal
flutter_bloc: ^8.1.3
url_launcher: ^6.1.11
freezed_annotation: ^2.2.0
# Information
http: ^1.0.0
http: ^1.1.0
package_info_plus: ^4.0.2
path_provider: ^2.0.15
go_router: ^8.2.0
go_router: ^9.0.0
json_annotation: ^4.8.1
dynamic_color: ^1.6.5
web_socket_channel: ^2.4.0
Expand All @@ -63,10 +63,10 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
build_runner: ^2.4.5
flutter_lints: ^2.0.1
build_runner: ^2.4.6
flutter_lints: ^2.0.2
freezed: ^2.3.5
json_serializable: ^6.7.0
json_serializable: ^6.7.1
dependency_overrides:
collection: 1.17.2
intl: 0.18.1
Expand Down
Loading

1 comment on commit a22b4e9

@vercel
Copy link

@vercel vercel bot commented on a22b4e9 Jul 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

qeck – ./app

qeck-linwood.vercel.app
qeck.linwood.dev
qeck.vercel.app
qeck-git-develop-linwood.vercel.app

Please sign in to comment.