Skip to content

Commit

Permalink
feat: Update Ansible Semaphore Client.
Browse files Browse the repository at this point in the history
  • Loading branch information
GSMLG-BOT committed Sep 18, 2023
1 parent 9296c62 commit fd2a518
Show file tree
Hide file tree
Showing 54 changed files with 3,082 additions and 1,734 deletions.
66 changes: 66 additions & 0 deletions lib/adaptive/alert_dialog.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import 'dart:io' show Platform;

import 'package:flutter/material.dart';
import 'package:macos_ui/macos_ui.dart';

import 'button.dart';

adaptiveAlertDialog({
required BuildContext context,
required Widget title,
required Widget content,
required AdaptiveButton primaryButton,
AdaptiveButton? secondaryButton,
}) {
if (Platform.isMacOS) {
showMacosAlertDialog(
context: context,
builder: (context) => MacosAlertDialog(
appIcon: const SizedBox(),
title: title,
message: content,
//horizontalActions: false,
primaryButton: PushButton(
controlSize: ControlSize.large,
onPressed: primaryButton.onPressed,
child: primaryButton.child,
),
secondaryButton: secondaryButton != null
? PushButton(
secondary: true,
controlSize: ControlSize.large,
onPressed: secondaryButton.onPressed,
child: secondaryButton.child,
)
: null,
),
);
} else {
showDialog(
context: context,
builder: (context) {
return AlertDialog.adaptive(
title: title,
content: content,
actions: secondaryButton == null
? <Widget>[
TextButton(
onPressed: primaryButton.onPressed,
child: primaryButton.child,
),
]
: <Widget>[
TextButton(
onPressed: secondaryButton.onPressed,
child: secondaryButton.child,
),
TextButton(
onPressed: primaryButton.onPressed,
child: primaryButton.child,
),
],
);
},
);
}
}
59 changes: 59 additions & 0 deletions lib/adaptive/app.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import 'dart:io' show Platform;

import 'package:flutter/material.dart';
import 'package:macos_ui/macos_ui.dart';
import 'package:semaphore/constants.dart';
import 'package:semaphore/state/theme.dart';

class AdaptiveApp extends StatelessWidget {
final bool debugShowCheckedModeBanner;
final String title;
final RouterConfig<Object>? routerConfig;
final ThemeMode themeMode;
final AppThemeData appThemeData;

const AdaptiveApp({
super.key,
this.title = Constants.appName,
this.debugShowCheckedModeBanner = false,
this.routerConfig,
this.themeMode = ThemeMode.system,
required this.appThemeData,
});

const AdaptiveApp.router({
super.key,
this.title = Constants.appName,
this.debugShowCheckedModeBanner = false,
this.routerConfig,
this.themeMode = ThemeMode.system,
required this.appThemeData,
});

@override
Widget build(BuildContext context) {
if (Platform.isMacOS) {
return MacosApp.router(
localizationsDelegates: const <LocalizationsDelegate<dynamic>>[
DefaultMaterialLocalizations.delegate,
DefaultWidgetsLocalizations.delegate,
],
debugShowCheckedModeBanner: debugShowCheckedModeBanner,
routerConfig: routerConfig,
title: title,
themeMode: themeMode,
// theme: MacosThemeData.light(),
darkTheme: MacosThemeData.dark(),
);
}

return MaterialApp.router(
debugShowCheckedModeBanner: debugShowCheckedModeBanner,
routerConfig: routerConfig,
title: title,
themeMode: themeMode,
theme: appThemeData.lightThemeData,
darkTheme: appThemeData.darkThemeData,
);
}
}
60 changes: 60 additions & 0 deletions lib/adaptive/button.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import 'dart:io' show Platform;

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:macos_ui/macos_ui.dart';
import 'package:material_neumorphic/material_neumorphic.dart'
show NeumorphicButton;

class AdaptiveButton extends StatelessWidget {
final Function()? onPressed;
final Widget child;
final ControlSize controlSize;

const AdaptiveButton({
super.key,
this.onPressed,
this.child = const SizedBox(),
this.controlSize = ControlSize.regular,
});

@override
Widget build(BuildContext context) {
if (Platform.isMacOS) {
return PushButton(
controlSize: controlSize, onPressed: onPressed, child: child);
}
return NeumorphicButton(
onPressed: onPressed,
child: child,
);
}
}

class AdaptiveTextButton extends StatelessWidget {
final Function()? onPressed;
final Widget child;
final ControlSize controlSize;

const AdaptiveTextButton({
super.key,
this.onPressed,
this.child = const SizedBox(),
this.controlSize = ControlSize.regular,
});

@override
Widget build(BuildContext context) {
if (Platform.isMacOS) {
return PushButton(
secondary: true,
controlSize: controlSize,
onPressed: onPressed,
child: child);
}
return TextButton(
onPressed: onPressed,
child: child,
);
}
}
28 changes: 28 additions & 0 deletions lib/adaptive/checkbox.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'dart:io' show Platform;

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:macos_ui/macos_ui.dart';
import 'package:material_neumorphic/material_neumorphic.dart';

class AdaptiveCheckbox extends StatelessWidget {
final void Function(bool)? onChanged;
final bool? value;

const AdaptiveCheckbox({
super.key,
this.onChanged,
this.value,
});

@override
Widget build(BuildContext context) {
if (Platform.isMacOS) {
return MacosCheckbox(onChanged: onChanged, value: value);
}
return NeumorphicCheckbox(
value: value ?? false,
onChanged: onChanged ?? (value) {},
);
}
}
28 changes: 28 additions & 0 deletions lib/adaptive/dialog.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'dart:io' show Platform;

import 'package:flutter/material.dart';
import 'package:macos_ui/macos_ui.dart';

adaptiveDialog({
required BuildContext context,
required Widget child,
}) {
if (Platform.isMacOS) {
showMacosSheet(
context: context,
barrierDismissible: true,
builder: (_) => MacosSheet(
child: child,
),
);
} else {
showDialog(
context: context,
builder: (context) {
return Dialog.fullscreen(
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
child: child,
);
});
}
}
104 changes: 104 additions & 0 deletions lib/adaptive/dropdown.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import 'dart:io' show Platform;

import 'package:flutter/material.dart';
import 'package:macos_ui/macos_ui.dart';

class AdaptiveDropdownMenu<T> extends StatelessWidget {
final T? value;
final void Function(T?)? onChanged;
final InputDecoration? decoration;
final List<AdaptiveDropdownMenuItem<T?>>? items;

const AdaptiveDropdownMenu({
super.key,
this.value,
this.onChanged,
this.decoration,
this.items,
});

@override
Widget build(BuildContext context) {
if (Platform.isMacOS) {
final theme = MacosTheme.of(context);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
decoration?.labelText != null
? Text(decoration!.labelText!, style: theme.typography.headline)
: Container(),
MacosPopupButton<T?>(
key: key,
value: value,
onChanged: onChanged,
items: items
?.map<MacosPopupMenuItem<T?>>((item) => MacosPopupMenuItem(
key: item.key,
onTap: item.onTap,
enabled: item.enabled,
alignment: item.alignment,
value: item.value,
child: item.child,
))
.toList(),
),
],
);
}
return DropdownButtonFormField<T?>(
key: key,
decoration: decoration,
onChanged: onChanged,
value: value,
items: items
?.map<DropdownMenuItem<T?>>((item) => DropdownMenuItem(
key: item.key,
onTap: item.onTap,
enabled: item.enabled,
alignment: item.alignment,
value: item.value,
child: item.child,
))
.toList(),
);
}
}

class AdaptiveDropdownMenuItem<T> extends StatelessWidget {
final T? value;
final Widget child;
final void Function()? onTap;
final bool enabled;
final AlignmentGeometry alignment;

const AdaptiveDropdownMenuItem({
super.key,
this.enabled = true,
this.onTap,
this.alignment = AlignmentDirectional.centerStart,
this.value,
required this.child,
});

@override
Widget build(BuildContext context) {
if (Platform.isMacOS) {
return MacosPopupMenuItem<T?>(
key: key,
onTap: onTap,
enabled: enabled,
alignment: alignment,
value: value,
child: child,
);
}
return DropdownMenuItem<T?>(
key: key,
onTap: onTap,
enabled: enabled,
alignment: alignment,
value: value,
child: child,
);
}
}
35 changes: 35 additions & 0 deletions lib/adaptive/floatingAction.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import 'dart:io' show Platform;

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:macos_ui/macos_ui.dart';
import 'package:material_neumorphic/material_neumorphic.dart'
show NeumorphicFloatingActionButton;

class AdaptiveFloatingAction {
final Function()? onPressed;
final Widget icon;
final String label;

const AdaptiveFloatingAction({
this.onPressed,
this.icon = const SizedBox(),
this.label = '',
});

ToolbarItem toolBarIconButton() {
return ToolBarIconButton(
icon: icon,
onPressed: onPressed,
showLabel: false,
label: label,
);
}

Widget floatingActionButton() {
return NeumorphicFloatingActionButton(
onPressed: onPressed,
child: icon,
);
}
}
Loading

0 comments on commit fd2a518

Please sign in to comment.