Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion src/NoteWidgetDetailsPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ const styles = StyleSheet.create({
flex: 1,
flexDirection: "column",
alignItems: "center",
margin: 30
margin: 30,
backgroundColor: "transparent"
},
titleBox: {
borderLeftWidth: 0,
Expand Down
2 changes: 1 addition & 1 deletion windows/ReactNativeNotes/NativeModules/DatabaseHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace winrt::ReactNativeNotes::implementation
REACT_METHOD( UpdateNote, L"updateNote" );
void UpdateNote( const std::string noteTitle, const std::string noteFullMessage, const unsigned int id ) noexcept
{
data->Update( std::move(NoteModel( noteTitle, false, noteFullMessage, id )) );
data->Update( std::move(NoteModel( noteTitle, false, noteFullMessage )), id );
}

REACT_METHOD( GetNoteTitle, L"getNoteTitle" );
Expand Down
20 changes: 7 additions & 13 deletions windows/ReactNativeNotes/NativeModules/Repository/NoteModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,14 @@

namespace winrt::ReactNativeNotes::implementation
{
NoteModel::NoteModel( const std::string& title, const bool& isDone, const std::string& post, const unsigned int& ID )
: title{title}, isDone{isDone}, post{post}, id{ID}
NoteModel::NoteModel( const std::string& title, const bool& isDone, const std::string& post )
: title{title}, isDone{isDone}, post{post}
{
}

bool NoteModel::operator==( const NoteModel& model ) const
{
return this->id == model.id;
}

unsigned int NoteModel::ID() const noexcept
{
return id;
}

void NoteModel::ID( unsigned int ID ) noexcept
{
this->id = ID;
return this->title == model.title;
}

std::string NoteModel::Title() const noexcept
Expand All @@ -48,9 +38,13 @@ namespace winrt::ReactNativeNotes::implementation
{
const unsigned int shortMessageTextLength = 97;
if( post.size() > 100 )
{
return post.substr( 0, shortMessageTextLength ).append( "..." );
}
else
{
return post;
}
}

bool NoteModel::IsDone() const noexcept
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@ namespace winrt::ReactNativeNotes::implementation
public:
explicit NoteModel() = default;

NoteModel( const std::string& title, const bool& isDone, const std::string& post = "", const unsigned int& ID = 0 );
NoteModel( const std::string& title, const bool& isDone, const std::string& post = "" );

bool operator==( const NoteModel& model ) const;

unsigned int ID() const noexcept;
void ID( unsigned int ) noexcept;

std::string Title() const noexcept;
void Title( std::string ) noexcept;

Expand All @@ -29,7 +26,6 @@ namespace winrt::ReactNativeNotes::implementation
void IsDone( bool ) noexcept;

private:
unsigned int id;
std::string title;
std::string post;
bool isDone;
Expand Down
35 changes: 9 additions & 26 deletions windows/ReactNativeNotes/NativeModules/Repository/Repository.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,27 @@ namespace winrt::ReactNativeNotes::implementation
{
void Repository::Create( NoteModel& note ) noexcept
{
note.ID( static_cast<unsigned int>(notes.size()) );
notes.push_back( note );
}

NoteModel Repository::Read( const unsigned int ID ) const noexcept
NoteModel Repository::Read( const int index ) const noexcept
{
for( auto it = notes.cbegin(); it != notes.cend(); ++it )
if( index < notes.size() )
{
if( it->ID() == ID )
return it.operator*();
return notes.at( index );
}
return NoteModel();
}

NoteModel Repository::Read( const int index ) const noexcept
{
if( index >= notes.size() )
return NoteModel();
else
return notes.at(index);
}

void Repository::Update( const NoteModel& note ) noexcept
{
if( note.ID() < notes.size() )
{
notes[note.ID()] = note;
return NoteModel();
}
}

void Repository::Delete( const unsigned int ID ) noexcept
void Repository::Update( const NoteModel& note, const unsigned int& index ) noexcept
{
auto it = std::find( notes.cbegin(), notes.cend(), Read(ID) );
notes.erase( it );
if( index < notes.size() )
{
notes[index] = note;
}
}

void Repository::Delete( const int index ) noexcept
Expand All @@ -52,10 +39,6 @@ namespace winrt::ReactNativeNotes::implementation
return notes.size();
}

const bool Repository::Exists( const unsigned int ID ) const noexcept
{
return std::find_if( notes.cbegin(), notes.cend(), [=]( const NoteModel& n )->bool { return n.ID() == ID; } ) != notes.cend();
}
const bool Repository::Exists( const int index ) const noexcept
{
return index < notes.size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,14 @@ namespace winrt::ReactNativeNotes::implementation

void Create( NoteModel& note ) noexcept;

NoteModel Read( const unsigned int ID ) const noexcept;
NoteModel Read( const int index ) const noexcept;

void Update( const NoteModel& note ) noexcept;
void Update( const NoteModel& note, const unsigned int& index ) noexcept;

void Delete( const unsigned int ID ) noexcept;
void Delete( const int index ) noexcept;

unsigned int Size() const noexcept;

const bool Exists( const unsigned int ID ) const noexcept;
const bool Exists( const int index ) const noexcept;

private:
Expand Down
30 changes: 20 additions & 10 deletions windows/ReactNativeNotes/NoteWidgetDetailsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,25 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="Transparent">
<react:ReactRootView x:Name="ReactRootView" ComponentName="NoteWidgetDetailsPanel" MinHeight="400">
<react:ReactRootView.Background>
<LinearGradientBrush>
<GradientStop Offset="0.3" Color="#D0E7F3"/>
<GradientStop Offset="1.4" Color="#A6B3D9"/>
<GradientStop Offset="0.6" Color="#F8A878"/>
<GradientStop Offset="0.9" Color="#D0E7F3"/>
</LinearGradientBrush>
</react:ReactRootView.Background>
</react:ReactRootView>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="14*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<react:ReactRootView x:Name="ReactRootView" ComponentName="NoteWidgetDetailsPanel" MinHeight="400" Grid.RowSpan="2">
<react:ReactRootView.Background>
<LinearGradientBrush>
<GradientStop Offset="0.3" Color="#D0E7F3"/>
<GradientStop Offset="1.4" Color="#A6B3D9"/>
<GradientStop Offset="0.6" Color="#F8A878"/>
<GradientStop Offset="0.9" Color="#D0E7F3"/>
</LinearGradientBrush>
</react:ReactRootView.Background>
</react:ReactRootView>
<StackPanel Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Right">
<TextBlock Grid.Row="1" Text="Powered by " HorizontalAlignment="Right" VerticalAlignment="Center" Foreground="White" FontSize="18"/>
<TextBlock Grid.Row="1" Margin="10,0,10,5" HorizontalAlignment="Right" VerticalAlignment="Center" Foreground="White" FontWeight="Bold" FontSize="25">{callstack}</TextBlock>
</StackPanel>
</Grid>

</Page>