Skip to content

Commit

Permalink
Refactor screens to ease adaptive design
Browse files Browse the repository at this point in the history
  • Loading branch information
bdlukaa committed Dec 4, 2022
1 parent c7b6d39 commit dc2fc24
Show file tree
Hide file tree
Showing 11 changed files with 1,502 additions and 1,537 deletions.
7 changes: 7 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

import 'dart:io';
import 'package:bluecherry_client/widgets/desktop_buttons.dart';
import 'package:bluecherry_client/widgets/misc.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
Expand Down Expand Up @@ -120,6 +121,12 @@ class MyApp extends StatelessWidget {
theme: createTheme(themeMode: ThemeMode.light),
darkTheme: createTheme(themeMode: ThemeMode.dark),
home: const MyHomePage(),
builder: (context, child) {
return Column(children: [
if (isDesktop) const WindowButtons(),
Expanded(child: child!),
]);
},
),
),
);
Expand Down
413 changes: 190 additions & 223 deletions lib/widgets/add_server_wizard.dart

Large diffs are not rendered by default.

18 changes: 12 additions & 6 deletions lib/widgets/desktop_buttons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@ class WindowButtons extends StatelessWidget {
Widget build(BuildContext context) {
final theme = Theme.of(context);

return SizedBox(
width: 138,
height: 50,
child: WindowCaption(
brightness: theme.brightness,
backgroundColor: Colors.transparent,
return Container(
color: theme.appBarTheme.backgroundColor,
child: Align(
alignment: AlignmentDirectional.centerEnd,
child: SizedBox(
width: 138,
height: 30,
child: WindowCaption(
brightness: theme.brightness,
backgroundColor: Colors.transparent,
),
),
),
);
}
Expand Down
175 changes: 89 additions & 86 deletions lib/widgets/device_selector_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,93 +40,96 @@ class _DeviceSelectorScreenState extends State<DeviceSelectorScreen> {
appBar: AppBar(
title: Text(AppLocalizations.of(context).selectACamera),
),
body: ServersProvider.instance.servers.isEmpty
? Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.dns,
size: 72.0,
color: Theme.of(context).iconTheme.color?.withOpacity(0.8),
),
const SizedBox(height: 8.0),
Text(
AppLocalizations.of(context).noServersAdded,
style: Theme.of(context)
.textTheme
.headline5
?.copyWith(fontSize: 16.0),
),
],
),
)
: SafeArea(
bottom: false,
child: ListView.builder(
itemCount: ServersProvider.instance.servers.length,
itemBuilder: (context, i) {
final server = ServersProvider.instance.servers[i];
return FutureBuilder(
future: (() async => server.devices.isEmpty
? API.instance.getDevices(
await API.instance.checkServerCredentials(server))
: true)(),
builder: (context, snapshot) {
return snapshot.hasData
? ListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: server.devices.length + 1,
itemBuilder: (context, index) => index == 0
? SubHeader(server.name)
: () {
index--;
return ListTile(
enabled: server.devices[index].status,
leading: CircleAvatar(
child: const Icon(Icons.camera_alt),
backgroundColor: Colors.transparent,
foregroundColor:
Theme.of(context).iconTheme.color,
),
title: Text(
server.devices[index].name
.split(' ')
.map((e) =>
e[0].toUpperCase() +
e.substring(1))
.join(' '),
),
subtitle: Text([
server.devices[index].status
? AppLocalizations.of(context)
.online
: AppLocalizations.of(context)
.offline,
server.devices[index].uri,
'${server.devices[index].resolutionX}x${server.devices[index].resolutionY}',
].join(' • ')),
onTap: () {
Navigator.of(context)
.pop(server.devices[index]);
},
);
}(),
)
: Center(
child: Container(
alignment: Alignment.center,
height: 156.0,
child: const CircularProgressIndicator(),
),
);
},
);
},
),
body: () {
if (ServersProvider.instance.servers.isEmpty) {
return Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.dns,
size: 72.0,
color: Theme.of(context).iconTheme.color?.withOpacity(0.8),
),
const SizedBox(height: 8.0),
Text(
AppLocalizations.of(context).noServersAdded,
style: Theme.of(context)
.textTheme
.headline5
?.copyWith(fontSize: 16.0),
),
],
),
);
} else {
return SafeArea(
bottom: false,
child: ListView.builder(
itemCount: ServersProvider.instance.servers.length,
itemBuilder: (context, i) {
final server = ServersProvider.instance.servers[i];
return FutureBuilder(
future: (() async => server.devices.isEmpty
? API.instance.getDevices(
await API.instance.checkServerCredentials(server))
: true)(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return ListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: server.devices.length + 1,
itemBuilder: (context, index) => index == 0
? SubHeader(server.name)
: () {
index--;
return ListTile(
enabled: server.devices[index].status,
leading: CircleAvatar(
child: const Icon(Icons.camera_alt),
backgroundColor: Colors.transparent,
foregroundColor:
Theme.of(context).iconTheme.color,
),
title: Text(
server.devices[index].name
.split(' ')
.map((e) =>
e[0].toUpperCase() + e.substring(1))
.join(' '),
),
subtitle: Text([
server.devices[index].status
? AppLocalizations.of(context).online
: AppLocalizations.of(context).offline,
server.devices[index].uri,
'${server.devices[index].resolutionX}x${server.devices[index].resolutionY}',
].join(' • ')),
onTap: () {
Navigator.of(context)
.pop(server.devices[index]);
},
);
}(),
);
} else {
return Center(
child: Container(
alignment: Alignment.center,
height: 156.0,
child: const CircularProgressIndicator(),
),
);
}
},
);
},
),
);
}
}(),
);
}
}
Loading

0 comments on commit dc2fc24

Please sign in to comment.