Skip to content

Commit

Permalink
update tran boxes view, update tran sender, add tran logo
Browse files Browse the repository at this point in the history
  • Loading branch information
abdfnx committed Feb 6, 2022
1 parent d211fc7 commit 40dde85
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 26 deletions.
19 changes: 19 additions & 0 deletions .github/assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions internal/tui/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type Bubble struct {
showDirectoriesOnly bool
showFileTreePreview bool
findMode bool
sendMode bool
receiveMode bool
showBoxSpinner bool
foundFilesPaths []string
Expand Down
13 changes: 8 additions & 5 deletions internal/tui/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import (
"sort"
"strings"

"github.com/abdfnx/tran/constants"
"github.com/abdfnx/tran/tools"
"github.com/charmbracelet/bubbles/progress"
"github.com/charmbracelet/bubbles/spinner"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/muesli/reflow/indent"
"github.com/abdfnx/tran/constants"
"github.com/muesli/reflow/wordwrap"
"github.com/charmbracelet/lipgloss"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/bubbles/spinner"
"github.com/charmbracelet/bubbles/progress"
"github.com/muesli/termenv"
)

// ui state flows from the top down
Expand Down Expand Up @@ -46,6 +47,8 @@ func NewSenderUI() *tea.Program {
m.resetSpinner()
var opts []tea.ProgramOption

termenv.AltScreen()

opts = append(opts, tea.WithAltScreen())

return tea.NewProgram(m, opts...)
Expand Down
26 changes: 5 additions & 21 deletions internal/tui/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@ package tui

import (
"os"
"fmt"
"errors"
"os/exec"
"path/filepath"

"github.com/muesli/termenv"
"github.com/abdfnx/tran/dfs"
"github.com/abdfnx/tran/tools"
"github.com/abdfnx/tran/models"
"github.com/abdfnx/tran/constants"
"github.com/charmbracelet/glamour"
"github.com/charmbracelet/lipgloss"
Expand Down Expand Up @@ -335,29 +332,15 @@ func (b *Bubble) handleKeys(msg tea.KeyMsg) tea.Cmd {
}

case key.Matches(msg, b.keyMap.Send):
selectedFile := b.treeFiles[b.treeCursor]

tools.RandomSeed()

err := ValidateTranxAddress()

if err != nil {
fmt.Println(err)
}

fn := []string{selectedFile.Name()}

HandleSendCommand(models.TranOptions{
TranxAddress: constants.DEFAULT_ADDRESS,
TranxPort: constants.DEFAULT_PORT,
}, fn)
b.sendMode = true

case key.Matches(msg, b.keyMap.Escape):
b.showCommandInput = false
b.showFilesOnly = false
b.showHiddenFiles = true
b.showDirectoriesOnly = false
b.findMode = false
b.sendMode = false
b.receiveMode = false
b.errorMsg = ""
b.foundFilesPaths = nil
Expand Down Expand Up @@ -495,6 +478,7 @@ func (b Bubble) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case findFilesByNameMsg:
b.showCommandInput = false
b.findMode = false
b.sendMode = false
b.receiveMode = false
b.treeCursor = 0
b.treeFiles = msg.entries
Expand Down Expand Up @@ -522,9 +506,9 @@ func (b Bubble) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
b.width = msg.Width
b.height = msg.Height

b.primaryViewport.Width = (msg.Width / 3) - b.primaryViewport.Style.GetHorizontalFrameSize()
b.primaryViewport.Width = (msg.Width / 5) - b.primaryViewport.Style.GetHorizontalFrameSize()
b.primaryViewport.Height = msg.Height - constants.StatusBarHeight - b.primaryViewport.Style.GetVerticalFrameSize()
b.secondaryViewport.Width = (msg.Width / 3) - b.secondaryViewport.Style.GetHorizontalFrameSize()
b.secondaryViewport.Width = (msg.Width / 2) - b.secondaryViewport.Style.GetHorizontalFrameSize()
b.secondaryViewport.Height = msg.Height - constants.StatusBarHeight - b.secondaryViewport.Style.GetVerticalFrameSize()
b.thirdViewport.Width = (msg.Width / 3) - b.thirdViewport.Style.GetHorizontalFrameSize() - 1
b.thirdViewport.Height = msg.Height - constants.StatusBarHeight - b.thirdViewport.Style.GetVerticalFrameSize()
Expand Down
21 changes: 21 additions & 0 deletions internal/tui/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"strings"

"github.com/abdfnx/tran/dfs"
"github.com/abdfnx/tran/tools"
"github.com/abdfnx/tran/models"
"github.com/abdfnx/tran/renderer"
"github.com/abdfnx/tran/constants"
"github.com/charmbracelet/lipgloss"
Expand Down Expand Up @@ -246,6 +248,25 @@ func (b Bubble) View() string {
return fmt.Sprintf("%s %s", b.spinner.View(), "loading...")
}

if b.sendMode {
selectedFile := b.treeFiles[b.treeCursor]

tools.RandomSeed()

err := ValidateTranxAddress()

if err != nil {
fmt.Println(err)
}

fn := []string{selectedFile.Name()}

HandleSendCommand(models.TranOptions{
TranxAddress: constants.DEFAULT_ADDRESS,
TranxPort: constants.DEFAULT_PORT,
}, fn)
}

var primaryBox string
var secondaryBox string
var thirdBox string
Expand Down

0 comments on commit 40dde85

Please sign in to comment.