본문 바로가기
프로그래밍/App 개발

[Xamarin] custom keyboard attachable view

by 엽기토기 2021. 6. 9.
반응형

https://dvlv.tistory.com/121

 

기술스택

이제 xaml 코드 짜는 속도가 거의 공장 찍어내는 급이 되었다. 근데, 애니메이션, 플랫폼 스페시픽 한 코드를 짜다보니 현타가 자주온다. 복잡하고 긴 줄 수도 덤. 키보드 위에 붙는 스티키한 뷰

dvlv.tistory.com

--> 전에 포스팅했던.. 키보드 위에 붙는 뷰를 개발했던 거를 팝업으로 바꿨음.

https://pub.dev/packages/keyboard_attachable

 

keyboard_attachable | Flutter Package

A Flutter package to build widgets that can be attached to the soft keyboard.

pub.dev

(flutter의 keyboard_attachable package 를 구현)

 

팝업은 rg.plugins.popup 을 사용.

https://github.com/rotorgames/Rg.Plugins.Popup

 

rotorgames/Rg.Plugins.Popup

Xamarin Forms popup plugin. Contribute to rotorgames/Rg.Plugins.Popup development by creating an account on GitHub.

github.com

 

 

<pages:PopupPage
    x:Class="DreamforaV2.Controls.Popups.HabitAddView"
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:animations="clr-namespace:Rg.Plugins.Popup.Animations;assembly=Rg.Plugins.Popup"
    xmlns:constants="clr-namespace:DreamforaV2.Constants"
    xmlns:customrenderers="clr-namespace:DreamforaV2.Controls.CustomRenderers"
    xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup"
    xmlns:yummy="clr-namespace:Xamarin.Forms.PancakeView;assembly=Xamarin.Forms.PancakeView"
    BackgroundColor="#33000000">
    <pages:PopupPage.Animation>
        <animations:ScaleAnimation
            DurationIn="0"
            DurationOut="0"
            HasBackgroundAnimation="True"
            PositionIn="Center"
            PositionOut="Center" />
    </pages:PopupPage.Animation>

    <Grid x:Name="OuterGrid">
        <Grid HorizontalOptions="Fill" VerticalOptions="Fill">
            <Grid.GestureRecognizers>
                <TapGestureRecognizer Tapped="OnBackgroundTapped" />
            </Grid.GestureRecognizers>
        </Grid>
        <yummy:PancakeView
            x:Name="habitAddAttachedView"
            Padding="0,32,0,32"
            BackgroundColor="{AppThemeBinding Dark=Black,
                                              Light=White}"
            CornerRadius="40,40,0,0"
            VerticalOptions="End">
            <StackLayout Margin="32,0,32,0">
                <StackLayout
                    BackgroundColor="Transparent"
                    HorizontalOptions="Fill"
                    Orientation="Horizontal">

                    <customrenderers:NoBorderEntry
                        x:Name="habitAddEntry"
                        Margin="5,0,0,0"
                        ClearButtonVisibility="WhileEditing"
                        Completed="OnHabitAddEntryCompleted"
                        HorizontalOptions="FillAndExpand"
                        IsSpellCheckEnabled="false"
                        IsTextPredictionEnabled="false"
                        Placeholder="Typing"
                        ReturnType="Done">
                        <customrenderers:NoBorderEntry.Keyboard>
                            <Keyboard x:FactoryMethod="Create">
                                <x:Arguments>
                                    <KeyboardFlags>None</KeyboardFlags>
                                </x:Arguments>
                            </Keyboard>
                        </customrenderers:NoBorderEntry.Keyboard>
                    </customrenderers:NoBorderEntry>
                </StackLayout>

                <ScrollView
                    Margin="0,24,0,0"
                    HorizontalScrollBarVisibility="Never"
                    Orientation="Horizontal"
                    VerticalScrollBarVisibility="Never">

                    <StackLayout Orientation="Horizontal">
                        <Grid VerticalOptions="Center">
                            <Frame
                                x:Name="habitRepeatDaysFrame"
                                Padding="13,10,13,10"
                                BackgroundColor="#F2F2F6"
                                CornerRadius="21"
                                HeightRequest="35"
                                HorizontalOptions="Start"
                                IsVisible="false"
                                VerticalOptions="Center">
                                <Frame.GestureRecognizers>
                                    <TapGestureRecognizer Tapped="OnHabitRepeatDaysButtonClicked" />
                                </Frame.GestureRecognizers>
                                <StackLayout Orientation="Horizontal">
                                    <Image
                                        HeightRequest="14"
                                        Source="repeatdays"
                                        VerticalOptions="Center"
                                        WidthRequest="14" />
                                    <Label
                                        x:Name="habitRepeatDaysLabel"
                                        Margin="8,0,0,0"
                                        CharacterSpacing="-0.34"
                                        FontFamily="{x:Static constants:Fonts.DMSansMedium}"
                                        FontSize="12"
                                        TextColor="#7265E3"
                                        VerticalOptions="Center" />

                                    <Frame
                                        Margin="5,0,0,0"
                                        BackgroundColor="Transparent"
                                        HeightRequest="40"
                                        HorizontalOptions="Start"
                                        VerticalOptions="Center"
                                        WidthRequest="40">

                                        <Frame.GestureRecognizers>
                                            <TapGestureRecognizer Tapped="OnHabitRepeatDaysDeleteTapped" />
                                        </Frame.GestureRecognizers>

                                        <Image
                                            HeightRequest="12"
                                            HorizontalOptions="Center"
                                            Source="x_icon"
                                            VerticalOptions="Center"
                                            WidthRequest="12" />
                                    </Frame>
                                </StackLayout>
                            </Frame>
                            <Frame
                                x:Name="habitRepeatDaysButton"
                                HeightRequest="40"
                                HorizontalOptions="Start"
                                VerticalOptions="Center"
                                WidthRequest="40">
                                <Frame.GestureRecognizers>
                                    <TapGestureRecognizer Tapped="OnHabitRepeatDaysButtonClicked" />
                                </Frame.GestureRecognizers>
                                <Image
                                    HeightRequest="19"
                                    HorizontalOptions="Center"
                                    Source="repeatdays_gray"
                                    VerticalOptions="Center"
                                    WidthRequest="19" />
                            </Frame>
                        </Grid>

                        <Grid Margin="32,0,0,0">
                            <Frame
                                x:Name="habitReminderFrame"
                                Padding="13,10,13,10"
                                BackgroundColor="#F2F2F6"
                                CornerRadius="24"
                                HeightRequest="35"
                                HorizontalOptions="Start"
                                IsVisible="false"
                                VerticalOptions="Center">
                                <Frame.GestureRecognizers>
                                    <TapGestureRecognizer Tapped="OnHabitReminderButtonClicked" />
                                </Frame.GestureRecognizers>
                                <StackLayout Orientation="Horizontal">
                                    <Image
                                        HeightRequest="14"
                                        Source="dreamdetail_addhabit_clock"
                                        VerticalOptions="Center"
                                        WidthRequest="14" />
                                    <Label
                                        Margin="8,0,0,0"
                                        CharacterSpacing="-0.34"
                                        FontFamily="{x:Static constants:Fonts.DMSansMedium}"
                                        FontSize="12"
                                        TextColor="#030202"
                                        VerticalOptions="Center">
                                        <Label.FormattedText>
                                            <FormattedString>
                                                <Span Text="Remind me " />
                                                <Span x:Name="habitReminderTimeSpan" />
                                            </FormattedString>
                                        </Label.FormattedText>
                                    </Label>
                                    <Frame
                                        Margin="5,0,0,0"
                                        BackgroundColor="Transparent"
                                        HeightRequest="40"
                                        HorizontalOptions="Start"
                                        VerticalOptions="Center"
                                        WidthRequest="40">
                                        <Frame.GestureRecognizers>
                                            <TapGestureRecognizer Tapped="OnHabitReminderDeleteTapped" />
                                        </Frame.GestureRecognizers>
                                        <Image
                                            HeightRequest="12"
                                            HorizontalOptions="Center"
                                            Source="x_icon"
                                            VerticalOptions="Center"
                                            WidthRequest="12" />
                                    </Frame>
                                </StackLayout>
                            </Frame>
                            <Frame
                                x:Name="habitReminderButton"
                                HeightRequest="40"
                                HorizontalOptions="Start"
                                VerticalOptions="Center"
                                WidthRequest="40">
                                <Frame.GestureRecognizers>
                                    <TapGestureRecognizer Tapped="OnHabitReminderButtonClicked" />
                                </Frame.GestureRecognizers>
                                <Image
                                    HeightRequest="19"
                                    HorizontalOptions="Center"
                                    Source="dreamdetail_addhabit_clock_gray"
                                    VerticalOptions="Center"
                                    WidthRequest="19" />
                            </Frame>
                        </Grid>
                    </StackLayout>

                </ScrollView>

            </StackLayout>
        </yummy:PancakeView>
        <customrenderers:DFCTimePicker
            x:Name="habitReminderTimePicker"
            DFTimeSelected="OnHabitReminderPickerTimeSelected"
            IsVisible="false"
            Unfocused="OnHabitReminderTimePickerUnfocused" />
    </Grid>
</pages:PopupPage>
반응형