-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Update Ansible Semaphore Client.
- Loading branch information
Showing
54 changed files
with
3,082 additions
and
1,734 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
), | ||
], | ||
); | ||
}, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) {}, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
); | ||
} | ||
} |
Oops, something went wrong.