<commit_before>(ns meo.ui.photos
  (:require [meo.ui.shared :refer [view text touchable-opacity cam-roll
                                   scroll image icon]]
            [cljs-react-navigation.reagent :refer [stack-navigator stack-screen]]
            [re-frame.core :refer [reg-sub subscribe]]
            [meo.ui.colors :as c]
            [meo.helpers :as h]
            [meo.utils.parse :as p]))

(defn photos-page [local put-fn]
  (let [theme (subscribe [:active-theme])]
    (fn [local put-fn]
      (let [bg (get-in c/colors [:list-bg @theme])
            text-color (get-in c/colors [:text @theme])]
        [scroll {:style {:flex-direction   "column"
                         :padding-top      10
                         :background-color bg
                         :padding-bottom   10}}
         (for [photo (:edges (:photos @local))]
           (let [node (:node photo)
                 loc (:location node)
                 lat (:latitude loc)
                 lon (:longitude loc)
                 img (:image node)
                 ts (.floor js/Math (* 1000 (:timestamp node)))
                 save-fn #(let [filename (str (h/img-fmt ts) "_" (:filename img))
                                entry {:latitude  lat
                                       :longitude lon
                                       :location  loc
                                       :md        ""
                                       :tags      #{"#import"}
                                       :perm_tags #{"#photo"}
                                       :mentions  #{}
                                       :media     (dissoc node :location)
                                       :img_file  filename
                                       :timestamp ts}]
                            (put-fn [:entry/new entry]))]
             ^{:key (:uri img)}
             [view {:style {:padding-top    10
                            :padding-bottom 10
                            :margin-bottom  10
                            :width          "100%"
                            :display        :flex
                            :flex-direction :row}}
              [image {:style  {:width      280
                               :height     160
                               :max-height 160}
                      :source {:uri (:uri img)}}]
              [touchable-opacity {:on-press save-fn
                                  :style    {:padding-left   20
                                             :padding-right  20
                                             :padding-top    50
                                             :padding-bottom 50}}
               [icon {:name  "plus-square-o"
                      :size  52
                      :color text-color}]]]))

         [text {:style {:color       "#777"
                        :text-align  "center"
                        :font-size   10
                        :font-weight "bold"}}
          (str (dissoc (:photos @local) :edges))]]))))

(defn photos-wrapper [local put-fn]
  (fn [{:keys [screenProps navigation] :as props}]
    (let [{:keys [navigate goBack]} navigation]
      [photos-page local put-fn])))

(defn photos-tab [local put-fn theme]
  (let [get-fn #(let [params (clj->js {:first     50
                                       :assetType "Photos"})
                      photos-promise (.getPhotos cam-roll params)]
                  (.then photos-promise
                         (fn [r]
                           (let [parsed (js->clj r :keywordize-keys true)]
                             (swap! local assoc-in [:photos] parsed)))))
        header-bg (get-in c/colors [:header-tab @theme])
        text-color (get-in c/colors [:text @theme])
        list-bg (get-in c/colors [:list-bg @theme])
        header-right (fn [_]
                       [touchable-opacity {:on-press get-fn
                                           :style    {:padding-top    8
                                                      :padding-left   12
                                                      :padding-right  12
                                                      :padding-bottom 8}}
                        [text {:style {:color      "#0078e7"
                                       :text-align "center"
                                       :font-size  18}}
                         "show"]])
        opts {:title            "Photos"
              :headerRight      header-right
              :headerTitleStyle {:color text-color}
              :headerStyle      {:backgroundColor header-bg}}]
    (stack-navigator
      {:photos {:screen (stack-screen (photos-wrapper local put-fn) opts)}}
      {:cardStyle {:backgroundColor list-bg}})))
<commit_msg>swipeout buttons in cam roll<commit_after>(ns meo.ui.photos
  (:require [meo.ui.shared :refer [view text touchable-opacity cam-roll
                                   scroll image icon swipeout]]
            [cljs-react-navigation.reagent :refer [stack-navigator stack-screen]]
            [re-frame.core :refer [reg-sub subscribe]]
            [meo.ui.colors :as c]
            [meo.helpers :as h]
            [meo.utils.parse :as p]))

(defn photos-page [local put-fn]
  (let [theme (subscribe [:active-theme])]
    (fn [local put-fn]
      (let [bg (get-in c/colors [:list-bg @theme])
            text-bg (get-in c/colors [:text-bg @theme])
            text-color (get-in c/colors [:text @theme])]
        [scroll {:style {:flex-direction   "column"
                         :background-color bg}}
         (for [photo (:edges (:photos @local))]
           (let [node (:node photo)
                 loc (:location node)
                 lat (:latitude loc)
                 lon (:longitude loc)
                 img (:image node)
                 ts (.floor js/Math (* 1000 (:timestamp node)))
                 save-fn #(let [filename (str (h/img-fmt ts) "_" (:filename img))
                                entry {:latitude  lat
                                       :longitude lon
                                       :location  loc
                                       :md        ""
                                       :tags      #{"#import"}
                                       :perm_tags #{"#photo"}
                                       :mentions  #{}
                                       :media     (dissoc node :location)
                                       :img_file  filename
                                       :timestamp ts}]
                            (put-fn [:entry/new entry]))
                 hide-fn #()
                 swipeout-btns [{:text            "hide"
                                 :backgroundColor "#CA3C3C"
                                 :onPress         hide-fn}
                                {:text            "add"
                                 :backgroundColor "#3CCA3C"
                                 :onPress         save-fn}]]
             ^{:key (:uri img)}
             [swipeout {:right swipeout-btns
                        :style {:margin-bottom    5
                                :background-color text-bg}}
              [view {:style {:width          "100%"
                             :display        :flex
                             :flex-direction :row}}
               [image {:style  {:width      "100%"
                                :height     160
                                :max-height 160}
                       :source {:uri (:uri img)}}]]]))
         #_[text {:style {:color       "#777"
                          :text-align  "center"
                          :font-size   10
                          :font-weight "bold"}}
            (str (dissoc (:photos @local) :edges))]]))))

(defn photos-wrapper [local put-fn]
  (fn [{:keys [screenProps navigation] :as props}]
    (let [{:keys [navigate goBack]} navigation]
      [photos-page local put-fn])))

(defn photos-tab [local put-fn theme]
  (let [get-fn #(let [params (clj->js {:first     50
                                       :assetType "Photos"})
                      photos-promise (.getPhotos cam-roll params)]
                  (.then photos-promise
                         (fn [r]
                           (let [parsed (js->clj r :keywordize-keys true)]
                             (swap! local assoc-in [:photos] parsed)))))
        header-bg (get-in c/colors [:header-tab @theme])
        text-color (get-in c/colors [:text @theme])
        list-bg (get-in c/colors [:list-bg @theme])
        header-right (fn [_]
                       [touchable-opacity {:on-press get-fn
                                           :style    {:padding-top    8
                                                      :padding-left   12
                                                      :padding-right  12
                                                      :padding-bottom 8}}
                        [text {:style {:color      "#0078e7"
                                       :text-align "center"
                                       :font-size  18}}
                         "cam roll"]])
        opts {:title            "Photos"
              :headerRight      header-right
              :headerTitleStyle {:color text-color}
              :headerStyle      {:backgroundColor header-bg}}]
    (stack-navigator
      {:photos {:screen (stack-screen (photos-wrapper local put-fn) opts)}}
      {:cardStyle {:backgroundColor list-bg}})))

{'fraction_non_alphanumeric': 0.11025124562705396, 'fraction_numerical': 0.010283048870984841, 'mean_word_length': 0.9209936876399919, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 55, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '346067', 'n_tokens_mistral': 2432, 'n_tokens_neox': 2225, 'n_words': 592}