Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7292a8b
MainAxisAlignment and CrossAxisAlignment to enums
FeodorFitsner Nov 22, 2022
4890ec1
Replaced typing.List with beartype.typing.List
FeodorFitsner Nov 22, 2022
be5b788
Added tests for alignment properties
FeodorFitsner Nov 23, 2022
4742f4a
Checkbox, Radio and Switch `label_position` to enum
FeodorFitsner Nov 23, 2022
3081191
BlendMode to enum
FeodorFitsner Nov 23, 2022
83d41ba
Run Python tests independently
FeodorFitsner Nov 23, 2022
f0e93a3
TextAlign to enum
FeodorFitsner Nov 23, 2022
b6a3c82
GradientTileMode to enum
FeodorFitsner Nov 23, 2022
084bf85
Add beartype checks to all `value` properties
FeodorFitsner Nov 23, 2022
c01dd23
Theme to enums
FeodorFitsner Nov 23, 2022
8cb061a
TextThemeStyle and TextOverflow to enums
FeodorFitsner Nov 23, 2022
bfe63ce
FilePickerFileType to enum
FeodorFitsner Nov 23, 2022
75ad72a
AnimationCurve to enum
FeodorFitsner Nov 23, 2022
4f1907f
AnimatedSwitcherTransition to enum
FeodorFitsner Nov 23, 2022
30f74c3
InputBorder ans ScrollMode to enums
FeodorFitsner Nov 24, 2022
7502a89
ClipBehavior to enum
FeodorFitsner Nov 24, 2022
c631d10
ImageFit and ImageRepeat to enum
FeodorFitsner Nov 24, 2022
8786f3a
ThemeMode and PageDesignLanguage to enums
FeodorFitsner Nov 24, 2022
1334e04
FontWeight to enum
FeodorFitsner Nov 24, 2022
fd53353
NavigationBar and NavigationRail to enums
FeodorFitsner Nov 24, 2022
a224b6f
Convert Enum in JSON key
FeodorFitsner Nov 24, 2022
6805813
MaterialState to enum
FeodorFitsner Nov 24, 2022
aba48a8
Update .gitignore
FeodorFitsner Nov 24, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,31 +63,32 @@ environment:

- job_name: Test Python 3.7
job_group: python_tests
job_depends_on: build_flet
python_stack: python 3.7
APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu

- job_name: Test Python 3.8
job_group: python_tests
job_depends_on: build_flet
python_stack: python 3.8
APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu

- job_name: Test Python 3.9
job_group: python_tests
job_depends_on: build_flet
python_stack: python 3.9
APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu

- job_name: Test Python 3.10
job_group: python_tests
job_depends_on: build_flet
python_stack: python 3.10
APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu

- job_name: Test Python 3.11
job_group: python_tests
python_stack: python 3.11
APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu

- job_name: Build Python wheels
job_group: python_build
job_depends_on: python_tests
job_depends_on: python_tests, build_flet
APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu
TWINE_USERNAME: __token__
TWINE_PASSWORD:
Expand All @@ -109,15 +110,15 @@ for:
- job_name: Build Flet package for Flutter

install:
- ps: |
if ($env:APPVEYOR_REPO_TAG_NAME) {
$v = $env:APPVEYOR_REPO_TAG_NAME.replace("v", "")
} else {
$cv = [version](git describe --abbrev=0).substring(1)
$v = "$($cv.major).$($cv.minor+1).0+$($env:APPVEYOR_BUILD_NUMBER)"
}
Update-AppveyorBuild -Version $v
- flutter upgrade
- ps: |
if ($env:APPVEYOR_REPO_TAG_NAME) {
$v = $env:APPVEYOR_REPO_TAG_NAME.replace("v", "")
} else {
$cv = [version](git describe --abbrev=0).substring(1)
$v = "$($cv.major).$($cv.minor+1).0+$($env:APPVEYOR_BUILD_NUMBER)"
}
Update-AppveyorBuild -Version $v
- flutter upgrade

build_script:
- cd package
Expand Down
1 change: 0 additions & 1 deletion sdk/python/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@@ -0,0 +1,125 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
55 changes: 45 additions & 10 deletions sdk/python/flet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
)
from flet.alert_dialog import AlertDialog
from flet.alignment import Alignment
from flet.animated_switcher import AnimatedSwitcher
from flet.animation import Animation
from flet.animated_switcher import AnimatedSwitcher, AnimatedSwitcherTransition
from flet.animation import Animation, AnimationCurve
from flet.app_bar import AppBar
from flet.audio import Audio
from flet.banner import Banner
Expand Down Expand Up @@ -42,6 +42,7 @@
from flet.elevated_button import ElevatedButton
from flet.file_picker import (
FilePicker,
FilePickerFileType,
FilePickerResultEvent,
FilePickerUploadEvent,
FilePickerUploadFile,
Expand All @@ -51,6 +52,7 @@
from flet.flet import *
from flet.flet_app import FletApp
from flet.floating_action_button import FloatingActionButton
from flet.form_field_control import InputBorder
from flet.gesture_detector import (
DragEndEvent,
DragStartEvent,
Expand All @@ -67,7 +69,12 @@
ScrollEvent,
TapEvent,
)
from flet.gradients import LinearGradient, RadialGradient, SweepGradient
from flet.gradients import (
GradientTileMode,
LinearGradient,
RadialGradient,
SweepGradient,
)
from flet.grid_view import GridView
from flet.haptic_feedback import HapticFeedback
from flet.icon import Icon
Expand All @@ -76,9 +83,17 @@
from flet.list_tile import ListTile
from flet.list_view import ListView
from flet.margin import Margin
from flet.markdown import Markdown
from flet.navigation_bar import NavigationBar, NavigationDestination
from flet.navigation_rail import NavigationRail, NavigationRailDestination
from flet.markdown import Markdown, MarkdownExtensionSet
from flet.navigation_bar import (
NavigationBar,
NavigationBarLabelBehavior,
NavigationDestination,
)
from flet.navigation_rail import (
NavigationRail,
NavigationRailDestination,
NavigationRailLabelType,
)
from flet.outlined_button import OutlinedButton
from flet.padding import Padding
from flet.page import KeyboardEvent, LoginEvent, Page, RouteChangeEvent, ViewPopEvent
Expand All @@ -101,14 +116,34 @@
from flet.switch import Switch
from flet.tabs import Tab, Tabs
from flet.template_route import TemplateRoute
from flet.text import Text
from flet.text import Text, TextOverflow, TextThemeStyle
from flet.text_button import TextButton
from flet.text_style import TextStyle
from flet.textfield import TextField
from flet.theme import PageTransitionsTheme, Theme
from flet.textfield import KeyboardType, TextCapitalization, TextField
from flet.theme import (
PageTransitionsTheme,
PageTransitionTheme,
Theme,
ThemeVisualDensity,
)
from flet.tooltip import Tooltip
from flet.transparent_pointer import TransparentPointer
from flet.types import BoxShape
from flet.types import (
BlendMode,
BoxShape,
ClipBehavior,
CrossAxisAlignment,
FontWeight,
ImageFit,
ImageRepeat,
LabelPosition,
MainAxisAlignment,
MaterialState,
PageDesignLanguage,
ScrollMode,
TextAlign,
ThemeMode,
)
from flet.user_control import UserControl
from flet.vertical_divider import VerticalDivider
from flet.view import View
Expand Down
20 changes: 14 additions & 6 deletions sdk/python/flet/alert_dialog.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from typing import Any, List, Optional
from typing import Any, Optional

from beartype import beartype
from beartype.typing import List

from flet.buttons import OutlinedBorder
from flet.control import Control, MainAxisAlignment
from flet.control import Control
from flet.ref import Ref
from flet.types import PaddingValue
from flet.types import MainAxisAlignment, MainAxisAlignmentString, PaddingValue


class AlertDialog(Control):
Expand All @@ -26,7 +27,7 @@ def __init__(
content_padding: PaddingValue = None,
actions: Optional[List[Control]] = None,
actions_padding: PaddingValue = None,
actions_alignment: MainAxisAlignment = None,
actions_alignment: MainAxisAlignment = MainAxisAlignment.NONE,
shape: Optional[OutlinedBorder] = None,
on_dismiss=None,
):
Expand Down Expand Up @@ -158,11 +159,18 @@ def actions_padding(self, value: PaddingValue):
# actions_alignment
@property
def actions_alignment(self) -> MainAxisAlignment:
return self._get_attr("actionsAlignment")
return self.__actions_alignment

@actions_alignment.setter
@beartype
def actions_alignment(self, value: MainAxisAlignment):
self.__actions_alignment = value
if isinstance(value, MainAxisAlignment):
self._set_attr("actionsAlignment", value.value)
else:
self.__set_actions_alignment(value)

@beartype
def __set_actions_alignment(self, value: MainAxisAlignmentString):
self._set_attr("actionsAlignment", value)

# shape
Expand Down
62 changes: 49 additions & 13 deletions sdk/python/flet/animated_switcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

from beartype import beartype

from flet.animation import Curve, TransitionValue
from enum import Enum

from flet.animation import AnimationCurveString, AnimationCurve
from flet.constrained_control import ConstrainedControl
from flet.control import Control, OptionalNumber
from flet.ref import Ref
Expand All @@ -14,6 +16,19 @@
ScaleValue,
)

try:
from typing import Literal
except ImportError:
from typing_extensions import Literal

TransitionValueString = Literal["fade", "rotation", "scale"]


class AnimatedSwitcherTransition(Enum):
FADE = "fade"
ROTATION = "rotation"
SCALE = "scale"


class AnimatedSwitcher(ConstrainedControl):
def __init__(
Expand Down Expand Up @@ -49,9 +64,9 @@ def __init__(
#
duration: Optional[int] = None,
reverse_duration: Optional[int] = None,
switch_in_curve: Optional[Curve] = None,
switch_out_curve: Optional[Curve] = None,
transition: Optional[TransitionValue] = None,
switch_in_curve: Optional[AnimationCurve] = None,
switch_out_curve: Optional[AnimationCurve] = None,
transition: Optional[AnimatedSwitcherTransition] = None,
):
ConstrainedControl.__init__(
self,
Expand Down Expand Up @@ -134,30 +149,51 @@ def reverse_duration(self, value: Optional[int]):

# switch_in_curve
@property
def switch_in_curve(self) -> Optional[Curve]:
return self._get_attr("switchInCurve")
def switch_in_curve(self) -> Optional[AnimationCurve]:
return self.__switch_in_curve

@switch_in_curve.setter
def switch_in_curve(self, value: Optional[AnimationCurve]):
self.__switch_in_curve = value
if isinstance(value, AnimationCurve):
self._set_attr("switchInCurve", value.value)
else:
self.__set_switch_in_curve(value)

@beartype
def switch_in_curve(self, value: Optional[Curve]):
def __set_switch_in_curve(self, value: Optional[AnimationCurveString]):
self._set_attr("switchInCurve", value)

# switch_out_curve
@property
def switch_out_curve(self) -> Optional[Curve]:
return self._get_attr("switchOutCurve")
def switch_out_curve(self) -> Optional[AnimationCurve]:
return self.__switch_out_curve

@switch_out_curve.setter
def switch_out_curve(self, value: Optional[AnimationCurve]):
self.__switch_out_curve = value
if isinstance(value, AnimationCurve):
self._set_attr("switchOutCurve", value.value)
else:
self.__set_switch_out_curve(value)

@beartype
def switch_out_curve(self, value: Optional[Curve]):
def __set_switch_out_curve(self, value: Optional[AnimationCurveString]):
self._set_attr("switchOutCurve", value)

# transition
@property
def transition(self) -> Optional[TransitionValue]:
return self._get_attr("transition")
def transition(self) -> Optional[AnimatedSwitcherTransition]:
return self.__transition

@transition.setter
def transition(self, value: Optional[AnimatedSwitcherTransition]):
self.__transition = value
if isinstance(value, AnimatedSwitcherTransition):
self._set_attr("transition", value.value)
else:
self.__set_transition(value)

@beartype
def transition(self, value: Optional[TransitionValue]):
def __set_transition(self, value: Optional[TransitionValueString]):
self._set_attr("transition", value)
52 changes: 48 additions & 4 deletions sdk/python/flet/animation.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import dataclasses
from dataclasses import field
from typing import Optional
from enum import Enum

try:
from typing import Literal
except ImportError:
from typing_extensions import Literal

Curve = Literal[
AnimationCurveString = Literal[
"bounceIn",
"bounceInOut",
"bounceOut",
Expand Down Expand Up @@ -52,14 +53,57 @@
"slowMiddle",
]

TransitionValue = Literal["fade", "rotation", "scale"]

class AnimationCurve(Enum):
BOUNCE_IN = "bounceIn"
BOUNCE_IN_OUT = "bounceInOut"
BOUNCE_OUT = "bounceOut"
DECELERATE = "decelerate"
EASE = "ease"
EASE_IN = "easeIn"
EASE_IN_BACK = "easeInBack"
EASE_IN_CIRC = "easeInCirc"
EASE_IN_CUBIC = "easeInCubic"
EASE_IN_EXPO = "easeInExpo"
EASE_IN_OUT = "easeInOut"
EASE_IN_OUT_BACK = "easeInOutBack"
EASE_IN_OUT_CIRC = "easeInOutCirc"
EASE_IN_OUT_CUBIC = "easeInOutCubic"
EASE_IN_OUT_CUBIC_EMPHASIZED = "easeInOutCubicEmphasized"
EASE_IN_OUT_EXPO = "easeInOutExpo"
EASE_IN_OUT_QUAD = "easeInOutQuad"
EASE_IN_OUT_QUART = "easeInOutQuart"
EASE_IN_OUT_QUINT = "easeInOutQuint"
EASE_IN_OUT_SINE = "easeInOutSine"
EASE_IN_QUAD = "easeInQuad"
EASE_IN_QUART = "easeInQuart"
EASE_IN_QUINT = "easeInQuint"
EASE_IN_SINE = "easeInSine"
EASE_IN_TO_LINEAR = "easeInToLinear"
EASE_OUT = "easeOut"
EASE_OUT_BACK = "easeOutBack"
EASE_OUT_CIRC = "easeOutCirc"
EASE_OUT_CUBIC = "easeOutCubic"
EASE_OUT_EXPO = "easeOutExpo"
EASE_OUT_QUAD = "easeOutQuad"
EASE_OUT_QUART = "easeOutQuart"
EASE_OUT_QUINT = "easeOutQuint"
EASE_OUT_SINE = "easeOutSine"
ELASTIC_IN = "elasticIn"
ELASTIC_IN_OUT = "elasticInOut"
ELASTIC_OUT = "elasticOut"
FAST_LINEAR_TO_SLOW_EASE_IN = "fastLinearToSlowEaseIn"
FAST_OUT_SLOWIN = "fastOutSlowIn"
LINEAR = "linear"
LINEAR_TO_EASE_OUT = "linearToEaseOut"
SLOW_MIDDLE = "slowMiddle"


@dataclasses.dataclass
class Animation:
duration: int = field(default=1)
curve: Optional[Curve] = field(default=None)
curve: Optional[AnimationCurve] = field(default=None)


def implicit(duration: int, curve: Optional[Curve] = None):
def implicit(duration: int, curve: Optional[AnimationCurve] = None):
return Animation(duration=duration, curve=curve)
Loading