mirror of
https://github.com/DefinedNet/mobile_nebula.git
synced 2025-01-30 17:07:02 +00:00
ad45cc1d78
TODO: - [x] Address Android, which this probably breaks. Previously the back button was taking up all the room in the title bar, this fixes it so that we can see titles again. It also truncates site names so they stay to one line. |Before|After| |---|---| |![image](https://github.com/user-attachments/assets/3e07a50d-fb40-40da-87f8-4d623019b26d)|![Simulator 2025-01-23 16 32 34](https://github.com/user-attachments/assets/ea668973-e67d-4fc5-8731-578e5f3fdd27)| |Before|After| |---|---| |![image](https://github.com/user-attachments/assets/d95e1a9d-f431-42aa-a9f2-357b20c37abb)|![Simulator 2025-01-23 16 11 15](https://github.com/user-attachments/assets/ff3f664b-1983-4514-a492-cf585153e294)| |Before|After| |---|---| |![image](https://github.com/user-attachments/assets/0ea3aa0d-340a-44db-8a0a-e0c8032c2450)|![image](https://github.com/user-attachments/assets/fb7e26c5-5c67-4dd7-808c-d471ca1e913e)| |Before|After| |---|---| |![image](https://github.com/user-attachments/assets/bffec7e3-561d-4a43-ab8a-3bd1cc95003c)|![Simulator 2025-01-23 16 13 23](https://github.com/user-attachments/assets/288c1f7f-4d79-4b59-b693-0cbcdd2024db)| A few other "After" screenshots: |Logs|DN enrollment| |---|---| |![Simulator 2025-01-23 16 30 48](https://github.com/user-attachments/assets/4698939e-c4ad-4929-bd0b-1b72fc21c439)|![image](https://github.com/user-attachments/assets/4c738c41-af3c-4465-9907-76fce34ecdd9)|
114 lines
3.5 KiB
Dart
114 lines
3.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
|
|
import 'package:mobile_nebula/services/utils.dart';
|
|
import 'package:pull_to_refresh/pull_to_refresh.dart';
|
|
|
|
enum SimpleScrollable {
|
|
none,
|
|
vertical,
|
|
horizontal,
|
|
both,
|
|
}
|
|
|
|
class SimplePage extends StatelessWidget {
|
|
const SimplePage(
|
|
{Key? key,
|
|
required this.title,
|
|
required this.child,
|
|
this.leadingAction,
|
|
this.trailingActions = const [],
|
|
this.scrollable = SimpleScrollable.vertical,
|
|
this.scrollbar = true,
|
|
this.scrollController,
|
|
this.bottomBar,
|
|
this.onRefresh,
|
|
this.onLoading,
|
|
this.alignment,
|
|
this.refreshController})
|
|
: super(key: key);
|
|
|
|
final Widget title;
|
|
final Widget child;
|
|
final SimpleScrollable scrollable;
|
|
final ScrollController? scrollController;
|
|
final AlignmentGeometry? alignment;
|
|
|
|
/// Set this to true to force draw a scrollbar without a scroll view, this is helpful for pages with Reorder-able listviews
|
|
/// This is set to true if you have any scrollable other than none
|
|
final bool scrollbar;
|
|
final Widget? bottomBar;
|
|
|
|
/// If no leading action is provided then a default "Back" widget than pops the page will be provided
|
|
final Widget? leadingAction;
|
|
final List<Widget> trailingActions;
|
|
|
|
final VoidCallback? onRefresh;
|
|
final VoidCallback? onLoading;
|
|
final RefreshController? refreshController;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Widget realChild = child;
|
|
var addScrollbar = this.scrollbar;
|
|
|
|
if (scrollable == SimpleScrollable.vertical || scrollable == SimpleScrollable.both) {
|
|
realChild = SingleChildScrollView(
|
|
scrollDirection: Axis.vertical,
|
|
child: realChild,
|
|
controller: refreshController == null ? scrollController : null);
|
|
addScrollbar = true;
|
|
}
|
|
|
|
if (scrollable == SimpleScrollable.horizontal || scrollable == SimpleScrollable.both) {
|
|
realChild = SingleChildScrollView(scrollDirection: Axis.horizontal, child: realChild);
|
|
addScrollbar = true;
|
|
}
|
|
|
|
if (refreshController != null) {
|
|
realChild = RefreshConfiguration(
|
|
headerTriggerDistance: 100,
|
|
footerTriggerDistance: -100,
|
|
maxUnderScrollExtent: 100,
|
|
child: SmartRefresher(
|
|
scrollController: scrollController,
|
|
onRefresh: onRefresh,
|
|
onLoading: onLoading,
|
|
controller: refreshController!,
|
|
child: realChild,
|
|
enablePullUp: onLoading != null,
|
|
enablePullDown: onRefresh != null,
|
|
footer: ClassicFooter(loadStyle: LoadStyle.ShowWhenLoading),
|
|
));
|
|
addScrollbar = true;
|
|
}
|
|
|
|
if (addScrollbar) {
|
|
realChild = Scrollbar(child: realChild);
|
|
}
|
|
|
|
if (alignment != null) {
|
|
realChild = Align(alignment: this.alignment!, child: realChild);
|
|
}
|
|
|
|
if (bottomBar != null) {
|
|
realChild = Column(children: [
|
|
Expanded(child: realChild),
|
|
bottomBar!,
|
|
]);
|
|
}
|
|
|
|
return PlatformScaffold(
|
|
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
|
appBar: PlatformAppBar(
|
|
title: title,
|
|
leading: leadingAction,
|
|
trailingActions: trailingActions,
|
|
cupertino: (_, __) => CupertinoNavigationBarData(
|
|
transitionBetweenRoutes: false,
|
|
// TODO: set title on route, show here instead of just "Back"
|
|
previousPageTitle: 'Back',
|
|
padding: EdgeInsetsDirectional.only(end: 8.0)),
|
|
),
|
|
body: SafeArea(child: realChild));
|
|
}
|
|
}
|