-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
1,422 additions
and
85 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,6 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="example" type="FlutterRunConfigurationType" factoryName="Flutter"> | ||
<option name="filePath" value="$PROJECT_DIR$/example/lib/main.dart" /> | ||
<method v="2" /> | ||
</configuration> | ||
</component> |
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
2 changes: 1 addition & 1 deletion
2
example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
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
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
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
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
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
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
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
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,93 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:pressable/pressable.dart'; | ||
|
||
class PressablePlatform extends Pressable { | ||
const PressablePlatform({ | ||
Key? key, | ||
required this.child, | ||
this.onPressed, | ||
this.onLongPressed, | ||
this.ios, | ||
this.android, | ||
this.macOS, | ||
this.windows, | ||
this.linux, | ||
}) : super(key: key); | ||
|
||
final Widget child; | ||
final VoidCallback? onPressed; | ||
final VoidCallback? onLongPressed; | ||
final PressableTheme? ios; | ||
final PressableTheme? android; | ||
final PressableTheme? macOS; | ||
final PressableTheme? windows; | ||
final PressableTheme? linux; | ||
|
||
@override | ||
_PressablePlatformState createState() => _PressablePlatformState(); | ||
} | ||
|
||
class _PressablePlatformState extends State<PressablePlatform> { | ||
@override | ||
Widget build(BuildContext context) { | ||
PressableTheme? pressable; | ||
if (Platform.isIOS) { | ||
pressable = widget.ios; | ||
} | ||
if (Platform.isAndroid) { | ||
pressable = widget.android; | ||
} | ||
if (Platform.isMacOS) { | ||
pressable = widget.macOS; | ||
} | ||
if (Platform.isWindows) { | ||
pressable = widget.windows; | ||
} | ||
if (Platform.isLinux) { | ||
pressable = widget.linux; | ||
} | ||
|
||
if (pressable == null) { | ||
throw ArgumentError( | ||
'PressableTheme for current platform is not provided.', | ||
); | ||
} | ||
|
||
return pressable.map( | ||
ripple: (theme) { | ||
return Pressable.ripple( | ||
onPressed: widget.onPressed, | ||
onLongPressed: widget.onLongPressed, | ||
theme: theme, | ||
child: widget.child, | ||
); | ||
}, | ||
scale: (theme) { | ||
return Pressable.scale( | ||
onPressed: widget.onPressed, | ||
onLongPressed: widget.onLongPressed, | ||
theme: theme, | ||
child: widget.child, | ||
); | ||
}, | ||
opacity: (theme) { | ||
return Pressable.opacity( | ||
onPressed: widget.onPressed, | ||
onLongPressed: widget.onLongPressed, | ||
theme: theme, | ||
child: widget.child, | ||
); | ||
}, | ||
fill: (theme) { | ||
return Pressable.fill( | ||
onPressed: widget.onPressed, | ||
onLongPressed: widget.onLongPressed, | ||
theme: theme, | ||
child: widget.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
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
Oops, something went wrong.